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

📄 main.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* * main.c: Subversion server administration tool. * * ==================================================================== * Copyright (c) 2000-2006 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 <apr_file_io.h>#include <apr_signal.h>#include "svn_pools.h"#include "svn_cmdline.h"#include "svn_error.h"#include "svn_opt.h"#include "svn_utf.h"#include "svn_subst.h"#include "svn_path.h"#include "svn_config.h"#include "svn_repos.h"#include "svn_fs.h"#include "svn_version.h"#include "svn_props.h"#include "svn_time.h"#include "svn_user.h"#include "svn_private_config.h"/*** Code. ***//* A flag to see if we've been cancelled by the client or not. */static volatile sig_atomic_t cancelled = FALSE;/* A signal handler to support cancellation. */static voidsignal_handler(int signum){  apr_signal(signum, SIG_IGN);  cancelled = TRUE;}/* A helper to set up the cancellation signal handlers. */static voidsetup_cancellation_signals(void (*handler)(int signum)){  apr_signal(SIGINT, handler);#ifdef SIGBREAK  /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */  apr_signal(SIGBREAK, handler);#endif#ifdef SIGHUP  apr_signal(SIGHUP, handler);#endif#ifdef SIGTERM  apr_signal(SIGTERM, handler);#endif}/* Our cancellation callback. */static svn_error_t *check_cancel(void *baton){  if (cancelled)    return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));  else    return SVN_NO_ERROR;}/* Helper to open stdio streams */static svn_error_t *create_stdio_stream(svn_stream_t **stream,                    APR_DECLARE(apr_status_t) open_fn(apr_file_t **,                                                       apr_pool_t *),                    apr_pool_t *pool){  apr_file_t *stdio_file;  apr_status_t apr_err = open_fn(&stdio_file, pool);    if (apr_err)    return svn_error_wrap_apr(apr_err, _("Can't open stdio file"));    *stream = svn_stream_from_aprfile(stdio_file, pool);  return SVN_NO_ERROR;   }/* Helper to parse local repository path.  Try parsing next parameter * of OS as a local path to repository.  If successfull *REPOS_PATH * will contain internal style path to the repository. */static svn_error_t *parse_local_repos_path(apr_getopt_t *os,                        const char ** repos_path,                        apr_pool_t *pool){  *repos_path = NULL;  /* Check to see if there is one more parameter. */  if (os->ind < os->argc)    {      const char * path = os->argv[os->ind++];      SVN_ERR(svn_utf_cstring_to_utf8(repos_path, path, pool));      *repos_path = svn_path_internal_style(*repos_path, pool);    }  if (*repos_path == NULL)    {      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,                               _("Repository argument required"));    }  else if (svn_path_is_url(*repos_path))    {      return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,                               _("'%s' is an URL when it should be a path"),                               *repos_path);    }  return SVN_NO_ERROR;   }/* Custom filesystem warning function. */static voidwarning_func(void *baton,              svn_error_t *err){  if (! err)    return;  svn_handle_error2(err, stderr, FALSE, "svnadmin: ");}/* Helper to open a repository and set a warning func (so we don't * SEGFAULT when libsvn_fs's default handler gets run).  */static svn_error_t *open_repos(svn_repos_t **repos,           const char *path,           apr_pool_t *pool){  SVN_ERR(svn_repos_open(repos, path, pool));  svn_fs_set_warning_func(svn_repos_fs(*repos), warning_func, NULL);  return SVN_NO_ERROR;}/* Version compatibility check */static svn_error_t *check_lib_versions(void){  static const svn_version_checklist_t checklist[] =    {      { "svn_subr",  svn_subr_version },      { "svn_repos", svn_repos_version },      { "svn_fs",    svn_fs_version },      { "svn_delta", svn_delta_version },      { NULL, NULL }    };  SVN_VERSION_DEFINE(my_version);  return svn_ver_check_list(&my_version, checklist);}/** Subcommands. **/static svn_opt_subcommand_t  subcommand_crashtest,  subcommand_create,  subcommand_deltify,  subcommand_dump,  subcommand_help,  subcommand_hotcopy,  subcommand_load,  subcommand_list_dblogs,  subcommand_list_unused_dblogs,  subcommand_lslocks,  subcommand_lstxns,  subcommand_recover,  subcommand_rmlocks,  subcommand_rmtxns,  subcommand_setlog,  subcommand_verify;enum   {     svnadmin__version = SVN_OPT_FIRST_LONGOPT_ID,    svnadmin__incremental,    svnadmin__deltas,    svnadmin__ignore_uuid,    svnadmin__force_uuid,    svnadmin__fs_type,    svnadmin__parent_dir,    svnadmin__bdb_txn_nosync,    svnadmin__bdb_log_keep,    svnadmin__config_dir,    svnadmin__bypass_hooks,    svnadmin__use_pre_commit_hook,    svnadmin__use_post_commit_hook,    svnadmin__clean_logs,    svnadmin__wait,    svnadmin__pre_1_4_compatible  };/* Option codes and descriptions. * * The entire list must be terminated with an entry of nulls. */static const apr_getopt_option_t options_table[] =  {    {"help",          'h', 0,     N_("show help on a subcommand")},    {NULL,            '?', 0,     N_("show help on a subcommand")},    {"version",       svnadmin__version, 0,     N_("show program version information")},    {"revision",      'r', 1,     N_("specify revision number ARG (or X:Y range)")},    {"incremental",   svnadmin__incremental, 0,     N_("dump incrementally")},    {"deltas",        svnadmin__deltas, 0,     N_("use deltas in dump output")},    {"bypass-hooks",  svnadmin__bypass_hooks, 0,     N_("bypass the repository hook system")},    {"quiet",         'q', 0,     N_("no progress (only errors) to stderr")},    {"ignore-uuid",   svnadmin__ignore_uuid, 0,     N_("ignore any repos UUID found in the stream")},    {"force-uuid",    svnadmin__force_uuid, 0,     N_("set repos UUID to that found in stream, if any")},    {"fs-type",       svnadmin__fs_type, 1,     N_("type of repository: 'fsfs' (default) or 'bdb'")},    {"parent-dir",    svnadmin__parent_dir, 1,     N_("load at specified directory in repository")},    {"bdb-txn-nosync", svnadmin__bdb_txn_nosync, 0,     N_("disable fsync at transaction commit [Berkeley DB]")},    {"bdb-log-keep",  svnadmin__bdb_log_keep, 0,     N_("disable automatic log file removal [Berkeley DB]")},    {"config-dir",    svnadmin__config_dir, 1,     N_("read user configuration files from directory ARG")},    {"clean-logs",    svnadmin__clean_logs, 0,     N_("remove redundant Berkeley DB log files\n"        "                             from source repository [Berkeley DB]")},    {"use-pre-commit-hook", svnadmin__use_pre_commit_hook, 0,     N_("call pre-commit hook before committing revisions")},    {"use-post-commit-hook", svnadmin__use_post_commit_hook, 0,     N_("call post-commit hook after committing revisions")},    {"wait",          svnadmin__wait, 0,     N_("wait instead of exit if the repository is in\n"        "                             use by another process")},    {"pre-1.4-compatible",     svnadmin__pre_1_4_compatible, 0,     N_("use format compatible with Subversion versions\n"        "                             earlier than 1.4")},    {NULL}  };/* Array of available subcommands. * The entire list must be terminated with an entry of nulls. */static const svn_opt_subcommand_desc_t cmd_table[] ={  {"crashtest", subcommand_crashtest, {0}, N_   ("usage: svnadmin crashtest REPOS_PATH\n\n"    "Open the repository at REPOS_PATH, then abort, thus simulating\n"    "a process that crashes while holding an open repository handle.\n"),   {0} },  {"create", subcommand_create, {0}, N_   ("usage: svnadmin create REPOS_PATH\n\n"    "Create a new, empty repository at REPOS_PATH.\n"),   {svnadmin__bdb_txn_nosync, svnadmin__bdb_log_keep,    svnadmin__config_dir, svnadmin__fs_type, svnadmin__pre_1_4_compatible} },  {"deltify", subcommand_deltify, {0}, N_   ("usage: svnadmin deltify [-r LOWER[:UPPER]] REPOS_PATH\n\n"    "Run over the requested revision range, performing predecessor delti-\n"    "fication on the paths changed in those revisions.  Deltification in\n"    "essence compresses the repository by only storing the differences or\n"    "delta from the preceding revision.  If no revisions are specified,\n"    "this will simply deltify the HEAD revision.\n"),   {'r', 'q'} },  {"dump", subcommand_dump, {0}, N_   ("usage: svnadmin dump REPOS_PATH [-r LOWER[:UPPER]] [--incremental]\n\n"    "Dump the contents of filesystem to stdout in a 'dumpfile'\n"    "portable format, sending feedback to stderr.  Dump revisions\n"    "LOWER rev through UPPER rev.  If no revisions are given, dump all\n"    "revision trees.  If only LOWER is given, dump that one revision tree.\n"    "If --incremental is passed, then the first revision dumped will be\n"    "a diff against the previous revision, instead of the usual fulltext.\n"),   {'r', svnadmin__incremental, svnadmin__deltas, 'q'} },  {"help", subcommand_help, {"?", "h"}, N_   ("usage: svnadmin help [SUBCOMMAND...]\n\n"    "Describe the usage of this program or its subcommands.\n"),   {0} },  {"hotcopy", subcommand_hotcopy, {0}, N_   ("usage: svnadmin hotcopy REPOS_PATH NEW_REPOS_PATH\n\n"    "Makes a hot copy of a repository.\n"),   {svnadmin__clean_logs} },  {"list-dblogs", subcommand_list_dblogs, {0}, N_   ("usage: svnadmin list-dblogs REPOS_PATH\n\n"    "List all Berkeley DB log files.\n\n"    "WARNING: Modifying or deleting logfiles which are still in use\n"    "will cause your repository to be corrupted.\n"),   {0} },  {"list-unused-dblogs", subcommand_list_unused_dblogs, {0}, N_   ("usage: svnadmin list-unused-dblogs REPOS_PATH\n\n"    "List unused Berkeley DB log files.\n\n"),   {0} },  {"load", subcommand_load, {0}, N_   ("usage: svnadmin load REPOS_PATH\n\n"    "Read a 'dumpfile'-formatted stream from stdin, committing\n"    "new revisions into the repository's filesystem.  If the repository\n"    "was previously empty, its UUID will, by default, be changed to the\n"    "one specified in the stream.  Progress feedback is sent to stdout.\n"),   {'q', svnadmin__ignore_uuid, svnadmin__force_uuid,    svnadmin__use_pre_commit_hook, svnadmin__use_post_commit_hook,    svnadmin__parent_dir} },  {"lslocks", subcommand_lslocks, {0}, N_   ("usage: svnadmin lslocks REPOS_PATH\n\n"    "Print descriptions of all locks.\n"),   {0} },  {"lstxns", subcommand_lstxns, {0}, N_   ("usage: svnadmin lstxns REPOS_PATH\n\n"    "Print the names of all uncommitted transactions.\n"),   {0} },  {"recover", subcommand_recover, {0}, N_   ("usage: svnadmin recover REPOS_PATH\n\n"    "Run the Berkeley DB recovery procedure on a repository.  Do\n"    "this if you've been getting errors indicating that recovery\n"

⌨️ 快捷键说明

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