GETLIN

Section: Howard\'s C library (3 -lhoward)
Updated: $Revision: 1.7 $
Index Return to Main Contents
 

NAME

getlin, getlic - read one line from a stream  

SYNOPSIS

#include <stdio.h>
#include <howard/port.h>

bStrT getlin (linebuf, bufsize, infile , filename, lineno, tabwidth )

bStrT linebuf;
unsigned bufsize;
streamT infile;
bStrT filename;
unsigned *lineno;
unsigned tabwidth;

bStrT getlic (linebuf, bufsize, infile , filename, lineno, tabwidth , comment)

bStrT linebuf;
unsigned bufsize;
streamT infile;
bStrT filename;
unsigned *lineno;
unsigned tabwidth;
rcharT comment;
 

COPYRIGHT

Copyright © 1989 Howard Lee Gayle  

DESCRIPTION

Getlin attempts to read one line from the Standard I/O Library stream infile. On success, the line is stored in the buffer to which linebuf points. The newline character at the end of the line is removed. The line is NUL terminated. The current line number, to which lineno points, is incremented. If tabwidth is zero then tabs are not expanded. Otherwise, tabs are expanded into spaces, and tabwidth gives the spacing between tab columns.

Getlic is like getlin, except that the final comment argument is taken to be a character indicating the start of a comment that continues until the end of a line. Getlic strips comments. It then strips any spaces or tabs at the ends of lines. It does not return blank lines.  

ERRORS

Getlic and getlin check for several errors. In each case, malf1 is called to print an appropriate error message and exit. The file name filename is included in the error messages. The following errors are checked:
-
The input line would overflow the buffer, whose size is given by bufsize.
-
Read error.
-
End of file in the middle of a line. That is, the file is not empty, and the last character is not a newline.
-
NUL in file.
 

RETURNS

On success, getlic and getlin return a pointer to the NUL terminator of the line read into linebuf. On normal end of file, they return NULBSTR. They do not return on error.  

EXAMPLE

To copy standard input to standard output and expand tabs into spaces:
   unsigned     ln = 0;
   static byteT l[1024];

   while (NULBSTR != getlin (l, 1024, stdin, "Standard Input", &ln, 8))
      (void) puts (l);
 

SEE ALSO

intro(3S), malf(3 -lhoward).  

BUGS

Overflow of the line number is not checked.  

LICENSE

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 1, as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  

AUTHOR

Howard Gayle, TN/ETX/T/BG, Ericsson Telecom AB, S-126 25 Stockholm, Sweden, howard@ericsson.se, uunet!ericsson.se!howard, Phone: +46 8 719 5565, FAX: +46 8 719 9598, Telex: 14910 ERIC S


 

Index

NAME
SYNOPSIS
COPYRIGHT
DESCRIPTION
ERRORS
RETURNS
EXAMPLE
SEE ALSO
BUGS
LICENSE
AUTHOR

This document was created by man2html, using the manual pages.
Time: 21:53:03 GMT, February 02, 2023