cc [ flag ... ] file ... -lnsl [ library ... ]
#include <rpcsvc/ypclnt.h> #include <rpcsvc/yp_prot.h>
Safe
This package of functions provides an interface to NIS , Network Information Service Version 2, formerly referred to as YP. In this version of SunOS, NIS version 2 is supported only for compatibility with previous versions. The recommended enterprise level information service is NIS+ or NIS version 3, see nis+(1) . Moreover, this version of SunOS supports only the client interface to NIS version 2. It is expected that this client interface will be served either by an existing ypserv process running on another machine on the network that has an earlier version of SunOS or by an NIS+ server, see rpc.nisd(1M) , running in "YP-compatibility mode". Refer to the NOTES section in ypfiles(4) for implications of being an NIS client of an NIS+ server in "YP-compatibility mode", and to ypbind(1M) , ypwhich(1) , ypmatch(1) , and ypcat(1) for commands to access NIS from a client machine. The package can be loaded from the standard library, /usr/lib/libnsl.so.1.
All input parameter names begin with in. Output parameters begin with out. Output parameters of type char ** should be addresses of uninitialized character pointers. Memory is allocated by the NIS client package using malloc(3C) , and may be freed by the user code if it has no continuing need for it. For each outkey and outval, two extra bytes of memory are allocated at the end that contain NEWLINE and null, respectively, but these two bytes are not reflected in outkeylen or outvallen. indomain and inmap strings must be non-null and null-terminated. String parameters which are accompanied by a count parameter may not be null, but may point to null strings, with the count parameter indicating this. Counted strings need not be null-terminated.
All functions in this package of type int return 0 if they succeed, and a failure code (YPERR _xxxx) otherwise. Failure codes are described under ERRORS below.
yp_bind (char *indomain);
void yp_unbind(char *indomain);
- the client process cannot bind a server for the proper domain, or
- RPC requests to the server fail.
yp_get_default_domain (char **outdomain);
yp_match(char *indomain, char *inmap, char *inkey, int inkeylen, char **outval, int *outvallen);
yp_first(char *indomain, char *inmap, char **outkey, int *outkeylen, char **outval, int *outvallen);
yp_next(char *indomain, char *inmap,
char *inkey, int inkeylen, char **outkey, int *outkeylen, char **outval,
int *outvallen);
yp_all(char *indomain, char *inmap, struct ypall_callback *incallback);
struct ypall_callback *incallback { int (*foreach)(); char *data; };
foreach(int instatus, char *inkey, int inkeylen, char *inval, int invallen, char *indata);
yp_order(char *indomain, char *inmap, unsigned long *outorder);
yp_master(char *indomain, char *inmap, char **outname);
char *yperr_string(int incode);
ypprot_err (unsigned int incode);
All integer functions return 0 if the requested operation is successful, or one of the following errors if the operation fails.
YPERR_ACCESS 15 /* access violation */ YPERR_BADARGS 1 /* args to function are bad */ YPERR_BADDB 13 /* yp database is bad */ YPERR_BUSY 16 /* database busy */ YPERR_DOMAIN 3 /* can’t bind to server on this domain */ YPERR_KEY 5 /* no such key in map */ YPERR_MAP 4 /* no such map in server’s domain */ YPERR_NODOM 12 /* local domain name not set */ YPERR_NOMORE 8 /* no more records in map database */ YPERR_PMAP 9 /* can’t communicate with rpcbinder */ YPERR_RESRC 7 /* resource allocation failure */ YPERR_RPC 2 /* RPC failure - domain has been unbound */ YPERR_YPBIND 10 /* can’t communicate with ypbind */ YPERR_YPERR 6 /* internal yp server or client error */ YPERR_YPSERV 11 /* can’t communicate with ypserv */ YPERR_VERS 14 /* yp version mismatch */