GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
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 }
int I_get_to_eol(char *line, int len, FILE *fd)
Definition: eol.c:12