Roxen.git / server / base_server / configuration.pike

version» Context lines:

Roxen.git/server/base_server/configuration.pike:1:   // A vitual server's main configuration   // Copyright © 1996 - 2000, Roxen IS. - constant cvs_version = "$Id: configuration.pike,v 1.381 2000/09/25 07:55:57 per Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.382 2000/09/30 19:19:49 per Exp $";   #include <module.h>   #include <module_constants.h>   #include <roxen.h>   #include <request_trace.h>         #define CATCH(P,X) do{mixed e;if(e=catch{X;})report_error("While "+P+"\n"+describe_backtrace(e));}while(0)      // --- Locale defines ---   //<locale-token project="roxen_start"> LOC_S </locale-token>
Roxen.git/server/base_server/configuration.pike:319:    return ret;    }    })) {    error[0] = "Error in call_provider(): "+error[0];    throw(error);    }    }    }   }    - array (function) file_extension_modules(string ext, RequestID id) + array (function) file_extension_modules(string ext)   {    if(!file_extension_module_cache[ext])    {    int i;    file_extension_module_cache[ext] = ({ });    for(i=9; i>=0; i--)    {    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 });    }    }    return file_extension_module_cache[ext];   }    - array (function) url_modules(RequestID id) + array (function) url_modules()   {    if(!url_module_cache)    {    int i;    url_module_cache=({ });    for(i=9; i>=0; i--)    {    array(RoxenModule) d;    RoxenModule p;    if(d=pri[i]->url_modules)
Roxen.git/server/base_server/configuration.pike:361:    }    return url_module_cache;   }      static mapping api_module_cache = ([]);   mapping api_functions(void|RequestID id)   {    return api_module_cache+([]);   }    - array (function) logger_modules(RequestID id) + array (function) logger_modules()   {    if(!logger_module_cache)    {    int i;    logger_module_cache=({ });    for(i=9; i>=0; i--)    {    array(RoxenModule) d;    RoxenModule p;    if(d=pri[i]->logger_modules)    foreach(d, p)    if(p->log)    logger_module_cache += ({ p->log });    }    }    return logger_module_cache;   }    - array (function) last_modules(RequestID id) + array (function) last_modules()   {    if(!last_module_cache)    {    int i;    last_module_cache=({ });    for(i=9; i>=0; i--)    {    array(RoxenModule) d;    RoxenModule p;    if(d=pri[i]->last_modules)
Roxen.git/server/base_server/configuration.pike:409: Inside #if defined(__NT__)
  #ifdef __NT__   static mixed strip_fork_information(RequestID id)   {    array a = id->not_query/"::";    id->not_query = a[0];    id->misc->fork_information = a[1..];    return 0;   }   #endif /* __NT__ */    - array (function) first_modules(RequestID id) + array (function) first_modules()   {    if(!first_module_cache)    {    int i;    first_module_cache=({   #ifdef __NT__    strip_fork_information, // Always first!   #endif /* __NT__ */    });    for(i=9; i>=0; i--)
Roxen.git/server/base_server/configuration.pike:436:    }    }    }    }    }       return first_module_cache;   }       - array location_modules(RequestID id) + array location_modules()   //! Return an array of all location modules the request would be   //! mapped through, by order of priority.   {    if(!location_module_cache)    {    int i;    array new_location_module_cache=({ });    for(i=9; i>=0; i--)    {    array(RoxenModule) d;
Roxen.git/server/base_server/configuration.pike:473:    new_location_module_cache += ({ ({ level_locations[j],    level_find_files[j] }) });    }    }    }    location_module_cache = new_location_module_cache;    }    return location_module_cache;   }    - array(function) filter_modules(RequestID id) + array(function) filter_modules()   {    if(!filter_module_cache)    {    int i;    filter_module_cache=({ });    for(i=9; i>=0; i--)    {    array(RoxenModule) d;    RoxenModule p;    if(d=pri[i]->filter_modules)
Roxen.git/server/base_server/configuration.pike:531:    foreach(foo, b)    if(strlen(b) && b[0] != '#' && sizeof(b/":")>1)    log_format[(int)(b/":")[0]] = fix_logging((b/":")[1..]*":");   }      public void log(mapping file, RequestID request_id)   {    function f;      // Call all logging functions -  foreach(logger_module_cache||logger_modules(request_id), f) +  foreach(logger_module_cache||logger_modules(), f)    if( f( request_id, file ) )    return;       if( !log_function )    return;// No file is open for logging.       if(do_not_log_patterns &&    Roxen._match(request_id->remoteaddr, do_not_log_patterns))    return;   
Roxen.git/server/base_server/configuration.pike:1083:    TRACE_LEAVE("");    }    }       // Well, this just _might_ be somewhat over-optimized, since it is    // quite unreadable, but, you cannot win them all..    if(!fid)    {   #ifdef URL_MODULES    // Map URL-modules -  foreach(url_module_cache||url_modules(id), funp) +  foreach(url_module_cache||url_modules(), funp)    {    LOCK(funp);    TRACE_ENTER("URL module", funp);    tmp=funp( id, file );    UNLOCK();       if(mappingp(tmp))    {    TRACE_LEAVE("");    TRACE_LEAVE("Returning data");
Roxen.git/server/base_server/configuration.pike:1121: Inside #if defined(URL_MODULES)
   nest = 0;    if(err) throw(err);    TRACE_LEAVE("");    TRACE_LEAVE("Returning data");    return tmp;    }    TRACE_LEAVE("");    }   #endif    -  foreach(location_module_cache||location_modules(id), tmp) +  foreach(location_module_cache||location_modules(), tmp)    {    loc = tmp[0];    if(!search(file, loc))    {    TRACE_ENTER(sprintf("Location module [%s] ", loc), tmp[1]);   #ifdef MODULE_LEVEL_SECURITY    if(tmp2 = check_security(tmp[1], id, slevel))    if(intp(tmp2))    {    TRACE_LEAVE("Permission to access module denied.");
