395e46 | 2000-01-18 | Martin Stjernholm | |
|
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) | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | mapping (string:mixed *) variables=([]);
|
7fb7f5 | 1999-11-29 | Per Hedbor | | RoxenModule this = this_object();
|
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;
|
dd341c | 2000-01-10 | Martin Nilsson | | constant module_type = MODULE_ZERO;
|
c5e096 | 1999-10-04 | Per Hedbor | | constant module_name = "Unnamed module";
constant module_doc = "Undocumented";
constant module_unique = 1;
|
b9ec25 | 2000-01-05 | Martin Stjernholm | | private string _module_identifier;
string module_identifier()
{
if (!_module_identifier) {
string|mapping name = register_module()[1];
if (mappingp (name)) name = name->standard;
_module_identifier = sprintf ("%s,%O", name || module_name, my_configuration());
}
return _module_identifier;
}
|
b6fb05 | 1999-11-02 | Per Hedbor | | string _sprintf()
{
|
b9ec25 | 2000-01-05 | Martin Stjernholm | | return "RoxenModule(" + module_identifier() + ")";
|
b6fb05 | 1999-11-02 | Per Hedbor | | }
|
c5e096 | 1999-10-04 | Per Hedbor | | array register_module()
{
return ({
module_type,
module_name,
module_doc,
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 | | }
|
7fb7f5 | 1999-11-29 | Per Hedbor | | int module_dependencies(Configuration configuration,
|
f5a274 | 1999-10-18 | Per Hedbor | | array (string) modules,
int|void now)
|
edb506 | 1997-08-25 | Peter Bortas | | {
|
f5a274 | 1999-10-18 | Per Hedbor | | if(configuration) configuration->add_modules( modules, now );
|
0fce59 | 1999-06-09 | Martin Stjernholm | | mixed err;
if (err = catch (_do_call_outs()))
report_error ("Error doing call outs:\n" + describe_backtrace (err));
|
edb506 | 1997-08-25 | Peter Bortas | | return 1;
}
|
2a2a5b | 1996-12-01 | Per Hedbor | | string file_name_and_stuff()
{
return ("<b>Loaded from:</b> "+(roxen->filename(this))+"<br>"+
|
00730e | 1999-11-18 | Per Hedbor | | (this->cvs_version?
"<b>CVS Version: </b>"+
fix_cvs(this->cvs_version)+"\n":""));
|
2a2a5b | 1996-12-01 | Per Hedbor | | }
|
9f2a97 | 1999-11-29 | Per Hedbor | | static private Configuration _my_configuration;
|
5839c3 | 1999-01-22 | Marcus Comstedt | |
|
9f2a97 | 1999-11-29 | Per Hedbor | | Configuration my_configuration()
|
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)
if(conf->otomod[this])
|
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;
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | string module_creator;
string module_url;
void set_module_creator(string c)
{
module_creator = c;
}
void set_module_url(string to)
{
module_url = to;
}
int killvar(string var)
{
|
2a2a5b | 1996-12-01 | Per Hedbor | | if(!variables[var]) error("Killing undefined variable.\n");
|
b1fca0 | 1996-11-12 | Per Hedbor | | m_delete(variables, var);
return 1;
}
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 | | string status() {}
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
7fb7f5 | 1999-11-29 | Per Hedbor | | string info(Configuration conf)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
7fb7f5 | 1999-11-29 | Per Hedbor | | return (this->register_module()[2]);
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
9d9b9b | 1999-11-17 | Per Hedbor | | constant ConfigurableWrapper = roxen.ConfigurableWrapper;
|
efc811 | 1999-09-05 | Per Hedbor | | constant reg_s_loc = Locale.Roxen.standard.register_module_doc;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
7fb7f5 | 1999-11-29 | Per Hedbor | | void defvar(string var, mixed value, string name,
int type, string|void doc_str, mixed|void misc,
|
c85684 | 1998-01-21 | Henrik Grubbström (Grubba) | | int|function|void not_in_config)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
273b3f | 1999-12-28 | Martin Nilsson | | #ifdef MODULE_DEBUG
|
b1fca0 | 1996-11-12 | Per Hedbor | | if(!strlen(var))
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("No name for variable!\n");
|
5e4ede | 1996-11-12 | Per Hedbor | |
|
273b3f | 1999-12-28 | Martin Nilsson | |
|
5e4ede | 1996-11-12 | Per Hedbor | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | if (!stringp(name))
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("The variable "+var+"has no name.\n");
|
efc811 | 1999-09-05 | Per Hedbor | |
|
f6d62d | 1997-03-26 | Per Hedbor | | if((search(name, "\"") != -1))
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("Please do not use \" in variable names");
|
b1fca0 | 1996-11-12 | Per Hedbor | |
if (!stringp(doc_str))
doc_str = "No documentation";
|
df6cd1 | 1998-10-13 | Per Hedbor | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | switch (type & VAR_TYPE_MASK)
{
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | case TYPE_NODE:
if(!arrayp(value))
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("TYPE_NODE variables should contain a list of variables "
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | "to use as subnodes.\n");
break;
case TYPE_CUSTOM:
if(!misc
&& arrayp(misc)
&& (sizeof(misc)>=3)
&& functionp(misc[0])
&& functionp(misc[1])
&& functionp(misc[2]))
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("When defining a TYPE_CUSTOM variable, the MISC "
"field must be an array of functionpointers: \n"
"({describe,describe_form,set_from_form})\n");
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | break;
case TYPE_TEXT_FIELD:
case TYPE_FILE:
case TYPE_STRING:
case TYPE_LOCATION:
case TYPE_PASSWORD:
if(value && !stringp(value)) {
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nPassing illegal value (%t:%O) "
"to string type variable.\n",
roxen->filename(this), value, value);
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | }
break;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | case TYPE_FLOAT:
if(!floatp(value))
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nPassing illegal value (%t:%O) "
"(not float) to floating point "
"decimal number variable.\n",
roxen->filename(this), value, value);
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | break;
case TYPE_INT:
if(!intp(value))
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nPassing illegal value (%t:%O) "
"(not int) to integer number variable.\n",
roxen->filename(this), value, value);
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | break;
case TYPE_MODULE_LIST:
value = ({});
break;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | case TYPE_MODULE:
value = 0;
break;
case TYPE_DIR_LIST:
int i;
if(!arrayp(value)) {
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nIllegal type %t to TYPE_DIR_LIST, "
"must be array.\n",
roxen->filename(this), value);
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | value = ({ "./" });
} else {
for(i=0; i<sizeof(value); i++) {
if(strlen(value[i])) {
if(value[i][-1] != '/')
value[i] += "/";
|
0f8c87 | 1997-06-01 | Henrik Grubbström (Grubba) | | } else {
value[i]="./";
}
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | }
}
break;
case TYPE_DIR:
if(value && !stringp(value))
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nPassing illegal value (%t:%O) (not string) "
"to directory variable.\n",
roxen->filename(this), value, value);
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | if(value && strlen(value) && ((string)value)[-1] != '/')
value+="/";
break;
case TYPE_INT_LIST:
case TYPE_STRING_LIST:
if(!misc && value && !arrayp(value)) {
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nPassing illegal misc (%t:%O) (not array) "
"to multiple choice variable.\n",
roxen->filename(this), value, value);
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | } else {
if(misc && !arrayp(misc)) {
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nPassing illegal misc (%t:%O) (not array) "
"to multiple choice variable.\n",
roxen->filename(this), misc, misc);
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | }
|
afd950 | 1998-07-24 | Martin Stjernholm | | if(misc && value && search(misc, value)==-1) {
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nPassing value (%t:%O) not present "
"in the misc array.\n",
roxen->filename(this), value, value);
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | }
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | break;
|
0f8c87 | 1997-06-01 | Henrik Grubbström (Grubba) | | case TYPE_FLAG:
|
b1fca0 | 1996-11-12 | Per Hedbor | | value=!!value;
break;
|
0f8c87 | 1997-06-01 | Henrik Grubbström (Grubba) | | case TYPE_ERROR:
|
b1fca0 | 1996-11-12 | Per Hedbor | | break;
|
0f8c87 | 1997-06-01 | Henrik Grubbström (Grubba) | | case TYPE_COLOR:
|
b1fca0 | 1996-11-12 | Per Hedbor | | if (!intp(value))
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nPassing illegal value (%t:%O) (not int) "
"to color variable.\n",
roxen->filename(this), value, value);
|
b1fca0 | 1996-11-12 | Per Hedbor | | break;
|
be377f | 1997-06-12 | Henrik Grubbström (Grubba) | | case TYPE_FILE_LIST:
case TYPE_PORTS:
case TYPE_FONT:
break;
|
0f8c87 | 1997-06-01 | Henrik Grubbström (Grubba) | | default:
|
273b3f | 1999-12-28 | Martin Nilsson | | report_debug("%s:\nIllegal type (%s) in defvar.\n",
roxen->filename(this), type);
|
0f8c87 | 1997-06-01 | Henrik Grubbström (Grubba) | | break;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
efc811 | 1999-09-05 | Per Hedbor | | #endif
reg_s_loc( this_object(), var, name, doc_str );
|
df6cd1 | 1998-10-13 | Per Hedbor | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | variables[var]=allocate( VAR_SIZE );
variables[var][ VAR_VALUE ]=value;
variables[var][ VAR_TYPE ]=type&VAR_TYPE_MASK;
variables[var][ VAR_DOC_STR ]=doc_str;
variables[var][ VAR_NAME ]=name;
|
e41643 | 1998-07-07 | Henrik Grubbström (Grubba) | |
type &= ~VAR_TYPE_MASK;
type &= (VAR_EXPERT | VAR_MORE);
if (functionp(not_in_config)) {
if (type) {
variables[var][ VAR_CONFIGURABLE ] = ConfigurableWrapper(type, not_in_config)->check;
} else {
variables[var][ VAR_CONFIGURABLE ] = not_in_config;
}
} else if (type) {
variables[var][ VAR_CONFIGURABLE ] = type;
} else if(intp(not_in_config)) {
variables[var][ VAR_CONFIGURABLE ] = !not_in_config;
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | variables[var][ VAR_MISC ]=misc;
variables[var][ VAR_SHORTNAME ]= var;
}
|
efc811 | 1999-09-05 | Per Hedbor | | static mapping locs = ([]);
|
df6cd1 | 1998-10-13 | Per Hedbor | | void deflocaledoc( string locale, string variable,
|
b796b5 | 1998-11-18 | Per Hedbor | | string name, string doc, mapping|void translate )
|
df6cd1 | 1998-10-13 | Per Hedbor | | {
|
efc811 | 1999-09-05 | Per Hedbor | | if(!locs[locale] )
locs[locale] = Locale.Roxen[locale]->register_module_doc;
if(!locs[locale])
|
df6cd1 | 1998-10-13 | Per Hedbor | | report_debug("Invalid locale: "+locale+". Ignoring.\n");
else
|
efc811 | 1999-09-05 | Per Hedbor | | locs[locale]( this_object(), variable, name, doc, translate );
|
df6cd1 | 1998-10-13 | Per Hedbor | | }
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
2c13a8 | 1999-11-10 | Per Hedbor | | void save_me()
|
e7e603 | 1999-11-05 | Per Hedbor | | {
my_configuration()->save_one( this_object() );
}
|
2c13a8 | 1999-11-10 | Per Hedbor | | void save()
{
save_me();
}
|
4cf115 | 1999-04-24 | Henrik Grubbström (Grubba) | |
|
0f8c87 | 1997-06-01 | Henrik Grubbström (Grubba) | | void definvisvar(string name, int value, int type, array|void misc)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
0f8c87 | 1997-06-01 | Henrik Grubbström (Grubba) | | defvar(name, value, "", type, "", misc, 1);
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
string check_variable( string s, mixed value )
{
return 0;
}
|
c85684 | 1998-01-21 | Henrik Grubbström (Grubba) | | mixed query(string|void var, int|void ok)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
c85684 | 1998-01-21 | Henrik Grubbström (Grubba) | | if(var) {
|
b1fca0 | 1996-11-12 | Per Hedbor | | if(variables[var])
return variables[var][VAR_VALUE];
|
c6fa43 | 1998-11-22 | Per Hedbor | | else if(!ok && var[0] != '_')
|
b1fca0 | 1996-11-12 | Per Hedbor | | error("Querying undefined variable.\n");
|
c6fa43 | 1998-11-22 | Per Hedbor | | return 0;
|
c85684 | 1998-01-21 | Henrik Grubbström (Grubba) | | }
|
b1fca0 | 1996-11-12 | Per Hedbor | |
return variables;
}
void set(string var, mixed value)
{
if(!variables[var])
error( "Setting undefined variable.\n" );
|
7fb7f5 | 1999-11-29 | Per Hedbor | | variables[var][VAR_VALUE]=value;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
int setvars( mapping (string:mixed) vars )
{
string v;
int err;
foreach( indices( vars ), v )
if(variables[v])
set( v, vars[v] );
return !err;
}
string comment()
{
return "";
}
|
5839c3 | 1999-01-22 | Marcus Comstedt | | string query_internal_location()
{
if(!_my_configuration)
error("Please do not call this function from create()!\n");
return _my_configuration->query_internal_location(this_object());
}
|
b7c45e | 1997-01-27 | Per Hedbor | |
string query_location()
{
string s;
catch{s = query("location");};
return s;
}
|
ae32d0 | 1998-03-23 | David Hedbor | |
string query_provides() { return 0; }
|
b7c45e | 1997-01-27 | Per Hedbor | |
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
17d173 | 1997-08-13 | Henrik Grubbström (Grubba) | | class IP_with_mask {
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=({ });
|
de493f | 1997-04-28 | Henrik Grubbström (Grubba) | | if(catch(query("_seclevels"))) {
|
b1fca0 | 1996-11-12 | Per Hedbor | | return patterns;
|
de493f | 1997-04-28 | Henrik Grubbström (Grubba) | | }
|
b1fca0 | 1996-11-12 | 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)
{
|
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) | | array(string|int) arr;
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":
array(string|int) arr;
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) | | array(string|int) arr;
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;
for(i=0; i < sizeof(users); i++) {
|
de493f | 1997-04-28 | Henrik Grubbström (Grubba) | | if (lower_case(users[i]) == "any") {
|
f6d62d | 1997-03-26 | Per Hedbor | | if(this->register_module()[0] & MODULE_PROXY)
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]*"|";
if(this->register_module()[0] & MODULE_PROXY) {
patterns += ({ ({ MOD_PROXY_USER, Regexp(value)->match, }) });
} else {
patterns += ({ ({ MOD_USER, Regexp(value)->match, }) });
}
}
}
if (i & 0x0f) {
value = users[0..(i-1)&0x0f]*"|";
if(this->register_module()[0] & MODULE_PROXY) {
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, ({ "?", ".", "*" }), ({ ".", "\\.", ".*" }));
array(string) users = (value/"," - ({""}));
int i;
for(i=0; i < sizeof(users); i++) {
if (lower_case(users[i]) == "any") {
if(this->register_module()[0] & MODULE_PROXY)
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]*"|";
if(this->register_module()[0] & MODULE_PROXY) {
patterns += ({ ({ MOD_PROXY_USER, Regexp(value)->match, }) });
} else {
patterns += ({ ({ MOD_ACCEPT_USER, Regexp(value)->match, }) });
}
}
}
if (i & 0x0f) {
value = users[0..(i-1)&0x0f]*"|";
if(this->register_module()[0] & MODULE_PROXY) {
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;
}
|
7fb7f5 | 1999-11-29 | Per Hedbor | | mixed stat_file(string f, RequestID id){}
mixed find_dir(string f, RequestID id){}
mapping(string:array(mixed)) 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);
mapping(string:array(mixed)) res = ([]);
|
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);
|
0c8b9a | 1997-10-22 | Henrik Grubbström (Grubba) | | array(mixed) st = stat_file(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);
}
|
7fb7f5 | 1999-11-29 | Per Hedbor | | mixed real_file(string f, RequestID id){}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
4f4bc1 | 1998-02-04 | Per Hedbor | | mapping _api_functions = ([]);
void add_api_function( string name, function f, void|array(string) types)
{
_api_functions[name] = ({ f, types });
}
mapping api_functions()
{
return _api_functions;
}
|
4ff8c6 | 1999-12-14 | Martin Nilsson | | function _rxml_error;
|
7fb7f5 | 1999-11-29 | Per Hedbor | | string rxml_error(string tag, string error, RequestID id) {
|
4ff8c6 | 1999-12-14 | Martin Nilsson | | if(_rxml_error) return _rxml_error(tag, error, id);
if(id->conf->get_provider("RXMLErrorAlert")) {
_rxml_error=id->conf->get_provider("RXMLErrorAlert")->rxml_error;
return _rxml_error(tag, error, id);
}
return ((id->misc->debug||id->prestate->debug)?
sprintf("(%s: %s)", capitalize(tag), error):"")+"<false>";
|
9512ee | 1999-08-07 | Martin Nilsson | | }
|
48ca16 | 1999-05-18 | Per Hedbor | | mapping query_tag_callers()
{
mapping m = ([]);
foreach(glob("tag_*", indices( this_object())), string q)
if(functionp( this_object()[q] ))
m[replace(q[4..], "_", "-")] = this_object()[q];
return m;
}
mapping query_container_callers()
{
mapping m = ([]);
foreach(glob("container_*", indices( this_object())), string q)
if(functionp( this_object()[q] ))
m[replace(q[10..], "_", "-")] = this_object()[q];
return m;
}
mapping query_if_callers()
{
mapping m = ([]);
foreach(glob("if_*", indices( this_object())), string q)
if(functionp( this_object()[q] ))
m[replace(q[3..], "_", "-")] = this_object()[q];
return m;
}
|
ea062e | 1999-11-21 | Martin Nilsson | |
|
395e46 | 2000-01-18 | Martin Stjernholm | | private RXML.TagSet module_tag_set;
|
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 | | }
|