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