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.197 2004/05/12 12:06:44 mast Exp $ + // $Id: module.pike,v 1.198 2004/05/12 14:31:10 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:1000:    }    else if (file_locks[path]) {    removed_lock = m_delete (file_locks[path], auth_user);    if (!sizeof (file_locks[path])) m_delete (file_locks, path);    }    ASSERT_IF_DEBUG (lock /*%O*/ == removed_lock /*%O*/, lock, removed_lock);    TRACE_LEAVE("Ok.");    return 0;   }    - //! Check if we may perform a write access to @[path]. + //! Checks that the conditions specified by the WebDAV @expr{"If"@} + //! header are fulfilled on the given path (RFC 2518 9.4). This means + //! that locks are checked as necessary using @[check_locks].   //! - //! The default implementation checks if the current locks match the - //! if-header. - //! - //! Usually called from @[find_file()], @[delete_file()] or similar. - //! - //! @note - //! Does not support checking against etags yet. - //! +    //! @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 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 relative_path, + mapping(string:mixed)|int(0..1) check_if_header(string relative_path,    int(0..1) recursive,    RequestID id)   { -  SIMPLE_TRACE_ENTER(this, "write_access(%O, %O, X)", -  relative_path, recursive); +  SIMPLE_TRACE_ENTER(this, "Checking \"If\" header for %O", +  relative_path);       int/*LockFlag*/|DAVLock lock = check_locks(relative_path, recursive, id);       int(0..1) got_sublocks;    if (lock && intp(lock)) {    if (lock & 1) {    TRACE_LEAVE("Locked by other user.");    return Roxen.http_status(Protocols.HTTP.DAV_LOCKED);    }    else if (recursive)
Roxen.git/server/base_server/module.pike:1133:    return got_sublocks; // Found matching sub-condition.    }    SIMPLE_TRACE_LEAVE("Conditional ok, but still locked (locktoken: %O).",    lock->locktoken);    }       TRACE_LEAVE("Failed.");    return res || Roxen.http_status(Protocols.HTTP.HTTP_PRECOND_FAILED);   }    + //! Used by some default implementations to check if we may perform a + //! write access to @[path]. It should at least call + //! @[check_if_header] to check DAV locks. It takes the same arguments + //! and has the same return value as that function. + //! + //! A filesystem module should typically put all needed write access + //! checks here and then use this from @[find_file()], + //! @[delete_file()] etc. + static mapping(string:mixed)|int(0..1) write_access(string relative_path, +  int(0..1) recursive, +  RequestID id) + { +  return check_if_header (relative_path, recursive, id); + } +    mapping(string:mixed)|int(-1..0)|Stdio.File find_file(string path,    RequestID id);      //! Delete the file specified by @[path].   //!   //! It's unspecified if it works recursively or not, but if it does   //! then it has to check DAV locks through @[write_access]   //! recursively.   //!   //! @returns