getservent.3n (2010 09)

g
getservent(3N) getservent(3N)
OBSOLESCENT INTERFACES
int getservent_r(struct servent *result,
struct servent_data *buffer);
int getservbyname_r(const char *name,
const char *proto,
struct servent *result,
struct servent_data *buffer);
int getservbyport_r(int port,
const char *proto,
struct servent *result,
struct servent_data *buffer);
int setservent_r(int stayopen, struct servent_data *buffer);
int endservent_r(struct servent_data *buffer);
The above reentrant interfaces have been moved from
libc to libd4r. They are included to support
existing applications and may be removed in a future release. New multithreaded applications should
use the regular APIs without the
_r suffix.
The reentrant interfaces performs the same operations as their regular counterpart (those without the
_r
suffix.) However, getservent_r()
, getservbyname_r(), and getservbyport_r()
expect to be
passed the address of a
struct servent and will store the address of the result at this supplied
parameter. An additional parameter, an address to a struct servent_data , which is defined in the file
<netdb.h> cannot be a NULL pointer.
The reentrant routines return
1 if the operation is unsuccessful, or, in the case of
getservent_r(),if
the end of the services list has been reached.
0 is returned otherwise.
RETURN VALUE
getservent(), getservbyname()
, and getservbyport() return a null pointer (0) on EOF or
when they are unable to open
/etc/services
.
EXAMPLES
The following code excerpt counts the number of service entries:
int count = 0;
(void) setservent(0);
while (getservent() != NULL)
count++;
(void) endservent();
WARNINGS
Programs that use the interfaces described in this manpage cannot be linked statically because the imple-
mentations of these functions employ dynamic loading and linking of shared objects at run time.
AUTHOR
getservent() was developed by Sun Microsystems Inc.
FILES
/etc/services
SEE ALSO
ypserv(1M), services(4), ypfiles(4), nsswitch.conf(4), thread_safety(5).
STANDARDS CONFORMANCE
getservent(): XPG4
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010