9330 stack overflow when creating a deeply nested dataset
[unleashed.git] / usr / src / man / man3c / fputc.3c
blob11f4d8f71134ab15427ed668e8f681f255903b82
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
44 .\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
45 .\"
46 .TH FPUTC 3C "May 13, 2017"
47 .SH NAME
48 fputc, putc, putc_unlocked, putchar, putchar_unlocked, putw \- put a byte on a
49 stream
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <stdio.h>
55 \fBint\fR \fBfputc\fR(\fBint\fR \fIc\fR, \fBFILE *\fR\fIstream\fR);
56 .fi
58 .LP
59 .nf
60 \fBint\fR \fBputc\fR(\fBint\fR \fIc\fR, \fBFILE *\fR\fIstream\fR);
61 .fi
63 .LP
64 .nf
65 \fBint\fR \fBputc_unlocked\fR(\fBint\fR \fIc\fR, \fBFILE *\fR\fIstream\fR);
66 .fi
68 .LP
69 .nf
70 \fBint\fR \fBputchar\fR(\fBint\fR \fIc\fR);
71 .fi
73 .LP
74 .nf
75 \fBint\fR \fBputchar_unlocked\fR(\fBint\fR \fIc\fR);
76 .fi
78 .LP
79 .nf
80 \fBint\fR \fBputw\fR(\fBint\fR \fIw\fR, \fBFILE *\fR\fIstream\fR);
81 .fi
83 .SH DESCRIPTION
84 .LP
85 The \fBfputc()\fR function writes the byte specified by \fIc\fR (converted to
86 an \fBunsigned char\fR) to the output stream pointed to by \fIstream\fR, at the
87 position indicated by the associated file-position indicator for the stream (if
88 defined), and advances the indicator appropriately. If the file cannot support
89 positioning requests, or if the stream was opened with append mode, the byte is
90 appended to the output stream.
91 .sp
92 .LP
93 The \fBst_ctime\fR and \fBst_mtime\fR fields of the file will be marked for
94 update between the successful execution of \fBfputc()\fR and the next
95 successful completion of a call to \fBfflush\fR(3C) or \fBfclose\fR(3C) on the
96 same stream or a call to \fBexit\fR(3C) or \fBabort\fR(3C).
97 .sp
98 .LP
99 The \fBputc()\fR routine behaves like \fBfputc()\fR, except that it is
100 implemented as a macro. It runs faster than \fBfputc()\fR, but it takes up more
101 space per invocation and its name cannot be passed as an argument to a function
102 call.
105 The call \fBputchar(\fR\fIc\fR\fB)\fR is equivalent to \fBputc(\fR\fIc\fR\fB,
106 \fR\fIstdout\fR\fB).\fR The \fBputchar()\fR routine is implemented as a macro.
109 The \fBputc_unlocked()\fR and \fBputchar_unlocked()\fR routines are variants of
110 \fBputc()\fR and \fBputchar()\fR, respectively, that do not lock the stream.
111 It is the caller's responsibility to acquire the stream lock before calling
112 these routines and releasing the lock afterwards; see \fBflockfile\fR(3C) and
113 \fBstdio\fR(3C). These routines are implemented as macros.
116 The \fBputw()\fR function writes the word (that is, type \fBint\fR) \fIw\fR to
117 the output \fIstream\fR (at the position at which the file offset, if defined,
118 is pointing). The size of a word is the size of a type \fBint\fR and varies
119 from machine to machine.  The \fBputw()\fR function neither assumes nor causes
120 special alignment in the file.
123 The \fBst_ctime\fR and \fBst_mtime\fR fields of the file will be marked for
124 update between the successful execution of \fBputw()\fR and the next successful
125 completion of a call to \fBfflush\fR(3C) or \fBfclose\fR(3C) on the same stream
126 or a call to \fBexit\fR(3C) or \fBabort\fR(3C).
127 .SH RETURN VALUES
129 Upon successful completion, \fBfputc()\fR, \fBputc()\fR, \fBputc_unlocked()\fR,
130 \fBputchar()\fR, and \fBputchar_unlocked()\fR return the value that was
131 written.  Otherwise, these functions return EOF, the error indicator for the
132 stream is set, and \fBerrno\fR is set to indicate the error.
135 Upon successful completion, \fBputw()\fR returns \fB0\fR. Otherwise, it returns
136 a non-zero value, sets the error indicator for the associated \fIstream\fR, and
137 sets \fBerrno\fR to indicate the error.
140 An unsuccessful completion will occur, for example, if the file associated with
141 \fIstream\fR is not open for writing or if the output file cannot grow.
142 .SH ERRORS
144 The \fBfputc()\fR, \fBputc()\fR, \fBputc_unlocked()\fR, \fBputchar()\fR,
145 \fBputchar_unlocked()\fR, and \fBputw()\fR functions will fail if either the
146 \fIstream\fR is unbuffered or the \fIstream\fR's buffer needs to be flushed,
147 and:
149 .ne 2
151 \fB\fBEAGAIN\fR\fR
153 .RS 10n
154 The \fBO_NONBLOCK\fR flag is set for the file descriptor underlying
155 \fIstream\fR and the process would be delayed in the write operation.
159 .ne 2
161 \fB\fBEBADF\fR\fR
163 .RS 10n
164 The file descriptor underlying \fIstream\fR is not a valid file descriptor open
165 for writing.
169 .ne 2
171 \fB\fBEFBIG\fR\fR
173 .RS 10n
174 An attempt was made to write to a file that exceeds the maximum file size or
175 the process' file size limit.
179 .ne 2
181 \fB\fBEFBIG\fR\fR
183 .RS 10n
184 The file is a regular file and an attempt was made to write at or beyond the
185 offset maximum.
189 .ne 2
191 \fB\fBEINTR\fR\fR
193 .RS 10n
194 The write operation was terminated due to the receipt of a signal, and no data
195 was transferred.
199 .ne 2
201 \fB\fBEIO\fR\fR
203 .RS 10n
204 A physical I/O error has occurred, or the process is a member of a background
205 process group attempting to write to its controlling terminal, \fBTOSTOP\fR is
206 set, the process is neither ignoring nor blocking \fBSIGTTOU\fR and the process
207 group of the process is orphaned. This error may also be returned under
208 implementation-dependent conditions.
212 .ne 2
214 \fB\fBENOSPC\fR\fR
216 .RS 10n
217 There was no free space remaining on the device containing the file.
221 .ne 2
223 \fB\fBEPIPE\fR\fR
225 .RS 10n
226 An attempt is made to write to a pipe or \fBFIFO\fR that is not open for
227 reading by any process. A \fBSIGPIPE\fR signal will also be sent to the calling
228 thread.
233 The \fBfputc()\fR, \fBputc()\fR, \fBputc_unlocked()\fR, \fBputchar()\fR,
234 \fBputchar_unlocked()\fR, and \fBputw()\fR functions may fail if:
236 .ne 2
238 \fB\fBENOMEM\fR\fR
240 .RS 10n
241 Insufficient storage space is available.
245 .ne 2
247 \fB\fBENXIO\fR\fR
249 .RS 10n
250 A request was made of a non-existent device, or the request was outside the
251 capabilities of the device.
254 .SH USAGE
256 Functions exist for the \fBputc()\fR, \fBputc_unlocked()\fR, \fBputchar()\fR,
257 and \fBputchar_unlocked()\fR macros. To get the function form, the macro name
258 must be undefined (for example, \fB#undef putc\fR).
261 When the macro forms are used, \fBputc()\fR and \fBputc_unlocked()\fR evaluate
262 the \fIstream\fR argument more than once. In particular, \fBputc(\fR\fIc\fR\fB,
263 \fR\fI*f++\fR\fB);\fR does not work sensibly.  The \fBfputc()\fR function
264 should be used instead when evaluating the \fIstream\fR argument has side
265 effects.
268 Because of possible differences in word length and byte ordering, files written
269 using \fBputw()\fR are implementation-dependent, and possibly cannot be read
270 using \fBgetw\fR(3C) by a different application or by the same application
271 running in a different environment.
274 The \fBputw()\fR function is inherently byte stream oriented and is not tenable
275 in the context of either multibyte character streams or wide-character streams.
276 Application programmers are encouraged to use one of the character-based output
277 functions instead.
278 .SH ATTRIBUTES
280 See \fBattributes\fR(5) for descriptions of the following attributes:
285 box;
286 c | c
287 l | l .
288 ATTRIBUTE TYPE  ATTRIBUTE VALUE
290 Interface Stability     T{
291 \fBfputc()\fR, \fBputc()\fR, \fBputc_unlocked()\fR, \fBputchar()\fR, and \fBputchar_unlocked()\fR are Standard.
294 MT-Level        See \fBNOTES\fR below.
297 .SH SEE ALSO
299 \fBgetrlimit\fR(2), \fBulimit\fR(2) \fBwrite\fR(2), \fBIntro\fR(3),
300 \fBabort\fR(3C), \fBexit\fR(3C), \fBfclose\fR(3C), \fBferror\fR(3C),
301 \fBfflush\fR(3C), \fBflockfile\fR(3C), \fBprintf\fR(3C),
302 \fBputc\fR(3C), \fBputs\fR(3C), \fBsetbuf\fR(3C), \fBstdio\fR(3C),
303 \fBattributes\fR(5), \fBstandards\fR(5)
304 .SH NOTES
306 The \fBfputc()\fR, \fBputc()\fR, \fBputchar()\fR, and \fBputw()\fR routines are
307 MT-Safe in multithreaded applications.  The \fBputc_unlocked()\fR and
308 \fBputchar_unlocked()\fR routines are unsafe in multithreaded applications.