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 - 2001, Roxen IS. - // $Id: module.pike,v 1.161 2004/03/23 14:40:18 mast Exp $ + // $Id: module.pike,v 1.162 2004/03/23 16:46:50 mast Exp $      #include <module_constants.h>   #include <module.h>   #include <request_trace.h>      constant __pragma_save_parent__ = 1;      inherit "basic_defvar";   mapping(string:array(int)) error_log=([]);   
Roxen.git/server/base_server/module.pike:260:   {    if(catch(query("_seclevels")) || (query("_seclevels") == 0))    return 0;    return roxen.compile_security_pattern(query("_seclevels"),this_object());   }      Stat stat_file(string f, RequestID id){}   array(string) find_dir(string f, RequestID id){}   mapping(string:Stat) find_dir_stat(string f, RequestID id)   { -  TRACE_ENTER("find_dir_stat(): \""+f+"\"", 0); +  SIMPLE_TRACE_ENTER(this, "find_dir_stat(): %O", f);       array(string) files = find_dir(f, id);    mapping(string:Stat) res = ([]);       foreach(files || ({}), string fname) { -  TRACE_ENTER("stat()'ing "+ f + "/" + fname, 0); +  SIMPLE_TRACE_ENTER(this, "stat()'ing %O", f + "/" + fname);    Stat st = stat_file(replace(f + "/" + fname, "//", "/"), id);    if (st) {    res[fname] = st;    TRACE_LEAVE("OK");    } else {    TRACE_LEAVE("No stat info");    }    }       TRACE_LEAVE("");
Roxen.git/server/base_server/module.pike:291:   //!   //! @returns   //! Returns @tt{0@} (zero) if @[path] does not exist.   //!   //! Returns an error mapping if there's some other error accessing   //! the properties.   //!   //! Otherwise returns a @[PropertySet] object.   PropertySet|mapping(string:mixed) query_properties(string path, RequestID id)   { +  SIMPLE_TRACE_ENTER (this, "Querying properties on %O", path);    Stat st = stat_file(path, id);    -  if (!st) return 0; -  return PropertySet(path, id, st); +  if (!st) { +  SIMPLE_TRACE_LEAVE ("No such file or dir"); +  return 0;    }    -  +  PropertySet res = PropertySet(path, st, id); +  SIMPLE_TRACE_LEAVE (""); +  return res; + } +    //! Returns the value of the specified property, or an error code   //! mapping.   //!   //! @param st   //! If set, this should be the stat that corresponds to @[path]. Its   //! only purpose is to save a call to @[stat_file] when the stat   //! already has been retrieved.   //!   //! @note   //! Returning a string is shorthand for returning an array
Roxen.git/server/base_server/module.pike:327:    return properties;    return properties->query_property(prop_name) ||    Roxen.http_status(Protocols.HTTP.HTTP_NOT_FOUND, "No such property.");   }      //! RFC 2518 PROPFIND implementation with recursion according to   //! @[depth]. See @[find_properties] for details.   void recurse_find_properties(string path, string mode,    int depth, MultiStatus result,    RequestID id, -  multiset(string)|void filt, -  void|Stat st) +  multiset(string)|void filt)   { -  +  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_properties(path, id);    -  if (!properties) return; // Path not found. +  if (!properties) { +  SIMPLE_TRACE_LEAVE ("No such file or dir"); +  return; +  }    -  +  {    mapping(string:mixed) ret = mappingp (properties) ?    properties : properties->find_properties(mode, result, filt);       if (ret) {    result->add_response(path, XMLStatusNode(ret->error, ret->rettext));    if (ret->rettext) {    Parser.XML.Tree.ElementNode descr =    Parser.XML.Tree.ElementNode ("DAV:responsedescription", ([]));    descr->add_child (Parser.XML.Tree.TextNode (ret->rettext));    result->add_response (path, descr);    } -  +  SIMPLE_TRACE_LEAVE ("Got status %d: %O", ret->error, ret->rettext);    return;    } -  if ((depth <= 0) || !st->isdir) return; +  } +  +  if (properties->st->isdir) { +  if (depth <= 0) { +  SIMPLE_TRACE_LEAVE ("Not recursing due to depth limit"); +  return; +  }    depth--;    foreach(find_dir(path, id) || ({}), string filename) {    recurse_find_properties(combine_path(path, filename), mode, depth,    result, id, filt);    } -  +  } +  +  SIMPLE_TRACE_LEAVE ("");    return;   }      mapping(string:mixed) patch_properties(string path,    array(PatchPropertyCommand) instructions,    MultiStatus result, RequestID id)   { -  +  SIMPLE_TRACE_ENTER (this, "Patching properties for %O", path);    mapping(string:mixed)|PropertySet properties = query_properties(path, id);    -  if (!properties) return 0; // Path not found. -  if (mappingp (properties)) return properties; +  if (!properties) { +  SIMPLE_TRACE_LEAVE ("No such file or dir"); +  return 0; +  } +  if (mappingp (properties)) { +  SIMPLE_TRACE_LEAVE ("Got error %d from query_properties: %O", +  properties->error, properties->rettext); +  return properties; +  }       mapping(string:mixed) errcode = properties->start();    -  if (errcode) return errcode; +  if (errcode) { +  SIMPLE_TRACE_LEAVE ("Got error %d from PropertySet.start: %O", +  errcode->error, errcode->rettext); +  return errcode; +  }       array(mapping(string:mixed)) results;       mixed err = catch {    results = instructions->execute(properties);    };    if (err) {    properties->unroll();    throw (err);    } else {
Roxen.git/server/base_server/module.pike:409:    } else {    int i;    for(i = 0; i < sizeof(results); i++) {    result->add_property(path, instructions[i]->property_name,    results[i]);    }    properties->commit();    }    }    +  SIMPLE_TRACE_LEAVE ("");    return 0;   }      //! Convenience variant of @[patch_properties()] that sets a single   //! property.   //!   //! @returns   //! Returns a mapping on any error, zero otherwise.   mapping(string:mixed) set_property (string path, string prop_name,    string|array(Parser.XML.Tree.Node) value,