2 .\" Copyright 1989 AT&T Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH BGETS 3GEN "May 9, 2001"
8 bgets \- read stream up to next delimiter
12 cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ]
15 \fBchar *\fR\fBbgets\fR(\fBchar *\fR\fIbuffer\fR, \fBsize_t\fR \fIcount\fR, \fBFILE *\fR\fIstream\fR,
16 \fBconst char *\fR\fIbreakstring\fR);
22 The \fBbgets()\fR function reads characters from \fIstream\fR into \fIbuffer\fR
23 until either \fIcount\fR is exhausted or one of the characters in
24 \fIbreakstring\fR is encountered in the stream. The read data is terminated
25 with a null byte ('\fB\e0\fR\&') and a pointer to the trailing null is
26 returned. If a \fIbreakstring\fR character is encountered, the last non-null is
27 the delimiter character that terminated the scan.
30 Note that, except for the fact that the returned value points to the \fBend\fR
31 of the read string rather than to the beginning, the call
35 bgets(buffer, sizeof buffer, stream, "\en");
45 fgets (buffer, sizeof buffer, stream);
51 There is always enough room reserved in the buffer for the trailing null
55 If \fIbreakstring\fR is a null pointer, the value of \fIbreakstring\fR from the
56 previous call is used. If \fIbreakstring\fR is null at the first call, no
57 characters will be used to delimit the string.
61 \fINULL\fR is returned on error or end-of-file. Reporting the condition is
62 delayed to the next call if any characters were read but not yet returned.
65 \fBExample 1 \fRExample of the \fBbgets()\fR function.
68 The following example prints the name of the first user encountered in
69 \fB/etc/passswd\fR, including a trailing ":"
82 if ((fp = fopen("/etc/passwd","r")) == NULL) {
83 perror("/etc/passwd");
86 if (bgets(buffer, 8, fp, ":") == NULL) {
99 See \fBattributes\fR(5) for descriptions of the following attributes:
107 ATTRIBUTE TYPE ATTRIBUTE VALUE
115 \fBgets\fR(3C), \fBattributes\fR(5)