1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef _OSL_PIPE_HXX_
20 #define _OSL_PIPE_HXX_
22 #include <osl/pipe_decl.hxx>
26 //______________________________________________________________________________
31 //______________________________________________________________________________
32 inline Pipe::Pipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
)
33 : m_handle( osl_createPipe( strName
.pData
, Options
, 0 ) )
36 //______________________________________________________________________________
37 inline Pipe::Pipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
,const Security
& rSecurity
)
38 : m_handle( osl_createPipe( strName
.pData
, Options
, rSecurity
.getHandle() ) )
41 //______________________________________________________________________________
42 inline Pipe::Pipe(const Pipe
& pipe
)
43 : m_handle( pipe
.m_handle
)
46 osl_acquirePipe( m_handle
);
49 //______________________________________________________________________________
50 inline Pipe::Pipe( oslPipe pipe
, __sal_NoAcquire
)
54 //______________________________________________________________________________
55 inline Pipe::Pipe(oslPipe pipe
)
59 osl_acquirePipe( m_handle
);
62 //______________________________________________________________________________
66 osl_releasePipe( m_handle
);
69 //______________________________________________________________________________
70 inline sal_Bool
Pipe::create( const ::rtl::OUString
& strName
,
71 oslPipeOptions Options
, const Security
&rSec
)
73 *this = Pipe( strName
, Options
, rSec
);
77 //______________________________________________________________________________
78 inline sal_Bool
Pipe::create( const ::rtl::OUString
& strName
, oslPipeOptions Options
)
80 *this = Pipe( strName
, Options
);
83 //______________________________________________________________________________
84 inline Pipe
& SAL_CALL
Pipe::operator= (const Pipe
& pipe
)
86 *this = pipe
.getHandle();
90 //______________________________________________________________________________
91 inline Pipe
& SAL_CALL
Pipe::operator=( oslPipe pipe
)
94 osl_acquirePipe( pipe
);
96 osl_releasePipe( m_handle
);
101 //______________________________________________________________________________
102 inline sal_Bool SAL_CALL
Pipe::is() const
104 return m_handle
!= 0;
107 //______________________________________________________________________________
108 inline sal_Bool SAL_CALL
Pipe::operator==( const Pipe
& rPipe
) const
110 return m_handle
== rPipe
.m_handle
;
113 //______________________________________________________________________________
114 inline void SAL_CALL
Pipe::close()
116 osl_closePipe( m_handle
);
119 //______________________________________________________________________________
120 inline void SAL_CALL
Pipe::clear()
124 osl_releasePipe( m_handle
);
129 //______________________________________________________________________________
130 inline oslPipeError SAL_CALL
Pipe::accept(StreamPipe
& Connection
)
132 Connection
= StreamPipe( osl_acceptPipe( m_handle
), SAL_NO_ACQUIRE
);
133 if( Connection
.is() )
134 return osl_Pipe_E_None
;
139 //______________________________________________________________________________
140 inline oslPipeError SAL_CALL
Pipe::getError() const
142 return osl_getLastPipeError( 0 );
145 //______________________________________________________________________________
146 inline oslPipe SAL_CALL
Pipe::getHandle() const
151 //______________________________________________________________________________
152 inline StreamPipe::StreamPipe(){}
154 //______________________________________________________________________________
155 inline StreamPipe::StreamPipe(oslPipe hPipe
)
160 //______________________________________________________________________________
161 inline StreamPipe::StreamPipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
, const Security
&rSec
)
162 : Pipe( strName
, Options
, rSec
)
165 //______________________________________________________________________________
166 inline StreamPipe::StreamPipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
)
167 : Pipe( strName
, Options
)
170 //______________________________________________________________________________
171 inline StreamPipe::StreamPipe(const StreamPipe
& aPipe
)
174 //______________________________________________________________________________
175 inline StreamPipe::StreamPipe( oslPipe pipe
, __sal_NoAcquire noacquire
)
176 : Pipe( pipe
, noacquire
)
179 //______________________________________________________________________________
180 inline sal_Int32 SAL_CALL
StreamPipe::read(void* pBuffer
, sal_Int32 n
) const
182 return osl_readPipe( m_handle
, pBuffer
, n
);
185 //______________________________________________________________________________
186 inline sal_Int32 SAL_CALL
StreamPipe::write(const void* pBuffer
, sal_Int32 n
) const
188 return osl_writePipe( m_handle
, pBuffer
, n
);
191 //______________________________________________________________________________
192 inline sal_Int32 SAL_CALL
StreamPipe::recv(void* pBuffer
, sal_Int32 BytesToRead
) const
194 return osl_receivePipe( m_handle
, pBuffer
, BytesToRead
);
197 //______________________________________________________________________________
198 inline sal_Int32 SAL_CALL
StreamPipe::send(const void* pBuffer
, sal_Int32 BytesToSend
) const
200 return osl_sendPipe( m_handle
, pBuffer
, BytesToSend
);
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */