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.170 2004/05/03 19:41:57 mast Exp $ + // $Id: module.pike,v 1.171 2004/05/04 12:35:13 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:574:   //! Only used internally by the default lock implementation.   static mapping(string:mapping(string:DAVLock)) prefix_locks = ([]);      //! Find some or all locks that apply to @[path].   //!   //! @param path   //! Canonical path relative to the filesystem root. Always ends with   //! a @expr{"/"@}.   //!   //! @param recursive - //! If @expr{1@} also return all locks under @[path]. + //! If @expr{1@} also return locks under @[path].   //!   //! @param exclude_shared   //! If @expr{1@} do not return shared locks that are held by users   //! other than the one the request is authenticated as. (This is   //! appropriate to get the list of locks that would conflict if the   //! current user were to make a shared lock.)   //!   //! @returns   //! Returns a multiset containing all applicable locks in   //! this location module, or @expr{0@} (zero) if there are none.
Roxen.git/server/base_server/module.pike:659:   //!   //! @param recursive   //! If @expr{1@} also check recursively under @[path] for locks.   //!   //! @returns   //! @mixed   //! @type DAVLock   //! Returns the lock owned by the authenticated user that apply   //! to @[path]. (It doesn't matter if the @expr{recursive@} flag   //! in the lock doesn't match the @[recursive] argument.) - //! @type int(-2..1) + //! @type int(0..3)   //! @int - //! @value -2 - //! Returns @expr{-2@} if there are one or more exclusive + //! @value 0 + //! Returns @expr{0@} if no locks apply. + //! @value 1 + //! Returns @expr{1@} if there only are one or more shared   //! locks held by other users. - //! @value -1 - //! Returns @expr{-1@} if @[recursive] is set, the + //! @value 2 + //! Returns @expr{2@} if @[recursive] is set, the   //! authenticated user has locks under @[path] (but not on   //! @[path] itself), and there are no exclusive locks held   //! by other users. - //! @value 0 - //! Returns @expr{0@} if no locks apply. - //! @value 1 - //! Returns @expr{1@} if there are one or more shared locks - //! held by other users only. + //! @value 3 + //! Returns @expr{3@} if there are one or more exclusive + //! locks held by other users.   //! @endint   //! @endmixed   //!   //! @note   //! @[DAVLock] objects may be created if the filesystem has some   //! persistent storage of them. The default implementation does not   //! store locks persistently.   //!   //! @note   //! The default implementation only handles the @expr{"DAV:write"@}   //! lock type. - DAVLock|int(-2..1) check_locks(string path, + DAVLock|int(0..3) check_locks(string path,    int(0..1) recursive,    RequestID id)   {    // Common case.    if (!sizeof(file_locks) && !sizeof(prefix_locks)) return 0;       User uid = id->conf->authenticate (id);    string auth_user = uid && uid->name();       if (DAVLock lock =    file_locks[path] && file_locks[path][auth_user] ||    prefix_locks[path] && prefix_locks[path][auth_user])    return lock;       int(0..1) shared;       if (mapping(string:DAVLock) locks = file_locks[path]) {    foreach(locks;; DAVLock lock) { -  if (lock->lockscope == "DAV:exclusive") return -2; +  if (lock->lockscope == "DAV:exclusive") return 3;    shared = 1;    break;    }    }       foreach(prefix_locks;    string prefix; mapping(string:DAVLock) locks) {    if (has_prefix(path, prefix)) {    if (DAVLock lock = locks[auth_user]) return lock;    if (!shared)    // If we've found a shared lock then we won't find an    // exclusive one higher up.    foreach(locks;; DAVLock lock) { -  if (lock->lockscope == "DAV:exclusive") return -2; +  if (lock->lockscope == "DAV:exclusive") return 3;    shared = 1;    break;    }    }    }       if (!recursive) return shared;       int(0..1) locked_by_auth_user;       // We want to know if there are any locks with @[path] as prefix    // that apply to us.    foreach(file_locks|prefix_locks;    string prefix; mapping(string:DAVLock) locks) {    if (has_prefix(prefix, path)) {    if (locks[auth_user])    locked_by_auth_user = 1;    else    foreach(locks;; DAVLock lock) { -  if (lock->lockscope == "DAV:exclusive") return -2; +  if (lock->lockscope == "DAV:exclusive") return 3;    shared = 1;    break;    }    }    }    -  return locked_by_auth_user ? -1 : shared; +  return locked_by_auth_user ? 2 : shared;   }      //! Lock the resource at @[path] with the given @[lock]. It's already   //! checked that no other lock that applies, i.e. a call   //! @code{check_locks(path,lock->recursive,id)@} would return   //! @expr{0@} or @expr{1@}.   //!   //! The implementation must at least support the @expr{"DAV:write"@}   //! lock type (RFC 2518, section 7). Briefly: An exclusive lock on a   //! file prohibits other users from changing its content. An exclusive