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.183 2004/05/07 19:44:58 mast Exp $ + // $Id: module.pike,v 1.184 2004/05/07 20:43:57 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:1008:   //!   //! @param path   //! Path below the filesystem location that the lock applies to.   //!   //! @param recursive   //! If @expr{1@} also check write access recursively under @[path].   //!   //! @returns   //! Returns @expr{0@} (zero) on success, a status mapping on   //! failure, or @expr{1@} if @[recursive] is set and write access is - //! allowed on this level but not somewhere recursively. The caller - //! should in the last case check recursively with @[write_access] - //! for each member in the directory. + //! allowed on this level but maybe not somewhere below. The caller + //! should in the last case do the operation on this level if + //! possible and then handle each member in the directory + //! recursively with @[write_access] etc.   mapping(string:mixed)|int(0..1) write_access(string path, int(0..1) recursive,    RequestID id)   {    SIMPLE_TRACE_ENTER(this, "write_access(%O, %O, X)", path, recursive);       int/*LockFlag*/|DAVLock lock = check_locks(path, recursive, id);       int(0..1) got_sublocks; -  if (intp(lock) && !(<LOCK_NONE, LOCK_OWN_BELOW>)[lock]) { +  if (lock && intp(lock)) {    if (lock & 1) {    TRACE_LEAVE("Locked by other user.");    return Roxen.http_status(Protocols.HTTP.DAV_LOCKED);    } -  else +  else if (recursive) +  // This is set for LOCK_OWN_BELOW too since it might be +  // necessary to come back here and check the If header for +  // those locks.    got_sublocks = 1;    }       if (!has_suffix (path, "/")) path += "/"; // get_if_data always adds a "/".    path = query_location() + path; // No need for fancy combine_path stuff here.       mapping(string:array(array(array(string)))) if_data = id->get_if_data();    array(array(array(string))) condition;    if (!if_data || !sizeof(condition = if_data[path] || if_data[0])) {    if (lock) {    TRACE_LEAVE("Locked, no if header.");    return Roxen.http_status(Protocols.HTTP.DAV_LOCKED);    } -  TRACE_LEAVE("No lock and no if header."); +  SIMPLE_TRACE_LEAVE("No lock and no if header - ok%s.", +  got_sublocks ? " (this level only)" : "");    return got_sublocks; // No condition and no lock -- Ok.    }       mapping(string:mixed) res;    next_condition:    foreach(condition, array(array(string)) sub_cond) {    SIMPLE_TRACE_ENTER(this,    "Trying condition ( %{%{%x:%O%} %})...", sub_cond);    int negate;    foreach(sub_cond, array(string) token) {
Roxen.git/server/base_server/module.pike:1071:    if ((lock && lock->locktoken == token[1]) != negate) {    // Lock mismatch.    TRACE_LEAVE("Lock mismatch.");    continue next_condition; // Fail.    }    negate = 0;    break;    }    }    TRACE_LEAVE("Found match."); -  TRACE_LEAVE("Ok."); +  SIMPLE_TRACE_LEAVE("Ok%s.", +  got_sublocks ? " (this level only)" : "");    return got_sublocks; // Found matching sub-condition.    }       TRACE_LEAVE("Failed.");    return res || Roxen.http_status(Protocols.HTTP.HTTP_PRECOND_FAILED);   }      mapping(string:mixed)|int(-1..0)|Stdio.File find_file(string path,    RequestID id);