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