HP-UX Reference (11i v1 05/09) - 3 Library Functions A-M (vol 6)

g
getprotoent(3N) getprotoent(3N)
RETURN VALUE
getprotoent()
, getprotobyname()
, and getprotobynumber()
return a null pointer (0) on
EOF or when they are unable to open
/etc/protocols.
OBSOLESCENT INTERFACES
int getprotoent_r(struct protoent *result,
struct protoent_data *buffer);
int getprotobyname_r(const char *name,
struct protoent *result,
struct protoent_data *buffer);
int getprotobynumber_r(int proto,
struct protoent *result,
struct protoent_data *buffer);
int setprotoent_r(int stayopen, struct protoent_data *buffer);
int endprotoent_r(struct protoent_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 _r.
The reentrant interfaces performs the same operation as their regular counterpart (those without the _r
suffix.) However, getprotoent_r()
, getprotobyname_r(), and getprotobyport_r()
expect to be passed the address of a struct protoent parameter and will store the address of the
result at this supplied parameter. An additional parameter, an address to struct protoent_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
getprotoent_r(),
if the end of the services list has been reached.
0 is returned otherwise.
EXAMPLES
The following code excerpt counts the number of protocols entries:
int count = 0;
(void) setprotoent(0);
while (getprotoent() != NULL)
count++;
(void) endprotoent();
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
getprotoent() was developed by Sun Microsystems Inc.
FILES
/etc/protocols
SEE ALSO
nis+(1), ypserv(1M), protocols(4), nsswitch.conf(4), ypfiles(4), thread_safety(5).
STANDARDS CONFORMANCE
getprotoent(): XPG4
Section 3360 Hewlett-Packard Company 2 HP-UX 11i Version 1: September 2005