1
/* File ggets.h - goodgets is a safe alternative to gets */
2
/* By C.B. Falconer. Public domain 2002-06-22 */
3
/* attribution appreciated. */
6
/* Revised 2002-06-26 New prototype.
7
2002-06-27 Incomplete final lines
10
/* fggets and ggets [which is fggets(ln, stdin)] set *ln to
11
a buffer filled with the next complete line from the text
12
stream f. The storage has been allocated within fggets,
13
and is normally reduced to be an exact fit. The trailing
14
\n has been removed, so the resultant line is ready for
15
dumping with puts. The buffer will be as large as is
16
required to hold the complete line.
18
Note: this means a final file line without a \n terminator
19
has an effective \n appended, as EOF occurs within the read.
21
If no error occurs fggets returns 0. If an EOF occurs on
22
the input file, EOF is returned. For memory allocation
23
errors some positive value is returned. In this case *ln
24
may point to a partial line. For other errors memory is
25
freed and *ln is set to NULL.
27
Freeing of assigned storage is the callers responsibility
37
int fggets(char* *ln, FILE *f);
39
#define ggets(ln) fggets(ln, stdin)
1
/* File ggets.h - goodgets is a safe alternative to gets */
2
/* By C.B. Falconer. Public domain 2002-06-22 */
3
/* attribution appreciated. */
6
/* Revised 2002-06-26 New prototype.
7
2002-06-27 Incomplete final lines
10
/* fggets and ggets [which is fggets(ln, stdin)] set *ln to
11
a buffer filled with the next complete line from the text
12
stream f. The storage has been allocated within fggets,
13
and is normally reduced to be an exact fit. The trailing
14
\n has been removed, so the resultant line is ready for
15
dumping with puts. The buffer will be as large as is
16
required to hold the complete line.
18
Note: this means a final file line without a \n terminator
19
has an effective \n appended, as EOF occurs within the read.
21
If no error occurs fggets returns 0. If an EOF occurs on
22
the input file, EOF is returned. For memory allocation
23
errors some positive value is returned. In this case *ln
24
may point to a partial line. For other errors memory is
25
freed and *ln is set to NULL.
27
Freeing of assigned storage is the callers responsibility
37
int fggets( char* *ln,
40
#define ggets( ln ) fggets( ln, stdin )