GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71942
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getl.c File Reference

GIS Library - Get line of text from file. More...

#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. More...
 
int G_getl2 (char *buf, int n, FILE *fd)
 Gets a line of text from a file of any pedigree. More...
 

Detailed Description

GIS Library - Get line of text from file.

(C) 2001-2009 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL

Definition in file getl.c.

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
bufstring buffer to receive read data
nmaximum number of bytes to read
fdfile descriptor structure
Returns
1 on success
0 EOF

Definition at line 31 of file getl.c.

Referenced by for(), G__read_Cell_head(), G_matrix_read(), G_myname(), M_read_list(), Rast__read_history(), Rast_get_cell_title(), and Rast_put_cell_title().

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-1 characters from stream (the last spot is reserved for the end-of-string NUL) 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 must be allocated for the string buffer.

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

Definition at line 64 of file getl.c.

Referenced by dig_read_frmt_ascii(), G_fread_key_value(), G_read_datum_table(), G_read_ellipsoid_table(), GPJ_get_datum_transform_by_name(), I_get_group_title(), Rast_put_reclass(), Rast_read_color_rule(), read_coor(), read_datum_table(), read_ellipsoid_table(), S_read(), Vect__read_head(), Vect_hist_read(), Vect_read_ascii(), and Vect_read_ascii_head().