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