yp_match(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

yp_match(3c)

ypclnt(3C)               Standard C Library Functions               ypclnt(3C)

NAME
       ypclnt,  yp_get_default_domain, yp_bind, yp_unbind, yp_match, yp_first,
       yp_next, yp_all, yp_order, yp_master, yperr_string,  ypprot_err  -  NIS
       Version 2 client interface

SYNOPSIS
       #include <rpcsvc/ypclnt.h>
       #include <rpcsvc/yp_prot.h>

       int yp_bind(char *indomain);


       void yp_unbind (char *indomain);


       int yp_get_default_domain(char **outdomain);


       int yp_match(char *indomain, char *inmap, char *inkey, int inkeylen,
            char *char **outval, int *outvallen);


       int yp_first(char *indomain, char *inmap, char **outkey, int *outkeylen,
            char **outval, int *outvallen);


       int yp_next(char *indomain, char *inmap, char *inkey, intinkeylen,
            char **outkey, int *outkeylen, char **outval,
            int *outvallen);


       int yp_all(char *indomain, char *inmap, struct ypall_callback *incallback);


       int yp_order(char *indomain, char *inmap, unsigned long *outorder);


       int yp_master(char *indomain, char *inmap, char **outname);


       char *yperr_string(int incode);


       int ypprot_err(int domain);

DESCRIPTION
       This  package of functions provides an interface to NIS, Network Infor‐
       mation Service Version 2, formerly referred to as YP. In  this  version
       of  Oracle  Solaris,  NIS version 2 is supported only for compatibility
       with previous versions. The current  Oracle  Solaris  operating  system
       supports  the  client interface to NIS version 2. This client interface
       will be served by an existing ypserv process running on another machine
       on the network. For commands used to access NIS from a client  machine,
       see ypbind(8), ypwhich(1), ypmatch(1), and ypcat(1).


       All  input  parameter names begin with in. Output parameters begin with
       out. Output parameters of type char ** should be  addresses  of  unini‐
       tialized  character  pointers.  Memory  is  allocated by the NIS client
       package using malloc(3C) and can 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, respec‐
       tively, but these two bytes are not  reflected  in  outkeylen  or  out‐
       vallen. The indomain and inmap strings must be non-null and null-termi‐
       nated.  String parameters that are accompanied by a count parameter may
       not be null, but they may point to null strings, with the count parame‐
       ter indicating this. Counted strings need not be null-terminated.


       All functions in this package of type int return  0  if  they  succeed.
       Otherwise,  they  return a failure code (YPERR_xxxx). Failure codes are
       described in the ERRORS section.

   Routines
       yp_bind()

           To use the NIS name services, the client process must be "bound" to
           an NIS server that serves the appropriate domain  using  yp_bind().
           Binding  need  not be done explicitly by user code. Binding is done
           automatically whenever  an  NIS  lookup  function  is  called.  The
           yp_bind()  function  can be called directly for processes that make
           use of a backup strategy, for example, a local file in  cases  when
           NIS  services  are not available. A process should call yp_unbind()
           when it is finished using NIS in order to free up resources.


       yp_unbind()

           Each binding allocates or uses up one  client  process  socket  de‐
           scriptor.  Each  bound domain costs one socket descriptor. However,
           multiple requests to the same domain use that same descriptor.  The
           yp_unbind()  function  is  available  at  the  client interface for
           processes that explicitly manage their socket descriptors while ac‐
           cessing multiple domains. The call to yp_unbind() makes the  domain
           unbound,  and  frees all per-process and per-node resources used to
           bind it.

           If an RPC failure results upon use of a binding, that  domain  will
           be  unbound  automatically.  At that point, the ypclnt() layer will
           retry a few more times or until the  operation  succeeds,  provided
           that rpcbind(8) and ypbind(8) are running, and either:

               o      The  client  process cannot bind a server for the proper
                      domain; or


               o      RPC requests to the server fail.



           Under the following circumstances, the  ypclnt  layer  will  return
           control  to the user code, with either an error or success code and
           the results:

               o      If an error is not RPC-related.


               o      If rpcbind is not running.


               o      If ypbind is not running.


               o      If a bound ypserv process returns any answer (success or
                      failure).



       yp_get_default_domain()

           NIS lookup calls require a map name and a domain name, at  minimum.
           The  client  process  should  know the name of the map of interest.
           Client  processes  fetch  the  node's  default  domain  by  calling
           yp_get_default_domain() and use the returned outdomain as the indo‐
           main parameter to successive NIS name service calls. The domain re‐
           turned  is  the same as that returned using the SI_SRPC_DOMAIN com‐
           mand to the sysinfo(2) system call. The value returned in outdomain
           should not be freed.


       yp_match()

           The yp_match() function returns the value associated with a  passed
           key.  This  key must be exact because no pattern matching is avail‐
           able. yp_match() requires a full YP map name, such as hosts.byname,
           instead of the nickname hosts.


       yp_first()

           The yp_first() function returns the first key-value pair  from  the
           named map in the named domain.


       yp_next()

           The  yp_next()  function returns the next key-value pair in a named
           map. The inkey parameter must be the outkey returned from  an  ini‐
           tial  call  to yp_first() (to get the second key-value pair) or the
           one returned from the nth call to yp_next() (to get the nth +  sec‐
           ond  key-value pair). Similarly, the inkeylen parameter must be the
           outkeylen returned from the earlier yp_first() or yp_next() call.

           The concept of first and next is particular to the structure of the
           NIS map being processed. Retrieval order is not related  to  either
           the  lexical order within any original (non-NIS name service) data‐
           base, or to any obvious numerical sorting order on the  keys,  val‐
           ues, or key-value pairs. The only ordering guarantee is that if the
           yp_first()  function  is  called  on a particular map, and then the
           yp_next() function 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  database is seen exactly once. Further, if the same
           sequence of operations is performed on the same  map  at  the  same
           server, the entries are seen in the same order.

           Under conditions of heavy server load or server failure, the domain
           can  become  unbound, then bound once again (perhaps to a different
           server) while a client is running. This binding 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 would otherwise be returned in  the  midst
           of  the  enumeration.  For a better solution to enumerating all en‐
           tries in a map, see yp_all().


       yp_all()

           The yp_all() function provides a way to transfer an entire map from
           server to client in a single request using TCP (rather than UDP  as
           with other functions in this package). The entire transaction takes
           place  as  a single RPC request and response. The yp_all() function
           can be used just like any other NIS name service procedure to iden‐
           tify the map in the normal manner and to supply the name of a func‐
           tion that will be called to process each key-value pair within  the
           map. The call to yp_all() returns only when the transaction is com‐
           pleted  (successfully or unsuccessfully), or the foreach() function
           decides that it does not want to see any more key-value pairs.

           The third parameter to yp_all() is:


             struct ypall_callback *incallback {
                  int (*foreach)();
                  char *data;
             };

           The function foreach() is called:


             foreach(int instatus, char *inkey,
             int inkeylen, char *inval,
             int invallen, char *indata);

           The instatus parameter holds one of the return  status  values  de‐
           fined  in  <rpcsvc/yp_prot.h>, either YP_TRUE or an error code. See
           ypprot_err(), for a function that converts an NIS name service pro‐
           tocol error code to a ypclnt layer error code.

           The key and value parameters are somewhat different than defined in
           the synopsis section above. First, the memory  pointed  to  by  the
           inkey and inval parameters is private to the yp_all() function, and
           is  overwritten  with  the  arrival of each new key-value pair. The
           foreach() function must do something useful with  the  contents  of
           that  memory,  but it does not own the memory itself. Key and value
           objects presented to the foreach() function look exactly as they do
           in the server's map. If they were not NEWLINE-terminated  or  null-
           terminated in the map, they would not be here either.

           The  indata  parameter is the contents of the incallback->data ele‐
           ment passed to yp_all(). The data element of the callback structure
           can be used to share state information between the foreach()  func‐
           tion and the mainline code. Its use is optional, and no part of the
           NIS client package inspects its contents; cast it to something use‐
           ful, or ignore it. The foreach() function is Boolean. It should re‐
           turn 0 to indicate that it wants to be called again for further re‐
           ceived  key-value  pairs, or non-zero to stop the flow of key-value
           pairs. If foreach() returns a non-zero  value,  it  is  not  called
           again. The functional value of yp_all() is then 0.


       yp_order()

           The yp_order() function returns the order number for a map.


       yp_master()

           The yp_master() function returns the machine name of the master NIS
           server for a map.


       yperr_string()

           The  yperr_string()  function returns a pointer to an error message
           string that is null-terminated but contains no period or NEWLINE.


       ypprot_err()

           The ypprot_err() function takes an NIS name service protocol  error
           code  as  input, and returns a ypclnt() layer error code, which can
           be used as an input to yperr_string().


RETURN VALUES
       All integer functions return 0 if the requested operation  is  success‐
       ful, or one of the following errors if the operation fails:

       YPERR_ACCESS     Access violation.


       YPERR_BADARGS    The arguments to the function are bad.


       YPERR_BADDB      The YP database is bad.


       YPERR_BUSY       The database is busy.


       YPERR_DOMAIN     Cannot bind to server on this domain.


       YPERR_KEY        No such key in map.


       YPERR_MAP        No such map in server's domain.


       YPERR_NODOM      Local domain name not set.


       YPERR_NOMORE     No more records in map database.


       YPERR_PMAP       Cannot communicate with rpcbind.


       YPERR_RESRC      Resource allocation failure.


       YPERR_RPC        RPC failure; domain has been unbound.


       YPERR_YPBIND     Cannot communicate with ypbind.


       YPERR_YPERR      Internal YP server or client error.


       YPERR_YPSERV     Cannot communicate with ypserv.


       YPERR_VERS       YP version mismatch.


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:

       tab()  box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
       TRIBUTE VALUE _ MT-LevelSafe


SEE ALSO
       ypcat(1), ypmatch(1), ypwhich(1), sysinfo(2),  malloc(3C),  ypfiles(5),
       attributes(7), rpcbind(8), ypbind(8), ypserv(8)

Oracle Solaris 11.4               11 May 2021                       ypclnt(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3