Roxen.git/server/base_server/configuration.pike:1228:    }    if(mappingp(fid))    {    TRACE_LEAVE("Returning data");    return (mapping)fid;    }    }       // Map the file extensions, but only if there is a file...    if(objectp(fid) && -  (tmp = file_extension_modules(loc = Roxen.extension(id->not_query, id), id))) { +  (tmp = file_extension_modules(loc = Roxen.extension(id->not_query, id)))) +  {    foreach(tmp, funp)    {    TRACE_ENTER(sprintf("Extension module [%s] ", loc), funp);   #ifdef MODULE_LEVEL_SECURITY    if(tmp=check_security(funp, id, slevel))    if(intp(tmp))    {    TRACE_LEAVE("Permission to access module denied.");    continue;    }
Roxen.git/server/base_server/configuration.pike:1297:    else    TRACE_LEAVE("Returning data");    return fid;   }      mixed handle_request( RequestID id )   {    function funp;    mixed file;    REQUEST_WERR("handle_request()"); -  foreach(first_module_cache||first_modules(id), funp) +  foreach(first_module_cache||first_modules(), funp)    {    if(file = funp( id ))    break;    if(id->conf != this_object()) {    REQUEST_WERR("handle_request(): Redirected (2)");    return id->conf->handle_request(id);    }    }    if(!mappingp(file) && !mappingp(file = get_file(id)))    {    mixed ret; -  foreach(last_module_cache||last_modules(id), funp) if(ret = funp(id)) break; +  foreach(last_module_cache||last_modules(), funp) if(ret = funp(id)) break;    if (ret == 1) {    REQUEST_WERR("handle_request(): Recurse");    return handle_request(id);    }    file = ret;    }    REQUEST_WERR("handle_request(): Done");    return file;   }   
Roxen.git/server/base_server/configuration.pike:1336:    id->misc->internal_get = internal_get;       mapping|int res;    mapping res2;    function tmp;    res = low_get_file(id, no_magic);       // finally map all filter type modules.    // Filter modules are like TYPE_LAST modules, but they get called    // for _all_ files. -  foreach(filter_module_cache||filter_modules(id), tmp) +  foreach(filter_module_cache||filter_modules(), tmp)    {    TRACE_ENTER("Filter module", tmp);    if(res2=tmp(res,id))    {    if(res && res->file && (res2->file != res->file))    destruct(res->file);    TRACE_LEAVE("Rewrote result.");    res=res2;    } else    TRACE_LEAVE("");
Roxen.git/server/base_server/configuration.pike:1366:    TRACE_ENTER(sprintf("List directory %O.", file), 0);       if(file[0] != '/')    file = "/" + file;      #ifdef URL_MODULES   #ifdef THREADS    object key;   #endif    // Map URL-modules -  foreach(url_modules(id), function funp) +  foreach(url_modules(), function funp)    {    string of = id->not_query;    id->not_query = file;    LOCK(funp);    TRACE_ENTER("URL module", funp);    void|mapping|object remap=funp( id, file );    UNLOCK();       if(mappingp( remap ))    {
Roxen.git/server/base_server/configuration.pike:1410: Inside #if defined(URL_MODULES)
   return dir;    }    id->not_query=of;    }   #endif /* URL_MODULES */       array(string) | mapping d;    array(string) locks=({});    object mod;    string loc; -  foreach(location_modules(id), array tmp) +  foreach(location_modules(), array tmp)    {    loc = tmp[0];    if(!search(file, loc)) {    /* file == loc + subpath */    TRACE_ENTER(sprintf("Location module [%s] ", loc), tmp[1]);   #ifdef MODULE_LEVEL_SECURITY    if(check_security(tmp[1], id)) {    TRACE_LEAVE("Permission denied");    continue;    }
Roxen.git/server/base_server/configuration.pike:1486: Inside #if defined(THREADS)
   mixed s, tmp;   #ifdef THREADS    object key;   #endif    TRACE_ENTER(sprintf("Stat file %O.", file), 0);       file=replace(file, "//", "/"); // "//" is really "/" here...      #ifdef URL_MODULES    // Map URL-modules -  foreach(url_modules(id), function funp) +  foreach(url_modules(), function funp)    {    string of = id->not_query;    id->not_query = file;       TRACE_ENTER("URL module", funp);    LOCK(funp);    tmp=funp( id, file );    UNLOCK();       if(mappingp( tmp )) {
Roxen.git/server/base_server/configuration.pike:1529: Inside #if defined(URL_MODULES)
   TRACE_LEAVE("");    TRACE_LEAVE("Returning data");    return tmp;    }    TRACE_LEAVE("");    id->not_query = of;    }   #endif       // Map location-modules. -  foreach(location_modules(id), tmp) +  foreach(location_modules(), tmp)    {    loc = tmp[0];    if((file == loc) || ((file+"/")==loc))    {    TRACE_ENTER(sprintf("Location module [%s] ", loc), tmp[1]);    TRACE_LEAVE("Exact match.");    TRACE_LEAVE("");    return ({ 0775, -3, 0, 0, 0, 0, 0 });    }    if(!search(file, loc))
