Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

rpcinfo(1M)

nsswitch.conf(4)

rpc(4)

getrpcbyname(3N)

NAME

getrpcbyname, getrpcbynumber, getrpcent, setrpcent, endrpcent − get RPC entry

SYNOPSIS

#include <rpc/rpcent.h>

struct rpcent ∗getrpcent(void);

struct rpcent ∗getrpcbyname(const char ∗ name);

struct rpcent ∗getrpcbynumber(const int number);

void setrpcent(const int stayopen);

void endrpcent(void);

cc [ flag ... ] file ... −lnsl [ library ... ]

MT-LEVEL

Unsafe

DESCRIPTION

getrpcbyname(), getrpcbynumber() and getrpcent() each return a RPC entry. 

The entry may come from one of the following sources: the RPC file (see rpc(4)), the NIS maps rpc.byname and rpc.bynumber, and the NIS+ table rpc.  The sources and their lookup order are specified in the /etc/nsswitch.conf file (see nsswitch.conf(4) for details). 

getrpcbyname() searches for a RPC entry with a given RPC name. 

getrpcbynumber() searches for a RPC entry with a given RPC program number. 

getrpcent() enumerates RPC entries:  successive calls to getrpcent() return either successive RPC entries or NULL.  Enumeration may not be supported by some sources. 

setrpcent() “rewinds” to the beginning of the enumeration of RPC entries.  If the stayopen flag is non-zero, resources such as open file descriptors are not deallocated after each call to getrpcbynumber() and getrpcbyname().  Calls to getrpcbyname() and getrpcbynumber() may leave the enumeration in an indeterminate state, so setrpcent() should be called before the first getrpcent(). 

endrpcent() may be called to indicate that RPC processing is complete; the system may then close any open RPC file, deallocate storage, and so forth.  It is legitimate, but possibly less efficient, to call more RPC routines after endrpcent(). 

The internal representation of a RPC entry the rpcent structure defined in the header <rpc/rpcent.h>, and containing the following members:

char ∗r_name;/∗ name of server for this rpc program ∗/
char ∗∗r_aliases;/∗ a zero-terminated list of alternate names ∗/
long r_number;/∗ rpc program number ∗/

RETURN VALUES

getrpcbyname() and getrpcbynumber() return a pointer to a struct rpcent if they successfully locate the requested entry; otherwise they return NULL. 

getrpcent() returns a pointer to a struct rpcent if it successfully enumerates an entry; otherwise it returns NULL, indicating the end of the enumeration. 

FILES

/etc/rpc

/etc/nsswitch.conf

SEE ALSO

rpcinfo(1M), nsswitch.conf(4), rpc(4)

NOTES

All information is contained in a static area, so it must be copied if it is to be saved. 

Use of getrpcent() is deprecated; enumeration is well-defined for the rpc file and is supported (albeit inefficiently) for NIS and NIS+, but in general may not be well-defined.  The semantics of enumeration are discussed in nsswitch.conf(4). 

These interfaces are unsafe in multithreaded applications.  Unsafe interfaces should be called only from the main thread. 

BUGS

Programs that call getrpcbyname() or getrpcbynumber() routines cannot be linked statically since the implementation of these routines requires dynamic linker functionality to access shared objects at run time. 

SunOS 5.2  —  Last change: 22 Jan 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026