Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

fparseln(3) [freebsd man page]

FPARSELN(3)						   BSD Library Functions Manual 					       FPARSELN(3)

NAME
fparseln -- return the next logical line from a stream LIBRARY
System Utilities Library (libutil, -lutil) SYNOPSIS
#include <stdio.h> #include <libutil.h> char * fparseln(FILE *stream, size_t *len, size_t *lineno, const char delim[3], int flags); DESCRIPTION
The fparseln() function returns a pointer to the next logical line from the stream referenced by stream. This string is NUL terminated and it is dynamically allocated on each invocation. It is the responsibility of the caller to free the pointer. By default, if a character is escaped, both it and the preceding escape character will be present in the returned string. Various flags alter this behaviour. The meaning of the arguments is as follows: stream The stream to read from. len If not NULL, the length of the string is stored in the memory location to which it points. lineno If not NULL, the value of the memory location to which is pointed to, is incremented by the number of lines actually read from the file. delim Contains the escape, continuation, and comment characters. If a character is NUL then processing for that character is disabled. If NULL, all characters default to values specified below. The contents of delim is as follows: delim[0] The escape character, which defaults to , is used to remove any special meaning from the next character. delim[1] The continuation character, which defaults to , is used to indicate that the next line should be concatenated with the current one if this character is the last character on the current line and is not escaped. delim[2] The comment character, which defaults to #, if not escaped indicates the beginning of a comment that extends until the end of the current line. flags If non-zero, alter the operation of fparseln(). The various flags, which may be or-ed together, are: FPARSELN_UNESCCOMM Remove escape preceding an escaped comment. FPARSELN_UNESCCONT Remove escape preceding an escaped continuation. FPARSELN_UNESCESC Remove escape preceding an escaped escape. FPARSELN_UNESCREST Remove escape preceding any other character. FPARSELN_UNESCALL All of the above. RETURN VALUES
Upon successful completion a pointer to the parsed line is returned; otherwise, NULL is returned. The fparseln() function uses internally fgetln(3), so all error conditions that apply to fgetln(3), apply to fparseln(). In addition fparseln() may set errno to ENOMEM and return NULL if it runs out of memory. SEE ALSO
fgetln(3) HISTORY
The fparseln() function first appeared in NetBSD 1.4 and FreeBSD 4.0. BSD
December 1, 1997 BSD

Check Out this Related Man Page

FGETLN(3)						   BSD Library Functions Manual 						 FGETLN(3)

NAME
fgetln -- get a line from a stream LIBRARY
Utility functions from BSD systems (libbsd, -lbsd) SYNOPSIS
#include <bsd/stdio.h> char * fgetln(FILE *stream, size_t *len); DESCRIPTION
The fgetln() function returns a pointer to the next line from the stream referenced by stream. This line is not a C string as it does not end with a terminating NUL character. The length of the line, including the final newline, is stored in the memory location to which len points and is guaranteed to be greater than 0 upon successful completion. (Note, however, that if the line is the last in a file that does not end in a newline, the returned text will not contain a newline.) RETURN VALUES
Upon successful completion a pointer is returned; this pointer becomes invalid after the next I/O operation on stream (whether successful or not) or as soon as the stream is closed. Otherwise, NULL is returned. The fgetln() function does not distinguish between end-of-file and error; the routines feof(3) and ferror(3) must be used to determine which occurred. If an error occurs, the global variable errno is set to indicate the error. The end-of-file condition is remembered, even on a terminal, and all subsequent attempts to read will return NULL until the condition is cleared with clearerr(3). The text to which the returned pointer points may be modified, provided that no changes are made beyond the returned size. These changes are lost as soon as the pointer becomes invalid. ERRORS
[EBADF] The argument stream is not a stream open for reading. The fgetln() function may also fail and set errno for any of the errors specified for the routines fflush(3), malloc(3), read(2), stat(2), or realloc(3). SEE ALSO
ferror(3), fgets(3), fgetwln(3), fopen(3), putc(3) HISTORY
The fgetln() function first appeared in 4.4BSD. BSD
April 19, 1994 BSD
Man Page