Add to git.
[pthrlib.git] / doc / io_get_outbufcount.3.html
1 <html>
2 <head>
3 <meta name="generator" content="groff -Thtml, see www.gnu.org">
4 <meta name="Content-Style" content="text/css">
5 <title>io_fdopen</title>
6 </head>
7 <body>
8
9 <h1 align=center>io_fdopen</h1>
10 <a href="#NAME">NAME</a><br>
11 <a href="#SYNOPSIS">SYNOPSIS</a><br>
12 <a href="#DESCRIPTION">DESCRIPTION</a><br>
13 <a href="#AUTHOR">AUTHOR</a><br>
14 <a href="#LICENSE">LICENSE</a><br>
15 <a href="#VERSION">VERSION</a><br>
16 <a href="#SEE ALSO">SEE ALSO</a><br>
17
18 <hr>
19 <!-- Creator     : groff version 1.17.2 -->
20 <!-- CreationDate: Fri Aug 30 16:16:27 2002 -->
21 <a name="NAME"></a>
22 <h2>NAME</h2>
23 <table width="100%" border=0 rules="none" frame="void"
24        cols="2" cellspacing="0" cellpadding="0">
25 <tr valign="top" align="left">
26 <td width="10%"></td><td width="90%">
27 io_fdopen, io_fclose, io_fgetc, io_fgets, io_ungetc, io_fread, io_fputc, io_fputs, io_fprintf, io_fwrite, io_fflush, io_fileno, io_popen, io_pclose, io_copy, io_setbufmode, io_get_inbufcount, io_get_outbufcount - A buffered I/O library</td></table>
28 <a name="SYNOPSIS"></a>
29 <h2>SYNOPSIS</h2>
30
31 <table width="100%" border=0 rules="none" frame="void"
32        cols="2" cellspacing="0" cellpadding="0">
33 <tr valign="top" align="left">
34 <td width="10%"></td><td width="90%">
35 <pre><b>#include &lt;pthr_iolib.h&gt;
36
37 io_handle io_fdopen (pseudothread pth, int sock);
38 void io_fclose (io_handle);
39 int io_fgetc (io_handle);
40 char *io_fgets (char *s, int max_size, io_handle, int store_eol);
41 int io_ungetc (int c, io_handle);
42 size_t io_fread (void *ptr, size_t size, size_t nmemb, io_handle);
43 int io_fputc (int c, io_handle);
44 int io_fputs (const char *s, io_handle);
45 int io_fprintf (io_handle, const char *fs, ...) __attribute__ ((format (printf, 2, 3)));
46 size_t io_fwrite (const void *ptr, size_t size, size_t nmemb, io_handle);
47 int io_fflush (io_handle);
48 int io_fileno (io_handle);
49 io_handle io_popen (pseudothread pth, const char *command, const char *mode);
50 void io_pclose (io_handle);
51 int io_copy (io_handle from_io, io_handle to_io, int len);
52 void io_setbufmode (io_handle, int mode);
53 int io_get_inbufcount (io_handle);
54 int io_get_outbufcount (io_handle);
55 </b></pre></td></table>
56 <a name="DESCRIPTION"></a>
57 <h2>DESCRIPTION</h2>
58
59 <table width="100%" border=0 rules="none" frame="void"
60        cols="2" cellspacing="0" cellpadding="0">
61 <tr valign="top" align="left">
62 <td width="10%"></td><td width="90%">
63 The <b>io_*</b> functions replace the normal blocking C
64 library <b>f*</b> functions with equivalents which work on
65 non-blocking pseudothread file descriptors.</td></table>
66
67 <table width="100%" border=0 rules="none" frame="void"
68        cols="2" cellspacing="0" cellpadding="0">
69 <tr valign="top" align="left">
70 <td width="10%"></td><td width="90%">
71 All of the functions in the synopsis above work identically
72 to the C library equivalents, except where documented
73 below.</td></table>
74
75 <table width="100%" border=0 rules="none" frame="void"
76        cols="2" cellspacing="0" cellpadding="0">
77 <tr valign="top" align="left">
78 <td width="10%"></td><td width="90%">
79 <b>io_fdopen</b> associates a socket <b>sock</b> with a I/O
80 handle. The association cannot be broken later (so use
81 <b>dup(2)</b> if you wish to later take back control of the
82 underlying socket). If either the current thread exits or
83 <b>io_fclose</b> is called, the underlying socket is closed
84 (with <b>close(2)</b>).</td></table>
85
86 <table width="100%" border=0 rules="none" frame="void"
87        cols="2" cellspacing="0" cellpadding="0">
88 <tr valign="top" align="left">
89 <td width="10%"></td><td width="90%">
90 <b>io_fclose</b> flushes all unwritten data out of the
91 socket and closes it.</td></table>
92
93 <table width="100%" border=0 rules="none" frame="void"
94        cols="2" cellspacing="0" cellpadding="0">
95 <tr valign="top" align="left">
96 <td width="10%"></td><td width="90%">
97 <b>io_fgets</b> operates similarly to the ordinary C library
98 function <b>fgets(3)</b>, except that it contains a useful
99 fourth argument, <b>store_eol</b>. If this fourth argument
100 is false, then the end of line characters (<b>CR</b>, <b>CR
101 LF</b> or <b>LF</b>) are stripped from the string before it
102 is stored.</td></table>
103
104 <table width="100%" border=0 rules="none" frame="void"
105        cols="2" cellspacing="0" cellpadding="0">
106 <tr valign="top" align="left">
107 <td width="10%"></td><td width="90%">
108 <b>io_copy</b> copies <b>len</b> bytes from <b>from_io</b>
109 to <b>to_io</b>. If <b>len</b> equals -1 then bytes are
110 copied from <b>from_io</b> until end of file is reached. If
111 <b>len</b> equals 0, then no bytes are copied. The number of
112 bytes actually copied is returned.</td></table>
113
114 <table width="100%" border=0 rules="none" frame="void"
115        cols="2" cellspacing="0" cellpadding="0">
116 <tr valign="top" align="left">
117 <td width="10%"></td><td width="90%">
118 <b>io_setbufmode</b> sets the output buffer mode, and works
119 completely differently to the ordinary C library function
120 <b>setbufmode(3)</b>. The three mode arguments possible are:
121 <b>IO_MODE_LINE_BUFFERED</b>, <b>IO_MODE_UNBUFFERED</b> and
122 <b>IO_MODE_FULLY_BUFFERED</b>, and these correspond to line
123 buffering, no buffering and full (block)
124 buffering.</td></table>
125
126 <table width="100%" border=0 rules="none" frame="void"
127        cols="2" cellspacing="0" cellpadding="0">
128 <tr valign="top" align="left">
129 <td width="10%"></td><td width="90%">
130 <b>io_get_inbufcount</b> and <b>io_get_outbufcount</b>
131 return the number of characters read and written on the
132 socket since the socket was associated with the I/O
133 object.</td></table>
134 <a name="AUTHOR"></a>
135 <h2>AUTHOR</h2>
136
137 <table width="100%" border=0 rules="none" frame="void"
138        cols="2" cellspacing="0" cellpadding="0">
139 <tr valign="top" align="left">
140 <td width="10%"></td><td width="90%">
141 Richard Jones &lt;rich@annexia.org&gt;</td></table>
142 <a name="LICENSE"></a>
143 <h2>LICENSE</h2>
144
145 <table width="100%" border=0 rules="none" frame="void"
146        cols="2" cellspacing="0" cellpadding="0">
147 <tr valign="top" align="left">
148 <td width="10%"></td><td width="90%">
149 GNU LGPL (see http://www.gnu.org/)</td></table>
150 <a name="VERSION"></a>
151 <h2>VERSION</h2>
152
153 <table width="100%" border=0 rules="none" frame="void"
154        cols="2" cellspacing="0" cellpadding="0">
155 <tr valign="top" align="left">
156 <td width="10%"></td><td width="90%">
157 pthrlib-3.0.3</td></table>
158 <a name="SEE ALSO"></a>
159 <h2>SEE ALSO</h2>
160
161 <table width="100%" border=0 rules="none" frame="void"
162        cols="2" cellspacing="0" cellpadding="0">
163 <tr valign="top" align="left">
164 <td width="10%"></td><td width="90%">
165 <b>fgetc(3)</b>, <b>fgets(3)</b>, <b>ungetc(3)</b>,
166 <b>fread(3)</b>, <b>fputc(3)</b>, <b>fputs(3)</b>,
167 <b>fprintf(3)</b>, <b>fwrite(3)</b>, <b>fflush(3)</b>,
168 <b>fileno(3)</b>, <b>popen(3)</b>, <b>pclose(3)</b>,
169 <b>pth_exit(3)</b>.</td></table>
170 <hr>
171 </body>
172 </html>