NAME

sget_line - Reads a line from a string into a buffer

SYNOPSIS

#include "l/l_string.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 


int sget_line
(
	char **str_ptr,
	char *line,
	size_t max_len
);

PARAMETERS

char **str_ptr
Address of string pointer. Will be moved to next line.
char *line
Buffer for the line.
size_t max_len
Size of buffer.

DESCRIPTION

The routine sget_line copies the next line of a string into a buffer. The string position is the set to the begining of the part which was not read. If there is enough room in the buffer, all the characters up to the new line are read. Otherwise, only max_len-1 characters are read. Regardless, the buffer is terminated with a NULL. The new line character is processed, but not copied. In other words, line will not contain a new line character.

RETURNS

If there are no more characters to be read, then EOF is returned. If the buffer is not large enough, SET_BUFFER_OVERFLOW_BUG() is called, and TRUNCATED is returned. Otherwise NO_ERROR is returned.

NOTE

If the argument is (const char**), then use const_sget_line() instead. Both sget_line() and const_sget_line() do the same thing. Neither change the actual string being parsed, only the position pointer. There are two versions to better communicate with various compilers.

NOTE

If the number of characters read is required, then sget_line_2 should be used.

MACROS

BUFF_SGET_LINE(char** str_ptr, char line[]) The buffer size parameter is set to sizeof(line). 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

signed_strlen , trim_beg , const_trim_beg , trim_end , trim_len , gen_trim_beg , const_gen_trim_beg , gen_trim_end , extended_uc_lc , extended_lc_uc , extended_n_uc_lc , extended_n_lc_uc , extended_tolower , extended_toupper , void_strcmp , kjb_strcmp , kjb_memcmp , kjb_strncmp , kjb_ic_strcmp , kjb_ic_strncmp , head_cmp , ic_head_cmp , ptr_strcmp , ptr_strncmp , ptr_ic_strcmp , ptr_head_cmp , ptr_ic_head_cmp , rpad , rpad_cpy , kjb_strdup , str_trunc_cpy , str_trunc_cat , trunc_quote_cpy , kjb_buff_cpy , kjb_strncpy , kjb_memcpy , extended_lc_strncpy , extended_uc_strncpy , kjb_buff_cat , kjb_strncat , cap_first_letter_cpy , str_build , str_n_build , str_char_build , byte_build , increment_byte_copy , fill_with_blanks , find_string , find_char , n_find_char , find_char_pair , count_char , word_in_phrase , char_for_char_translate , remove_duplicate_chars , str_delete , str_insert , const_sget_line , sget_line_2 , const_sget_line_2 , get_str_indent , last_char , kjb_reverse , output_str