Roxen.git/server/base_server/configuration.pike:1564:    }    TRACE_LEAVE("");    }    }    TRACE_LEAVE("Returned 'no such file'.");   }      // this is not as trivial as it sounds. Consider gtext. :-)   array open_file(string fname, string mode, RequestID id, void|int internal_get)   { +  if( id->conf && (id->conf != this_object()) ) +  return id->conf->open_file( fname, mode, id, internal_get ); +     object oc = id->conf;    string oq = id->not_query;    function funp;    mapping|int(0..1) file;       id->not_query = fname;    -  foreach(oc->first_modules(), funp) +  foreach(first_modules(), funp)    if(file = funp( id ))    break; -  else if(id->conf != oc) +  else if(id->conf && (id->conf != oc))    { -  return open_file(fname, mode,id, internal_get); +  return id->conf->open_file(fname, mode,id, internal_get);    }    fname = id->not_query;       if(search(mode, "R")!=-1) // raw (as in not parsed..)    {    string f;    mode -= "R";    if(f = real_file(fname, id))    {    // werror("opening "+fname+" in raw mode.\n");    return ({ open(f, mode), ([]) });    }   // return ({ 0, (["error":302]) });    }       if(mode=="r")    {    if(!file)    { -  file = oc->get_file( id, 0, internal_get ); +  file = get_file( id, 0, internal_get );    if(!file) { -  foreach(oc->last_modules(), funp) if(file = funp( id )) +  foreach(last_modules(), funp) if(file = funp( id ))    break;    if (file == 1) {    // Recurse.    return open_file(id->not_query, mode, id, internal_get);    }    }    }       if(!mappingp(file))    {
Roxen.git/server/base_server/configuration.pike:1667:       // FIXME: Should I append a "/" to file if missing?       TRACE_ENTER(sprintf("Request for directory and stat's \"%s\".", file), 0);      #ifdef URL_MODULES   #ifdef THREADS    object key;   #endif    // Map URL-modules -  foreach(url_modules(id), function funp) +  foreach(url_modules(), function funp)    {    string of = id->not_query;    id->not_query = file;    LOCK(funp);    TRACE_ENTER("URL module", funp);    tmp=funp( id, file );    UNLOCK();       if(mappingp( tmp ))    {
Roxen.git/server/base_server/configuration.pike:1718: Inside #if defined(URL_MODULES)
  #endif /* MODULE_DEBUG */    TRACE_LEAVE("Returned object.");    TRACE_LEAVE("Returning it.");    return tmp; // FIXME: Return 0 instead?    }    id->not_query=of;    TRACE_LEAVE("");    }   #endif /* URL_MODULES */    -  foreach(location_modules(id), tmp) +  foreach(location_modules(), tmp)    {    loc = tmp[0];       TRACE_ENTER(sprintf("Location module [%s] ", loc), 0);    /* Note that only new entries are added. */    if(!search(file, loc))    {    /* file == loc + subpath */   #ifdef MODULE_LEVEL_SECURITY    if(check_security(tmp[1], id)) continue;
Roxen.git/server/base_server/configuration.pike:1780:   // Access a virtual file?      array access(string file, RequestID id)   {    string loc;    array s, tmp;       file=replace(file, "//", "/"); // "//" is really "/" here...       // Map location-modules. -  foreach(location_modules(id), tmp) +  foreach(location_modules(), tmp)    {    loc = tmp[0];    if((file+"/")==loc) {   #ifdef MODULE_LEVEL_SECURITY    if(check_security(tmp[1], id)) continue;   #endif    if(s=function_object(tmp[1])->access("", id))    return s;    } else if(!search(file, loc)) {   #ifdef MODULE_LEVEL_SECURITY
Roxen.git/server/base_server/configuration.pike:1811:   //! Return the _real_ filename of a virtual file, if any.   {    string loc;    string s;    array tmp;    file=replace(file, "//", "/"); // "//" is really "/" here...       if(!id) error("No id passed to real_file");       // Map location-modules. -  foreach(location_modules(id), tmp) +  foreach(location_modules(), tmp)    {    loc = tmp[0];    if(!search(file, loc))    {   #ifdef MODULE_LEVEL_SECURITY    if(check_security(tmp[1], id)) continue;   #endif    if(s=function_object(tmp[1])->real_file(file[strlen(loc)..], id))    return s;    }