⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_dav_svn.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * mod_dav_svn.c: an Apache mod_dav sub-module to provide a Subversion *                repository. * * ==================================================================== * Copyright (c) 2000-2004 CollabNet.  All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution.  The terms * are also available at http://subversion.tigris.org/license-1.html. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * * This software consists of voluntary contributions made by many * individuals.  For exact contribution history, see the revision * history and logs, available at http://subversion.tigris.org/. * ==================================================================== */#include <httpd.h>#include <http_config.h>#include <http_request.h>#include <http_log.h>#include <mod_dav.h>#include <ap_provider.h>#include <apr_strings.h>#include "svn_version.h"#include "svn_fs.h"#include "svn_utf.h"#include "svn_dso.h"#include "mod_dav_svn.h"#include "dav_svn.h"#include "mod_dav_svn.h"/* This is the default "special uri" used for SVN's special resources   (e.g. working resources, activities) */#define SVN_DEFAULT_SPECIAL_URI "!svn"/* per-server configuration */typedef struct {  const char *special_uri;} dav_svn_server_conf;/* A tri-state enum used for per directory on/off flags.  Note that   it's important that DAV_SVN_FLAG_DEFAULT is 0 to make   dav_svn_merge_dir_config do the right thing. */enum dav_svn_flag {  DAV_SVN_FLAG_DEFAULT,  DAV_SVN_FLAG_ON,  DAV_SVN_FLAG_OFF};/* per-dir configuration */typedef struct {  const char *fs_path;               /* path to the SVN FS */  const char *repo_name;             /* repository name */  const char *xslt_uri;              /* XSL transform URI */  const char *fs_parent_path;        /* path to parent of SVN FS'es  */  enum dav_svn_flag autoversioning;  /* whether autoversioning is active */  enum dav_svn_flag do_path_authz;   /* whether GET subrequests are active */  enum dav_svn_flag list_parentpath; /* whether to allow GET of parentpath */} dav_svn_dir_conf;#define INHERIT_VALUE(parent, child, field) \                ((child)->field ? (child)->field : (parent)->field)/* Note: the "dav_svn" prefix is mandatory */extern module AP_MODULE_DECLARE_DATA dav_svn_module;static int dav_svn_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp,                        server_rec *s){    svn_error_t *serr;    ap_add_version_component(p, "SVN/" SVN_VER_NUMBER);    serr = svn_fs_initialize(p);    if (serr)      {        ap_log_perror(APLOG_MARK, APLOG_ERR, serr->apr_err, p,                      "dav_svn_init: error calling svn_fs_initialize: '%s'",                      serr->message ? serr->message : "(no more info)");        return HTTP_INTERNAL_SERVER_ERROR;      }    /* This returns void, so we can't check for error. */    svn_utf_initialize(p);    return OK;}static intinit_dso(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp){  /* This isn't ideal, we're not actually being called before any     pool is created, but we are being called before the server or     request pools are created, which is probably good enough for     98% of cases. */  svn_dso_initialize();  return OK;}static void *dav_svn_create_server_config(apr_pool_t *p, server_rec *s){    return apr_pcalloc(p, sizeof(dav_svn_server_conf));}static void *dav_svn_merge_server_config(apr_pool_t *p,                                         void *base, void *overrides){    dav_svn_server_conf *parent = base;    dav_svn_server_conf *child = overrides;    dav_svn_server_conf *newconf;    newconf = apr_pcalloc(p, sizeof(*newconf));    newconf->special_uri = INHERIT_VALUE(parent, child, special_uri);    return newconf;}static void *dav_svn_create_dir_config(apr_pool_t *p, char *dir){    /* NOTE: dir==NULL creates the default per-dir config */    dav_svn_dir_conf *conf = apr_pcalloc(p, sizeof(*conf));    return conf;}static void *dav_svn_merge_dir_config(apr_pool_t *p,                                      void *base, void *overrides){    dav_svn_dir_conf *parent = base;    dav_svn_dir_conf *child = overrides;    dav_svn_dir_conf *newconf;    newconf = apr_pcalloc(p, sizeof(*newconf));    newconf->fs_path = INHERIT_VALUE(parent, child, fs_path);    newconf->repo_name = INHERIT_VALUE(parent, child, repo_name);    newconf->xslt_uri = INHERIT_VALUE(parent, child, xslt_uri);    newconf->fs_parent_path = INHERIT_VALUE(parent, child, fs_parent_path);    newconf->autoversioning = INHERIT_VALUE(parent, child, autoversioning);    newconf->do_path_authz = INHERIT_VALUE(parent, child, do_path_authz);    newconf->list_parentpath = INHERIT_VALUE(parent, child, list_parentpath);    return newconf;}static const char *dav_svn_repo_name(cmd_parms *cmd, void *config,                                     const char *arg1){  dav_svn_dir_conf *conf = config;  conf->repo_name = apr_pstrdup(cmd->pool, arg1);  return NULL;}static const char *dav_svn_xslt_uri(cmd_parms *cmd, void *config,                                    const char *arg1){  dav_svn_dir_conf *conf = config;  conf->xslt_uri = apr_pstrdup(cmd->pool, arg1);  return NULL;}static const char *dav_svn_autoversioning_cmd(cmd_parms *cmd, void *config,                                              int arg){  dav_svn_dir_conf *conf = config;  if (arg)    conf->autoversioning = DAV_SVN_FLAG_ON;  else    conf->autoversioning = DAV_SVN_FLAG_OFF;  return NULL;}static const char *dav_svn_pathauthz_cmd(cmd_parms *cmd, void *config,                                         int arg){  dav_svn_dir_conf *conf = config;  if (arg)    conf->do_path_authz = DAV_SVN_FLAG_ON;  else    conf->do_path_authz = DAV_SVN_FLAG_OFF;  return NULL;}static const char *dav_svn_list_parentpath_cmd(cmd_parms *cmd, void *config,                                               int arg){  dav_svn_dir_conf *conf = config;  if (arg)    conf->list_parentpath = DAV_SVN_FLAG_ON;  else    conf->list_parentpath = DAV_SVN_FLAG_OFF;  return NULL;}static const char *dav_svn_path_cmd(cmd_parms *cmd, void *config,                                    const char *arg1){    dav_svn_dir_conf *conf = config;    if (conf->fs_parent_path != NULL)      return "SVNPath cannot be defined at same time as SVNParentPath.";    conf->fs_path      = svn_path_canonicalize(apr_pstrdup(cmd->pool, arg1), cmd->pool);    return NULL;}static const char *dav_svn_parent_path_cmd(cmd_parms *cmd, void *config,                                           const char *arg1){    dav_svn_dir_conf *conf = config;    if (conf->fs_path != NULL)      return "SVNParentPath cannot be defined at same time as SVNPath.";    conf->fs_parent_path      = svn_path_canonicalize(apr_pstrdup(cmd->pool, arg1), cmd->pool);    return NULL;}static const char *dav_svn_special_uri_cmd(cmd_parms *cmd, void *config,                                           const char *arg1){    dav_svn_server_conf *conf;    char *uri;    apr_size_t len;    uri = apr_pstrdup(cmd->pool, arg1);    /* apply a bit of processing to the thing:       - eliminate .. and . components       - eliminate double slashes       - eliminate leading and trailing slashes     */    ap_getparents(uri);    ap_no2slash(uri);    if (*uri == '/')      ++uri;    len = strlen(uri);    if (len > 0 && uri[len - 1] == '/')      uri[--len] = '\0';    if (len == 0)      return "The special URI path must have at least one component.";    conf = ap_get_module_config(cmd->server->module_config,                                &dav_svn_module);    conf->special_uri = uri;    return NULL;}/** Accessor functions for the module's configuration state **/const char *dav_svn_get_fs_path(request_rec *r){    dav_svn_dir_conf *conf;    conf = ap_get_module_config(r->per_dir_config, &dav_svn_module);    return conf->fs_path;}const char *dav_svn_get_fs_parent_path(request_rec *r){    dav_svn_dir_conf *conf;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -