📄 mod_dav_svn.c
字号:
conf = ap_get_module_config(r->per_dir_config, &dav_svn_module); return conf->fs_parent_path;}AP_MODULE_DECLARE(dav_error *) dav_svn_get_repos_path(request_rec *r, const char *root_path, const char **repos_path){ const char *fs_path; const char *fs_parent_path; const char *repos_name; const char *ignored_path_in_repos; const char *ignored_cleaned_uri; const char *ignored_relative; int ignored_had_slash; dav_error *derr; /* Handle the SVNPath case. */ fs_path = dav_svn_get_fs_path(r); if (fs_path != NULL) { *repos_path = fs_path; return NULL; } /* Handle the SVNParentPath case. If neither directive was used, dav_svn_split_uri will throw a suitable error for us - we do not need to check that here. */ fs_parent_path = dav_svn_get_fs_parent_path(r); /* Split the svn URI to get the name of the repository below the parent path. */ derr = dav_svn_split_uri(r, r->uri, root_path, &ignored_cleaned_uri, &ignored_had_slash, &repos_name, &ignored_relative, &ignored_path_in_repos); if (derr) return derr; /* Construct the full path from the parent path base directory and the repository name. */ *repos_path = svn_path_join(fs_parent_path, repos_name, r->pool); return NULL;}const char *dav_svn_get_repo_name(request_rec *r){ dav_svn_dir_conf *conf; conf = ap_get_module_config(r->per_dir_config, &dav_svn_module); return conf->repo_name;}const char *dav_svn_get_xslt_uri(request_rec *r){ dav_svn_dir_conf *conf; conf = ap_get_module_config(r->per_dir_config, &dav_svn_module); return conf->xslt_uri;}const char *dav_svn_get_special_uri(request_rec *r){ dav_svn_server_conf *conf; conf = ap_get_module_config(r->server->module_config, &dav_svn_module); return conf->special_uri ? conf->special_uri : SVN_DEFAULT_SPECIAL_URI;}svn_boolean_t dav_svn_get_autoversioning_flag(request_rec *r){ dav_svn_dir_conf *conf; conf = ap_get_module_config(r->per_dir_config, &dav_svn_module); return conf->autoversioning == DAV_SVN_FLAG_ON;}svn_boolean_t dav_svn_get_pathauthz_flag(request_rec *r){ dav_svn_dir_conf *conf; conf = ap_get_module_config(r->per_dir_config, &dav_svn_module); return conf->do_path_authz != DAV_SVN_FLAG_OFF;}svn_boolean_t dav_svn_get_list_parentpath_flag(request_rec *r){ dav_svn_dir_conf *conf; conf = ap_get_module_config(r->per_dir_config, &dav_svn_module); return conf->list_parentpath == DAV_SVN_FLAG_ON;}static void merge_xml_filter_insert(request_rec *r){ /* We only care about MERGE and DELETE requests. */ if ((r->method_number == M_MERGE) || (r->method_number == M_DELETE)) { dav_svn_dir_conf *conf; conf = ap_get_module_config(r->per_dir_config, &dav_svn_module); /* We only care if we are configured. */ if (conf->fs_path || conf->fs_parent_path) { ap_add_input_filter("SVN-MERGE", NULL, r, r->connection); } }}typedef struct { apr_bucket_brigade *bb; apr_xml_parser *parser; apr_pool_t *pool;} merge_ctx_t;static apr_status_t merge_xml_in_filter(ap_filter_t *f, apr_bucket_brigade *bb, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes){ apr_status_t rv; request_rec *r = f->r; merge_ctx_t *ctx = f->ctx; apr_bucket *bucket; int seen_eos = 0; /* We shouldn't be added if we're not a MERGE/DELETE, but double check. */ if ((r->method_number != M_MERGE) && (r->method_number != M_DELETE)) { ap_remove_input_filter(f); return ap_get_brigade(f->next, bb, mode, block, readbytes); } if (!ctx) { f->ctx = ctx = apr_palloc(r->pool, sizeof(*ctx)); ctx->parser = apr_xml_parser_create(r->pool); ctx->bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); apr_pool_create(&ctx->pool, r->pool); } rv = ap_get_brigade(f->next, ctx->bb, mode, block, readbytes); if (rv != APR_SUCCESS) { return rv; } for (bucket = APR_BRIGADE_FIRST(ctx->bb); bucket != APR_BRIGADE_SENTINEL(ctx->bb); bucket = APR_BUCKET_NEXT(bucket)) { const char *data; apr_size_t len; if (APR_BUCKET_IS_EOS(bucket)) { seen_eos = 1; break; } if (APR_BUCKET_IS_METADATA(bucket)) { continue; } rv = apr_bucket_read(bucket, &data, &len, APR_BLOCK_READ); if (rv != APR_SUCCESS) { return rv; } rv = apr_xml_parser_feed(ctx->parser, data, len); if (rv != APR_SUCCESS) { /* Clean up the parser. */ (void) apr_xml_parser_done(ctx->parser, NULL); break; } } /* This will clear-out the ctx->bb as well. */ APR_BRIGADE_CONCAT(bb, ctx->bb); if (seen_eos) { apr_xml_doc *pdoc; /* Remove ourselves now. */ ap_remove_input_filter(f); /* tell the parser that we're done */ rv = apr_xml_parser_done(ctx->parser, &pdoc); if (rv == APR_SUCCESS) {#if APR_CHARSET_EBCDIC apr_xml_parser_convert_doc(r->pool, pdoc, ap_hdrs_from_ascii);#endif /* stash the doc away for mod_dav_svn's later use. */ rv = apr_pool_userdata_set(pdoc, "svn-request-body", NULL, r->pool); if (rv != APR_SUCCESS) { return rv; } } } return APR_SUCCESS;}/** Module framework stuff **/static const command_rec dav_svn_cmds[] ={ /* per directory/location */ AP_INIT_TAKE1("SVNPath", dav_svn_path_cmd, NULL, ACCESS_CONF, "specifies the location in the filesystem for a Subversion " "repository's files."), /* per server */ AP_INIT_TAKE1("SVNSpecialURI", dav_svn_special_uri_cmd, NULL, RSRC_CONF, "specify the URI component for special Subversion " "resources"), /* per directory/location */ AP_INIT_TAKE1("SVNReposName", dav_svn_repo_name, NULL, ACCESS_CONF, "specify the name of a Subversion repository"), /* per directory/location */ AP_INIT_TAKE1("SVNIndexXSLT", dav_svn_xslt_uri, NULL, ACCESS_CONF, "specify the URI of an XSL transformation for " "directory indexes"), /* per directory/location */ AP_INIT_TAKE1("SVNParentPath", dav_svn_parent_path_cmd, NULL, ACCESS_CONF, "specifies the location in the filesystem whose " "subdirectories are assumed to be Subversion repositories."), /* per directory/location */ AP_INIT_FLAG("SVNAutoversioning", dav_svn_autoversioning_cmd, NULL, ACCESS_CONF|RSRC_CONF, "turn on deltaV autoversioning."), /* per directory/location */ AP_INIT_FLAG("SVNPathAuthz", dav_svn_pathauthz_cmd, NULL, ACCESS_CONF|RSRC_CONF, "control path-based authz by enabling/disabling subrequests"), /* per directory/location */ AP_INIT_FLAG("SVNListParentPath", dav_svn_list_parentpath_cmd, NULL, ACCESS_CONF|RSRC_CONF, "allow GET of SVNParentPath."), { NULL }};static dav_provider dav_svn_provider ={ &dav_svn_hooks_repos, &dav_svn_hooks_propdb, &dav_svn_hooks_locks, &dav_svn_hooks_vsn, NULL, /* binding */ NULL /* search */};static void register_hooks(apr_pool_t *pconf){ ap_hook_pre_config(init_dso, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_post_config(dav_svn_init, NULL, NULL, APR_HOOK_MIDDLE); /* our provider */ dav_register_provider(pconf, "svn", &dav_svn_provider); /* input filter to read MERGE bodies. */ ap_register_input_filter("SVN-MERGE", merge_xml_in_filter, NULL, AP_FTYPE_RESOURCE); ap_hook_insert_filter(merge_xml_filter_insert, NULL, NULL, APR_HOOK_MIDDLE); /* live property handling */ dav_hook_gather_propsets(dav_svn_gather_propsets, NULL, NULL, APR_HOOK_MIDDLE); dav_hook_find_liveprop(dav_svn_find_liveprop, NULL, NULL, APR_HOOK_MIDDLE); dav_hook_insert_all_liveprops(dav_svn_insert_all_liveprops, NULL, NULL, APR_HOOK_MIDDLE); dav_svn_register_uris(pconf);}module AP_MODULE_DECLARE_DATA dav_svn_module ={ STANDARD20_MODULE_STUFF, dav_svn_create_dir_config, /* dir config creater */ dav_svn_merge_dir_config, /* dir merger --- default is to override */ dav_svn_create_server_config, /* server config */ dav_svn_merge_server_config, /* merge server config */ dav_svn_cmds, /* command table */ register_hooks, /* register hooks */};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -