/* tab:8 * * read_line.h - header file for line-by-line parsing utility * * "Copyright (c) 1999 by Steven S. Lumetta." * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice and the following * two paragraphs appear in all copies of this software. * * IN NO EVENT SHALL THE AUTHOR OR THE UNIVERSITY OF ILLINOIS BE LIABLE TO * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, * EVEN IF THE AUTHOR AND/OR THE UNIVERSITY OF ILLINOIS HAS BEEN ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * THE AUTHOR AND THE UNIVERSITY OF ILLINOIS SPECIFICALLY DISCLAIM ANY * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND NEITHER THE AUTHOR NOR * THE UNIVERSITY OF ILLINOIS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * * Author: Steve Lumetta * Version: 1 * Creation Date: Wed Feb 17 18:00:57 1999 * Filename: read_line.h * History: * SL 1 Wed Feb 17 18:00:57 1999 * First written. */ #ident "$Id$" #ifndef _READ_LINE_H #define _READ_LINE_H /* Reads from a file descriptor into a buffer, blocking unti one of the following conditions becomes true: an end-of-line is found in the input (see below) the input fills the buffer provided an error is encountered reading the file descriptor the input ends (end-of-file) Valid end-of-line sequences: CR, LF, CR/LF, LF/CR Returns a pointer to the buffer if any data were read successfully. Returns NULL if an error or EOF is reached without reading any data. EOL sequence is not included in the data returned. NOTE: read_line buffers data on a per-fd basis between calls; do not mix with other methods of reading data from the descriptor! */ char* read_line (int fd, char* buf, int len); #endif /* _READ_LINE_H */