HP-UX Reference (11i v1 00/12) - 3 Library Functions A-M (vol 6)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/!!!intro.3c
________________________________________________________________
___ ___
g
getprotoent(3N) getprotoent(3N)
Name Service Switch-Based Operation
The library routines getprotobyname(), getprotobynumber(), getprotoent(), and their
reentrant counterparts, internally call the name service switch to access the "protocols" database lookup
policy configured in the /etc/nsswitch.conf file (see nsswitch.conf(4)). The lookup policy defines the
order and the criteria of the supported name services used to resolve protocol names and numbers.
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
ypserv(1M), protocols(4), nis+(1), nsswitch.conf(4), ypfiles(4).
STANDARDS CONFORMANCE
getprotoent(): XPG4
Section 3−−330 − 2 − HP-UX Release 11i: December 2000
___
___