bgets man page on SmartOS

Man page or keyword search:  
man Server   16655 pages
apropos Keyword Search (all sections)
Output format
SmartOS logo
[printable version]

BGETS(3GEN)							   BGETS(3GEN)

       bgets - read stream up to next delimiter

       cc [ flag ... ] file ... -lgen [ library ... ]
       #include <libgen.h>

       char *bgets(char *buffer, size_t count, FILE  *stream,
	    const char *breakstring);

       The  bgets()  function  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 character.

       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.

       NULL is returned on error or end-of-file.  Reporting the	 condition  is
       delayed	to  the	 next	call  if  any characters were read but not yet

       Example 1 Example of the bgets() function.

       The following example prints the name of the first user encountered  in
       /etc/passswd, including a trailing ":"

	 #include <stdio.h>

	 int main()
	     char buffer[8];
	     FILE *fp;

	     if ((fp = fopen("/etc/passwd","r")) == NULL) {
		 return 1;
	     if (bgets(buffer, 8, fp, ":") == NULL) {
		 return 1;
	     (void) puts(buffer);
	     return 0;

       See attributes(5) for descriptions of the following attributes:

       │MT-Level       │ MT-Safe	 │

       gets(3C), attributes(5)

       When  compiling	multithread  applications, the _REENTRANT flag must be
       defined on the compile line.  This flag should only be used  in	multi‐
       threaded applications.

				  May 9, 2001			   BGETS(3GEN)

List of man pages available for SmartOS

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net