The central parts of fsvs (main). More...
#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <getopt.h>#include <sys/time.h>#include <time.h>#include <stdarg.h>#include <langinfo.h>#include <locale.h>#include <apr_pools.h>#include <subversion-1/svn_error.h>#include "global.h"#include "interface.h"#include "ignore.h"#include "checksum.h"#include "helper.h"#include "waa.h"#include "options.h"#include "cp_mv.h"#include "status.h"#include "url.h"#include "warnings.h"#include "actions.h"#include "racallback.h"
Go to the source code of this file.
Defines | |
| #define | MAX_DEBUG_LINE_LEN (1024) |
| This constant is used to determine when to rotate the debug output buffer. | |
| #define | _STRINGIFY(x) #x |
| #define | STRINGIFY(x) " " #x "=" _STRINGIFY(x) |
Functions | |
| void | _DEBUGP_open_output (FILE **output, int *was_popened) |
| Opens the debug output file or pipe, as specified. | |
| void | _DEBUGP (const char *file, int line, const char *func, char *format,...) |
| -. | |
| int | _STOP (const char *file, int line, const char *function, int errl, const char *format,...) |
| -. | |
| const char * | Version (FILE *output) |
| For keyword expansion - the version string. | |
| int | ac__Usage (struct estat *root UNUSED, int argc UNUSED, char *argv[]) |
| -. | |
| void | sigUSR1 (int num) |
| USR1 increases FSVS' verbosity. | |
| void | sigUSR2 (int num) |
| USR2 decreases FSVS' verbosity. | |
| void | sigDebug (int num) |
| Signal handler for debug binaries. | |
| void | sigPipe (int num) |
| Handler for SIGPIPE. | |
| void * | _do_component_tests (int a) |
| This function is used for the component tests. | |
| int | main (int argc, char *args[], char *env[]) |
| The main function. | |
Variables | |
| char | parm_dump [] = "dump" |
| -. | |
| char | parm_test [] = "test" |
| char | parm_load [] = "load" |
| int | debuglevel = 0 |
| Whether debug messages are wanted. | |
| int | opt_recursive = 1 |
| -. | |
| svn_revnum_t | target_revision |
| The revision we're getting from the repository. | |
| svn_revnum_t | opt_target_revision = SVN_INVALID_REVNUM |
The revision the user wants to get at (-r parameter). | |
| svn_revnum_t | opt_target_revision2 = SVN_INVALID_REVNUM |
| The second revision number the user specified. | |
| int | opt_target_revisions_given = 0 |
| How many revisions the user specified on the commandline (0, 1 or 2). | |
| char * | opt_commitmsg |
| A pointer to the commit message; possibly a mmap()ped file. | |
| char * | opt_debugprefix |
| char * | opt_commitmsgfile |
| The file name of the commit message file. | |
| int | make_STOP_silent = 0 |
| -. | |
| static char * | program_name |
| Remember how the program was called. | |
| char * | start_path = NULL |
| -. | |
| int | start_path_len = 0 |
| -. | |
| char * | local_codeset |
| The local character encoding, according to LC_ALL or LC_CTYPE). | |
| apr_pool_t * | global_pool |
| The first allocated APR pool. | |
| struct url_t * | current_url |
| Pointer to current URL. | |
| char ** | environ = NULL |
| For Solaris. | |
The central parts of fsvs (main).
Definition in file fsvs.c.
| #define MAX_DEBUG_LINE_LEN (1024) |
| #define STRINGIFY | ( | x | ) | " " #x "=" _STRINGIFY(x) |
| void _DEBUGP | ( | const char * | file, | |
| int | line, | |||
| const char * | func, | |||
| char * | format, | |||
| ... | ||||
| ) |
-.
Never called directly, used only via the macro DEBUGP().
For uninitializing in the use case debug_buffer the line value is misused to show whether an error occured.
Definition at line 404 of file fsvs.c.
References _DEBUGP_open_output(), debuglevel, DEBUGP, MAX_DEBUG_LINE_LEN, OPT__DEBUG_BUFFER, opt__set_int(), opt_debugprefix, and PRIO_MUSTHAVE.
Referenced by main(), and sigDebug().


