VirtualBox

source: vbox/trunk/include/iprt/pipe.h@ 27405

Last change on this file since 27405 was 27405, checked in by vboxsync, 15 years ago

IPRT: Typo.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1/** @file
2 * IPRT - Anonymous Pipes.
3 */
4
5/*
6 * Copyright (C) 2010 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___iprt_pipe_h
31#define ___iprt_pipe_h
32
33#include <iprt/cdefs.h>
34#include <iprt/types.h>
35
36RT_C_DECLS_BEGIN
37
38/** @defgroup grp_rt_pipe RTPipe - Anonymous Pipes
39 * @ingroup grp_rt
40 * @{
41 */
42
43/**
44 * Create an anonymous pipe.
45 *
46 * @returns IPRT status code.
47 * @param phPipeRead Where to return the read end of the pipe.
48 * @param phPipeWrite Where to return the write end of the pipe.
49 * @param fFlags A combination of RTPIPE_C_XXX defines.
50 */
51RTDECL(int) RTPipeCreate(PRTPIPE phPipeRead, PRTPIPE phPipeWrite, uint32_t fFlags);
52
53/** @name RTPipeCreate flags.
54 * @{ */
55/** Mark the read end as inheritable. */
56#define RTPIPE_C_INHERIT_READ RT_BIT(0)
57/** Mark the write end as inheritable. */
58#define RTPIPE_C_INHERIT_WRITE RT_BIT(1)
59/** Mask of valid flags. */
60#define RTPIPE_C_VALID_MASK UINT32_C(0x00000003)
61/** @} */
62
63/**
64 * Closes one end of a pipe created by RTPipeCreate.
65 *
66 * @returns IPRT status code.
67 * @param hPipe The pipe end to close.
68 */
69RTDECL(int) RTPipeClose(RTPIPE hPipe);
70
71/**
72 * Gets the native handle for an IPRT pipe handle.
73 *
74 * @returns The native handle.
75 * @param hPipe The IPRT pipe handle.
76 */
77RTDECL(RTHCINTPTR) RTPipeToNative(RTPIPE hPipe);
78
79/**
80 * Read bytes from a pipe, non-blocking.
81 *
82 * @returns IPRT status code.
83 * @retval VERR_WRONG_ORDER if racing a call to RTPipeReadBlocking.
84 * @retval VERR_BROKEN_PIPE if the remote party has disconnected and we've read
85 * all the buffered data.
86 * @retval VINF_TRY_AGAIN if no data was available. @a *pcbRead will be set to
87 * 0.
88 * @retval VERR_ACCESS_DENIED if it's a write pipe.
89 *
90 * @param hPipe The IPRT pipe handle to read from.
91 * @param pvBuf Where to put the bytes we read.
92 * @param cbToRead How much to read. Must be greater than 0.
93 * @param pcbRead Where to return the number of bytes that has been
94 * read (mandatory). This is 0 if there is no more
95 * bytes to read.
96 * @sa RTPipeReadBlocking.
97 */
98RTDECL(int) RTPipeRead(RTPIPE hPipe, void *pvBuf, size_t cbToRead, size_t *pcbRead);
99
100/**
101 * Read bytes from a pipe, blocking.
102 *
103 * @returns IPRT status code.
104 * @retval VERR_WRONG_ORDER if racing a call to RTPipeRead.
105 * @retval VERR_BROKEN_PIPE if the remote party has disconnected and we've read
106 * all the buffered data.
107 * @retval VERR_ACCESS_DENIED if it's a write pipe.
108 *
109 * @param hPipe The IPRT pipe handle to read from.
110 * @param pvBuf Where to put the bytes we read.
111 * @param cbToRead How much to read.
112 * @param pcbRead Where to return the number of bytes that has been
113 * read. Optional.
114 */
115RTDECL(int) RTPipeReadBlocking(RTPIPE hPipe, void *pvBuf, size_t cbToRead, size_t *pcbRead);
116
117/**
118 * Write bytes to a pipe, non-blocking.
119 *
120 * @returns IPRT status code.
121 * @retval VERR_WRONG_ORDER if racing a call to RTPipeWriteBlocking.
122 * @retval VERR_BROKEN_PIPE if the remote party has disconnected. Does not
123 * trigger when @a cbToWrite is 0.
124 * @retval VINF_TRY_AGAIN if no data was written. @a *pcbWritten will be set
125 * to 0.
126 * @retval VERR_ACCESS_DENIED if it's a read pipe.
127 *
128 * @param hPipe The IPRT pipe handle to write to.
129 * @param pvBuf What to write.
130 * @param cbToWrite How much to write.
131 * @param pcbWritten How many bytes we wrote, mandatory. The return can
132 * be 0.
133 */
134RTDECL(int) RTPipeWrite(RTPIPE hPipe, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
135
136/**
137 * Write bytes to a pipe, blocking.
138 *
139 * @returns IPRT status code.
140 * @retval VERR_WRONG_ORDER if racing a call to RTPipeWrite.
141 * @retval VERR_BROKEN_PIPE if the remote party has disconnected. Does not
142 * trigger when @a cbToWrite is 0.
143 * @retval VERR_ACCESS_DENIED if it's a read pipe.
144 *
145 * @param hPipe The IPRT pipe handle to write to.
146 * @param pvBuf What to write.
147 * @param cbToWrite How much to write.
148 * @param pcbWritten How many bytes we wrote, optional. If NULL then all
149 * bytes will be written.
150 */
151RTDECL(int) RTPipeWriteBlocking(RTPIPE hPipe, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
152
153/**
154 * Flushes the buffers for the specified pipe and making sure the other party
155 * reads them.
156 *
157 * @returns IPRT status code.
158 * @retval VERR_NOT_SUPPORTED if not supported by the OS.
159 * @retval VERR_BROKEN_PIPE if the remote party has disconnected.
160 * @retval VERR_ACCESS_DENIED if it's a read pipe.
161 *
162 * @param hPipe The IPRT pipe handle to flush.
163 */
164RTDECL(int) RTPipeFlush(RTPIPE hPipe);
165
166/**
167 * Checks if the pipe is ready for reading or writing (depending on the pipe
168 * end).
169 *
170 * @returns IPRT status code.
171 * @retval VERR_TIMEOUT if the timeout was reached before the pipe was ready
172 * for reading/writing.
173 * @retval VERR_NOT_SUPPORTED if not supported by the OS?
174 *
175 * @param hPipe The IPRT pipe handle to select on.
176 * @param cMillies Number of milliseconds to wait. Use
177 * RT_INDEFINITE_WAIT to wait for ever.
178 */
179RTDECL(int) RTPipeSelectOne(RTPIPE hPipe, RTMSINTERVAL cMillies);
180
181/** @} */
182
183RT_C_DECLS_END
184
185#endif
186
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette