merge the formfield patch from ooo-build
[ooovba.git] / sal / workben / testpip2.cxx
blobb12a811db58f7db92b2dddb0c89a5b018db75b6f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testpip2.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sal.hxx"
34 #include <stdio.h>
35 #include <stdlib.h>
37 #define INCL_DOSPROCESS
38 #include <osl/pipe.h>
39 #include <os2.h>
41 // eindeutiger Name f�r die Pipe
42 const char pszPipeName[] = "TestPipe";
44 oslPipe Pipe;
47 void fail( const char * pszText, int retval )
49 fprintf( stderr, "TestPipe Client: %s", pszText );
50 fprintf( stderr, "TestPipe Client: test failed, ErrNo: %d.\n", retval );
51 exit( retval );
57 * Teste die Pipe-Implementation in osl
60 int main (void)
62 char szBuffer[ 256 ];
63 sSize_t nChars;
65 // gib dem Server die Chance, die Pipe zu ”ffnen
66 DosSleep( 1000 );
68 // erzeuge die Pipe
69 Pipe = osl_createPipe( pszPipeName, osl_Pipe_OPEN, 0 );
71 if( !Pipe )
72 fail( "unable to open pipe.\n",
73 osl_getLastPipeError(NULL));
76 // empfange Daten vom Server
77 nChars = osl_receivePipe( Pipe, szBuffer, 256 );
79 if( nChars < 0 )
80 fail( "unable to read from pipe.\n",
81 osl_getLastPipeError( Pipe ) );
83 printf( "TestPipe Client: data received: %s.\n", szBuffer );
85 // Sende die Daten wieder zur�ck.
86 nChars = osl_sendPipe( Pipe, szBuffer, nChars );
88 if( nChars < 0 )
89 fail( "unable to write on pipe.\n",
90 osl_getLastPipeError( Pipe ) );
92 // schliesse die Pipe
93 osl_destroyPipe( Pipe );
95 printf( "TestPipe Client: test passed.\n" );
96 return 0;