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