Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / sal / workben / testpip2.cxx
blob21dc18cc50d8414d739f70d0422f0fe5c7cc1f19
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <stdio.h>
22 #include <stdlib.h>
24 #include <osl/pipe.h>
26 // eindeutiger Name f�r die Pipe
27 const char pszPipeName[] = "TestPipe";
29 oslPipe Pipe;
32 void fail( const char * pszText, int retval )
34 fprintf( stderr, "TestPipe Client: %s", pszText );
35 fprintf( stderr, "TestPipe Client: test failed, ErrNo: %d.\n", retval );
36 exit( retval );
42 * Teste die Pipe-Implementation in osl
45 int main (void)
47 char szBuffer[ 256 ];
48 rtl_uString* ustrPipeName=0;
49 sal_Int32 nChars;
51 rtl_uString_newFromAscii(&ustrPipeName,pszPipeName);
53 // erzeuge die Pipe
54 Pipe = osl_createPipe( ustrPipeName, osl_Pipe_OPEN, 0 );
56 if( !Pipe )
57 fail( "unable to open pipe.\n",
58 osl_getLastPipeError(NULL));
61 // empfange Daten vom Server
62 nChars = osl_receivePipe( Pipe, szBuffer, 256 );
64 if( nChars < 0 )
65 fail( "unable to read from pipe.\n",
66 osl_getLastPipeError( Pipe ) );
68 printf( "TestPipe Client: data received: %s.\n", szBuffer );
70 // Sende die Daten wieder zur�ck.
71 nChars = osl_sendPipe( Pipe, szBuffer, nChars );
73 if( nChars < 0 )
74 fail( "unable to write on pipe.\n",
75 osl_getLastPipeError( Pipe ) );
77 // schliesse die Pipe
78 osl_releasePipe( Pipe );
80 printf( "TestPipe Client: test passed.\n" );
81 return 0;
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */