1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sal.hxx" 26 27 #include <stdio.h> 28 #include <stdlib.h> 29 30 #define INCL_DOSPROCESS 31 #include <osl/pipe.h> 32 #include <os2.h> 33 34 // eindeutiger Name f�r die Pipe 35 const char pszPipeName[] = "TestPipe"; 36 37 oslPipe Pipe; 38 39 40 void fail( const char * pszText, int retval ) 41 { 42 fprintf( stderr, "TestPipe Client: %s", pszText ); 43 fprintf( stderr, "TestPipe Client: test failed, ErrNo: %d.\n", retval ); 44 exit( retval ); 45 } 46 47 48 49 /* 50 * Teste die Pipe-Implementation in osl 51 */ 52 53 int main (void) 54 { 55 char szBuffer[ 256 ]; 56 sSize_t nChars; 57 58 // gib dem Server die Chance, die Pipe zu �ffnen 59 DosSleep( 1000 ); 60 61 // erzeuge die Pipe 62 Pipe = osl_createPipe( pszPipeName, osl_Pipe_OPEN, 0 ); 63 64 if( !Pipe ) 65 fail( "unable to open pipe.\n", 66 osl_getLastPipeError(NULL)); 67 68 69 // empfange Daten vom Server 70 nChars = osl_receivePipe( Pipe, szBuffer, 256 ); 71 72 if( nChars < 0 ) 73 fail( "unable to read from pipe.\n", 74 osl_getLastPipeError( Pipe ) ); 75 76 printf( "TestPipe Client: data received: %s.\n", szBuffer ); 77 78 // Sende die Daten wieder zur�ck. 79 nChars = osl_sendPipe( Pipe, szBuffer, nChars ); 80 81 if( nChars < 0 ) 82 fail( "unable to write on pipe.\n", 83 osl_getLastPipeError( Pipe ) ); 84 85 // schliesse die Pipe 86 osl_destroyPipe( Pipe ); 87 88 printf( "TestPipe Client: test passed.\n" ); 89 return 0; 90 } 91 92 93 94