Pipe9x
Pipes with overlapped-style I/O on Windows 9x
pipe9x.h
Go to the documentation of this file.
1/* Pipe9X - Anonymous pipes with overlapped I/O semantics on Windows 9x
2 * Copyright (C) 2024 Daniel Collins <solemnwarning@solemnwarning.net>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29*/
30
35#ifndef PIPE9X_H
36#define PIPE9X_H
37
38#include <windows.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44typedef struct _PipeWriteHandle *PipeWriteHandle;
45typedef struct _PipeReadHandle *PipeReadHandle;
46
71DWORD pipe9x_create(
72 PipeReadHandle *prh_out,
73 size_t read_size,
74 BOOL read_inherit,
75 PipeWriteHandle *pwh_out,
76 size_t write_size,
77 BOOL write_inherit);
78
84void pipe9x_read_close(PipeReadHandle prh);
85
104DWORD pipe9x_read_initiate(PipeReadHandle prh);
105
127DWORD pipe9x_read_result(PipeReadHandle prh, void **data_out, size_t *data_size_out, BOOL wait);
128
136BOOL pipe9x_read_pending(PipeReadHandle prh);
137
147HANDLE pipe9x_read_pipe(PipeReadHandle prh);
148
158HANDLE pipe9x_read_event(PipeReadHandle prh);
159
165void pipe9x_write_close(PipeWriteHandle pwh);
166
190DWORD pipe9x_write_initiate(PipeWriteHandle prh, const void *data, size_t data_size);
191
211DWORD pipe9x_write_result(PipeWriteHandle pwh, size_t *data_written_out, BOOL wait);
212
220BOOL pipe9x_write_pending(PipeWriteHandle pwh);
221
231HANDLE pipe9x_write_pipe(PipeWriteHandle pwh);
232
242HANDLE pipe9x_write_event(PipeWriteHandle prh);
243
244#ifdef __cplusplus
245}
246#endif
247
248#endif /* !PIPE9X_H */
DWORD pipe9x_write_result(PipeWriteHandle pwh, size_t *data_written_out, BOOL wait)
Get the result from a write operation.
Definition: pipe9x.c:598
BOOL pipe9x_write_pending(PipeWriteHandle pwh)
Check if a write operation is pending.
Definition: pipe9x.c:672
void pipe9x_read_close(PipeReadHandle prh)
Closes the read end of a pipe created by pipe9x_create().
Definition: pipe9x.c:337
DWORD pipe9x_read_result(PipeReadHandle prh, void **data_out, size_t *data_size_out, BOOL wait)
Get the result from a read operation.
Definition: pipe9x.c:427
DWORD pipe9x_create(PipeReadHandle *prh_out, size_t read_size, BOOL read_inherit, PipeWriteHandle *pwh_out, size_t write_size, BOOL write_inherit)
Create a pair of connected pipe handles.
Definition: pipe9x.c:73
void pipe9x_write_close(PipeWriteHandle pwh)
Closes the write end of a pipe created by pipe9x_create().
Definition: pipe9x.c:661
HANDLE pipe9x_write_pipe(PipeWriteHandle pwh)
Get the underlying Windows HANDLE of the pipe.
Definition: pipe9x.c:678
DWORD pipe9x_write_initiate(PipeWriteHandle prh, const void *data, size_t data_size)
Start a write in the background.
Definition: pipe9x.c:532
HANDLE pipe9x_read_pipe(PipeReadHandle prh)
Get the underlying Windows HANDLE of the pipe.
Definition: pipe9x.c:498
HANDLE pipe9x_write_event(PipeWriteHandle prh)
Get an event object for detecting I/O completion.
Definition: pipe9x.c:684
HANDLE pipe9x_read_event(PipeReadHandle prh)
Get an event object for detecting I/O completion.
Definition: pipe9x.c:504
DWORD pipe9x_read_initiate(PipeReadHandle prh)
Start a read in the background.
Definition: pipe9x.c:370
BOOL pipe9x_read_pending(PipeReadHandle prh)
Check if a read operation is pending.
Definition: pipe9x.c:492