fsvs.c File Reference

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"
Include dependency graph for fsvs.c:

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_tcurrent_url
 Pointer to current URL.
char ** environ = NULL
 For Solaris.

Detailed Description

The central parts of fsvs (main).

Definition in file fsvs.c.


Define Documentation

#define _STRINGIFY (  )     #x

Definition at line 627 of file fsvs.c.

#define MAX_DEBUG_LINE_LEN   (1024)

This constant is used to determine when to rotate the debug output buffer.

Definition at line 397 of file fsvs.c.

Referenced by _DEBUGP().

#define STRINGIFY (  )     " " #x "=" _STRINGIFY(x)

Definition at line 628 of file fsvs.c.

Referenced by Version().


Function Documentation

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

int main ( int  argc,
char *  args[],
char *  env[] 
)

The main function.

It does the following things (not in that order):

  • Initializes the various parts
    • APR (apr_initialize()),
    • WAA (waa__init()),
    • RA (svn_ra_initialize()),
    • Callback functions (cb__init()) ...
    • Local charset (LC_CTYPE)
  • Processes the command line. In glibc the options are reordered to the front; on BSD systems this is not done, so there's an extra loop to do that manually. We want all options processed, and then the paths (or other parameters) in a clean list.
  • And calls the main action.

How the parameters get mungled - example

On entry we have eg. this:

inline_dotgraph_1.dot

After command line parsing we have:

inline_dotgraph_2.dot

Argumentation for parsing the urllist

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

  • might run out of space before some argument (because two extra NULL pointers are needed, and only a single one is provided on startup),
  • and we'd have to move the pointers around every time we find a non-option argument.

Consider the case [fsvs, update, /bin/, -uURLa, -uURLb, /lib, NULL]. That would be transformed to

  1. [update, NULL, /bin/, -uURLa, -uURLb, /lib, NULL]
  2. [update, /bin/, NULL, -uURLa, -uURLb, /lib, NULL]
  3. And now we'd have to do [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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char** environ = NULL

For Solaris.

Definition at line 360 of file fsvs.c.

Referenced by hlp__format_path(), hlp__match_path_envs(), and main().

Definition at line 332 of file fsvs.c.

Referenced by _DEBUGP(), and main().

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().


Generated for fsvs by  doxygen 1.6.1