xref: /freebsd/lib/libc/stdio/fgetws.3 (revision 3494f7c0)
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. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\" FreeBSD: src/lib/libc/stdio/fgets.3,v 1.16 2002/05/31 05:01:17 archie Exp
32.\"
33.Dd August 6, 2002
34.Dt FGETWS 3
35.Os
36.Sh NAME
37.Nm fgetws
38.Nd get a line of wide characters from a stream
39.Sh LIBRARY
40.Lb libc
41.Sh SYNOPSIS
42.In stdio.h
43.In wchar.h
44.Ft "wchar_t *"
45.Fn fgetws "wchar_t * restrict ws" "int n" "FILE * restrict fp"
46.Sh DESCRIPTION
47The
48.Fn fgetws
49function
50reads at most one less than the number of characters specified by
51.Fa n
52from the given
53.Fa fp
54and stores them in the wide character string
55.Fa ws .
56Reading stops when a newline character is found,
57at end-of-file or error.
58The newline, if any, is retained.
59If any characters are read and there is no error, a
60.Ql \e0
61character is appended to end the string.
62.Sh RETURN VALUES
63Upon successful completion,
64.Fn fgetws
65returns
66.Fa ws .
67If end-of-file occurs before any characters are read,
68.Fn fgetws
69returns
70.Dv NULL
71and the buffer contents remain unchanged.
72If an error occurs,
73.Fn fgetws
74returns
75.Dv NULL
76and the buffer contents are indeterminate.
77The
78.Fn fgetws
79function
80does not distinguish between end-of-file and error, and callers must use
81.Xr feof 3
82and
83.Xr ferror 3
84to determine which occurred.
85.Sh ERRORS
86The
87.Fn fgetws
88function will fail if:
89.Bl -tag -width Er
90.It Bq Er EBADF
91The given
92.Fa fp
93argument is not a readable stream.
94.It Bq Er EILSEQ
95The data obtained from the input stream does not form a valid
96multibyte character.
97.El
98.Pp
99The function
100.Fn fgetws
101may also fail and set
102.Va errno
103for any of the errors specified for the routines
104.Xr fflush 3 ,
105.Xr fstat 2 ,
106.Xr read 2 ,
107or
108.Xr malloc 3 .
109.Sh SEE ALSO
110.Xr feof 3 ,
111.Xr ferror 3 ,
112.Xr fgets 3
113.Sh STANDARDS
114The
115.Fn fgetws
116function
117conforms to
118.St -p1003.1-2001 .
119