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