NAME
get_real_line - Reads a line from a stream ignoring blanks and comments
SYNOPSIS
#include "l/l_io.h"
Example compile flags (system dependent):
-DLINUX_X86_64 -DLINUX_X86_64_OPTERON -DGNU_COMPILER
-I/home/kobus/include
-L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
-lKJB -lfftw3 -lgsl -lgslcblas -ljpeg -lSVM -lstdc++ -lpthread -lSLATEC -lg2c -lacml -lacml_mv -lblas -lg2c -lncursesw
long get_real_line
(
FILE *fp,
char *line,
size_t max_len
);
DESCRIPTION
This routine is similar to fget_line() except that blank lines and
comment lines are ignored. Comment lines are identified by having the
kjb_comment_char in the first column. Normally kjb_comment_char is '#';
however this is normally exposed to the user as option.
The routine also looks for the comment character in the first column,
followed by !eof (e.g., #!eof), which acts like a soft end of file. In this
case the routine returns EOF, but a subsequent call will return the next
line. This is useful for laying out multiple data structures in a file,
separating them by the soft end of file. Then routines for reading the
sub-structures (e.g. read_matrix()) can be used in sequence for reading the
sub-data structures.
RETURNS
On success get_real_line() returns the number of bytes placed in the
buffer, excluding the NULL. Alternate return values are all negative. In
the case of end of file or soft end of file, EOF returned. If the line was
truncated, then TRUNCATED is returned. Depending on the signal traps and
options in place, INTERRUPTED is an additional possible return value. In
the case of non-blocking reads WOULD_BLOCK is returned unless a complete
line can be returned. ERROR is returned for unexpected problems and an
error message is set.
MACROS
BUFF_GET_REAL_LINE(FILE fp, char line[])
The max_len parameter is set to sizeof(line) with the appropriate cast.
Using sizeof to set the buffer size is recomended where applicable, as
the code will not be broken if the buffer size changes. HOWEVER, neither
this method, nor the macro, is applicable if line is NOT a character
array. If line is declared by "char* line", then the size of line is the
number of bytes in a character pointer (usually 4), which is NOT what is
normally intended. You have been WARNED!
DISCLAIMER
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.
AUTHOR
Kobus Barnard
DOCUMENTER
Kobus Barnard
SEE ALSO
set_program_prompt
,
kjb_query
,
print_blanks
,
rep_print
,
count_real_lines
,
count_data_lines_until_next_header
,
count_tokens_in_file
,
string_count_real_lines
,
string_get_real_line
,
get_command_text
,
add_line_to_input_stream
,
read_int_from_file
,
read_dbl_from_file
,
push_no_overwrite
,
pop_no_overwrite
,
set_no_overwrite
,
get_no_overwrite