Roxen.git / server / base_server / module.pike

version» Context lines:

Roxen.git/server/base_server/module.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2009, Roxen IS. - // $Id: module.pike,v 1.244 2010/06/28 06:57:57 marty Exp $ + // $Id$      #include <module_constants.h>   #include <module.h>   #include <request_trace.h>      constant __pragma_save_parent__ = 1;      // Tell Pike.count_memory this is global.   constant pike_cycle_depth = 0;   
Roxen.git/server/base_server/module.pike:59:   void report_fatal(sprintf_format fmt, sprintf_args ... args)    { predef::report_fatal(fmt, @args); }   void report_error(sprintf_format fmt, sprintf_args ... args)    { predef::report_error(fmt, @args); }   void report_warning(sprintf_format fmt, sprintf_args ... args)    { predef::report_warning(fmt, @args); }   void report_notice(sprintf_format fmt, sprintf_args ... args)    { predef::report_notice(fmt, @args); }   void report_debug(sprintf_format fmt, sprintf_args ... args)    { predef::report_debug(fmt, @args); } + void report_warning_sparsely (sprintf_format fmt, sprintf_args ... args) +  {predef::report_warning_sparsely (fmt, @args);} + void report_error_sparsely (sprintf_format fmt, sprintf_args ... args) +  {predef::report_error_sparsely (fmt, @args);}      void log_event (string facility, string action, string resource,    void|mapping(string:mixed) info)   //! Log an event. See @[Configuration.log_event] for details.   //!   //! @[facility] may be zero. The local module identifier as returned   //! by @[module_local_id] is used as facility in that case.   {    _my_configuration->log_event (facility || _module_local_identifier,    action, resource, info);
Roxen.git/server/base_server/module.pike:364:    if(has_value(uri->host, "*") || has_value(uri->host, "?"))    if(glob(uri->host, hostname))    uri->host = hostname;    else {    if(!candidate_uri) {    candidate_uri = uri;    candidate_uri->host = hostname;    }    continue;    } -  return (string)uri + loc[1..]; +  uri->path += loc[1..]; +  return (string)uri;    }    if(candidate_uri) {    report_warning("Warning: Could not find any suitable ports, continuing anyway. "    "Please make sure that your Primary Server URL matches "    "at least one port. Primary Server URL: %O, URLs: %s.\n",    world_url, short_array(urls)); -  return (string)candidate_uri + loc[1..]; +  candidate_uri->path += loc[1..]; +  return (string)candidate_uri;    }    return 0;   }      /* By default, provide nothing. */   multiset(string) query_provides() { return 0; }         function(RequestID:int|mapping) query_seclevels()   {
Roxen.git/server/base_server/module.pike:477:    mapping(string:string) get_response_headers()    {    if (!response_headers) {    // Old kludge inherited from configuration.try_get_file.    if (!id->misc->common)    id->misc->common = ([]);       RequestID sub_id = id->clone_me();    sub_id->misc->common = id->misc->common;    -  sub_id->not_query = query_location() + path; -  sub_id->raw_url = replace (id->raw_url, id->not_query, sub_id->not_query); +  sub_id->raw_url = sub_id->not_query = query_location() + path; +  if ((sub_id->raw_url != id->raw_url) && (id->raw_url != id->not_query)) { +  // sub_id->raw_url = replace (id->raw_url, id->not_query, sub_id->not_query); +  sub_id->raw_url = sub_id->not_query + +  (({ "" }) + (id->raw_url/"?")[1..]) * "?"; +  }    sub_id->method = "HEAD";       mapping(string:mixed)|int(-1..0)|object res = find_file (path, sub_id);    if (res == -1) res = ([]);    else if (objectp (res)) {    string ext;    if(stringp(sub_id->extension)) {    sub_id->not_query += sub_id->extension;    ext = lower_case(Roxen.extension(sub_id->not_query, sub_id));    }
Roxen.git/server/base_server/module.pike:562:      //! RFC 2518 PROPFIND implementation with recursion according to   //! @[depth]. See @[PropertySet()->find_properties()] for details.   //!   //! @seealso   //! @[query_property_set()]   mapping(string:mixed) recurse_find_properties(string path, string mode,    int depth, RequestID id,    multiset(string)|void filt)   { +  string prefix = map(query_location()[1..]/"/", Roxen.http_encode_url)*"/";    MultiStatus.Prefixed result = -  id->get_multi_status()->prefix (id->url_base() + query_location()[1..]); +  id->get_multi_status()->prefix (id->url_base() + prefix);       mapping(string:mixed) recurse (string path, int depth) {    SIMPLE_TRACE_ENTER (this, "%s for %O, depth %d",    mode == "DAV:propname" ? "Listing property names" :    mode == "DAV:allprop" ? "Retrieving all properties" :    mode == "DAV:prop" ? "Retrieving specific properties" :    "Finding properties with mode " + mode,    path, depth);    mapping(string:mixed)|PropertySet properties = query_property_set(path, id);   
Roxen.git/server/base_server/module.pike:649:       array(mapping(string:mixed)) results;       mixed err = catch {    results = instructions->execute(properties);    };    if (err) {    properties->unroll();    throw (err);    } else { +  string prefix = map((query_location()[1..] + path)/"/", +  Roxen.http_encode_url)*"/";    MultiStatus.Prefixed result = -  id->get_multi_status()->prefix (id->url_base() + query_location()[1..] + path); +  id->get_multi_status()->prefix (id->url_base() + prefix);    int any_failed;    foreach(results, mapping(string:mixed) answer) {    if (any_failed = (answer && (answer->error >= 300))) {    break;    }    }    if (any_failed) {    // Unroll and fail any succeeded items.    int i;    mapping(string:mixed) answer =
Roxen.git/server/base_server/module.pike:1719:    "overlay");    string src_tmp = has_suffix(source, "/")?source:(source+"/");    string dst_tmp = has_suffix(destination, "/")?destination:(destination+"/");    if ((src_tmp == dst_tmp) ||    has_prefix(src_tmp, dst_tmp) ||    has_prefix(dst_tmp, src_tmp)) {    TRACE_LEAVE("Source and destination overlap.");    return Roxen.http_status(403, "Source and destination overlap.");    }    -  string loc = query_location(); +  string prefix = map(query_location()[1..]/"/", Roxen.http_encode_url)*"/";    MultiStatus.Prefixed result = -  id->get_multi_status()->prefix (id->url_base() + loc[1..]); +  id->get_multi_status()->prefix (id->url_base() + prefix);       mapping(string:mixed) recurse(string source, string destination) {    // Note: Already got an extra TRACE_ENTER level on entry here.       Stat st = stat_file(source, id);    if (!st) {    TRACE_LEAVE("Source not found.");    return 0;    }    // FIXME: Check destination?
Roxen.git/server/base_server/module.pike:1867:    // Fall back to find_file().    RequestID tmp_id = id->clone_me();    tmp_id->not_query = query_location() + source;    tmp_id->misc["new-uri"] = query_location() + destination;    tmp_id->request_headers->destination =    id->url_base() + query_location()[1..] + destination;    tmp_id->method = "MOVE";    mapping(string:mixed) res = find_file(source, tmp_id);    if (!res || res->error != 501) return res;    // Not implemented. Fall back to COPY + DELETE. +  string prefix = map(query_location()[1..]/"/", Roxen.http_encode_url)*"/";    MultiStatus.Prefixed result = -  id->get_multi_status()->prefix (id->url_base() + query_location()[1..]); +  id->get_multi_status()->prefix (id->url_base() + prefix);    res = copy_collection(source, destination, behavior, overwrite, result, id);    if (res && (res->error >= 300 || !sizeof(res))) {    // Copy failed.    return res;    }    int fail;    foreach(find_dir(source, id), string filename) {    string subsrc = combine_path_unix(source, filename);    string subdst = combine_path_unix(destination, filename);    SIMPLE_TRACE_ENTER(this, "Recursive move from %O to %O\n",
Roxen.git/server/base_server/module.pike:2023:    Stdio.File file=Stdio.File();    if(!file->open(path,"r")) return 0;    if(has_suffix(index, "()"))    index = index[..sizeof(index) - 3];       // Pass path to original file so that include statements for local files    // work correctly.    return compile_string((pre || "") + file->read(), path)[index];   }    + #if constant(roxen.FSGarbWrapper) + //! Register a filesystem path for automatic garbage collection. + //! + //! @param path + //! Path in the real filesystem to garbage collect. + //! + //! @param max_age + //! Maximum allowed age in seconds for files. + //! + //! @param max_size + //! Maximum total size in bytes for all files under the path. + //! Zero to disable the limit. + //! + //! @param max_files + //! Maximum number of files under the path. + //! Zero to disable the limit. + //! + //! @returns + //! Returns a roxen.FSGarbWrapper object. The garbage collector + //! will be removed when this object is destructed (eg via + //! refcount-garb). + roxen.FSGarbWrapper register_fsgarb(string path, int max_age, +  int|void max_size, int|void max_files) + { +  return roxen.register_fsgarb(module_identifier(), path, max_age, +  max_size, max_files); + } + #endif +    private mapping __my_tables = ([]);      array(mapping(string:mixed)) sql_query( string query, mixed ... args )   //! Do a SQL-query using @[get_my_sql], the table names in the query   //! should be written as &table; instead of table. As an example, if   //! the tables 'meta' and 'data' have been created with create_tables   //! or get_my_table, this query will work:   //!   //! SELECT &meta;.id AS id, &data;.data as DATA   //! FROM &data;, &meta; WHERE &my.meta;.xsize=200
Roxen.git/server/base_server/module.pike:2235:   //! Return a SQL-object for the database set with @[set_my_db],   //! defaulting to the 'shared' database. If @[read_only] is specified,   //! the database will be opened in read_only mode. @[charset] may be   //! used to specify a charset for the connection if the database   //! supports it.   //!   //! See also @[DBManager.get]   {    return DBManager.cached_get( my_db, _my_configuration, read_only, charset );   } +  + // Callback used by the DB browser, if defined, for custom formatting + // of database fields. + int|string format_db_browser_value (string db_name, string table_name, +  string column_name, array(string) col_names, +  array(string) col_types, array(string) row, +  RequestID id);