| void _DEBUGP_open_output | ( | FILE ** | output, | |
| int * | was_popened | |||
| ) |
Opens the debug output file or pipe, as specified.
If a debug buffer is given, this is filled first; and only in case of a buffer flush the given file or pipe is opened, to receive the buffer contents.
This function cannot return errors.
Definition at line 370 of file fsvs.c.
References DEBUGP, and OPT__DEBUG_OUTPUT.
Referenced by _DEBUGP().

| void* _do_component_tests | ( | int | a | ) |
This function is used for the component tests.
When FSVS is run with "-d" as parameter, a call to fileno() is guaranteed to happen here; a single "up" gets into this stack frame, and allows easy setting/quering of some values.
Definition at line 928 of file fsvs.c.
Referenced by main().

| int _STOP | ( | const char * | file, | |
| int | line, | |||
| const char * | function, | |||
| int | errl, | |||
| const char * | format, | |||
| ... | ||||
| ) |
-.
It checks the given status code, and (depending on the command line flag -v) prints only the first error or the whole call stack. If debuglevel is set, prints some more details - time, file and line. Never called directly; only via some macros.
In case the first character of the format is a "!", it's a user error - here we normally print only the message, without the error code line. The full details are available via -d and -v.
-EPIPE is handled specially, in that it is passed up, but no message is printed.
Definition at line 547 of file fsvs.c.
References debuglevel, make_STOP_silent, opt__is_verbose(), OPT__VERBOSE, and VERBOSITY_STACKTRACE.

| int ac__Usage | ( | struct estat *root | UNUSED, | |
| int argc | UNUSED, | |||
| char * | argv[] | |||
| ) |
-.
Prints help for the given action.
Definition at line 738 of file fsvs.c.
References act__find_action_by_name(), action, action_list, action_list_count, DEFAULT_CONF_PATH, DEFAULT_WAA_PATH, actionlist_t::help_text, actionlist_t::name, STOPIF, and Version().

| int main | ( | int | argc, | |
| char * | args[], | |||
| char * | env[] | |||
| ) |
The main function.
It does the following things (not in that order):
LC_CTYPE)On entry we have eg. this:
After command line parsing we have:
I'd have liked to keep the url__parm_list in the original args as well; but we cannot easily let it start at the end, and putting it just after the non-parameter arguments
NULL pointers are needed, and only a single one is provided on startup),Consider the case [fsvs, update, /bin/, -uURLa, -uURLb, /lib, NULL]. That would be transformed to
[update, NULL, /bin/, -uURLa, -uURLb, /lib, NULL][update, /bin/, NULL, -uURLa, -uURLb, /lib, NULL][update, /bin/, NULL, -uURLa, NULL, -uURLb, /lib, NULL]; this is too long. We could reuse the NULL at the end ... but that's not that fine, either -- the url__parm_list wouldn't be terminated.So we go the simple route - allocate an array of pointers, and store them there.
Definition at line 1053 of file fsvs.c.
References _DEBUGP(), _do_component_tests(), ac__Usage_dflt, ac__Usage_this, act__find_action_by_name(), action, action_list, cb__init(), cm__get_source(), conf_tmp_fn, conf_tmp_path, debuglevel, DEBUGP, estat::do_filter_allows, estat::do_filter_allows_done, estat::entry_count, environ, FILTER__ALL, FSVS_DEBUG_ENV, global_pool, hlp__chrooter(), hlp__parse_rev(), hlp__rightmost_0_bit(), local_codeset, sstat_t::mode, actionlist_t::name, estat::name, OPT__CHANGECHECK, OPT__DEBUG_BUFFER, OPT__DEBUG_OUTPUT, OPT__FILTER, opt__load_env(), opt__load_settings(), opt__parse(), opt__parse_option(), opt__set_int(), opt__set_string(), OPT__STATUS_COLOR, OPT__VERBOSE, opt__verbosity(), opt_commitmsg, opt_commitmsgfile, opt_debugprefix, opt_recursive, opt_target_revision, opt_target_revision2, opt_target_revisions_given, PRIO_CMDLINE, PRIO_ETC_FILE, PRIO_MUSTHAVE, PRIO_PRE_CMDLINE, program_name, estat::repos_rev, sigDebug(), sigPipe(), sigUSR1(), sigUSR2(), sstat_t::size, estat::st, st__status_string_fromint(), start_path, start_path_len, STOPIF, STOPIF_SVNERR, estat::strings, url__close_sessions(), url__store_url_name(), VERBOSITY_DEFAULT, VERBOSITY_QUIET, VERBOSITY_VERYQUIET, Version(), wa__set_warn_option(), wa__summary(), wa__warn(), waa__init(), waa__save_cwd(), actionlist_t::work, WRN__CHARSET_INVALID, and WRN__TEST_WARNING.

