Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ bgets(3G) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

gets(3S)

bgets(3G)                                                         bgets(3G)

NAME
     bgets - read stream up to next delimiter

SYNOPSIS
     cc [flag ...] file ... -lgen [library ...]

     #include <libgen.h>

     char *bgets(char *buffer, sizet *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 ter-
     minated 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 following
     calls are identical:

          bgets (buffer, sizeof buffer, stream, "\n")

          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.

EXAMPLES
     #include  <libgen.h>

     char buffer[8];
     /* read in first user name from /etc/passwd */
     fp = fopen("/etc/passwd","r");
     bgets(buffer, 8, fp, ":");

RESULT
     NULL is returned on error or end-of-file. If characters have been read
     but not yet returned, the error condition is not reported until the
     next call.

SEE ALSO
     gets(3S).






Page 1                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026