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
  
inherit Array; 
inherit Stdio; 
inherit String; 
inherit Process; 
 
#define error(X) throw( ({ (X), backtrace()[0..sizeof(backtrace())-2] }) ) 
 
inherit Regexp : regexp; 
 
varargs int member_array(mixed needle,mixed *haystack,int start) 
{ 
  return search(haystack,needle,start); 
} 
 
object previous_object() 
{ 
  int e; 
  mixed **trace; 
  object o,ret; 
  trace=backtrace(); 
  o=function_object(trace[-2][2]); 
  for(e=sizeof(trace)-3;e>=0;e--) 
  { 
    if(!trace[e][2]) continue; 
    ret=function_object(trace[e][2]); 
    if(o!=ret) return ret; 
  } 
  return 0; 
} 
 
function this_function() 
{ 
  return backtrace()[-2][2]; 
} 
 
 
function get_function(object o, string a) 
{ 
  mixed ret; 
  ret=o[a]; 
  return functionp(ret) ? ret : 0; 
} 
 
string *map_regexp(string *s, string reg) 
{ 
   
  regexp::create(reg); 
  s=filter(s,regexp::match); 
  regexp::create(); /* Free compiled regexp */ 
  return s; 
} 
 
constant PI = 3.1415926535897932384626433832795080; 
constant all_efuns = all_constants; 
constant explode = `/; 
constant filter_array = filter; 
constant map_array = map; 
constant implode = `*; 
constant m_indices = indices; 
constant m_sizeof = sizeof; 
constant m_values = values; 
constant strstr = search; 
constant sum = `+; 
constant add_efun = add_constant; 
constant l_sizeof = sizeof; 
constant listp = multisetp; 
constant mklist = mkmultiset; 
constant aggregate_list = aggregate_multiset; 
#if efun(gethostname) 
constant query_host_name=gethostname; 
#endif