| void sigDebug | ( | int | num | ) |
Signal handler for debug binaries.
If the configure run included --enable-debug, we intercept SIGSEGV and try to start gdb.
We use a pipe to stop the parent process; debugging within gdb normally starts with a bt (backtrace), followed by up 3 to skip over the signal handler and its fallout. FSVS GCOV MARK: sigDebug should not be executed
Definition at line 857 of file fsvs.c.
References _DEBUGP(), and program_name.
Referenced by main().


| void sigPipe | ( | int | num | ) |
Handler for SIGPIPE.
We give the running action a single chance to catch an EPIPE, to clean up on open files and similar; if it doesn't take this chance, the next SIGPIPE kills FSVS.
Definition at line 917 of file fsvs.c.
References DEBUGP.
Referenced by main().

| void sigUSR1 | ( | int | num | ) |
USR1 increases FSVS' verbosity.
Definition at line 825 of file fsvs.c.
References debuglevel, DEBUGP, opt__set_int(), OPT__VERBOSE, opt__verbosity(), PRIO_MUSTHAVE, and VERBOSITY_DEFAULT.
Referenced by main().


| void sigUSR2 | ( | int | num | ) |
USR2 decreases FSVS' verbosity.
Definition at line 836 of file fsvs.c.
References debuglevel, DEBUGP, opt__set_int(), OPT__VERBOSE, opt__verbosity(), PRIO_MUSTHAVE, VERBOSITY_DEFAULT, and VERBOSITY_QUIET.
Referenced by main().


| const char* Version | ( | FILE * | output | ) |
For keyword expansion - the version string.
Definition at line 631 of file fsvs.c.
References AC_CV_C_UINT32_T, ENABLE_DEBUG, ENABLE_DEBUGBUFFER, ENABLE_GCOV, HAVE_COMPARISON_FN_T, HAVE_DIRFD, HAVE_FMEMOPEN, HAVE_LCHOWN, HAVE_LINUX_KDEV_T_H, HAVE_LINUX_TYPES_H, HAVE_LINUX_UNISTD_H, HAVE_LOCALES, HAVE_LUTIMES, HAVE_O_DIRECTORY, HAVE_STRSEP, HAVE_STRUCT_STAT_ST_MTIM, HAVE_VALGRIND, NAME_MAX, opt__is_verbose(), STRINGIFY, and WAA_WC_MD5_CHARS.
Referenced by ac__Usage(), and main().


| char** environ = NULL |
For Solaris.
Definition at line 360 of file fsvs.c.
Referenced by hlp__format_path(), hlp__match_path_envs(), and main().
| char * opt_debugprefix |
char* program_name [static] |
Remember how the program was called.
Definition at line 345 of file fsvs.c.
Referenced by main(), and sigDebug().
| char* start_path = NULL |
-.
Remember where we started.
Definition at line 347 of file fsvs.c.
Referenced by hlp__pathcopy(), ign__work(), main(), and waa__find_common_base2().
| int start_path_len = 0 |
-.
How much bytes the start_path has.
Definition at line 349 of file fsvs.c.
Referenced by cm___absolute_path(), hlp__pathcopy(), ign__work(), main(), and waa__find_common_base2().
1.6.1