Branch: Tag:

1999-11-29

1999-11-29 22:07:01 by Per Hedbor <ph@opera.com>

More progress in my quest for eradication of 'object id' (should be RequestID id). I also replaced some 'object m' with 'RoxenModule m', and a few object sql with Sql.sql sql

Rev: server/base_server/configuration.pike:1.237

3:    * (C) 1996, 1999 Idonex AB.    */    - constant cvs_version = "$Id: configuration.pike,v 1.236 1999/11/28 04:32:11 jhs Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.237 1999/11/29 22:07:01 per Exp $";   constant is_configuration = 1;   #include <module.h>   #include <roxen.h>
32:      #include "rxml.pike";    - object throttler=0; - function store = roxen->store; - function retrieve = roxen->retrieve; - function remove = roxen->remove; - function do_dest = roxen->do_dest; - object types_module; - object auth_module; - object dir_module; - function types_fun; - function auth_fun; + object throttler; + function store = roxen->store; + function retrieve = roxen->retrieve; + function remove = roxen->remove; + RoxenModule types_module; + RoxenModule auth_module; + RoxenModule dir_module; + function types_fun; + function auth_fun;      string name;   
50:      string get_doc_for( string region, string variable )   { -  object module; +  RoxenModule module;    if(variable[0] == '_')    return 0;    if((int)reverse(region))
139:    return defvar(var, value, "", type, "", 0, 1);   }    - string query_internal_location(object|void mod) + string query_internal_location(RoxenModule|void mod)   {    return QUERY(InternalLoc)+(mod?replace(otomod[mod]||"", "#", "!")+"/":"");   }
163:    return "Priority()";    }    -  array (object) url_modules = ({ }); -  array (object) logger_modules = ({ }); -  array (object) location_modules = ({ }); -  array (object) filter_modules = ({ }); -  array (object) last_modules = ({ }); -  array (object) first_modules = ({ }); -  mapping (string:array(object)) file_extension_modules = ([ ]); -  mapping (object:multiset) provider_modules = ([ ]); +  array (RoxenModule) url_modules = ({ }); +  array (RoxenModule) logger_modules = ({ }); +  array (RoxenModule) location_modules = ({ }); +  array (RoxenModule) filter_modules = ({ }); +  array (RoxenModule) last_modules = ({ }); +  array (RoxenModule) first_modules = ({ }); +  mapping (string:array(RoxenModule)) file_extension_modules = ([ ]); +  mapping (RoxenModule:multiset(string)) provider_modules = ([ ]);       void stop()    { -  foreach(url_modules, object m) +  foreach(url_modules, RoxenModule m)    CATCH("stopping url modules",m->stop && m->stop()); -  foreach(logger_modules, object m) +  foreach(logger_modules, RoxenModule m)    CATCH("stopping logging modules",m->stop && m->stop()); -  foreach(filter_modules, object m) +  foreach(filter_modules, RoxenModule m)    CATCH("stopping filter modules",m->stop && m->stop()); -  foreach(location_modules, object m) +  foreach(location_modules, RoxenModule m)    CATCH("stopping location modules",m->stop && m->stop()); -  foreach(last_modules, object m) +  foreach(last_modules, RoxenModule m)    CATCH("stopping last modules",m->stop && m->stop()); -  foreach(first_modules, object m) +  foreach(first_modules, RoxenModule m)    CATCH("stopping first modules",m->stop && m->stop()); -  foreach(indices(provider_modules), object m) +  foreach(indices(provider_modules), RoxenModule m)    CATCH("stopping provider modules",m->stop && m->stop());    }   }
198:    * performance reasons later on.    */    - array (object) allocate_pris() + array (Priority) allocate_pris()   {    return allocate(10, Priority)();   }
224:   private mapping (string:string) log_format = ([]);      // A list of priority objects - private array (object) pri = allocate_pris(); + private array (Priority) pri = allocate_pris();      // All enabled modules in this virtual server.   // The format is "module":{ "copies":([ num:instance, ... ]) }   public mapping modules = ([]);      // A mapping from objects to module names - public mapping (object:string) otomod = ([]); + public mapping (RoxenModule:string) otomod = ([]);         // Caches to speed up the handling of the module search.
242:   private array (function) filter_module_cache;   private array (array (string|function)) location_module_cache;   private mapping (string:array (function)) file_extension_module_cache=([]); - private mapping (string:array (object)) provider_module_cache=([]); + private mapping (string:array (RoxenModule)) provider_module_cache=([]);         // Call stop in all modules.
256:    dir_module && dir_module->stop && dir_module->stop());    for(int i=0; i<10; i++)    CATCH("stopping priority group", -  pri[i] && pri[i]->stop && pri[i]->stop()); +  (pri[i],pri[i]->stop,pri[i]->stop()));   }      public string type_from_filename( string file, int|void to, string|void myext )
289:   }      // Return an array with all provider modules that provides "provides". - array (object) get_providers(string provides) + array (RoxenModule) get_providers(string provides)   {    // FIXME: Is there any way to clear this cache?    // /grubba 1998-05-28
300:    provider_module_cache[provides] = ({ });    for(i = 9; i >= 0; i--)    { -  foreach(indices(pri[i]->provider_modules), object d) +  foreach(indices(pri[i]->provider_modules), RoxenModule d)    if(pri[i]->provider_modules[ d ][ provides ])    provider_module_cache[provides] += ({ d });    }
309:   }      // Return the first provider module that provides "provides". - object get_provider(string provides) + RoxenModule get_provider(string provides)   { -  array (object) prov = get_providers(provides); +  array (RoxenModule) prov = get_providers(provides);    if(sizeof(prov))    return prov[0];    return 0;
320:   // map the function "fun" over all matching provider modules.   array(mixed) map_providers(string provides, string fun, mixed ... args)   { -  array (object) prov = get_providers(provides); +  array (RoxenModule) prov = get_providers(provides);    array error;    array a=({ });    mixed m; -  foreach(prov, object mod) +  foreach(prov, RoxenModule mod)    {    if(!objectp(mod))    continue;
345:   // return the first positive response.   mixed call_provider(string provides, string fun, mixed ... args)   { -  foreach(get_providers(provides), object mod) { +  foreach(get_providers(provides), RoxenModule mod) +  {    function f;    if(objectp(mod) && functionp(f = mod[fun])) {    mixed error;
362:    }   }    - array (function) file_extension_modules(string ext, object id) + array (function) file_extension_modules(string ext, RequestID id)   {    if(!file_extension_module_cache[ext])    {
370:    file_extension_module_cache[ext] = ({ });    for(i=9; i>=0; i--)    { -  object *d, p; +  array(RoxenModule) d; +  RoxenModule p;    if(d = pri[i]->file_extension_modules[ext])    foreach(d, p)    file_extension_module_cache[ext] += ({ p->handle_file_extension });
379:    return file_extension_module_cache[ext];   }    - array (function) url_modules(object id) + array (function) url_modules(RequestID id)   {    if(!url_module_cache)    {
387:    url_module_cache=({ });    for(i=9; i>=0; i--)    { -  object *d, p; +  array(RoxenModule) d; +  RoxenModule p;    if(d=pri[i]->url_modules)    foreach(d, p)    url_module_cache += ({ p->remap_url });
397:   }      mapping api_module_cache = ([]); - mapping api_functions(void|object id) + mapping api_functions(void|RequestID id)   {    return copy_value(api_module_cache);   }    - array (function) logger_modules(object id) + array (function) logger_modules(RequestID id)   {    if(!logger_module_cache)    {
410:    logger_module_cache=({ });    for(i=9; i>=0; i--)    { -  object *d, p; +  array(RoxenModule) d; +  RoxenModule p;    if(d=pri[i]->logger_modules)    foreach(d, p)    if(p->log)
420:    return logger_module_cache;   }    - array (function) last_modules(object id) + array (function) last_modules(RequestID id)   {    if(!last_module_cache)    {
428:    last_module_cache=({ });    for(i=9; i>=0; i--)    { -  object *d, p; +  array(RoxenModule) d; +  RoxenModule p;    if(d=pri[i]->last_modules)    foreach(d, p)    if(p->last_resort)
439:   }      #ifdef __NT__ - static mixed strip_fork_information(object id) + static mixed strip_fork_information(RequestID id)   {    array a = id->not_query/"::";    id->not_query = a[0];
448:   }   #endif /* __NT__ */    - array (function) first_modules(object id) + array (function) first_modules(RequestID id)   {    if(!first_module_cache)    {
460:    });    for(i=9; i>=0; i--)    { -  object *d, p; +  array(RoxenModule) d; RoxenModule p;    if(d=pri[i]->first_modules) {    foreach(d, p) {    if(p->first_try) {
475:   }       - array location_modules(object id) + array location_modules(RequestID id)   {    if(!location_module_cache)    {
483:    array new_location_module_cache=({ });    for(i=9; i>=0; i--)    { -  object *d, p; +  array(RoxenModule) d; +  RoxenModule p;    if(d=pri[i]->location_modules) {    array level_find_files = ({});    array level_locations = ({});
509:    return location_module_cache;   }    - array filter_modules(object id) + array filter_modules(RequestID id)   {    if(!filter_module_cache)    {
517:    filter_module_cache=({ });    for(i=9; i>=0; i--)    { -  object *d, p; +  array(RoxenModule) d; +  RoxenModule p;    if(d=pri[i]->filter_modules)    foreach(d, p)    if(p->filter)
551:    if(strlen(logfile))    {    do { -  object lf=open( logfile, "wac"); +  Stdio.File lf=open( logfile, "wac");    if(!lf) {    mkdirhier(logfile);    if(!(lf=open( logfile, "wac"))) {
738:    return res;   }    - public string *userinfo(string u, object|void id) + public array(string) userinfo(string u, RequestID|void id)   {    if(auth_module) return auth_module->userinfo(u);    else report_warning(sprintf("userinfo(): %s\n"
747:    describe_backtrace(backtrace())));   }    - public string *userlist(object|void id) + public array(string) userlist(RequestID|void id)   {    if(auth_module) return auth_module->userlist();    else report_warning(sprintf("userlist(): %s\n"
756:    describe_backtrace(backtrace())));   }    - public string *user_from_uid(int u, object|void id) + public array(string) user_from_uid(int u, RequestID|void id)   {    if(auth_module)    return auth_module->user_from_uid(u);
766:    describe_backtrace(backtrace())));   }    - public string last_modified_by(object file, object id) + public string last_modified_by(Stdio.File file, RequestID id)   {    int *s;    int uid;
793:    // Disallow "internal-gopher-..", it won't really do much harm, but a list of    // all files in '..' might be retrieved (that is, the actual directory    // file was sent to the browser) -  object f = open("roxen-images/dir/"+from+".gif","r"); +  Stdio.File f = open("roxen-images/dir/"+from+".gif","r");    if (f) {    return (["file":f, "type":"image/gif"]);    } else {
807: Inside #if defined(MODULE_LEVEL_SECURITY)
  #ifdef MODULE_LEVEL_SECURITY   private mapping misc_cache=([]);    - int|mapping check_security(function a, object id, void|int slevel) + int|mapping check_security(function a, RequestID id, void|int slevel)   {    array level;    array seclevels;
945:   void clear_memory_caches()   {    invalidate_cache(); -  foreach(indices(otomod), object m) +  foreach(indices(otomod), RoxenModule m)    if (m && m->clear_memory_caches)    if (mixed err = catch( m->clear_memory_caches() ))    report_error(LOCALE->
955:      string draw_saturation_bar(int hue,int brightness, int where)   { -  object bar=Image.image(30,256); +  Image.Image bar=Image.Image(30,256);       for(int i=0;i<128;i++)    {
1009: Inside #if defined(THREADS)
     mapping locked = ([]), thread_safe = ([]);    - object _lock(object|function f) + mixed _lock(object|function f)   {    object key;    function|int l;
1122:   // The function that actually tries to find the data requested. All   // modules are mapped, in order, and the first one that returns a   // suitable responce is used. - mapping|int low_get_file(object id, int|void no_magic) + mapping|int low_get_file(RequestID id, int|void no_magic)   {   #ifdef MODULE_LEVEL_SECURITY    int slevel;
1179:    if(!search(file, QUERY(InternalLoc)))    {    TRACE_ENTER(LOCALE->magic_internal_module_location(), 0); -  object module; +  RoxenModule module;    string name, rest;    function find_internal;    if(2==sscanf(file[strlen(QUERY(InternalLoc))..], "%s/%s", name, rest) &&
1463:   }       - mixed handle_request( object id ) + mixed handle_request( RequestID id )   {    function funp;    mixed file;
1500:    return file;   }    - mixed get_file(object id, int|void no_magic) + mixed get_file(RequestID id, int|void no_magic)   {    mixed res, res2;    function tmp;
1523:    return res;   }    - public array find_dir(string file, object id) + public array find_dir(string file, RequestID id)   {    string loc;    array dir = ({ }), tmp;
1631:      // Stat a virtual file.    - public array stat_file(string file, object id) + public array(int) stat_file(string file, RequestID id)   {    string loc;    array s, tmp;
1760:         // this is not as trivial as it sounds. Consider gtext. :-) - public array open_file(string fname, string mode, object id) + public array open_file(string fname, string mode, RequestID id)   {    object oc = id->conf;    string oq = id->not_query;
1834:   }       - public mapping(string:array(mixed)) find_dir_stat(string file, object id) + public mapping(string:array(mixed)) find_dir_stat(string file, RequestID id)   {    string loc;    mapping(string:array(mixed)) dir = ([]);
1918: Inside #if defined(MODULE_LEVEL_SECURITY)
  #ifdef MODULE_LEVEL_SECURITY    if(check_security(tmp[1], id)) continue;   #endif -  object c = function_object(tmp[1]); +  RoxenModule c = function_object(tmp[1]);    string f = file[strlen(loc)..];    if (c->find_dir_stat) {    TRACE_ENTER(LOCALE->has_find_dir_stat(), 0);
1930:    TRACE_LEAVE("");    } else if(d = c->find_dir(f, id)) {    TRACE_ENTER(LOCALE->returned_array(), 0); -  dir = mkmapping(d, Array.map(d, lambda(string f, string base, -  object c, object id) { -  return c->stat_file(base + f, id); -  }, f, c, id)) | dir; +  dir = mkmapping(d, Array.map(d, lambda(string fn) +  { +  return c->stat_file(f + fn, id); +  })) | dir;    TRACE_LEAVE("");    }    } else if(search(loc, file)==0 && loc[strlen(file)-1]=='/' &&
1959:      // Access a virtual file?    - public array access(string file, object id) + public array access(string file, RequestID id)   {    string loc;    array s, tmp;
1989:      // Return the _real_ filename of a virtual file, if any.    - public string real_file(string file, object id) + public string real_file(string file, RequestID id)   {    string loc;    string s;
2018:      // NOTE: A 'file' can be a cgi script, which will be executed, resulting in   // a horrible delay. - int|string try_get_file(string s, object id, int|void status, int|void nocache) + int|string try_get_file(string s, RequestID id, +  int|void status, int|void nocache)   {    string res, q; -  object fake_id; +  RequestID fake_id;    mapping m;    -  if(objectp(id)) { +  if(!objectp(id)) +  error("No ID passed to 'try_get_file'\n"); +     // id->misc->common makes it possible to pass information to    // the originating request.    if ( !id->misc )
2035:    fake_id = id->clone_me();       fake_id->misc->common = id->misc->common; -  } else -  error("No ID passed to 'try_get_file'\n"); +        if(!id->pragma["no-cache"] && !nocache && (!id->auth || !id->auth[0]))    if(res = cache_lookup("file:"+id->conf->name, s))
2088:   }      // Is 'what' a file in our virtual filesystem? - int(0..1) is_file(string what, object id) + int(0..1) is_file(string what, RequestID id)   {    return !!stat_file(what, id);   }
2138:   }      // Save all variables in _one_ module. - int save_one( object o ) + int save_one( RoxenModule o )   {    mapping mod;    if(!o)
2160:      void reload_module( string modname )   { -  object old_module = find_module( modname ); +  RoxenModule old_module = find_module( modname );    int do_delete_doto;       if( !old_module )
2183:    string _sprintf( ) { return "ModuleCopies()"; }   }    - object enable_module( string modname, object|void me ) + RoxenModule enable_module( string modname, RoxenModule|void me )   {    int id; -  object moduleinfo; -  object module; +  ModuleInfo moduleinfo; +  ModuleCopies module;    int pr;    mixed err;    int module_type;
2638:      int disable_module( string modname )   { -  object me; +  RoxenModule me;    int id, pr;    sscanf(modname, "%s#%d", modname, id );    -  object moduleinfo = roxen->find_module( modname ); +  ModuleInfo moduleinfo = roxen->find_module( modname );    mapping module = modules[ modname ];       if(!module)
2745:    return 1;   }    - object|string find_module(string name) + RoxenModule|string find_module(string name)   {    int id;    sscanf(name, "%s#%d", name, id);
2787:      mapping sql_cache = ([]);    - object sql_cache_get(string what) + Sql.sql sql_cache_get(string what)   {   #ifdef THREADS    if(sql_cache[what] && sql_cache[what][this_thread()])
2804:   #endif   }    - object sql_connect(string db) + Sql.sql sql_connect(string db)   {    if (sql_urls[db])    return sql_cache_get(sql_urls[db]);