pike.git / src / modules / Yp / doc

version» Context lines:

pike.git/src/modules/Yp/doc:1: + Efuns    -  + string default_yp_domain(); +  +  Returns the default yp-domain. +  +  + The YpDomain class +  +  object YpDomain(string|void domain); +  Return a new YpDomain object. If no domain is specified, the +  default domain will be used. This is usualy best. +  +  If there is no YP server available for the domain, this +  functioncall will block until there is one. If no server apperars +  in about ten minutes or so, an error will be returned. The timeout +  is not configurable from the C-yp interface either. +  +  void domain->bind(string domain); +  Re-bind the object to another (or the same) domain. +  +  string domain->match(string map, string key); +  Search in 'map' for the key 'key'. If there is no 'key' in 'map', 0 +  will be returned. If 'map' does not exist, an error will be +  generated, otherwise the string matching the key will be returned. +  +  mapping (string:string) domain->all(string map); +  Return the whole map as a mapping. +  +  void domain->map(string map, function(string,string:void) +  |array(function(string,string:void)) over); +  For each entry in 'map', call the function(s) specified by 'over'. +  The function will be called like 'void over(string key, string +  value)' +  +  string domain->server(string map); +  Return the hostname of the server serving the map 'map'. +  +  int domain->order(string map); +  Return the 'order' number for the map map. This is usually a +  time_t (see the efun time()) +  +  + The YpMap class +  +  object YpMap(string map,string|void domain); +  Return a new YpMap object. If no domain is specified, the +  default domain will be used. This is usualy best. +  +  If there is no YP server available for the domain, this +  functioncall will block until there is one. If no server apperars +  in about ten minutes or so, an error will be returned. The timeout +  is not configurable from the C-yp interface either. +  +  string map->match(string key); +  or +  map[key]; +  +  Search for the key 'key'. If there is no 'key' in the map, 0 +  will be returned, otherwise the string matching the key will +  be returned. +  +  mapping (string:string) map->all(); +  or +  (mapping)map; +  Return the whole map as a mapping. +  +  void map->map(function(string,string:void)|array(function(string,string:void)) over); +  For each entry in the map, call the function(s) specified by 'over'. +  The function will be called like 'void over(string key, string value)' +  +  string map->server(); +  Return the hostname of the server serving this map. +  +  int map->order(); +  Return the 'order' number for this map. This is usually a +  time_t (see the efun time()) +  +  sizeof(map) +  Return the number of entries in the map. This is equivalent to +  sizeof((mapping)map); +  +  array(string) indices(map); +  and +  array(string) values(map); +  +  Return the indices of the map. If indices is called first, values must +  be called immediately after. If values is called first, it is the +  other way around. +  +  + EXAMPLE +  +  #include <yp.h> +  +  void print_entry(string key, string val) +  { +  val = (val/":")[4]; +  if(strlen(val)) +  { +  string q = ".......... "; +  werror(key+q[strlen(key)..]+val+"\n"); +  } +  } +  +  void main(int argc,array argv) +  { +  object (YpMap) o = YpMap("passwd.byname"); +  +  werror("server.... " + o->server() + "\n" +  "age....... " + (-o->order()+time()) + "\n" +  "per....... " + o["per"] + "\n" +  "size...... " + sizeof(o) + "\n"); +  +  o->map(print_entry); // Print username/GECOS pairs +  }   Newline at end of file added.