]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3p/getservent.3p
Import of man-pages 1.70
[thirdparty/man-pages.git] / man3p / getservent.3p
1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "ENDSERVENT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
3 .\" endservent
4 .SH NAME
5 endservent, getservbyname, getservbyport, getservent, setservent \-
6 network services database functions
7 .SH SYNOPSIS
8 .LP
9 \fB#include <netdb.h>
10 .br
11 .sp
12 void endservent(void);
13 .br
14 struct servent *getservbyname(const char *\fP\fIname\fP\fB, const
15 char *\fP\fIproto\fP\fB);
16 .br
17 struct servent *getservbyport(int\fP \fIport\fP\fB, const char *\fP\fIproto\fP\fB);
18 .br
19 struct servent *getservent(void);
20 .br
21 void setservent(int\fP \fIstayopen\fP\fB);
22 .br
23 \fP
24 .SH DESCRIPTION
25 .LP
26 These functions shall retrieve information about network services.
27 This information is considered to be stored in a database
28 that can be accessed sequentially or randomly. The implementation
29 of this database is unspecified.
30 .LP
31 The \fIsetservent\fP() function shall open a connection to the database,
32 and set the next entry to the first entry. If the
33 \fIstayopen\fP argument is non-zero, the \fInet\fP database shall
34 not be closed after each call to the \fIgetservent\fP()
35 function (either directly, or indirectly through one of the other
36 \fIgetserv*\fP()
37 functions), and the implementation may maintain an open file descriptor
38 for the database.
39 .LP
40 The \fIgetservent\fP() function shall read the next entry of the database,
41 opening and closing a connection to the database as
42 necessary.
43 .LP
44 The \fIgetservbyname\fP() function shall search the database from
45 the beginning and find the first entry for which the service
46 name specified by \fIname\fP matches the \fIs_name\fP member and the
47 protocol name specified by \fIproto\fP matches the
48 \fIs_proto\fP member, opening and closing a connection to the database
49 as necessary. If \fIproto\fP is a null pointer, any value
50 of the \fIs_proto\fP member shall be matched.
51 .LP
52 The \fIgetservbyport\fP() function shall search the database from
53 the beginning and find the first entry for which the port
54 specified by \fIport\fP matches the \fIs_port\fP member and the protocol
55 name specified by \fIproto\fP matches the
56 \fIs_proto\fP member, opening and closing a connection to the database
57 as necessary. If \fIproto\fP is a null pointer, any value
58 of the \fIs_proto\fP member shall be matched. The \fIport\fP argument
59 shall be in network byte order.
60 .LP
61 The \fIgetservbyname\fP(), \fIgetservbyport\fP(), and \fIgetservent\fP()
62 functions shall each return a pointer to a
63 \fBservent\fP structure, the members of which shall contain the fields
64 of an entry in the network services database.
65 .LP
66 The \fIendservent\fP() function shall close the database, releasing
67 any open file descriptor.
68 .LP
69 These functions need not be reentrant. A function that is not required
70 to be reentrant is not required to be thread-safe.
71 .SH RETURN VALUE
72 .LP
73 Upon successful completion, \fIgetservbyname\fP(), \fIgetservbyport\fP(),
74 and \fIgetservent\fP() return a pointer to a
75 \fBservent\fP structure if the requested entry was found, and a null
76 pointer if the end of the database was reached or the
77 requested entry was not found. Otherwise, a null pointer is returned.
78 .SH ERRORS
79 .LP
80 No errors are defined.
81 .LP
82 \fIThe following sections are informative.\fP
83 .SH EXAMPLES
84 .LP
85 None.
86 .SH APPLICATION USAGE
87 .LP
88 The \fIport\fP argument of \fIgetservbyport\fP() need not be compatible
89 with the port values of all address families.
90 .LP
91 The \fIgetservbyname\fP(), \fIgetservbyport\fP(), and \fIgetservent\fP()
92 functions may return pointers to static data, which
93 may be overwritten by subsequent calls to any of these functions.
94 .SH RATIONALE
95 .LP
96 None.
97 .SH FUTURE DIRECTIONS
98 .LP
99 None.
100 .SH SEE ALSO
101 .LP
102 \fIendhostent\fP() , \fIendprotoent\fP() , \fIhtonl\fP() , \fIinet_addr\fP()
103 , the Base Definitions volume of
104 IEEE\ Std\ 1003.1-2001, \fI<netdb.h>\fP
105 .SH COPYRIGHT
106 Portions of this text are reprinted and reproduced in electronic form
107 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
108 -- Portable Operating System Interface (POSIX), The Open Group Base
109 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
110 Electrical and Electronics Engineers, Inc and The Open Group. In the
111 event of any discrepancy between this version and the original IEEE and
112 The Open Group Standard, the original IEEE and The Open Group Standard
113 is the referee document. The original Standard can be obtained online at
114 http://www.opengroup.org/unix/online.html .