summaryrefslogtreecommitdiffstats
path: root/newlib/libc/sys/linux/net/getprotoent.3
blob: 18b56541bf18d4b19e13a6f60ec55af30e944600 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
GETPROTOENT(3)                     BSD Library Functions Manual                    GETPROTOENT(3)

NAME
     getprotoent, getprotobynumber, getprotobyname, setprotoent, endprotoent -- get protocol en-
     try

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <netdb.h>

     struct protoent *
     getprotoent(void);

     struct protoent *
     getprotobyname(const char *name);

     struct protoent *
     getprotobynumber(int proto);

     void
     setprotoent(int stayopen);

     void
     endprotoent(void);

DESCRIPTION
     The getprotoent(), getprotobyname(), and getprotobynumber() functions each return a pointer
     to an object with the following structure containing the broken-out fields of a line in the
     network protocol data base, /etc/protocols.

           struct  protoent {
                   char    *p_name;        /* official name of protocol */
                   char    **p_aliases;    /* alias list */
                   int     p_proto;        /* protocol number */
           };

     The members of this structure are:

     p_name     The official name of the protocol.

     p_aliases  A zero terminated list of alternate names for the protocol.

     p_proto    The protocol number.

     The getprotoent() function reads the next line of the file, opening the file if necessary.

     The setprotoent() function opens and rewinds the file.  If the stayopen flag is non-zero,
     the net data base will not be closed after each call to getprotobyname() or
     getprotobynumber().

     The endprotoent() function closes the file.

     The getprotobyname() function and getprotobynumber() sequentially search from the beginning
     of the file until a matching protocol name or protocol number is found, or until EOF is en-
     countered.

RETURN VALUES
     Null pointer (0) returned on EOF or error.

FILES
     /etc/protocols

SEE ALSO
     protocols(5)

HISTORY
     The getprotoent(), getprotobynumber(), getprotobyname(), setprotoent(), and endprotoent()
     functions appeared in 4.2BSD.

BUGS
     These functions use a static data space; if the data is needed for future use, it should be
     copied before any subsequent calls overwrite it.  Only the Internet protocols are currently
     understood.

BSD                                        June 4, 1993                                       BSD