GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
eol.c
Go to the documentation of this file.
1 /***********************************************************
2  * I_get_to_eol (line,len,fd)
3  *
4  * Reads from fd until the newline, copying the first len-1
5  * characters into line. The newline is not copied.
6  * len should be the length of line in bytes. This allows for
7  * a NULL to be added at the end.
8  ***********************************************************/
9 
10 #include <grass/imagery.h>
11 #include <stdio.h>
12 
13 int I_get_to_eol(char *line, int len, FILE *fd)
14 {
15  int c;
16  int n;
17 
18  n = len - 1;
19  while ((c = fgetc(fd)) >= 0 && c != '\n')
20  if (n-- > 0)
21  *line++ = c;
22  if (len > 0)
23  *line = 0;
24  return c == '\n';
25 }
int I_get_to_eol(char *line, int len, FILE *fd)
Definition: eol.c:13