Welcome to mirror list, hosted at ThFree Co, Russian Federation.

getline.c « stdio « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 741a7dc7784361f88b7e212b2615deb544e3a4d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
FUNCTION
<<getline>>---read a line from a file

INDEX
        getline

ANSI_SYNOPSIS
        #include <stdio.h>
        ssize_t getline(char **<[bufptr]>, size_t *<[n]>, FILE *<[fp]>);

TRAD_SYNOPSIS
        #include <stdio.h>
        ssize_t getline(<[bufptr]>, <[n]>, <[fp]>)
        char **<[bufptr]>;
        size_t *<[n]>;
        FILE *<[fp]>;

DESCRIPTION
<<getline>> reads a file <[fp]> up to and possibly including the
newline character.  The line is read into a buffer pointed to
by <[bufptr]> and designated with size *<[n]>.  If the buffer is
not large enough, it will be dynamically grown by <<getdelim>>.
As the buffer is grown, the pointer to the size <[n]> will be
updated.

<<getline>> is equivalent to getdelim(bufptr, n, '\n', fp);

RETURNS
<<getline>> returns <<-1>> if no characters were successfully read,
otherwise, it returns the number of bytes successfully read.
at end of file, the result is nonzero.

PORTABILITY
<<getline>> is a glibc extension.

No supporting OS subroutines are directly required.
*/

/* Copyright 2002, Red Hat Inc. - all rights reserved */

#include <stdio.h>

extern ssize_t __getdelim (char **, size_t *, int, FILE *);

ssize_t
__getline (lptr, n, fp)
     char **lptr;
     size_t *n;
     FILE *fp;
{
  return __getdelim (lptr, n, '\n', fp);
}