HP-UX Reference (11i v1 00/12) - 3 Library Functions A-M (vol 6)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/!!!intro.3c
________________________________________________________________
___ ___
b
bgets(3G) bgets(3G)
NAME
bgets() - read stream up to next delimiter
SYNOPSIS
#include <libgen.h>
char *bgets (char *
buffer, size_t *count, FILE *stream,
const char *
breakstring);
DESCRIPTION
bgets reads characters from stream into buffer until either count is exhausted or one of the characters in
breakstring is encountered in the stream. The read data is terminated with a null byte (’ \0’) and a pointer
to the trailing null is returned. If a breakstring character is encountered, the last non-null is the delimiter
character that terminated the scan.
Note that, except for the fact that the returned value points to the end of the read string rather than to
the beginning, the call
bgets(buffer, sizeof buffer, stream, \n);
is identical to
fgets(buffer, sizeof buffer, stream);
There is always enough room reserved in the buffer for the trailing null.
If breakstring is a null pointer, the value of breakstring from the previous call is used. If breakstring is null
at the first call, no characters will be used to delimit the string.
RETURN VALUE
NULL is returned on error or end-of-file. Reporting the condition is delayed to the next call if any charac-
ters were read but not yet returned.
APPLICATION USAGE
bgets is thread-safe. It is not async-cancel-safe. A cancellation point may occur when a thread is execut-
ing bgets.
EXAMPLES
#include <libgen.h>
char buffer[8];
/* read in first user name from /etc/passwd */
fp = fopen("/etc/passwd","r");
bgets(buffer, 8, fp, ":");
SEE ALSO
gets(3S).
HP-UX Release 11i: December 2000 1 Section 337
___
___