📄 mod_dav.h
字号:
#define DAV_VALIDATE_RESOURCE 0x0010 /* validate just the resource */#define DAV_VALIDATE_PARENT 0x0020 /* validate resource AND its parent */#define DAV_VALIDATE_ADD_LD 0x0040 /* add DAV:lockdiscovery into the 424 DAV:response */#define DAV_VALIDATE_USE_424 0x0080 /* return 424 status, not 207 */#define DAV_VALIDATE_IS_PARENT 0x0100 /* for internal use *//* Lock-null related public lock functions */int dav_get_resource_state(request_rec *r, const dav_resource *resource);/* Lock provider hooks. Locking is optional, so there may be no * lock provider for a given repository. */struct dav_hooks_locks{ /* Return the supportedlock property for a resource */ const char * (*get_supportedlock)( const dav_resource *resource ); /* Parse a lock token URI, returning a lock token object allocated * in the given pool. */ dav_error * (*parse_locktoken)( apr_pool_t *p, const char *char_token, dav_locktoken **locktoken_p ); /* Format a lock token object into a URI string, allocated in * the given pool. * * Always returns non-NULL. */ const char * (*format_locktoken)( apr_pool_t *p, const dav_locktoken *locktoken ); /* Compare two lock tokens. * * Result < 0 => lt1 < lt2 * Result == 0 => lt1 == lt2 * Result > 0 => lt1 > lt2 */ int (*compare_locktoken)( const dav_locktoken *lt1, const dav_locktoken *lt2 ); /* Open the provider's lock database. * * The provider may or may not use a "real" database for locks * (a lock could be an attribute on a resource, for example). * * The provider may choose to use the value of the DAVLockDB directive * (as returned by dav_get_lockdb_path()) to decide where to place * any storage it may need. * * The request storage pool should be associated with the lockdb, * so it can be used in subsequent operations. * * If ro != 0, only readonly operations will be performed. * If force == 0, the open can be "lazy"; no subsequent locking operations * may occur. * If force != 0, locking operations will definitely occur. */ dav_error * (*open_lockdb)( request_rec *r, int ro, int force, dav_lockdb **lockdb ); /* Indicates completion of locking operations */ void (*close_lockdb)( dav_lockdb *lockdb ); /* Take a resource out of the lock-null state. */ dav_error * (*remove_locknull_state)( dav_lockdb *lockdb, const dav_resource *resource ); /* ** Create a (direct) lock structure for the given resource. A locktoken ** will be created. ** ** The lock provider may store private information into lock->info. */ dav_error * (*create_lock)(dav_lockdb *lockdb, const dav_resource *resource, dav_lock **lock); /* ** Get the locks associated with the specified resource. ** ** If resolve_locks is true (non-zero), then any indirect locks are ** resolved to their actual, direct lock (i.e. the reference to followed ** to the original lock). ** ** The locks, if any, are returned as a linked list in no particular ** order. If no locks are present, then *locks will be NULL. */ dav_error * (*get_locks)(dav_lockdb *lockdb, const dav_resource *resource, int calltype, dav_lock **locks);#define DAV_GETLOCKS_RESOLVED 0 /* resolve indirects to directs */#define DAV_GETLOCKS_PARTIAL 1 /* leave indirects partially filled */#define DAV_GETLOCKS_COMPLETE 2 /* fill out indirect locks */ /* ** Find a particular lock on a resource (specified by its locktoken). ** ** *lock will be set to NULL if the lock is not found. ** ** Note that the provider can optimize the unmarshalling -- only one ** lock (or none) must be constructed and returned. ** ** If partial_ok is true (non-zero), then an indirect lock can be ** partially filled in. Otherwise, another lookup is done and the ** lock structure will be filled out as a DAV_LOCKREC_INDIRECT. */ dav_error * (*find_lock)(dav_lockdb *lockdb, const dav_resource *resource, const dav_locktoken *locktoken, int partial_ok, dav_lock **lock); /* ** Quick test to see if the resource has *any* locks on it. ** ** This is typically used to determine if a non-existent resource ** has a lock and is (therefore) a locknull resource. ** ** WARNING: this function may return TRUE even when timed-out locks ** exist (i.e. it may not perform timeout checks). */ dav_error * (*has_locks)(dav_lockdb *lockdb, const dav_resource *resource, int *locks_present); /* ** Append the specified lock(s) to the set of locks on this resource. ** ** If "make_indirect" is true (non-zero), then the specified lock(s) ** should be converted to an indirect lock (if it is a direct lock) ** before appending. Note that the conversion to an indirect lock does ** not alter the passed-in lock -- the change is internal the ** append_locks function. ** ** Multiple locks are specified using the lock->next links. */ dav_error * (*append_locks)(dav_lockdb *lockdb, const dav_resource *resource, int make_indirect, const dav_lock *lock); /* ** Remove any lock that has the specified locktoken. ** ** If locktoken == NULL, then ALL locks are removed. */ dav_error * (*remove_lock)(dav_lockdb *lockdb, const dav_resource *resource, const dav_locktoken *locktoken); /* ** Refresh all locks, found on the specified resource, which has a ** locktoken in the provided list. ** ** If the lock is indirect, then the direct lock is referenced and ** refreshed. ** ** Each lock that is updated is returned in the <locks> argument. ** Note that the locks will be fully resolved. */ dav_error * (*refresh_locks)(dav_lockdb *lockdb, const dav_resource *resource, const dav_locktoken_list *ltl, time_t new_time, dav_lock **locks); /* ** Look up the resource associated with a particular locktoken. ** ** The search begins at the specified <start_resource> and the lock ** specified by <locktoken>. ** ** If the resource/token specifies an indirect lock, then the direct ** lock will be looked up, and THAT resource will be returned. In other ** words, this function always returns the resource where a particular ** lock (token) was asserted. ** ** NOTE: this function pointer is allowed to be NULL, indicating that ** the provider does not support this type of functionality. The ** caller should then traverse up the repository hierarchy looking ** for the resource defining a lock with this locktoken. */ dav_error * (*lookup_resource)(dav_lockdb *lockdb, const dav_locktoken *locktoken, const dav_resource *start_resource, const dav_resource **resource);};/* what types of resources can be discovered by dav_get_resource_state() */#define DAV_RESOURCE_LOCK_NULL 10 /* resource lock-null */#define DAV_RESOURCE_NULL 11 /* resource null */#define DAV_RESOURCE_EXISTS 12 /* resource exists */#define DAV_RESOURCE_ERROR 13 /* an error occurred *//* --------------------------------------------------------------------**** PROPERTY HANDLING*/typedef struct dav_propdb dav_propdb;dav_error *dav_open_propdb( request_rec *r, dav_lockdb *lockdb, const dav_resource *resource, int ro, apr_array_header_t *ns_xlate, dav_propdb **propdb);void dav_close_propdb(dav_propdb *db);dav_get_props_result dav_get_props( dav_propdb *db, ap_xml_doc *doc);dav_get_props_result dav_get_allprops( dav_propdb *db, dav_prop_insert what);void dav_get_liveprop_supported( dav_propdb *propdb, const char *ns_uri, const char *propname, ap_text_header *body);/*** 3-phase property modification.**** 1) validate props. readable? unlocked? ACLs allow access?** 2) execute operation (set/delete)** 3) commit or rollback**** ### eventually, auth must be available. a ref to the request_rec (which** ### contains the auth info) should be in the shared context struct.**** Each function may alter the error values and information contained within** the context record. This should be done as an "increasing" level of** error, rather than overwriting any previous error.**** Note that commit() cannot generate errors. It should simply free the** rollback information.**** rollback() may generate additional errors because the rollback operation** can sometimes fail(!).**** The caller should allocate an array of these, one per operation. It should** be zero-initialized, then the db, operation, and prop fields should be** filled in before calling dav_prop_validate. Note that the set/delete** operations are order-dependent. For a given (logical) context, the same** pointer must be passed to each phase.**** error_type is an internal value, but will have the same numeric value** for each possible "desc" value. This allows the caller to group the** descriptions via the error_type variable, rather than through string** comparisons. Note that "status" does not provide enough granularity to** differentiate/group the "desc" values.**** Note that the propdb will maintain some (global) context across all** of the property change contexts. This implies that you can have only** one open transaction per propdb.*/typedef struct dav_prop_ctx{ dav_propdb *propdb; int operation;#define DAV_PROP_OP_SET 1 /* set a property value */#define DAV_PROP_OP_DELETE 2 /* delete a prop value *//* ### add a GET? */ ap_xml_elem *prop; /* property to affect */ dav_error *err; /* error (if any) */ /* private items to the propdb */ int is_liveprop; void *liveprop_ctx; struct dav_rollback_item *rollback; /* optional rollback info */ /* private to mod_dav.c */ request_rec *r;} dav_prop_ctx;void dav_prop_validate(dav_prop_ctx *ctx);void dav_prop_exec(dav_prop_ctx *ctx);void dav_prop_commit(dav_prop_ctx *ctx);void dav_prop_rollback(dav_prop_ctx *ctx);#define DAV_PROP_CTX_HAS_ERR(dpc) ((dpc).err && (dpc).err->status >= 300)/* --------------------------------------------------------------------**** WALKER STRUCTURE*/enum { DAV_CALLTYPE_MEMBER = 1, /* called for a member resource */ DAV_CALLTYPE_COLLECTION, /* called for a collection */ DAV_CALLTYPE_LOCKNULL /* called for a locknull resource */};typedef struct{ /* the client-provided context */ void *walk_ctx; /* pool to use for allocations in the callback */ apr_pool_t *pool; /* the current resource */ const dav_resource *resource; /* OUTPUT: add responses to this */ dav_response *response;} dav_walk_resource;typedef struct{ int walk_type;#define DAV_WALKTYPE_AUTH 0x0001 /* limit to authorized files */#define DAV_WALKTYPE_NORMAL 0x0002 /* walk normal files */#define DAV_WALKTYPE_LOCKNULL 0x0004 /* walk locknull resources */ /* callback function and a client context for the walk */ dav_error * (*func)(dav_walk_resource *wres, int calltype); void *walk_ctx; /* what pool to use for allocations needed by walk logic */ apr_pool_t *pool; /* beginning root of the walk */ const dav_resource *root; /* lock database to enable walking LOCKNULL resources */ dav_lockdb *lockdb;} dav_walk_params;/* directory tree walking context */typedef struct dav_walker_ctx{ /* input: */ dav_walk_params w; /* ### client data... phasing out this big glom */ request_rec *r; /* original request */ /* for PROPFIND operations */ ap_xml_doc *doc; int propfind_type;#define DAV_PROPFIND_IS_ALLPROP 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -