]> git.saurik.com Git - apple/libc.git/blob - stdio/fgetws.3
Libc-594.9.4.tar.gz
[apple/libc.git] / stdio / fgetws.3
1 .\" Copyright (c) 1990, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Chris Torek and the American National Standards Committee X3,
6 .\" on Information Processing Systems.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\" must display the following acknowledgement:
18 .\" This product includes software developed by the University of
19 .\" California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\" may be used to endorse or promote products derived from this software
22 .\" without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .\" @(#)fgets.3 8.1 (Berkeley) 6/4/93
37 .\" FreeBSD: src/lib/libc/stdio/fgets.3,v 1.16 2002/05/31 05:01:17 archie Exp
38 .\" $FreeBSD: src/lib/libc/stdio/fgetws.3,v 1.3 2003/03/09 02:56:54 tjr Exp $
39 .\"
40 .Dd August 6, 2002
41 .Dt FGETWS 3
42 .Os
43 .Sh NAME
44 .Nm fgetws ,
45 .Nm fgetws_l
46 .Nd get a line of wide characters from a stream
47 .Sh LIBRARY
48 .Lb libc
49 .Sh SYNOPSIS
50 .In stdio.h
51 .In wchar.h
52 .Ft "wchar_t *"
53 .Fo fgetws
54 .Fa "wchar_t *restrict ws"
55 .Fa "int n"
56 .Fa "FILE *restrict stream"
57 .Fc
58 .In stdio.h
59 .In wchar.h
60 .In xlocale.h
61 .Ft "wchar_t *"
62 .Fo fgetws_l
63 .Fa "wchar_t *restrict ws"
64 .Fa "int n"
65 .Fa "FILE *restrict stream"
66 .Fa "locale_t loc"
67 .Fc
68 .Sh DESCRIPTION
69 The
70 .Fn fgetws
71 function
72 reads at most one less than the number of characters specified by
73 .Fa n
74 from the given
75 .Fa stream
76 and stores them in the wide character string
77 .Fa ws .
78 Reading stops when a newline character is found,
79 at end-of-file or error.
80 The newline, if any, is retained.
81 If any characters are read and there is no error, a
82 .Ql \e0
83 character is appended to end the string.
84 .Pp
85 While the
86 .Fn fgetws
87 function uses the current locale, the
88 .Fn fgetws_l
89 function may be passed a locale directly. See
90 .Xr xlocale 3
91 for more information.
92 .Sh RETURN VALUES
93 Upon successful completion,
94 .Fn fgetws
95 returns
96 .Fa ws .
97 If end-of-file occurs before any characters are read,
98 .Fn fgetws
99 returns
100 .Dv NULL
101 and the buffer contents remain unchanged.
102 If an error occurs,
103 .Fn fgetws
104 returns
105 .Dv NULL
106 and the buffer contents are indeterminate.
107 The
108 .Fn fgetws
109 function
110 does not distinguish between end-of-file and error;
111 callers must use
112 .Xr feof 3
113 and
114 .Xr ferror 3
115 to determine which occurred.
116 .Sh ERRORS
117 The
118 .Fn fgetws
119 function will fail if:
120 .Bl -tag -width Er
121 .It Bq Er EBADF
122 The given
123 .Fa stream
124 argument is not a readable stream.
125 .It Bq Er EILSEQ
126 The data obtained from the input stream does not form a valid
127 multibyte character.
128 .El
129 .Pp
130 The function
131 .Fn fgetws
132 may also fail and set
133 .Va errno
134 for any of the errors specified for the routines
135 .Xr fflush 3 ,
136 .Xr fstat 2 ,
137 .Xr read 2 ,
138 or
139 .Xr malloc 3 .
140 .Sh SEE ALSO
141 .Xr feof 3 ,
142 .Xr ferror 3 ,
143 .Xr fgets 3 ,
144 .Xr xlocale 3
145 .Sh STANDARDS
146 The
147 .Fn fgetws
148 function
149 conforms to
150 .St -p1003.1-2001 .