1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
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 
  }