Commit | Line | Data |
---|---|---|
56e6bd55 KB |
1 | .\" Copyright (c) 1983 The Regents of the University of California. |
2 | .\" All rights reserved. | |
ed06f32e | 3 | .\" |
91cff1e1 | 4 | .\" %sccs.include.redist.man% |
ed06f32e | 5 | .\" |
91cff1e1 | 6 | .\" @(#)getservent.3 6.5 (Berkeley) %G% |
56e6bd55 KB |
7 | .\" |
8 | .TH GETSERVENT 3 "" | |
ed06f32e KM |
9 | .UC 5 |
10 | .SH NAME | |
56e6bd55 KB |
11 | getservent, getservbyport, getservbyname, setservent, |
12 | endservent \- get service entry | |
ed06f32e KM |
13 | .SH SYNOPSIS |
14 | .nf | |
15 | .ft B | |
16 | #include <netdb.h> | |
17 | .PP | |
18 | .ft B | |
19 | struct servent *getservent() | |
20 | .PP | |
21 | .ft B | |
22 | struct servent *getservbyname(name, proto) | |
23 | char *name, *proto; | |
24 | .PP | |
25 | .ft B | |
26 | struct servent *getservbyport(port, proto) | |
27 | int port; char *proto; | |
28 | .PP | |
29 | .ft B | |
30 | setservent(stayopen) | |
31 | int stayopen | |
32 | .PP | |
33 | .ft B | |
34 | endservent() | |
35 | .fi | |
36 | .SH DESCRIPTION | |
37 | .IR Getservent , | |
38 | .IR getservbyname , | |
39 | and | |
40 | .I getservbyport | |
41 | each return a pointer to an object with the | |
42 | following structure | |
43 | containing the broken-out | |
44 | fields of a line in the network services data base, | |
45 | .IR /etc/services . | |
46 | .RS | |
47 | .PP | |
48 | .nf | |
49 | struct servent { | |
50 | char *s_name; /* official name of service */ | |
51 | char **s_aliases; /* alias list */ | |
50159ed7 | 52 | int s_port; /* port service resides at */ |
ed06f32e KM |
53 | char *s_proto; /* protocol to use */ |
54 | }; | |
55 | .ft R | |
56 | .ad | |
57 | .fi | |
58 | .RE | |
59 | .PP | |
60 | The members of this structure are: | |
61 | .TP \w's_aliases'u+2n | |
62 | s_name | |
63 | The official name of the service. | |
64 | .TP \w's_aliases'u+2n | |
65 | s_aliases | |
66 | A zero terminated list of alternate names for the service. | |
67 | .TP \w's_aliases'u+2n | |
68 | s_port | |
69 | The port number at which the service resides. | |
70 | Port numbers are returned in network byte order. | |
71 | .TP \w's_aliases'u+2n | |
72 | s_proto | |
73 | The name of the protocol to use when contacting the | |
74 | service. | |
75 | .PP | |
76 | .I Getservent | |
77 | reads the next line of the file, opening the file if necessary. | |
78 | .PP | |
79 | .I Setservent | |
80 | opens and rewinds the file. If the | |
81 | .I stayopen | |
82 | flag is non-zero, | |
83 | the net data base will not be closed after each call to | |
ec178508 JL |
84 | .I getservbyname |
85 | or .IR getservbyport . | |
ed06f32e KM |
86 | .PP |
87 | .I Endservent | |
88 | closes the file. | |
89 | .PP | |
90 | .I Getservbyname | |
91 | and | |
92 | .I getservbyport | |
93 | sequentially search from the beginning | |
94 | of the file until a matching | |
95 | protocol name or | |
96 | port number is found, | |
97 | or until EOF is encountered. | |
98 | If a protocol name is also supplied (non-NULL), | |
99 | searches must also match the protocol. | |
100 | .SH FILES | |
101 | /etc/services | |
102 | .SH "SEE ALSO" | |
56e6bd55 | 103 | getprotoent(3), services(5) |
ed06f32e KM |
104 | .SH DIAGNOSTICS |
105 | Null pointer | |
106 | (0) returned on EOF or error. | |
107 | .SH BUGS | |
108 | All information | |
109 | is contained in a static area | |
110 | so it must be copied if it is | |
111 | to be saved. Expecting port | |
112 | numbers to fit in a 32 bit | |
113 | quantity is probably naive. |