from the ANSI standard
[unix-history] / usr / src / lib / libc / net / getservent.3
CommitLineData
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
21getservent, getservbyport, getservbyname, setservent,
22endservent \- get service entry
ed06f32e
KM
23.SH SYNOPSIS
24.nf
25.ft B
26#include <netdb.h>
27.PP
28.ft B
29struct servent *getservent()
30.PP
31.ft B
32struct servent *getservbyname(name, proto)
33char *name, *proto;
34.PP
35.ft B
36struct servent *getservbyport(port, proto)
37int port; char *proto;
38.PP
39.ft B
40setservent(stayopen)
41int stayopen
42.PP
43.ft B
44endservent()
45.fi
46.SH DESCRIPTION
47.IR Getservent ,
48.IR getservbyname ,
49and
50.I getservbyport
51each return a pointer to an object with the
52following structure
53containing the broken-out
54fields of a line in the network services data base,
55.IR /etc/services .
56.RS
57.PP
58.nf
59struct 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
70The members of this structure are:
71.TP \w's_aliases'u+2n
72s_name
73The official name of the service.
74.TP \w's_aliases'u+2n
75s_aliases
76A zero terminated list of alternate names for the service.
77.TP \w's_aliases'u+2n
78s_port
79The port number at which the service resides.
80Port numbers are returned in network byte order.
81.TP \w's_aliases'u+2n
82s_proto
83The name of the protocol to use when contacting the
84service.
85.PP
86.I Getservent
87reads the next line of the file, opening the file if necessary.
88.PP
89.I Setservent
90opens and rewinds the file. If the
91.I stayopen
92flag is non-zero,
93the net data base will not be closed after each call to
ec178508
JL
94.I getservbyname
95or .IR getservbyport .
ed06f32e
KM
96.PP
97.I Endservent
98closes the file.
99.PP
100.I Getservbyname
101and
102.I getservbyport
103sequentially search from the beginning
104of the file until a matching
105protocol name or
106port number is found,
107or until EOF is encountered.
108If a protocol name is also supplied (non-NULL),
109searches must also match the protocol.
110.SH FILES
111/etc/services
112.SH "SEE ALSO"
56e6bd55 113getprotoent(3), services(5)
ed06f32e
KM
114.SH DIAGNOSTICS
115Null pointer
116(0) returned on EOF or error.
117.SH BUGS
118All information
119is contained in a static area
120so it must be copied if it is
121to be saved. Expecting port
122numbers to fit in a 32 bit
123quantity is probably naive.