ypclnt.3yp
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 3YP 代码 · 共 389 行
3YP
389 行
.\" SCCSID: @(#)ypclnt.3yp 8.1 9/11/90.TH ypclnt 3yp.SH Nameyp_get_default_domain, yp_bind, yp_unbind, yp_match, yp_first,yp_next, yp_all, yp_order, yp_master, yperr_string, ypprot_err \- Yellow Pages client package.SH Syntax.nf.B #include <rpcsvc/ypclnt.h>.sp .5.B yp_get_default_domain(\fIoutdomain\fP).B char \fI**outdomain\fP;.sp .5.B yp_bind(\fIindomain\fP).B char *\fIindomain\fP;.sp .5.B void yp_unbind(\fIindomain\fP).B char \fI*indomain\fP;.sp .5.B yp_match(\fIindomain, inmap, inkey, inkeylen, outval, outvallen\fP).B char \fI*indomain\fP;.B char \fI*inmap\fP;.B char \fI*inkey\fP;.B int \fIinkeylen\fP;.B char \fI**outval\fP;.B int \fI*outvallen\fP;.sp .5.B yp_first(\fIindomain, inmap, outkey, outkeylen, outval, outvallen\fP).B char \fI*indomain\fP;.B char \fI*inmap\fP;.B char \fI**outkey\fP;.B int \fI*outkeylen\fP;.B char \fI**outval\fP;.B int \fI*outvallen\fP;.sp .5.B yp_next(\fIindomain, inmap, inkey, inkeylen, outkey, outkeylen, outval, outvallen\fP).B char \fI*indomain\fP;.B char \fI*inmap\fP;.B char \fI*inkey\fP;.B int \fIinkeylen\fP;.B char \fI**outkey\fP;.B int \fI*outkeylen\fP;.B char \fI**outval\fP;.B int \fI*outvallen\fP;.sp .5.B yp_all(\fIindomain, inmap, incallback\fP).B char \fI*indomain\fP;.B char \fI*inmap\fP;.B struct ypall_callback \fIincallback\fP;.sp .5.B yp_order(\fIindomain, inmap, outorder\fP).B char \fI*indomain\fP;.B char \fI*inmap\fP;.B int \fI*outorder\fP;.sp .5.B yp_master(\fIindomain, inmap, outname\fP).B char \fI*indomain\fP;.B char \fI*inmap\fP;.B char \fI**outname\fP;.sp .5.B char *yperr_string(\fIincode\fP).B int \fIincode\fP;.sp .5.B ypprot_err(\fIincode\fP).B unsigned int \fIincode\fP;.fi.SH Description.NXR "ypclnt keyword".NXR "yp_get_default_domain subroutine".NXR "yp_bind subroutine".NXR "yp_unbind subroutine".NXR "yp_match subroutine".NXR "yp_first subroutine".NXR "yp_next subroutine".NXR "yp_all subroutine".NXR "yp_order subroutine".NXR "yp_master subroutine".NXR "yperr_string subroutine".NXR "ypprot_err subroutine".NXR "YP client interface"This package of functions provides an interface to the Yellow Pages (YP) data base lookup service. The package can be loaded from the standard library, .PN /lib/libc.a .Refer to .MS ypfiles 5ypand.MS ypserv 8ypfor an overview of the Yellow Pages, including the definitions of .B mapand .B domain,and for a description of the servers, data bases, and commands that constitute the YP application..PPAll input parameters names begin with .B in.Output parameters begin with .B out. Output parameters of type.B "char **"should be addresses of uninitialized character pointers.The YP client package allocates memory using.MS malloc 3 .This memory can be freed ifthe user code has no continuing need for it. For each.B outkey and.B outval,two extra bytes of memory are allocated at the end that containNEWLINE and NULL, respectively,but these two bytes are not reflected in.B outkeylen or.B outvallen.The.B indomainand .B inmapstrings must be non-null and null-terminated. Stringparameters that are accompanied by a count parameter cannot be null, butcan point to null strings, with the count parameter indicating this.Counted strings need not be null-terminated..PPAll functions of type \fBint\fPreturn 0 if they succeed, or a failure code (YPERR_ xxxx )if they do not succeed. Failure codes are described under .B Diagnostics..PPThe YP lookup calls require a map name and a domain name.It is assumed that the client process knows the name of the map of interest. Client processes fetch the node's default domain by calling .PN yp_get_default_domain ,and use the returned.B outdomain as the.B indomain parameter to successive YP calls..PPTo use YP services, the client process must be bound to a YP server that serves the appropriate domain. The binding is accomplishedwith.PN yp_bind .Binding need not be done explicitly by user code; it is done automatically whenever a YP lookup function is called.The .PN yp_bindfunction can be called directly for processes that make use of a backup strategy in cases whenYP services are not available..PPEach binding allocates one client process socket descriptor;each bound domain requires one socket descriptor. Multiple requests to the same domain use that same descriptor.The.PN yp_unbindfunction is available at the client interface for processes that explicitly manage their socket descriptors while accessing multiple domains. The call to .PN yp_unbindmakes the domain unbound, and frees all per-process and per-node resources used to bind it..PPIf an RPC failure results upon use of a binding, that domain will beunbound automatically. At that point, the ypclnt layer will retry forever or until the operation succeeds. This action occurs provided that .PN ypbindis running, and eitherthe client process cannot bind a server for the proper domain, orRPC requests to the server fail. .PPThe .PN ypbind .B \-s option allows the system administratorto lock .PN ypbind to a particular domain and set of servers.Up to four servers can be specified.An example of the .B \-soption follows:.EX/etc/ypbind \-s domain,server1[,server2,server3,server4].EE.PPThe ypclnt layer will return control to the user code, either with anerror code, or with a success code and any results under certain circumstances. For example, control will be returned to the user code when an error is not RPC-relatedand also when the .PN ypbindfunction is not running.An additional situation that will cause the return of control is when a bound ypserv process returns any answer (success or failure)..PPThe.PN yp_matchfunction returns the value associated with a passed key. This key must be exact; no pattern matching is available..PPThe.PN yp_firstfunction returns the first key-value pair from the named map in thenamed domain..PPThe.PN yp_nextfunction returns the next key-value pair in a named map. The .B inkey parameter should be the.B outkeyreturned from an initial call to .PN yp_first(to get the second key-value pair)or the one returned from the nth call to .PN yp_next(to get the nth + second key-value pair)..PPThe concept of first and of next is particular to thestructure of the YP map being processed; there is no relation inretrieval order to either the lexical order within any original (non-YP)data base, or to any obvious numerical sorting order on the keys, values, or key-value pairs. The only ordering guarantee made is that if the .PN yp_firstfunction is called on a particular map, and then the.PN yp_nextfunction is repeatedly called on the same map at the same server until the call fails with a reason of YPERR_NOMORE, every entry in the data base will be seen exactly once. Further, if the same sequence of operations is performed on the same map at the same server, the entries will be seen in the same order. .PPUnder conditions of heavy server load or server failure, itis possible for the domain to become unbound, then boundonce again (perhaps to a different server) while a client is running. This can cause a break in one of the enumeration rules;specific entries may be seen twice by the client, or not at all.This approach protects the client from error messages that wouldotherwise be returned in the midst of the enumeration.Enumerating all entries in a map is accomplished with the.PN yp_allfunction..PPThe.PN yp_allfunction provides a way to transfer an entire mapfrom server to client in a single request using TCP (rather than UDP as with other functions in this package).The entire transaction take place as a single RPC request andresponse.The .PN yp_allfunction can be used like any other YP procedure, to identify the map in the normal manner, and to supply the name of afunction that will be called to process each key-value pair within the map. Returns from the call to.PN yp_alloccur only when the transaction is completed (successfully or unsuccessfully), or when the.PN foreachfunction decides that it does not want to see any more key-value pairs..PPThe third parameter to.PN yp_allis .EXstruct ypall_callback *incallback { int (*foreach)(); char *data;};.EE.PPThe function.PN foreachis called .EXforeach(instatus, inkey, inkeylen, inval, invallen, indata);int instatus;char *inkey;int inkeylen;char *inval;int invallen;char *indata;.EE.PPThe.B instatusparameter will hold one of the return status values defined in <rpcsvc/yp_prot.h> \(em either YP_TRUE or an error code. (See .B ypprot_err,below, for a function thatconverts a YP protocol error code to a ypclnt layer error code.).PPThe key and value parameters are somewhat different than defined in the syntax section above. First, the memory pointed to by the .B inkeyand .B invalparameters is private to the .PN yp_allfunction and is overwritten with thearrival of each new key-value pair.It is the responsibility of the .PN foreach function to do something useful with the contents of that memory, but itdoes not own the memory itself. Key and value objects presented to the.PN foreach function look exactly as they do in the server's map \(em if theywere not newline-terminated or null-terminated in the map, they will not behere either..PPThe.B indataparameter is the contents of the .B incallback->dataelement passed to.PN yp_all .The.B dataelement of the callback structure may be used to share state informationbetween the .PN foreachfunction and the mainline code. Its use is optional, and no part of the YP client package inspects its contents..PPThe .PN foreachfunction returns a Boolean value.It should return zero to indicate that itwants to be called again for further received key-value pairs, ornonzero to stop the flow of key-value pairs. If.PN foreachreturns a nonzero value, it is not called again; the functionalvalue of.PN yp_allis then 0..PPThe.PN yp_orderfunction returns the order number for a map..PPThe.PN yp_masterfunction returns the machine name of the master YP server for a map..PPThe.PN yperr_stringfunction returns a pointer to an error message string that isnull-terminated but contains no period or new line..PPThe.PN ypprot_errfunction takes a YP protocol error code as input and returns a ypclntlayer error code, which may be used in turn as an input to .PN yperr_string ..SH DiagnosticsAll integer functions return 0 if the requested operation is successful,or one of the following errors if the operation fails..PP.ta \w'#define\0'u +\w'YPERR_BADARGS\0\0'u +\w'1\0\0'u.nf#define YPERR_BADARGS 1 /* args to function are bad */#define YPERR_RPC 2 /* RPC failure - domain has been unbound */#define YPERR_DOMAIN 3 /* can't bind to server on this domain */#define YPERR_MAP 4 /* no such map in server's domain */#define YPERR_KEY 5 /* no such key in map */#define YPERR_YPERR 6 /* internal yp server or client error */#define YPERR_RESRC 7 /* resource allocation failure */#define YPERR_NOMORE 8 /* no more records in map database */#define YPERR_PMAP 9 /* can't communicate with portmapper */#define YPERR_YPBIND 10 /* can't communicate with ypbind */#define YPERR_YPSERV 11 /* can't communicate with ypserv */#define YPERR_NODOM 12 /* local domain name not set */.fi.SH Files/usr/include/rpcsvc/ypclnt.h.br/usr/include/rpcsvc/yp_prot.h.SH See Alsoypfiles(5yp), ypserv(8yp)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?