📄 mod_dav.h
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. *//*** DAV extension module for Apache 2.0.**/#ifndef _MOD_DAV_H_#define _MOD_DAV_H_#include "apr_hooks.h"#include "apr_hash.h"#include "apr_dbm.h"#include "apr_tables.h"#include "httpd.h"#include "util_xml.h"#include <limits.h> /* for INT_MAX */#ifdef __cplusplusextern "C" {#endif#define DAV_VERSION AP_SERVER_BASEREVISION#define DAV_XML_HEADER "<?xml version=\"1.0\" encoding=\"utf-8\"?>"#define DAV_XML_CONTENT_TYPE "text/xml; charset=\"utf-8\""#define DAV_READ_BLOCKSIZE 2048 /* used for reading input blocks */#define DAV_RESPONSE_BODY_1 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<HTML><HEAD>\n<TITLE>"#define DAV_RESPONSE_BODY_2 "</TITLE>\n</HEAD><BODY>\n<H1>"#define DAV_RESPONSE_BODY_3 "</H1>\n"#define DAV_RESPONSE_BODY_4 "</BODY></HTML>\n"#define DAV_DO_COPY 0#define DAV_DO_MOVE 1#if 1#define DAV_DEBUG 1#define DEBUG_CR "\n"#define DBG0(f) ap_log_error(APLOG_MARK, \ APLOG_ERR|APLOG_NOERRNO, 0, NULL, (f))#define DBG1(f,a1) ap_log_error(APLOG_MARK, \ APLOG_ERR|APLOG_NOERRNO, 0, NULL, f, a1)#define DBG2(f,a1,a2) ap_log_error(APLOG_MARK, \ APLOG_ERR|APLOG_NOERRNO, 0, NULL, f, a1, a2)#define DBG3(f,a1,a2,a3) ap_log_error(APLOG_MARK, \ APLOG_ERR|APLOG_NOERRNO, 0, NULL, f, a1, a2, a3)#else#undef DAV_DEBUG#define DEBUG_CR ""#endif#define DAV_INFINITY INT_MAX /* for the Depth: header *//* Create a set of DAV_DECLARE(type), DAV_DECLARE_NONSTD(type) and * DAV_DECLARE_DATA with appropriate export and import tags for the platform */#if !defined(WIN32)#define DAV_DECLARE(type) type#define DAV_DECLARE_NONSTD(type) type#define DAV_DECLARE_DATA#elif defined(DAV_DECLARE_STATIC)#define DAV_DECLARE(type) type __stdcall#define DAV_DECLARE_NONSTD(type) type#define DAV_DECLARE_DATA#elif defined(DAV_DECLARE_EXPORT)#define DAV_DECLARE(type) __declspec(dllexport) type __stdcall#define DAV_DECLARE_NONSTD(type) __declspec(dllexport) type#define DAV_DECLARE_DATA __declspec(dllexport)#else#define DAV_DECLARE(type) __declspec(dllimport) type __stdcall#define DAV_DECLARE_NONSTD(type) __declspec(dllimport) type#define DAV_DECLARE_DATA __declspec(dllimport)#endif/* --------------------------------------------------------------------**** ERROR MANAGEMENT*//*** dav_error structure.**** In most cases, mod_dav uses a pointer to a dav_error structure. If the** pointer is NULL, then no error has occurred.**** In certain cases, a dav_error structure is directly used. In these cases,** a status value of 0 means that an error has not occurred.**** Note: this implies that status != 0 whenever an error occurs.**** The desc field is optional (it may be NULL). When NULL, it typically** implies that Apache has a proper description for the specified status.*/typedef struct dav_error { int status; /* suggested HTTP status (0 for no error) */ int error_id; /* DAV-specific error ID */ const char *desc; /* DAV:responsedescription and error log */ int save_errno; /* copy of errno causing the error */ struct dav_error *prev; /* previous error (in stack) */ /* deferred computation of the description */ void (*compute_desc)(struct dav_error *err, apr_pool_t *p); int ctx_i; const char *ctx_s; void *ctx_p;} dav_error;/*** Create a new error structure. save_errno will be filled with the current** errno value.*/DAV_DECLARE(dav_error*) dav_new_error(apr_pool_t *p, int status, int error_id, const char *desc);/*** Push a new error description onto the stack of errors.**** This function is used to provide an additional description to an existing** error.**** <status> should contain the caller's view of what the current status is,** given the underlying error. If it doesn't have a better idea, then the** caller should pass prev->status.**** <error_id> can specify a new error_id since the topmost description has** changed.*/DAV_DECLARE(dav_error*) dav_push_error(apr_pool_t *p, int status, int error_id, const char *desc, dav_error *prev);/* error ID values... *//* IF: header errors */#define DAV_ERR_IF_PARSE 100 /* general parsing error */#define DAV_ERR_IF_MULTIPLE_NOT 101 /* multiple "Not" found */#define DAV_ERR_IF_UNK_CHAR 102 /* unknown char in header */#define DAV_ERR_IF_ABSENT 103 /* no locktokens given */#define DAV_ERR_IF_TAGGED 104 /* in parsing tagged-list */#define DAV_ERR_IF_UNCLOSED_PAREN 105 /* in no-tagged-list *//* Prop DB errors */#define DAV_ERR_PROP_BAD_MAJOR 200 /* major version was wrong */#define DAV_ERR_PROP_READONLY 201 /* prop is read-only */#define DAV_ERR_PROP_NO_DATABASE 202 /* writable db not avail */#define DAV_ERR_PROP_NOT_FOUND 203 /* prop not found */#define DAV_ERR_PROP_BAD_LOCKDB 204 /* could not open lockdb */#define DAV_ERR_PROP_OPENING 205 /* problem opening propdb */#define DAV_ERR_PROP_EXEC 206 /* problem exec'ing patch *//* Predefined DB errors *//* ### any to define?? *//* Predefined locking system errors */#define DAV_ERR_LOCK_OPENDB 400 /* could not open lockdb */#define DAV_ERR_LOCK_NO_DB 401 /* no database defined */#define DAV_ERR_LOCK_CORRUPT_DB 402 /* DB is corrupt */#define DAV_ERR_LOCK_UNK_STATE_TOKEN 403 /* unknown State-token */#define DAV_ERR_LOCK_PARSE_TOKEN 404 /* bad opaquelocktoken */#define DAV_ERR_LOCK_SAVE_LOCK 405 /* err saving locks *//*** Some comments on Error ID values:**** The numbers do not necessarily need to be unique. Uniqueness simply means** that two errors that have not been predefined above can be distinguished** from each other. At the moment, mod_dav does not use this distinguishing** feature, but it could be used in the future to collapse <response> elements** into groups based on the error ID (and associated responsedescription).**** If a compute_desc is provided, then the error ID should be unique within** the context of the compute_desc function (so the function can figure out** what to filled into the desc).**** Basically, subsystems can ignore defining new error ID values if they want** to. The subsystems *do* need to return the predefined errors when** appropriate, so that mod_dav can figure out what to do. Subsystems can** simply leave the error ID field unfilled (zero) if there isn't an error** that must be placed there.*//* --------------------------------------------------------------------**** HOOK STRUCTURES**** These are here for forward-declaration purposes. For more info, see** the section title "HOOK HANDLING" for more information, plus each** structure definition.*//* forward-declare this structure */typedef struct dav_hooks_propdb dav_hooks_propdb;typedef struct dav_hooks_locks dav_hooks_locks;typedef struct dav_hooks_vsn dav_hooks_vsn;typedef struct dav_hooks_repository dav_hooks_repository;typedef struct dav_hooks_liveprop dav_hooks_liveprop;typedef struct dav_hooks_binding dav_hooks_binding;/* ### deprecated name */typedef dav_hooks_propdb dav_hooks_db;/* --------------------------------------------------------------------**** RESOURCE HANDLING*//*** Resource Types:** The base protocol defines only file and collection resources.** The versioning protocol defines several additional resource types** to represent artifacts of a version control system.**** This enumeration identifies the type of URL used to identify the** resource. Since the same resource may have more than one type of** URL which can identify it, dav_resource_type cannot be used** alone to determine the type of the resource; attributes of the** dav_resource object must also be consulted.*/typedef enum { DAV_RESOURCE_TYPE_UNKNOWN, DAV_RESOURCE_TYPE_REGULAR, /* file or collection; could be * unversioned, or version selector, * or baseline selector */ DAV_RESOURCE_TYPE_VERSION, /* version or baseline URL */ DAV_RESOURCE_TYPE_HISTORY, /* version or baseline history URL */ DAV_RESOURCE_TYPE_WORKING, /* working resource URL */ DAV_RESOURCE_TYPE_WORKSPACE, /* workspace URL */ DAV_RESOURCE_TYPE_ACTIVITY, /* activity URL */ DAV_RESOURCE_TYPE_PRIVATE /* repository-private type */} dav_resource_type;/*** Opaque, repository-specific information for a resource.*/typedef struct dav_resource_private dav_resource_private;/*** Resource descriptor, generated by a repository provider.**** Note: the lock-null state is not explicitly represented here,** since it may be expensive to compute. Use dav_get_resource_state()** to determine whether a non-existent resource is a lock-null resource.**** A quick explanation of how the flags can apply to different resources:**** unversioned file or collection:** type = DAV_RESOURCE_TYPE_REGULAR** exists = ? (1 if exists)** collection = ? (1 if collection)** versioned = 0** baselined = 0** working = 0**** version/baseline selector:** type = DAV_RESOURCE_TYPE_REGULAR** exists = 1** collection = ? (1 if collection)** versioned = 1** baselined = ? (1 if baseline selector)** working = ? (1 if checked out)**** version/baseline history:** type = DAV_RESOURCE_TYPE_HISTORY** exists = 1** collection = 0** versioned = 0** baselined = 0** working = 0**** version/baseline:** type = DAV_RESOURCE_TYPE_VERSION** exists = 1** collection = ? (1 if collection)** versioned = 1** baselined = ? (1 if baseline)** working = 0**** working resource:** type = DAV_RESOURCE_TYPE_WORKING** exists = 1** collection = ? (1 if collection)** versioned = 1** baselined = 0** working = 1**** workspace:** type = DAV_RESOURCE_TYPE_WORKSPACE** exists = ? (1 if exists)** collection = 1** versioned = * (jvasta: I'm seeking clarification on whether a** baselined = * workspace can be versioned or baselined)** working = ***** activity:** type = DAV_RESOURCE_TYPE_ACTIVITY** exists = ? (1 if exists)** collection = 0** versioned = 0** baselined = 0** working = 0*/typedef struct dav_resource { dav_resource_type type; int exists; /* 0 => null resource */ int collection; /* 0 => file; can be 1 for * REGULAR, VERSION, and WORKING resources,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -