69b2971997-06-09Henrik Grubbström (Grubba) /*
fdd03d1997-06-09Henrik Grubbström (Grubba)  * $Id: module.pmod.in,v 1.4 1997/06/09 18:54:30 grubba Exp $
69b2971997-06-09Henrik Grubbström (Grubba)  * * YP (NIS) Functionality for Pike * * Per Hedbor & Henrik Grubbström 1996-1997 */
63d9661997-06-09Henrik Grubbström (Grubba) class Domain {
69b2971997-06-09Henrik Grubbström (Grubba)  inherit @module@; };
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; // Force an error if the map does not exist. domain->match(ypmap, "foo"); } 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) { return(domain->map(ypmap, fn)); } string server() {
fdd03d1997-06-09Henrik Grubbström (Grubba)  return(domain->server(ypmap));
69b2971997-06-09Henrik Grubbström (Grubba)  } int order() { return(domain->order(ypmap)); } int sizeof() { return(sizeof(domain->all(ypmap))); } array(string) indices() { return(indices(domain->all(ypmap))); } array(string) values() {
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)  } };