Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _OSL_PIPE_HXX_
20 : #define _OSL_PIPE_HXX_
21 :
22 : #include <osl/pipe_decl.hxx>
23 :
24 : namespace osl
25 : {
26 : //______________________________________________________________________________
27 493 : inline Pipe::Pipe()
28 493 : : m_handle( 0 )
29 493 : {}
30 :
31 : //______________________________________________________________________________
32 : inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options )
33 : : m_handle( osl_createPipe( strName.pData, Options , 0 ) )
34 : {}
35 :
36 : //______________________________________________________________________________
37 153 : inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity)
38 153 : : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) )
39 153 : {}
40 :
41 : //______________________________________________________________________________
42 : inline Pipe::Pipe(const Pipe& pipe )
43 : : m_handle( pipe.m_handle )
44 : {
45 : if( m_handle )
46 : osl_acquirePipe( m_handle );
47 : }
48 :
49 : //______________________________________________________________________________
50 186 : inline Pipe::Pipe( oslPipe pipe, __sal_NoAcquire )
51 186 : : m_handle ( pipe )
52 186 : {}
53 :
54 : //______________________________________________________________________________
55 0 : inline Pipe::Pipe(oslPipe pipe)
56 0 : : m_handle( pipe )
57 : {
58 0 : if( m_handle )
59 0 : osl_acquirePipe( m_handle );
60 0 : }
61 :
62 : //______________________________________________________________________________
63 829 : inline Pipe::~Pipe()
64 : {
65 829 : if( m_handle )
66 478 : osl_releasePipe( m_handle );
67 829 : }
68 :
69 : //______________________________________________________________________________
70 101 : inline sal_Bool Pipe::create( const ::rtl::OUString & strName,
71 : oslPipeOptions Options, const Security &rSec )
72 : {
73 101 : *this = Pipe( strName, Options, rSec );
74 101 : return is();
75 : }
76 :
77 : //______________________________________________________________________________
78 : inline sal_Bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options )
79 : {
80 : *this = Pipe( strName, Options );
81 : return is();
82 : }
83 : //______________________________________________________________________________
84 493 : inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
85 : {
86 493 : *this = pipe.getHandle();
87 493 : return *this;
88 : }
89 :
90 : //______________________________________________________________________________
91 493 : inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
92 : {
93 493 : if( pipe )
94 343 : osl_acquirePipe( pipe );
95 493 : if( m_handle )
96 0 : osl_releasePipe( m_handle );
97 493 : m_handle = pipe;
98 493 : return *this;
99 : }
100 :
101 : //______________________________________________________________________________
102 493 : inline sal_Bool SAL_CALL Pipe::is() const
103 : {
104 493 : return m_handle != 0;
105 : }
106 :
107 : //______________________________________________________________________________
108 : inline sal_Bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
109 : {
110 : return m_handle == rPipe.m_handle;
111 : }
112 :
113 : //______________________________________________________________________________
114 270 : inline void SAL_CALL Pipe::close()
115 : {
116 270 : osl_closePipe( m_handle );
117 270 : }
118 :
119 : //______________________________________________________________________________
120 51 : inline void SAL_CALL Pipe::clear()
121 : {
122 51 : if( m_handle )
123 : {
124 51 : osl_releasePipe( m_handle );
125 51 : m_handle = 0;
126 : }
127 51 : }
128 :
129 : //______________________________________________________________________________
130 186 : inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
131 : {
132 186 : Connection = StreamPipe( osl_acceptPipe( m_handle ), SAL_NO_ACQUIRE);
133 186 : if( Connection.is() )
134 52 : return osl_Pipe_E_None;
135 : else
136 134 : return getError();
137 : }
138 :
139 : //______________________________________________________________________________
140 150 : inline oslPipeError SAL_CALL Pipe::getError() const
141 : {
142 150 : return osl_getLastPipeError( 0 );
143 : }
144 :
145 : //______________________________________________________________________________
146 493 : inline oslPipe SAL_CALL Pipe::getHandle() const
147 : {
148 493 : return m_handle;
149 : }
150 :
151 : //______________________________________________________________________________
152 204 : inline StreamPipe::StreamPipe(){}
153 :
154 : //______________________________________________________________________________
155 0 : inline StreamPipe::StreamPipe(oslPipe hPipe)
156 0 : : Pipe( hPipe )
157 : {
158 0 : }
159 :
160 : //______________________________________________________________________________
161 : inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
162 : : Pipe( strName, Options , rSec )
163 : {}
164 :
165 : //______________________________________________________________________________
166 : inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options )
167 : : Pipe( strName, Options )
168 : {}
169 :
170 : //______________________________________________________________________________
171 : inline StreamPipe::StreamPipe(const StreamPipe& aPipe)
172 : : Pipe( aPipe )
173 : {}
174 : //______________________________________________________________________________
175 186 : inline StreamPipe::StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire )
176 186 : : Pipe( pipe , noacquire )
177 186 : {}
178 :
179 : //______________________________________________________________________________
180 502846 : inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
181 : {
182 502846 : return osl_readPipe( m_handle, pBuffer, n );
183 : }
184 :
185 : //______________________________________________________________________________
186 206000 : inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
187 : {
188 206000 : return osl_writePipe( m_handle, pBuffer , n );
189 : }
190 :
191 : //______________________________________________________________________________
192 0 : inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
193 : {
194 0 : return osl_receivePipe( m_handle, pBuffer , BytesToRead );
195 : }
196 :
197 : //______________________________________________________________________________
198 : inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
199 : {
200 : return osl_sendPipe( m_handle, pBuffer , BytesToSend );
201 : }
202 :
203 : }
204 : #endif
205 :
206 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|