GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
eol.c
Go to the documentation of this file.
1 
2 /***********************************************************
3 * I_get_to_eol (line,len,fd)
4 *
5 * Reads from fd until the newline, copying the first len-1
6 * characters into line. The newline is not copied.
7 * len should be the length of line in bytes. This allows for
8 * a NULL to be added at the end.
9 ***********************************************************/
10 #include <grass/imagery.h>
11 #include <stdio.h>
12 int I_get_to_eol(char *line, int len, FILE * fd)
13 {
14  int c;
15  int n;
16 
17  n = len - 1;
18  while ((c = fgetc(fd)) >= 0 && c != '\n')
19  if (n-- > 0)
20  *line++ = c;
21  if (len > 0)
22  *line = 0;
23  return c == '\n';
24 }
FILE * fd
Definition: g3dcolor.c:368
int n
Definition: dataquad.c:291
int I_get_to_eol(char *line, int len, FILE *fd)
Definition: eol.c:12