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 INCLUDED_OSL_PIPE_HXX
20 #define INCLUDED_OSL_PIPE_HXX
22 #include <osl/pipe_decl.hxx>
32 inline Pipe::Pipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
)
33 : m_handle( osl_createPipe( strName
.pData
, Options
, 0 ) )
37 inline Pipe::Pipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
,const Security
& rSecurity
)
38 : m_handle( osl_createPipe( strName
.pData
, Options
, rSecurity
.getHandle() ) )
42 inline Pipe::Pipe(const Pipe
& pipe
)
43 : m_handle( pipe
.m_handle
)
46 osl_acquirePipe( m_handle
);
50 inline Pipe::Pipe( oslPipe pipe
, __sal_NoAcquire
)
55 inline Pipe::Pipe(oslPipe pipe
)
59 osl_acquirePipe( m_handle
);
66 osl_releasePipe( m_handle
);
70 inline bool Pipe::create( const ::rtl::OUString
& strName
,
71 oslPipeOptions Options
, const Security
&rSec
)
73 *this = Pipe( strName
, Options
, rSec
);
78 inline bool Pipe::create( const ::rtl::OUString
& strName
, oslPipeOptions Options
)
80 *this = Pipe( strName
, Options
);
84 inline Pipe
& SAL_CALL
Pipe::operator= (const Pipe
& pipe
)
86 *this = pipe
.getHandle();
91 inline Pipe
& SAL_CALL
Pipe::operator=( oslPipe pipe
)
94 osl_acquirePipe( pipe
);
96 osl_releasePipe( m_handle
);
102 inline bool SAL_CALL
Pipe::is() const
104 return m_handle
!= 0;
108 inline bool SAL_CALL
Pipe::operator==( const Pipe
& rPipe
) const
110 return m_handle
== rPipe
.m_handle
;
114 inline void SAL_CALL
Pipe::close()
116 osl_closePipe( m_handle
);
120 inline void SAL_CALL
Pipe::clear()
124 osl_releasePipe( m_handle
);
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
;
140 inline oslPipeError SAL_CALL
Pipe::getError() const
142 return osl_getLastPipeError( 0 );
146 inline oslPipe SAL_CALL
Pipe::getHandle() const
152 inline StreamPipe::StreamPipe(){}
155 inline StreamPipe::StreamPipe(oslPipe hPipe
)
161 inline StreamPipe::StreamPipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
, const Security
&rSec
)
162 : Pipe( strName
, Options
, rSec
)
166 inline StreamPipe::StreamPipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
)
167 : Pipe( strName
, Options
)
171 inline StreamPipe::StreamPipe(const StreamPipe
& aPipe
)
175 inline StreamPipe::StreamPipe( oslPipe pipe
, __sal_NoAcquire noacquire
)
176 : Pipe( pipe
, noacquire
)
180 inline sal_Int32 SAL_CALL
StreamPipe::read(void* pBuffer
, sal_Int32 n
) const
182 return osl_readPipe( m_handle
, pBuffer
, n
);
186 inline sal_Int32 SAL_CALL
StreamPipe::write(const void* pBuffer
, sal_Int32 n
) const
188 return osl_writePipe( m_handle
, pBuffer
, n
);
192 inline sal_Int32 SAL_CALL
StreamPipe::recv(void* pBuffer
, sal_Int32 BytesToRead
) const
194 return osl_receivePipe( m_handle
, pBuffer
, BytesToRead
);
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: */