Roxen.git / server / base_server / module.pike

version» Context lines:

Roxen.git/server/base_server/module.pike:1: - /* $Id: module.pike,v 1.57 1999/11/29 18:50:04 per Exp $ */ + /* $Id: module.pike,v 1.58 1999/11/29 22:09:05 per Exp $ */   #include <module.h>   #include <request_trace.h>      mapping (string:mixed *) variables=([]); - object this = this_object(); + RoxenModule this = this_object();   mapping(string:array(int)) error_log=([]);      constant is_module = 1;   constant module_type = MODULE_PARSER;   constant module_name = "Unnamed module";   constant module_doc = "Undocumented";   constant module_unique = 1;      string _sprintf()   { -  return sprintf("Module("+register_module()[1]+",%s)", my_configuration()); +  return sprintf("RoxenModule("+register_module()[1]+",%s)", my_configuration());   }      array register_module()   {    return ({    module_type,    module_name,    module_doc,    0,    module_unique,    });   }      string fix_cvs(string from)   {    from = replace(from, ({ "$", "Id: "," Exp $" }), ({"","",""}));    sscanf(from, "%*s,v %s", from);    return replace(from,"/","-");   }    - int module_dependencies(object configuration, + int module_dependencies(Configuration configuration,    array (string) modules,    int|void now)   {    if(configuration) configuration->add_modules( modules, now );    mixed err;    if (err = catch (_do_call_outs()))    report_error ("Error doing call outs:\n" + describe_backtrace (err));    return 1;   }   
Roxen.git/server/base_server/module.pike:53:    "<b>CVS Version: </b>"+    fix_cvs(this->cvs_version)+"\n":""));   }      static private Configuration _my_configuration;      Configuration my_configuration()   {    if(_my_configuration)    return _my_configuration; -  object conf; +  Configuration conf;    foreach(roxen->configurations, conf)    if(conf->otomod[this])    return _my_configuration = conf;    return 0;   }    - nomask void set_configuration(object c) + nomask void set_configuration(Configuration c)   {    if(_my_configuration && _my_configuration != c)    error("set_configuration() called twice.\n");    _my_configuration = c;   }      string module_creator;   string module_url;      void set_module_creator(string c)
Roxen.git/server/base_server/module.pike:89:      int killvar(string var)   {    if(!variables[var]) error("Killing undefined variable.\n");    m_delete(variables, var);    return 1;   }      void free_some_sockets_please(){}    - void start(void|int num, void|object conf) {} + void start(void|int num, void|Configuration conf) {}   string status() {}       - string info(object conf) + string info(Configuration conf)   { -  return (this->register_module(conf)[2]); +  return (this->register_module()[2]);   }      constant ConfigurableWrapper = roxen.ConfigurableWrapper;   constant reg_s_loc = Locale.Roxen.standard.register_module_doc;      // Define a variable, with more than a little error checking... - void defvar(string|void var, mixed|void value, string|void name, -  int|void type, string|void doc_str, mixed|void misc, + void defvar(string var, mixed value, string name, +  int type, string|void doc_str, mixed|void misc,    int|function|void not_in_config)   {   #if defined(MODULE_DEBUG)    if(!strlen(var))    error("No name for variable!\n");   // if(var[0]=='_' && previous_object() != roxen)   // error("Variable names beginning with '_' are reserved for"   // " internal usage.\n");    if (!stringp(name))    error("The variable "+var+"has no name.\n");
Roxen.git/server/base_server/module.pike:327:    if(variables[var])    return variables[var][VAR_VALUE];    else if(!ok && var[0] != '_')    error("Querying undefined variable.\n");    return 0;    }       return variables;   }    - void set_module_list(string var, string what, object to) - { -  int p; -  p = search(variables[var][VAR_VALUE], what); -  if(p == -1) -  { - #ifdef MODULE_DEBUG -  perror("The variable '"+var+"': '"+what+"' found by hook.\n"); -  perror("Not found in variable!\n"); - #endif -  } else -  variables[var][VAR_VALUE][p]=to; - } -  +    void set(string var, mixed value)   {    if(!variables[var])    error( "Setting undefined variable.\n" ); -  else -  if(variables[var][VAR_TYPE] == TYPE_MODULE && stringp(value)) -  roxenp()->register_module_load_hook( value, set, var ); -  else if(variables[var][VAR_TYPE] == TYPE_MODULE_LIST) -  { +     variables[var][VAR_VALUE]=value; -  if(arrayp(value)) -  foreach(value, value) -  if(stringp(value)) -  roxenp()->register_module_load_hook(value,set_module_list,var,value); +    } -  else -  variables[var][VAR_VALUE]=value; - } +       int setvars( mapping (string:mixed) vars )   {    string v;    int err;       foreach( indices( vars ), v )    if(variables[v])    set( v, vars[v] );    return !err;
Roxen.git/server/base_server/module.pike:590:    break;    }    } else {    report_error(sprintf("Syntax error in Security:Patterns directive: "    "line=\"%s\"\n", sl));    }    }    return patterns;   }    - mixed stat_file(string f, object id){} - mixed find_dir(string f, object id){} - mapping(string:array(mixed)) find_dir_stat(string f, object id) + 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)   {    TRACE_ENTER("find_dir_stat(): \""+f+"\"", 0);       array(string) files = find_dir(f, id);    mapping(string:array(mixed)) res = ([]);       foreach(files || ({}), string fname) {    TRACE_ENTER("stat()'ing "+ f + "/" + fname, 0);    array(mixed) st = stat_file(f + "/" + fname, id);    if (st) {    res[fname] = st;    TRACE_LEAVE("OK");    } else {    TRACE_LEAVE("No stat info");    }    }       TRACE_LEAVE("");    return(res);   } - mixed real_file(string f, object id){} + mixed real_file(string f, RequestID id){}      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;   }    - string rxml_error(string tag, string error, object id) { + string rxml_error(string tag, string error, RequestID id) {    return (id->misc->debug?sprintf("(%s: %s)",capitalize(tag),error):"")+"<false>";   }    - object get_font_from_var(string base) - { -  int weight, slant; -  switch(query(base+"_weight")) -  { -  case "light": weight=-1; break; -  default: weight=0; break; -  case "bold": weight=1; break; -  case "black": weight=2; break; -  } -  switch(query(base+"_slant")) -  { -  case "obligue": slant=-1; break; -  default: slant=0; break; -  case "italic": slant=1; break; -  } -  return get_font(query(base+"_font"), 32, weight, slant, "left", 0, 0); - } -  -  +    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()
Roxen.git/server/base_server/module.pike:679:   {    mapping m = ([]);    foreach(glob("if_*", indices( this_object())), string q)    if(functionp( this_object()[q] ))    m[replace(q[3..], "_", "-")] = this_object()[q];    return m;   }      mixed get_commented_value(string path, int start)   { -  object file=Stdio.File(); +  Stdio.File file=Stdio.File();    if(!file->open(path,"r")) return 0;    string in,comment;    in=file->read();    if(sscanf((in/"\n")[start..]*"\n","%*s/*%s*/",comment)!=2) return 0;    return compile_string( "mixed f(){ return "+comment+"; }" )()->f();   }