]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
4b72fb64 | 3 | .\" %%%LICENSE_START(verbatim) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" References consulted: | |
26 | .\" Linux libc source code | |
27 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
28 | .\" 386BSD man pages | |
29 | .\" Modified Sat Jul 24 19:19:11 1993 by Rik Faith (faith@cs.unc.edu) | |
30 | .\" Modified Wed Oct 18 20:23:54 1995 by Martin Schulze <joey@infodrom.north.de> | |
31 | .\" Modified Mon Apr 22 01:50:54 1996 by Martin Schulze <joey@infodrom.north.de> | |
32 | .\" 2001-07-25 added a clause about NULL proto (Martin Michlmayr or David N. Welton) | |
33 | .\" | |
c973f769 | 34 | .TH GETSERVENT 3 2008-08-19 "GNU" "Linux Programmer's Manual" |
fea681da MK |
35 | .SH NAME |
36 | getservent, getservbyname, getservbyport, setservent, endservent \- | |
c13182ef | 37 | get service entry |
fea681da MK |
38 | .SH SYNOPSIS |
39 | .nf | |
40 | .B #include <netdb.h> | |
41 | .sp | |
42 | .B struct servent *getservent(void); | |
43 | .sp | |
44 | .BI "struct servent *getservbyname(const char *" name ", const char *" proto ); | |
45 | .sp | |
46 | .BI "struct servent *getservbyport(int " port ", const char *" proto ); | |
47 | .sp | |
48 | .BI "void setservent(int " stayopen ); | |
49 | .sp | |
50 | .B void endservent(void); | |
51 | .fi | |
52 | .SH DESCRIPTION | |
60a90ecd MK |
53 | The |
54 | .BR getservent () | |
01089ed5 MK |
55 | function reads the next entry from the services database (see |
56 | .BR services (5)) | |
57 | and returns a \fIservent\fP structure containing | |
58 | the broken-out fields from the entry. | |
59 | A connection is opened to the database if necessary. | |
fea681da | 60 | .PP |
60a90ecd MK |
61 | The |
62 | .BR getservbyname () | |
63 | function returns a \fIservent\fP structure | |
01089ed5 MK |
64 | for the entry from the database |
65 | that matches the service \fIname\fP using protocol \fIproto\fP. | |
1c44bd5b | 66 | If \fIproto\fP is NULL, any protocol will be matched. |
01089ed5 | 67 | A connection is opened to the database if necessary. |
fea681da | 68 | .PP |
60a90ecd MK |
69 | The |
70 | .BR getservbyport () | |
71 | function returns a \fIservent\fP structure | |
01089ed5 MK |
72 | for the entry from the database |
73 | that matches the port \fIport\fP (given in network byte order) | |
1c44bd5b MK |
74 | using protocol \fIproto\fP. |
75 | If \fIproto\fP is NULL, any protocol will be matched. | |
01089ed5 | 76 | A connection is opened to the database if necessary. |
fea681da | 77 | .PP |
60a90ecd MK |
78 | The |
79 | .BR setservent () | |
01089ed5 MK |
80 | function opens a connection to the database, |
81 | and sets the next entry to the first entry. | |
c7094399 | 82 | If \fIstayopen\fP is nonzero, |
01089ed5 MK |
83 | then the connection to the database |
84 | will not be closed between calls to one of the | |
85 | .BR getserv* () | |
86 | functions. | |
fea681da | 87 | .PP |
60a90ecd MK |
88 | The |
89 | .BR endservent () | |
01089ed5 | 90 | function closes the connection to the database. |
fea681da MK |
91 | .PP |
92 | The \fIservent\fP structure is defined in \fI<netdb.h>\fP as follows: | |
93 | .sp | |
bd191423 | 94 | .in +4n |
fea681da | 95 | .nf |
fea681da | 96 | struct servent { |
7295b7ed MK |
97 | char *s_name; /* official service name */ |
98 | char **s_aliases; /* alias list */ | |
99 | int s_port; /* port number */ | |
100 | char *s_proto; /* protocol to use */ | |
fea681da | 101 | } |
fea681da | 102 | .fi |
bd191423 | 103 | .in |
fea681da MK |
104 | .PP |
105 | The members of the \fIservent\fP structure are: | |
106 | .TP | |
107 | .I s_name | |
108 | The official name of the service. | |
109 | .TP | |
110 | .I s_aliases | |
01089ed5 | 111 | A NULL-terminated list of alternative names for the service. |
fea681da MK |
112 | .TP |
113 | .I s_port | |
114 | The port number for the service given in network byte order. | |
115 | .TP | |
116 | .I s_proto | |
117 | The name of the protocol to use with this service. | |
47297adb | 118 | .SH RETURN VALUE |
60a90ecd MK |
119 | The |
120 | .BR getservent (), | |
121 | .BR getservbyname () | |
122 | and | |
123 | .BR getservbyport () | |
23b21158 MK |
124 | functions return a pointer to a |
125 | statically allocated \fIservent\fP structure, or a NULL pointer if an | |
fea681da MK |
126 | error occurs or the end of the file is reached. |
127 | .SH FILES | |
128 | .TP | |
129 | .I /etc/services | |
130 | services database file | |
47297adb | 131 | .SH CONFORMING TO |
68e1685c | 132 | 4.3BSD, POSIX.1-2001. |
47297adb | 133 | .SH SEE ALSO |
fea681da MK |
134 | .BR getnetent (3), |
135 | .BR getprotoent (3), | |
23b21158 | 136 | .BR getservent_r (3), |
fea681da | 137 | .BR services (5) |