24c6c1 | 2000-02-20 | Martin Nilsson | |
|
1e9a1b | 2001-02-21 | Per Hedbor | |
|
c20c87 | 2000-02-16 | Per Hedbor | |
#include <module_constants.h>
|
b1fca0 | 1996-11-12 | Per Hedbor | | #include <module.h>
|
c5e096 | 1999-10-04 | Per Hedbor | | #include <request_trace.h>
|
b27587 | 1998-05-23 | Henrik Grubbström (Grubba) | |
|
a59d25 | 2000-07-04 | Per Hedbor | | inherit "basic_defvar";
|
9d9b9b | 1999-11-17 | Per Hedbor | | mapping(string:array(int)) error_log=([]);
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
9d9b9b | 1999-11-17 | Per Hedbor | | constant is_module = 1;
|
a730c2 | 2001-01-19 | Per Hedbor | |
constant module_unique = 1;
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
a59d25 | 2000-07-04 | Per Hedbor | |
private string _module_identifier;
private Configuration _my_configuration;
static mapping _api_functions = ([]);
string|array(string) module_creator;
string module_url;
RXML.TagSet module_tag_set;
|
c20c87 | 2000-02-16 | Per Hedbor | |
void report_fatal( mixed ... args ) { predef::report_fatal( @args ); }
void report_error( mixed ... args ) { predef::report_error( @args ); }
void report_notice( mixed ... args ) { predef::report_notice( @args ); }
void report_debug( mixed ... args ) { predef::report_debug( @args ); }
|
b9ec25 | 2000-01-05 | Martin Stjernholm | | string module_identifier()
{
if (!_module_identifier) {
|
225c8e | 2001-01-31 | Marcus Comstedt | | string|mapping name = this_object()->register_module()[1];
|
b9ec25 | 2000-01-05 | Martin Stjernholm | | if (mappingp (name)) name = name->standard;
|
8d4919 | 2000-03-18 | Martin Stjernholm | | string cname = sprintf ("%O", my_configuration());
if (sscanf (cname, "Configuration(%s", cname) == 1 &&
sizeof (cname) && cname[-1] == ')')
cname = cname[..sizeof (cname) - 2];
|
55a866 | 2000-11-20 | Per Hedbor | | _module_identifier = sprintf ("%s,%s",
|
ad5607 | 2001-01-29 | Per Hedbor | | name||this_object()->module_name, cname);
|
b9ec25 | 2000-01-05 | Martin Stjernholm | | }
return _module_identifier;
}
|
b6fb05 | 1999-11-02 | Per Hedbor | | string _sprintf()
{
|
c2768e | 2000-08-22 | Martin Stjernholm | | return "RoxenModule(" +
(Roxen.get_modname (this_object()) || module_identifier()) + ")";
|
b6fb05 | 1999-11-02 | Per Hedbor | | }
|
c5e096 | 1999-10-04 | Per Hedbor | | array register_module()
{
return ({
|
a730c2 | 2001-01-19 | Per Hedbor | | this_object()->module_type,
|
ad5607 | 2001-01-29 | Per Hedbor | | this_object()->module_name,
this_object()->module_doc,
|
c5e096 | 1999-10-04 | Per Hedbor | | 0,
module_unique,
});
}
|
2a2a5b | 1996-12-01 | Per Hedbor | | string fix_cvs(string from)
{
|
fd0b6f | 1996-12-02 | Per Hedbor | | from = replace(from, ({ "$", "Id: "," Exp $" }), ({"","",""}));
|
2a2a5b | 1996-12-01 | Per Hedbor | | sscanf(from, "%*s,v %s", from);
|
00730e | 1999-11-18 | Per Hedbor | | return replace(from,"/","-");
|
2a2a5b | 1996-12-01 | Per Hedbor | | }
|
72ac57 | 2000-01-31 | Per Hedbor | | int module_dependencies(Configuration configuration,
|
f5a274 | 1999-10-18 | Per Hedbor | | array (string) modules,
int|void now)
|
facee7 | 2000-07-18 | Johan Sundström | |
|
cb9c22 | 2000-09-06 | Martin Stjernholm | |
|
edb506 | 1997-08-25 | Peter Bortas | | {
|
cb9c22 | 2000-09-06 | Martin Stjernholm | | modules = map (modules,
lambda (string modname) {
sscanf ((modname / "/")[-1], "%[^#]", modname);
return modname;
});
Configuration conf = configuration || my_configuration();
if (!conf)
report_warning ("Configuration not resolved; module(s) %s that %s "
"depend on weren't added.", String.implode_nicely (modules),
Roxen.get_modname (this_object()) || module_identifier());
else
conf->add_modules( modules, now );
|
edb506 | 1997-08-25 | Peter Bortas | | return 1;
}
|
2a2a5b | 1996-12-01 | Per Hedbor | | string file_name_and_stuff()
{
|
a59d25 | 2000-07-04 | Per Hedbor | | return ("<b>Loaded from:</b> "+(roxen->filename(this_object()))+"<br>"+
(this_object()->cvs_version?
|
00730e | 1999-11-18 | Per Hedbor | | "<b>CVS Version: </b>"+
|
a59d25 | 2000-07-04 | Per Hedbor | | fix_cvs(this_object()->cvs_version)+"\n":""));
|
2a2a5b | 1996-12-01 | Per Hedbor | | }
|
5839c3 | 1999-01-22 | Marcus Comstedt | |
|
9f2a97 | 1999-11-29 | Per Hedbor | | Configuration my_configuration()
|
facee7 | 2000-07-18 | Johan Sundström | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
5839c3 | 1999-01-22 | Marcus Comstedt | | if(_my_configuration)
return _my_configuration;
|
7fb7f5 | 1999-11-29 | Per Hedbor | | Configuration conf;
|
b1fca0 | 1996-11-12 | Per Hedbor | | foreach(roxen->configurations, conf)
|
a59d25 | 2000-07-04 | Per Hedbor | | if(conf->otomod[this_object()])
|
33266d | 1999-05-24 | Per Hedbor | | return _my_configuration = conf;
|
b1fca0 | 1996-11-12 | Per Hedbor | | return 0;
}
|
7fb7f5 | 1999-11-29 | Per Hedbor | | nomask void set_configuration(Configuration c)
|
5839c3 | 1999-01-22 | Marcus Comstedt | | {
if(_my_configuration && _my_configuration != c)
error("set_configuration() called twice.\n");
_my_configuration = c;
}
|
48679b | 2000-02-03 | Johan Sundström | | void set_module_creator(string|array(string) c)
|
facee7 | 2000-07-18 | Johan Sundström | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
module_creator = c;
}
void set_module_url(string to)
|
facee7 | 2000-07-18 | Johan Sundström | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
module_url = to;
}
void free_some_sockets_please(){}
|
7fb7f5 | 1999-11-29 | Per Hedbor | | void start(void|int num, void|Configuration conf) {}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
a59d25 | 2000-07-04 | Per Hedbor | | string status() {}
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
7fb7f5 | 1999-11-29 | Per Hedbor | | string info(Configuration conf)
|
72ac57 | 2000-01-31 | Per Hedbor | | {
|
facee7 | 2000-07-18 | Johan Sundström | | return (this_object()->register_module()[2]);
|
df6cd1 | 1998-10-13 | Per Hedbor | | }
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
a730c2 | 2001-01-19 | Per Hedbor | | string sname( )
{
|
4a5018 | 2001-01-30 | Per Hedbor | | return my_configuration()->otomod[ this_object() ];
|
a730c2 | 2001-01-19 | Per Hedbor | | }
|
2f4ac1 | 2000-11-02 | Per Hedbor | | ModuleInfo my_moduleinfo( )
{
|
a730c2 | 2001-01-19 | Per Hedbor | | string f = sname();
|
2f4ac1 | 2000-11-02 | Per Hedbor | | if( f ) return roxen.find_module( (f/"#")[0] );
}
|
2c13a8 | 1999-11-10 | Per Hedbor | | void save_me()
|
e7e603 | 1999-11-05 | Per Hedbor | | {
my_configuration()->save_one( this_object() );
|
2f4ac1 | 2000-11-02 | Per Hedbor | | my_configuration()->module_changed( my_moduleinfo(), this_object() );
|
e7e603 | 1999-11-05 | Per Hedbor | | }
|
1e9a1b | 2001-02-21 | Per Hedbor | | void save() { save_me(); }
string comment() { return ""; }
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
5839c3 | 1999-01-22 | Marcus Comstedt | | string query_internal_location()
|
facee7 | 2000-07-18 | Johan Sundström | |
|
5839c3 | 1999-01-22 | Marcus Comstedt | | {
if(!_my_configuration)
error("Please do not call this function from create()!\n");
return _my_configuration->query_internal_location(this_object());
}
|
525f72 | 2000-12-05 | Martin Nilsson | | string query_absolute_internal_location(RequestID id)
{
return (id->misc->site_prefix_path || "") + query_internal_location();
}
|
b7c45e | 1997-01-27 | Per Hedbor | | string query_location()
|
1e9a1b | 2001-02-21 | Per Hedbor | |
|
b7c45e | 1997-01-27 | Per Hedbor | | {
string s;
catch{s = query("location");};
return s;
}
|
162bd5 | 2000-02-20 | Martin Stjernholm | | array(string) location_urls()
|
facee7 | 2000-07-18 | Johan Sundström | |
|
162bd5 | 2000-02-20 | Martin Stjernholm | | {
string loc = query_location();
if (!loc) return ({});
if(!_my_configuration)
error("Please do not call this function from create()!\n");
|
3adf20 | 2000-03-06 | Jonas Wallden | | array(string) urls = copy_value(_my_configuration->query("URLs"));
|
7984d6 | 2000-10-06 | Martin Stjernholm | | string hostname;
if (string world_url = _my_configuration->query ("MyWorldLocation"))
sscanf (world_url, "%*s://%s%*[:/]", hostname);
if (!hostname) hostname = gethostname();
for (int i = 0; i < sizeof (urls); i++)
if (sizeof (urls[i]/"*") == 2)
|
162bd5 | 2000-02-20 | Martin Stjernholm | | urls[i] = replace(urls[i], "*", hostname);
return map (urls, `+, loc[1..]);
}
|
ae32d0 | 1998-03-23 | David Hedbor | |
|
72ac57 | 2000-01-31 | Per Hedbor | | string query_provides() { return 0; }
|
b7c45e | 1997-01-27 | Per Hedbor | |
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
a59d25 | 2000-07-04 | Per Hedbor | | class IP_with_mask
{
|
17d173 | 1997-08-13 | Henrik Grubbström (Grubba) | | int net;
int mask;
static private int ip_to_int(string ip)
{
int res;
|
eac26d | 1997-09-27 | Henrik Grubbström (Grubba) | | foreach(((ip/".") + ({ "0", "0", "0" }))[..3], string num) {
|
17d173 | 1997-08-13 | Henrik Grubbström (Grubba) | | res = res*256 + (int)num;
}
return(res);
}
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | | void create(string _ip, string|int _mask)
|
17d173 | 1997-08-13 | Henrik Grubbström (Grubba) | | {
net = ip_to_int(_ip);
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | | if (intp(_mask)) {
if (_mask > 32) {
report_error(sprintf("Bad netmask: %s/%d\n"
"Using %s/32\n", _ip, _mask, _ip));
_mask = 32;
}
mask = ~0<<(32-_mask);
} else {
mask = ip_to_int(_mask);
}
|
17d173 | 1997-08-13 | Henrik Grubbström (Grubba) | | if (net & ~mask) {
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | | report_error(sprintf("Bad netmask: %s for network %s\n"
"Ignoring node-specific bits\n", _ip, _mask));
net &= mask;
|
17d173 | 1997-08-13 | Henrik Grubbström (Grubba) | | }
}
int `()(string ip)
{
return((ip_to_int(ip) & mask) == net);
}
};
|
b7c45e | 1997-01-27 | Per Hedbor | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | array query_seclevels()
{
array patterns=({ });
|
a59d25 | 2000-07-04 | Per Hedbor | | if(catch(query("_seclevels")) || (query("_seclevels") == 0))
|
b1fca0 | 1996-11-12 | Per Hedbor | | return patterns;
|
72ac57 | 2000-01-31 | Per Hedbor | |
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | | foreach(replace(query("_seclevels"),
({" ","\t","\\\n"}),
({"","",""}))/"\n", string sl) {
|
b1fca0 | 1996-11-12 | Per Hedbor | | if(!strlen(sl) || sl[0]=='#')
continue;
|
de493f | 1997-04-28 | Henrik Grubbström (Grubba) | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | string type, value;
if(sscanf(sl, "%s=%s", type, value)==2)
{
|
02a63f | 2000-09-05 | Per Hedbor | | array(string|int) arr;
|
de493f | 1997-04-28 | Henrik Grubbström (Grubba) | | switch(lower_case(type))
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
case "allowip":
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | | if (sizeof(arr = (value/"/")) == 2) {
arr[1] = (int)arr[1];
patterns += ({ ({ MOD_ALLOW, IP_with_mask(@arr) }) });
} else if ((sizeof(arr = (value/":")) == 2) ||
|
891971 | 1998-02-06 | Gerald Schupfner | | (sizeof(arr = (value/",")) > 1)) {
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | |
patterns += ({ ({ MOD_ALLOW, IP_with_mask(@arr) }) });
} else {
|
17d173 | 1997-08-13 | Henrik Grubbström (Grubba) | | value = replace(value, ({ "?", ".", "*" }), ({ ".", "\\.", ".*" }));
patterns += ({ ({ MOD_ALLOW, Regexp(value)->match, }) });
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | break;
|
957978 | 1998-06-29 | Henrik Grubbström (Grubba) | | case "acceptip":
if (sizeof(arr = (value/"/")) == 2) {
arr[1] = (int)arr[1];
patterns += ({ ({ MOD_ACCEPT, IP_with_mask(@arr) }) });
} else if ((sizeof(arr = (value/":")) == 2) ||
(sizeof(arr = (value/",")) > 1)) {
patterns += ({ ({ MOD_ACCEPT, IP_with_mask(@arr) }) });
} else {
value = replace(value, ({ "?", ".", "*" }), ({ ".", "\\.", ".*" }));
patterns += ({ ({ MOD_ACCEPT, Regexp(value)->match, }) });
}
break;
|
b1fca0 | 1996-11-12 | Per Hedbor | | case "denyip":
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | | if (sizeof(arr = (value/"/")) == 2) {
arr[1] = (int)arr[1];
patterns += ({ ({ MOD_DENY, IP_with_mask(@arr) }) });
} else if ((sizeof(arr = (value/":")) == 2) ||
|
891971 | 1998-02-06 | Gerald Schupfner | | (sizeof(arr = (value/",")) > 1)) {
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | |
patterns += ({ ({ MOD_DENY, IP_with_mask(@arr) }) });
} else {
|
17d173 | 1997-08-13 | Henrik Grubbström (Grubba) | | value = replace(value, ({ "?", ".", "*" }), ({ ".", "\\.", ".*" }));
patterns += ({ ({ MOD_DENY, Regexp(value)->match, }) });
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | break;
|
f6d62d | 1997-03-26 | Per Hedbor | | case "allowuser":
|
17d173 | 1997-08-13 | Henrik Grubbström (Grubba) | | value = replace(value, ({ "?", ".", "*" }), ({ ".", "\\.", ".*" }));
|
f6d62d | 1997-03-26 | Per Hedbor | | array(string) users = (value/"," - ({""}));
int i;
|
72ac57 | 2000-01-31 | Per Hedbor | |
|
f6d62d | 1997-03-26 | Per Hedbor | | for(i=0; i < sizeof(users); i++) {
|
de493f | 1997-04-28 | Henrik Grubbström (Grubba) | | if (lower_case(users[i]) == "any") {
|
a59d25 | 2000-07-04 | Per Hedbor | | if(this_object()->register_module()[0] & MODULE_PROXY)
|
f6d62d | 1997-03-26 | Per Hedbor | | patterns += ({ ({ MOD_PROXY_USER, lambda(){ return 1; } }) });
else
patterns += ({ ({ MOD_USER, lambda(){ return 1; } }) });
break;
} else {
users[i & 0x0f] = "(^"+users[i]+"$)";
}
if ((i & 0x0f) == 0x0f) {
value = users[0..0x0f]*"|";
|
a59d25 | 2000-07-04 | Per Hedbor | | if(this_object()->register_module()[0] & MODULE_PROXY) {
|
f6d62d | 1997-03-26 | Per Hedbor | | patterns += ({ ({ MOD_PROXY_USER, Regexp(value)->match, }) });
} else {
patterns += ({ ({ MOD_USER, Regexp(value)->match, }) });
}
}
}
if (i & 0x0f) {
value = users[0..(i-1)&0x0f]*"|";
|
a59d25 | 2000-07-04 | Per Hedbor | | if(this_object()->register_module()[0] & MODULE_PROXY) {
|
f6d62d | 1997-03-26 | Per Hedbor | | patterns += ({ ({ MOD_PROXY_USER, Regexp(value)->match, }) });
} else {
patterns += ({ ({ MOD_USER, Regexp(value)->match, }) });
}
|
a397fe | 1996-12-13 | David Hedbor | | }
|
b1fca0 | 1996-11-12 | Per Hedbor | | break;
|
957978 | 1998-06-29 | Henrik Grubbström (Grubba) | |
case "acceptuser":
value = replace(value, ({ "?", ".", "*" }), ({ ".", "\\.", ".*" }));
|
02a63f | 2000-09-05 | Per Hedbor | | users = (value/"," - ({""}));
|
72ac57 | 2000-01-31 | Per Hedbor | |
|
957978 | 1998-06-29 | Henrik Grubbström (Grubba) | | for(i=0; i < sizeof(users); i++) {
if (lower_case(users[i]) == "any") {
|
a59d25 | 2000-07-04 | Per Hedbor | | if(this_object()->register_module()[0] & MODULE_PROXY)
|
957978 | 1998-06-29 | Henrik Grubbström (Grubba) | | patterns += ({ ({ MOD_PROXY_USER, lambda(){ return 1; } }) });
else
patterns += ({ ({ MOD_ACCEPT_USER, lambda(){ return 1; } }) });
break;
} else {
users[i & 0x0f] = "(^"+users[i]+"$)";
}
if ((i & 0x0f) == 0x0f) {
value = users[0..0x0f]*"|";
|
a59d25 | 2000-07-04 | Per Hedbor | | if(this_object()->register_module()[0] & MODULE_PROXY) {
|
957978 | 1998-06-29 | Henrik Grubbström (Grubba) | | patterns += ({ ({ MOD_PROXY_USER, Regexp(value)->match, }) });
} else {
patterns += ({ ({ MOD_ACCEPT_USER, Regexp(value)->match, }) });
}
}
}
if (i & 0x0f) {
value = users[0..(i-1)&0x0f]*"|";
|
a59d25 | 2000-07-04 | Per Hedbor | | if(this_object()->register_module()[0] & MODULE_PROXY) {
|
957978 | 1998-06-29 | Henrik Grubbström (Grubba) | | patterns += ({ ({ MOD_PROXY_USER, Regexp(value)->match, }) });
} else {
patterns += ({ ({ MOD_ACCEPT_USER, Regexp(value)->match, }) });
}
}
break;
|
de493f | 1997-04-28 | Henrik Grubbström (Grubba) | | default:
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | | report_error(sprintf("Unknown Security:Patterns directive: "
"type=\"%s\"\n", type));
|
de493f | 1997-04-28 | Henrik Grubbström (Grubba) | | break;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
de493f | 1997-04-28 | Henrik Grubbström (Grubba) | | } else {
|
411750 | 1997-08-13 | Henrik Grubbström (Grubba) | | report_error(sprintf("Syntax error in Security:Patterns directive: "
"line=\"%s\"\n", sl));
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
}
return patterns;
}
|
8b8ecf | 2000-08-28 | Johan Sundström | | Stat stat_file(string f, RequestID id){}
array(string) find_dir(string f, RequestID id){}
mapping(string:Stat) find_dir_stat(string f, RequestID id)
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | {
|
b27587 | 1998-05-23 | Henrik Grubbström (Grubba) | | TRACE_ENTER("find_dir_stat(): \""+f+"\"", 0);
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | array(string) files = find_dir(f, id);
|
8b8ecf | 2000-08-28 | Johan Sundström | | mapping(string:Stat) res = ([]);
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | |
|
0c8b9a | 1997-10-22 | Henrik Grubbström (Grubba) | | foreach(files || ({}), string fname) {
|
b27587 | 1998-05-23 | Henrik Grubbström (Grubba) | | TRACE_ENTER("stat()'ing "+ f + "/" + fname, 0);
|
c0f454 | 2001-02-19 | Jonas Wallden | | Stat st = stat_file(replace(f + "/" + fname, "//", "/"), id);
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | if (st) {
|
0c8b9a | 1997-10-22 | Henrik Grubbström (Grubba) | | res[fname] = st;
|
b27587 | 1998-05-23 | Henrik Grubbström (Grubba) | | TRACE_LEAVE("OK");
} else {
TRACE_LEAVE("No stat info");
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | }
}
|
b27587 | 1998-05-23 | Henrik Grubbström (Grubba) | |
TRACE_LEAVE("");
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | return(res);
}
|
a59d25 | 2000-07-04 | Per Hedbor | |
|
8b8ecf | 2000-08-28 | Johan Sundström | | string real_file(string f, RequestID id){}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
4f4bc1 | 1998-02-04 | Per Hedbor | | void add_api_function( string name, function f, void|array(string) types)
{
_api_functions[name] = ({ f, types });
}
mapping api_functions()
{
return _api_functions;
}
|
60b81c | 2001-01-04 | Martin Nilsson | | #if ROXEN_COMPAT <= 1.4
|
9ed3ea | 2000-08-06 | Martin Stjernholm | | mapping(string:function) query_tag_callers()
|
facee7 | 2000-07-18 | Johan Sundström | |
|
48ca16 | 1999-05-18 | Per Hedbor | | {
|
9ed3ea | 2000-08-06 | Martin Stjernholm | | mapping(string:function) m = ([]);
|
48ca16 | 1999-05-18 | Per Hedbor | | foreach(glob("tag_*", indices( this_object())), string q)
if(functionp( this_object()[q] ))
m[replace(q[4..], "_", "-")] = this_object()[q];
return m;
}
|
9ed3ea | 2000-08-06 | Martin Stjernholm | | mapping(string:function) query_container_callers()
|
48ca16 | 1999-05-18 | Per Hedbor | | {
|
9ed3ea | 2000-08-06 | Martin Stjernholm | | mapping(string:function) m = ([]);
|
48ca16 | 1999-05-18 | Per Hedbor | | foreach(glob("container_*", indices( this_object())), string q)
if(functionp( this_object()[q] ))
m[replace(q[10..], "_", "-")] = this_object()[q];
return m;
}
|
60b81c | 2001-01-04 | Martin Nilsson | | #endif
|
48ca16 | 1999-05-18 | Per Hedbor | |
|
9ed3ea | 2000-08-06 | Martin Stjernholm | | mapping(string:array(int|function)) query_simpletag_callers()
|
7d2a5d | 2000-01-31 | Martin Nilsson | | {
|
9ed3ea | 2000-08-06 | Martin Stjernholm | | mapping(string:array(int|function)) m = ([]);
|
7d2a5d | 2000-01-31 | Martin Nilsson | | foreach(glob("simpletag_*", indices(this_object())), string q)
if(functionp(this_object()[q]))
|
d6b20a | 2000-02-08 | Martin Stjernholm | | m[replace(q[10..],"_","-")] =
({ intp (this_object()[q + "_flags"]) && this_object()[q + "_flags"],
this_object()[q] });
|
7d2a5d | 2000-01-31 | Martin Nilsson | | return m;
|
48ca16 | 1999-05-18 | Per Hedbor | | }
|
ea062e | 1999-11-21 | Martin Nilsson | |
|
9ed3ea | 2000-08-06 | Martin Stjernholm | | mapping(string:array(int|function)) query_simple_pi_tag_callers()
{
mapping(string:array(int|function)) m = ([]);
foreach (glob ("simple_pi_tag_*", indices (this_object())), string q)
if (functionp (this_object()[q]))
m[replace (q[sizeof ("simple_pi_tag_")..], "_", "-")] =
({(intp (this_object()[q + "_flags"]) && this_object()[q + "_flags"]) |
RXML.FLAG_PROC_INSTR, this_object()[q]});
return m;
}
|
1b2b75 | 2000-01-07 | Martin Stjernholm | | RXML.TagSet query_tag_set()
|
b9ec25 | 2000-01-05 | Martin Stjernholm | | {
|
395e46 | 2000-01-18 | Martin Stjernholm | | if (!module_tag_set) {
array(function|program|object) tags =
filter (rows (this_object(),
glob ("Tag*", indices (this_object()))),
functionp);
for (int i = 0; i < sizeof (tags); i++)
if (programp (tags[i]))
if (!tags[i]->is_RXML_Tag) tags[i] = 0;
else tags[i] = tags[i]();
else {
tags[i] = tags[i]();
if (!tags[i]->is_RXML_Tag) tags[i] = 0;
}
tags -= ({0});
module_tag_set =
(this_object()->ModuleTagSet || RXML.TagSet) (module_identifier(), tags);
}
return module_tag_set;
|
b9ec25 | 2000-01-05 | Martin Stjernholm | | }
|
12e79e | 1999-12-07 | Martin Nilsson | | mixed get_value_from_file(string path, string index, void|string pre)
|
ea062e | 1999-11-21 | Martin Nilsson | | {
|
7fb7f5 | 1999-11-29 | Per Hedbor | | Stdio.File file=Stdio.File();
|
ea062e | 1999-11-21 | Martin Nilsson | | if(!file->open(path,"r")) return 0;
|
12e79e | 1999-12-07 | Martin Nilsson | | if(index[sizeof(index)-2..sizeof(index)-1]=="()") {
return compile_string((pre||"")+file->read())[index[..sizeof(index)-3]]();
}
return compile_string((pre||"")+file->read())[index];
|
ea062e | 1999-11-21 | Martin Nilsson | | }
|
a730c2 | 2001-01-19 | Per Hedbor | |
|
1e9a1b | 2001-02-21 | Per Hedbor | | string get_my_table( string|array(string) name,
void|array(string)|string defenition )
{
if( !defenition )
{
defenition = name;
name = "";
}
else if(strlen(name))
name = "_"+name;
|
a730c2 | 2001-01-19 | Per Hedbor | |
|
a66538 | 2001-01-29 | Per Hedbor | | Sql.Sql sql = get_my_sql();
|
1e9a1b | 2001-02-21 | Per Hedbor | | string res = hash(_my_configuration->name)->digits(36)
+ "_" + replace(sname(),"#","_") + name;
|
a66538 | 2001-01-29 | Per Hedbor | | if( !sql )
{
report_error("Failed to get SQL handle, permission denied for "+my_db+"\n");
return 0;
}
|
1e9a1b | 2001-02-21 | Per Hedbor | | if( arrayp( defenition ) )
defenition *= ", ";
|
a66538 | 2001-01-29 | Per Hedbor | | if( catch(sql->query( "SELECT * FROM "+res+" LIMIT 1" )) )
|
1e9a1b | 2001-02-21 | Per Hedbor | | {
mixed error =
catch
{
get_my_sql()->query( "CREATE TABLE "+res+" ("+defenition+")" );
};
if( error )
{
if( strlen( name ) )
name = " "+name;
report_notice( "Failed to create table"+name+": "+
describe_error( error ) );
return 0;
}
return res;
}
mixed error =
catch
{
get_my_sql()->query( "ALTER TABLE "+res+" ("+defenition+")" );
};
if( error )
{
if( strlen( name ) )
name = " for "+name;
report_notice( "Failed to update table defenition"+name+": "+
describe_error( error ) );
}
|
a730c2 | 2001-01-19 | Per Hedbor | | return res;
}
|
1e9a1b | 2001-02-21 | Per Hedbor | | string my_db = "shared";
void set_my_db( string to )
{
my_db = to;
}
Sql.Sql get_my_sql( int|void read_only )
|
a730c2 | 2001-01-19 | Per Hedbor | | {
|
1e9a1b | 2001-02-21 | Per Hedbor | | return DBManager.get( my_db, _my_configuration, read_only );
|
a730c2 | 2001-01-19 | Per Hedbor | | }
|