xref: /386bsd/usr/share/man/cat3/gets.0 (revision a2142627)
1FGETS(3)                  386BSD Programmer's Manual                  FGETS(3)
2
3NNAAMMEE
4     ffggeettss, ggeettss - get a line from a stream
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<ssttddiioo..hh>>
8
9     _c_h_a_r *
10     ffggeettss(_c_h_a_r *_s_t_r, _s_i_z_e__t _s_i_z_e, _F_I_L_E *_s_t_r_e_a_m)
11
12     _c_h_a_r *
13     ggeettss(_c_h_a_r *_s_t_r)
14
15DDEESSCCRRIIPPTTIIOONN
16     The ffggeettss() function reads at most one less than the number of characters
17     specified by size from the given _s_t_r_e_a_m and stores them in the string
18     _s_t_r. Reading stops when a newline character is found, at end-of-file or
19     error.  The newline, if any, is retained.  In any case a `\0' character
20     is appended to end the string.
21
22     The ggeettss() function is equivalent to ffggeettss() with an infinite size and a
23     _s_t_r_e_a_m of _s_t_d_i_n, except that the newline character (if any) is not stored
24     in the string.  It is the caller's responsibility to ensure that the
25     input line, if any, is sufficiently short to fit in the string.
26
27RREETTUURRNN VVAALLUUEESS
28     Upon successful completion, ffggeettss() and ggeettss() return a pointer to the
29     string.  If end-of-file or an error occurs before any characters are
30     read, they return NULL. The ffggeettss() and functions ggeettss() do not
31     distinguish between end-of-file and error, and callers must use feof(3)
32     and ferror(3) to determine which occurred.
33
34EERRRROORRSS
35     [EBADF]  The given _s_t_r_e_a_m is not a readable stream.
36
37     The function ffggeettss() may also fail and set _e_r_r_n_o for any of the errors
38     specified for the routines fflush(3),  fstat(2),  read(2),  or malloc(3).
39
40
41     The function ggeettss() may also fail and set _e_r_r_n_o for any of the errors
42     specified for the routine getchar(3).
43
44SSEEEE AALLSSOO
45     feof(3),  ferror(3),  fgetline(3)
46
47SSTTAANNDDAARRDDSS
48     The functions ffggeettss() and ggeettss() conform to ANSI C3.159-1989 (``ANSI
49     C'').
50
51BBUUGGSS
52     Since it is usually impossible to ensure that the next input line is less
53     than some arbitrary length, and because overflowing the input buffer is
54     almost invariably a security violation, programs should _N_E_V_E_R use ggeettss().
55     The ggeettss() function exists purely to conform to ANSI C3.159-1989 (``ANSI
56     C'').
57
58BSD Experimental                 June 29, 1991                               1
59
60
61
62
63
64
65
66
67