getl.c File Reference

#include <stdio.h>
#include <grass/gis.h>

Include dependency graph for getl.c:

Go to the source code of this file.

Functions

int G_getl (char *buf, int n, FILE *fd)
 gets a line of text from a file
int G_getl2 (char *buf, int n, FILE *fd)
 gets a line of text from a file of any pedigree


Function Documentation

int G_getl ( char *  buf,
int  n,
FILE *  fd 
)

gets a line of text from a file

This routine runs fgets() to fetch a line of text from a file (advancing file pointer) and removes trailing newline. fgets() does not recognize '\r' as an EOL and will read past it.

Parameters:
buf,: string buffer to receive read data
n,: maximum number of bytes to read
fd,: file descriptor structure
Returns:
1 if ok, 0 if EOF

Definition at line 17 of file getl.c.

Referenced by G__read_cats(), G__read_Cell_head(), G_fread_key_value(), G_get_cell_title(), G_get_dig_title(), G_myname(), G_put_cell_title(), and G_read_history().

int G_getl2 ( char *  buf,
int  n,
FILE *  fd 
)

gets a line of text from a file of any pedigree

This routine is like G_getl() but is more portable. It supports text files created on various platforms (UNIX, MacOS9, DOS), i.e. \n (\012), \r (\015), and \r\n (\015\012) style newlines.

Reads in at most n characters from stream and stores them into the buffer pointed to by buf. Reading stops after an EOF or a newline. New line is not stored in the buffer. At least n+1 must be allocated for the string buffer.

Parameters:
buf,: string buffer to receive read data, at least n+1 must be allocated
n,: maximum number of bytes to read
fd,: file descriptor structure
Returns:
1 if ok, 0 if EOF

Definition at line 52 of file getl.c.

References G_debug().


Generated on Sun Apr 6 17:32:20 2008 for GRASS by  doxygen 1.5.5