HP-UX Reference (11i v2 07/12) - 3 Library Functions A-M (vol 6)

g
getrpcent(3C) getrpcent(3C)
NAME
getrpcent(), getrpcbyname(), getrpcbynumber(), - get rpc entry
SYNOPSIS
cc [ flag ... ] file ...
-lnsl [ library ... ]
#include <netdb.h>
struct rpcent *getrpcent();
struct rpcent *getrpcbyname(char *name);
struct rpcent *getrpcbynumber(int number);
int setrpcent(int stayopen);
int endrpcent();
DESCRIPTION
These functions are used to obtain entries for RPC (Remote Procedure Call) services. An entry may come
from any of the sources for rpc specified in the /etc/nsswitch.conf
file (see nsswitch.conf(4)).
getrpcbyname() searches for an entry with the RPC service name specified by the parameter name.
getrpcbynumber()
searches for an entry with the RPC program number number.
The functions
setrpcent() , getrpcent() , and endrpcent() are used to enumerate RPC entries
from the database.
setrpcent() sets (or resets) the enumeration to the beginning of the set of RPC entries. This function
should be called before the first call to getrpcent() . Calls to getrpcbyname()
and
getrpcbynumber()
leave the enumeration position in an indeterminate state. If the stayopen flag is
non-zero, the system may keep allocated resources such as open file descriptors until a subsequent call to
endrpcent() .
Successive calls to getrpcent() return either successive entries or NULL, indicating the end of the
enumeration.
endrpcent() may be called to indicate that the caller expects to do no further RPC entry retrieval
operations; the system may then deallocate resources it was using. It is still allowed, but possibly less
efcient, for the process to call more RPC entry retrieval functions after calling endrpcent() .
MULTITHREAD USAGE
Thread Safe: Yes
Cancel Safe: Yes
Fork Safe: No
Async-cancel Safe: No
Async-signal Safe: No
These functions can be called safely in a multithreaded environment. They may be cancellation points in
that they call functions that are cancel points.
In a multithreaded environment, these functions are not safe to be called by a child process after
fork()
and before exec(). These functions should not be called by a multithreaded application that support
asynchronous cancellation or asynchronous signals.
getrpcbyname(), getrpcbynumber() and getrpcent() use thread specific storage that is re-
used in each call. The return value,
struct rpcent, should be unique for each thread and should be
saved, if desired, before the thread makes the next getrpc*() call.
For enumeration in multithreaded applications, the position within the enumeration is a process-wide pro-
perty shared by all threads. setrpcent() may be used in a multithreaded application but resets the
enumeration position for all threads. If multiple threads interleave calls to getrpcent() , the threads
will enumerate disjoint subsets of the RPC entry database.
RETURN VALUE
RPC entries are represented by the struct rpcent structure defined in <netdb.h>:
struct rpcent {
char *r_name; /* name of this rpc service */
char **r_aliases; /* zero-terminated list of alternate names */
536 Hewlett-Packard Company 1 HP-UX 11i Version 2: December 2007 Update