69b2971997-06-09Henrik Grubbström (Grubba) /*
bca3001997-06-09Henrik Grubbström (Grubba)  * $Id: module.pmod.in,v 1.5 1997/06/09 20:26:22 grubba Exp $
69b2971997-06-09Henrik Grubbström (Grubba)  * * YP (NIS) Functionality for Pike * * Per Hedbor & Henrik Grubbström 1996-1997 */
bca3001997-06-09Henrik Grubbström (Grubba) inherit @module@; // Usual nicknames constant nicknames = ([ "passwd":"passwd.byname" "group":"group.byname" "networks":"networks.byaddr" "hosts":"hosts.byname" "protocols":"protocols.bynumber" "services":"services.byname" "aliases":"mail.aliases" "ethers":"ethers.byname" ]);
69b2971997-06-09Henrik Grubbström (Grubba) 
63d9661997-06-09Henrik Grubbström (Grubba) class Map { object(Domain) domain;
69b2971997-06-09Henrik Grubbström (Grubba)  string ypmap; void create(string map,string|void d) { if (d) {
63d9661997-06-09Henrik Grubbström (Grubba)  domain = Domain(d);
69b2971997-06-09Henrik Grubbström (Grubba)  } else {
63d9661997-06-09Henrik Grubbström (Grubba)  domain = Domain();
69b2971997-06-09Henrik Grubbström (Grubba)  } ypmap = map;
bca3001997-06-09Henrik Grubbström (Grubba)  array err; do { // Force an error if the map does not exist. err = catch{ domain->match(ypmap, "foo"); return; }; } while (ypmap = nicknames[ypmap]); throw(err);
69b2971997-06-09Henrik Grubbström (Grubba)  } string match(string key) { return(domain->match(ypmap, key)); } string `[](string key) {
7d014c1997-06-09Henrik Grubbström (Grubba)  return(domain->match(ypmap, key));
69b2971997-06-09Henrik Grubbström (Grubba)  } mapping all() { return(domain->all(ypmap)); } mapping cast_to_mapping() { return(domain->all(ypmap)); } void map(function(string,string:void)|array(function(string,string:void)) fn) {
bca3001997-06-09Henrik Grubbström (Grubba)  domain->map(ypmap, fn);
69b2971997-06-09Henrik Grubbström (Grubba)  } string server() {
fdd03d1997-06-09Henrik Grubbström (Grubba)  return(domain->server(ypmap));
69b2971997-06-09Henrik Grubbström (Grubba)  } int order() { return(domain->order(ypmap)); }
bca3001997-06-09Henrik Grubbström (Grubba)  int _sizeof()
69b2971997-06-09Henrik Grubbström (Grubba)  {
bca3001997-06-09Henrik Grubbström (Grubba)  return(sizeof(indices(domain->all(ypmap))));
69b2971997-06-09Henrik Grubbström (Grubba)  }
bca3001997-06-09Henrik Grubbström (Grubba)  array(string) _indices()
69b2971997-06-09Henrik Grubbström (Grubba)  { return(indices(domain->all(ypmap))); }
bca3001997-06-09Henrik Grubbström (Grubba)  array(string) _values()
69b2971997-06-09Henrik Grubbström (Grubba)  {
7d014c1997-06-09Henrik Grubbström (Grubba)  return(values(domain->all(ypmap))); } mixed cast(string type) { switch(type) { case "mapping": return(cast_to_mapping()); default: throw(({ "Yp.YpDomain: Cast to " + type + " not supported.\n", backtrace() })); }
69b2971997-06-09Henrik Grubbström (Grubba)  } };