1 /* Copyright 2002, Red Hat Inc. - all rights reserved */
2 /*
3 FUNCTION
4 <<getline>>---read a line from a file
5 
6 INDEX
7         getline
8 
9 SYNOPSIS
10         #include <stdio.h>
11         ssize_t getline(char **<[bufptr]>, size_t *<[n]>, FILE *<[fp]>);
12 
13 DESCRIPTION
14 <<getline>> reads a file <[fp]> up to and possibly including the
15 newline character.  The line is read into a buffer pointed to
16 by <[bufptr]> and designated with size *<[n]>.  If the buffer is
17 not large enough, it will be dynamically grown by <<getdelim>>.
18 As the buffer is grown, the pointer to the size <[n]> will be
19 updated.
20 
21 <<getline>> is equivalent to getdelim(bufptr, n, '\n', fp);
22 
23 RETURNS
24 <<getline>> returns <<-1>> if no characters were successfully read,
25 otherwise, it returns the number of bytes successfully read.
26 at end of file, the result is nonzero.
27 
28 PORTABILITY
29 <<getline>> is a glibc extension.
30 
31 No supporting OS subroutines are directly required.
32 */
33 
34 #define _DEFAULT_SOURCE
35 #include <_ansi.h>
36 #include <stdio.h>
37 
38 extern ssize_t __getdelim (char **, size_t *, int, FILE *);
39 
40 ssize_t
__getline(char ** lptr,size_t * n,FILE * fp)41 __getline (char **lptr,
42        size_t *n,
43        FILE *fp)
44 {
45   return __getdelim (lptr, n, '\n', fp);
46 }
47 
48