00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <unistd.h>
00010 #include <stdio.h>
00011 #include <stdlib.h>
00012 #include <getopt.h>
00013 #include <sys/time.h>
00014 #include <time.h>
00015 #include <stdarg.h>
00016 #include <langinfo.h>
00017 #include <locale.h>
00018
00019 #include <apr_pools.h>
00020
00021 #include <subversion-1/svn_error.h>
00022
00023 #include "global.h"
00024 #include "interface.h"
00025 #include "ignore.h"
00026 #include "checksum.h"
00027 #include "helper.h"
00028 #include "waa.h"
00029 #include "options.h"
00030 #include "cp_mv.h"
00031 #include "status.h"
00032 #include "url.h"
00033 #include "warnings.h"
00034 #include "options.h"
00035 #include "actions.h"
00036 #include "racallback.h"
00037
00318 char parm_dump[]="dump",
00319 parm_test[]="test",
00320 parm_load[]="load";
00321
00322
00323 int debuglevel=0,
00325 opt_recursive=1;
00326
00327 svn_revnum_t target_revision;
00328 svn_revnum_t opt_target_revision=SVN_INVALID_REVNUM;
00329 svn_revnum_t opt_target_revision2=SVN_INVALID_REVNUM;
00330 int opt_target_revisions_given=0;
00331
00332 char *opt_commitmsg,
00333 *opt_debugprefix,
00334 *opt_commitmsgfile;
00335
00342 int make_STOP_silent=0;
00343
00345 static char *program_name;
00347 char *start_path=NULL;
00349 int start_path_len=0;
00350
00351 #ifdef HAVE_LOCALES
00352 char *local_codeset;
00353 #endif
00354
00355 apr_pool_t *global_pool;
00356
00357 struct url_t *current_url;
00358
00359
00360 char **environ=NULL;
00361
00362
00370 void _DEBUGP_open_output(FILE **output, int *was_popened)
00371 {
00372 const char *fn;
00373 FILE *tmp;
00374
00375
00376 *output=stdout;
00377 *was_popened=0;
00378
00379 fn=opt__get_string(OPT__DEBUG_OUTPUT);
00380 if (fn)
00381 {
00382 *was_popened= (fn[0] == '|');
00383 if (*was_popened)
00384 tmp=popen(fn+1, "w");
00385 else
00386 tmp=fopen(fn, "w");
00387
00388 if (tmp) *output=tmp;
00389 else DEBUGP("'%s' cannot be opened: %d=%s",
00390 opt__get_string(OPT__DEBUG_OUTPUT),
00391 errno, strerror(errno));
00392 }
00393 }
00394
00397 #define MAX_DEBUG_LINE_LEN (1024)
00398
00404 void _DEBUGP(const char *file, int line,
00405 const char *func,
00406 char *format, ...)
00407 {
00408 static struct timeval tv;
00409 static struct timezone tz;
00410 struct tm *tm;
00411 va_list va;
00412 static FILE *debug_out=NULL;
00413 static int was_popened=0;
00414 int ms;
00415 const char *fn;
00416 static char *buffer_start=NULL;
00417 static int did_wrap=0;
00418 FILE *real_out;
00419 long mem_pos;
00420
00421
00422 if (!file)
00423 {
00424 if (line && opt__get_int(OPT__DEBUG_BUFFER) && debug_out)
00425 {
00426
00427 _DEBUGP_open_output(&real_out, &was_popened);
00428
00429 mem_pos=ftell(debug_out);
00430 if (mem_pos>=0 && did_wrap)
00431 {
00432 buffer_start[mem_pos]=0;
00433
00434
00435 fn=strchr(buffer_start+mem_pos,'\n');
00436 if (fn)
00437 fputs(fn+1, real_out);
00438 }
00439 fputs(buffer_start, real_out);
00440
00441
00442 fclose(debug_out);
00443
00444 debug_out=real_out;
00445 }
00446
00447 if (debug_out)
00448 {
00449 if (was_popened)
00450 pclose(debug_out);
00451 else
00452 if (debug_out != stdout)
00453 fclose(debug_out);
00454 debug_out=NULL;
00455 }
00456 return;
00457 }
00458
00459 if (!debuglevel) return;
00460
00461
00462 if (opt_debugprefix &&
00463 strncmp(opt_debugprefix, func, strlen(opt_debugprefix)))
00464 return;
00465
00466 if (!debug_out)
00467 {
00468
00469 debug_out=stdout;
00470
00471 #ifdef ENABLE_DEBUGBUFFER
00472 if (opt__get_int(OPT__DEBUG_BUFFER))
00473 {
00474 buffer_start=malloc(opt__get_int(OPT__DEBUG_BUFFER));
00475 if (buffer_start)
00476 debug_out=fmemopen(buffer_start,
00477 opt__get_int(OPT__DEBUG_BUFFER), "w+");
00478
00479 if (buffer_start && debug_out)
00480 {
00481 DEBUGP("using a buffer of %d bytes.", opt__get_int(OPT__DEBUG_BUFFER));
00482 }
00483 else
00484 {
00485 opt__set_int(OPT__DEBUG_BUFFER, PRIO_MUSTHAVE, 0);
00486 debug_out=stdout;
00487 DEBUGP("cannot use memory buffer for debug");
00488 }
00489 }
00490 else
00491 {
00492 _DEBUGP_open_output(&debug_out, &was_popened);
00493 }
00494 #else
00495 _DEBUGP_open_output(&debug_out, &was_popened);
00496 #endif
00497 }
00498
00499 gettimeofday(&tv, &tz);
00500 tm=localtime(&tv.tv_sec);
00501
00502
00503 ms=tv.tv_usec/1000;
00504
00505
00506 #ifdef ENABLE_DEBUGBUFFER
00507 if (opt__get_int(OPT__DEBUG_BUFFER))
00508 {
00509
00510 mem_pos=ftell(debug_out);
00511 if (mem_pos+MAX_DEBUG_LINE_LEN >= opt__get_int(OPT__DEBUG_BUFFER))
00512 {
00513
00514 fseek(debug_out, 0, SEEK_SET);
00515 did_wrap++;
00516 }
00517 }
00518 #endif
00519
00520 fprintf(debug_out, "%02d:%02d:%02d.%03d %s[%s:%d] ",
00521 tm->tm_hour, tm->tm_min, tm->tm_sec, ms,
00522 func,
00523 file, line);
00524
00525 va_start(va, format);
00526 vfprintf(debug_out, format, va);
00527
00528 fputc('\n', debug_out);
00529 fflush(debug_out);
00530 }
00531
00532
00547 int _STOP(const char *file, int line, const char *function,
00548 int errl, const char *format, ...)
00549 {
00550 static int already_stopping=0;
00551 static int error_number;
00552 int is_usererror;
00553 struct timeval tv;
00554 struct timezone tz;
00555 struct tm *tm;
00556 va_list va;
00557 FILE *stop_out=stderr;
00558 char errormsg[256];
00559
00560
00561 if (make_STOP_silent) return errl;
00562 if (errl==-EPIPE) return errl;
00563
00564 is_usererror= format && *format == '!';
00565 if (is_usererror) format++;
00566
00567
00568
00569 if ( (already_stopping || !format) &&
00570 !(opt__get_int(OPT__VERBOSE) & VERBOSITY_STACKTRACE))
00571 return error_number;
00572
00573 if (! (already_stopping++))
00574 {
00575
00576 fflush(NULL);
00577
00578 if (is_usererror)
00579 {
00580 va_start(va, format);
00581 vfprintf(stop_out, format, va);
00582 if (!(debuglevel || opt__is_verbose()>0))
00583 goto eol;
00584 }
00585
00586
00587 fputs("\n\nAn error occurred", stop_out);
00588
00589 if (debuglevel || opt__is_verbose()>0)
00590 {
00591 gettimeofday(&tv, &tz);
00592 tm=localtime(&tv.tv_sec);
00593 fprintf(stop_out, " at %02d:%02d:%02d.%03d",
00594 tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec+500)/1000);
00595 }
00596
00597 errormsg[0]=0;
00598 svn_strerror (errl, errormsg, sizeof(errormsg));
00599 fprintf(stop_out, ": %s (%d)\n",
00600 errormsg[0] ? errormsg : strerror(abs(errl)), errl);
00601 }
00602
00603
00604 fputs(" in ", stop_out);
00605 fputs(function, stop_out);
00606 if (debuglevel)
00607 fprintf(stop_out, " [%s:%d]", file, line);
00608
00609 if (format)
00610 {
00611 fputs(": ", stop_out);
00612
00613 va_start(va, format);
00614 vfprintf(stop_out, format, va);
00615 }
00616
00617 eol:
00618 fputc('\n', stop_out);
00619 fflush(stop_out);
00620
00621 error_number=errl;
00622 already_stopping=1;
00623 return errl;
00624 }
00625
00626
00627 #define _STRINGIFY(x) #x
00628 #define STRINGIFY(x) " " #x "=" _STRINGIFY(x)
00629
00631 const char* Version(FILE *output)
00632 {
00633 static const char Id[] ="$Id: fsvs.c 2396 2009-10-12 19:05:54Z pmarek $";
00634
00635 fprintf(output, "FSVS (licensed under the GPLv3), (C) by Ph. Marek;"
00636 " version " FSVS_VERSION "\n");
00637 if (opt__is_verbose()>0)
00638 {
00639 fprintf(output, "compiled on " __DATE__ " " __TIME__
00640 ", with options:\n\t"
00641 #ifdef HAVE_VALGRIND
00642 STRINGIFY(HAVE_VALGRIND)
00643 #endif
00644 #ifdef HAVE_VALGRIND_VALGRIND_H
00645 STRINGIFY(HAVE_VALGRIND_VALGRIND_H)
00646 #endif
00647 #ifdef ENABLE_DEBUG
00648 STRINGIFY(ENABLE_DEBUG)
00649 #endif
00650 #ifdef ENABLE_GCOV
00651 STRINGIFY(ENABLE_GCOV)
00652 #endif
00653 #ifdef ENABLE_RELEASE
00654 STRINGIFY(ENABLE_RELEASE)
00655 #endif
00656 #ifdef HAVE_LOCALES
00657 STRINGIFY(HAVE_LOCALES)
00658 #endif
00659 #ifdef HAVE_UINT32_T
00660 STRINGIFY(HAVE_UINT32_T)
00661 #endif
00662 #ifdef AC_CV_C_UINT32_T
00663 STRINGIFY(AC_CV_C_UINT32_T)
00664 #endif
00665 #ifdef HAVE_LINUX_TYPES_H
00666 STRINGIFY(HAVE_LINUX_TYPES_H)
00667 #endif
00668 #ifdef HAVE_LINUX_UNISTD_H
00669 STRINGIFY(HAVE_LINUX_UNISTD_H)
00670 #endif
00671 #ifdef HAVE_DIRFD
00672 STRINGIFY(HAVE_DIRFD)
00673 #endif
00674 #ifdef HAVE_STRUCT_STAT_ST_MTIM
00675 STRINGIFY(HAVE_STRUCT_STAT_ST_MTIM)
00676 #endif
00677 #ifdef CHROOTER_JAIL
00678 STRINGIFY(CHROOTER_JAIL)
00679 #endif
00680 #ifdef HAVE_COMPARISON_FN_T
00681 STRINGIFY(HAVE_COMPARISON_FN_T)
00682 #endif
00683 #ifdef HAVE_O_DIRECTORY
00684 STRINGIFY(HAVE_O_DIRECTORY)
00685 #endif
00686 #ifdef O_DIRECTORY
00687 STRINGIFY(O_DIRECTORY)
00688 #endif
00689 #ifdef HAVE_LINUX_KDEV_T_H
00690 STRINGIFY(HAVE_LINUX_KDEV_T_H)
00691 #endif
00692 #ifdef ENABLE_DEV_FAKE
00693 STRINGIFY(ENABLE_DEV_FAKE)
00694 #endif
00695 #ifdef DEVICE_NODES_DISABLED
00696 STRINGIFY(DEVICE_NODES_DISABLED)
00697 #endif
00698 #ifdef HAVE_STRSEP
00699 STRINGIFY(HAVE_STRSEP)
00700 #endif
00701 #ifdef HAVE_LUTIMES
00702 STRINGIFY(HAVE_LUTIMES)
00703 #endif
00704 #ifdef HAVE_LCHOWN
00705 STRINGIFY(HAVE_LCHOWN)
00706 #endif
00707 #ifdef WAA_WC_MD5_CHARS
00708 STRINGIFY(WAA_WC_MD5_CHARS)
00709 #endif
00710 #ifdef HAVE_FMEMOPEN
00711 STRINGIFY(HAVE_FMEMOPEN)
00712 #endif
00713 #ifdef ENABLE_DEBUGBUFFER
00714 STRINGIFY(ENABLE_DEBUGBUFFER)
00715 #endif
00716 STRINGIFY(NAME_MAX)
00717 "\n");
00718 }
00719 return Id;
00720 }
00721
00722
00738 int ac__Usage(struct estat *root UNUSED,
00739 int argc UNUSED, char *argv[])
00740 {
00741 int status;
00742 int i, hpos, len;
00743 char const* const*names;
00744
00745
00746 status=0;
00747 Version(stdout);
00748
00749
00750 if (argv && *argv)
00751 {
00752 STOPIF( act__find_action_by_name(*argv, &action), NULL);
00753 printf("\n"
00754 "Help for command \"%s\".\n", action->name[0]);
00755 names=action->name+1;
00756 if (*names)
00757 {
00758 printf("Aliases: ");
00759 while (*names)
00760 {
00761 printf("%s%s",
00762 names[0],
00763 names[1] ? ", " : "\n");
00764 names++;
00765 }
00766 }
00767
00768 puts("");
00769
00770 puts(action->help_text);
00771 }
00772 else
00773 {
00774
00775 printf(
00776 "\n"
00777 "Known commands:\n"
00778 "\n ");
00779 hpos=2;
00780 for(i=0; i<action_list_count; i++)
00781 {
00782 len = strlen(action_list[i].name[0]);
00783
00784
00785 if (hpos+2+len >= 75)
00786 {
00787 printf("\n ");
00788 hpos=2;
00789 }
00790
00791 printf("%s%s", action_list[i].name[0],
00792 i+1 == action_list_count ? "\n" : ", ");
00793 hpos += 2 + len;
00794 }
00795
00796 puts(
00797 "\n"
00798 "Parameters:\n"
00799 "\n"
00800 "-v increase verbosity\n"
00801 "-q decrease verbosity (quiet)\n"
00802 "\n"
00803 "-C checksum possibly changed files;\n"
00804 " if given twice checksum *all* files.\n"
00805 "\n"
00806 "-V show version\n"
00807 "\n"
00808 "Environment variables:\n"
00809 "\n"
00810 "$FSVS_CONF defines the location of the FSVS Configuration area\n"
00811 " Default is " DEFAULT_CONF_PATH ", but any writeable directory is allowed.\n"
00812 "$FSVS_WAA defines the location of the Working copy Administrative Area\n"
00813 " Default is " DEFAULT_WAA_PATH ", but any writeable directory is allowed.\n"
00814 );
00815 }
00816
00817 ex:
00818 exit(status);
00819
00820
00821 return 0;
00822 }
00823
00825 void sigUSR1(int num)
00826 {
00827 if (opt__verbosity() < VERBOSITY_DEFAULT)
00828 opt__set_int(OPT__VERBOSE, PRIO_MUSTHAVE, VERBOSITY_DEFAULT);
00829 else if (debuglevel < 3)
00830 {
00831 debuglevel++;
00832 DEBUGP("more debugging via SIGUSR1");
00833 }
00834 }
00836 void sigUSR2(int num)
00837 {
00838 if (debuglevel)
00839 {
00840 DEBUGP("less debugging via SIGUSR2");
00841 debuglevel--;
00842 }
00843 else if (opt__verbosity() >= VERBOSITY_DEFAULT)
00844 opt__set_int(OPT__VERBOSE, PRIO_MUSTHAVE, VERBOSITY_QUIET);
00845 }
00846
00847
00855 #ifdef ENABLE_DEBUG
00857 void sigDebug(int num)
00858 {
00859 char ppid_str[20];
00860 int pid;
00861 int pipes[2];
00862
00863
00864
00865 signal(SIGSEGV, SIG_DFL);
00866
00867
00868 _DEBUGP(NULL, EBUSY, NULL, NULL);
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879 pipes[0]=pipes[1]=-1;
00880 if ( pipe(pipes) == -1) goto ex;
00881
00882 pid=fork();
00883 if (pid == -1) return;
00884
00885 if (pid)
00886 {
00887
00888
00889 close(pipes[0]);
00890
00891 sprintf(ppid_str, "%d", pid);
00892 execlp("gdb", "gdb", program_name, ppid_str, NULL);
00893
00894 close(pipes[1]);
00895 exit(1);
00896 }
00897 else
00898 {
00899
00900
00901
00902 close(pipes[1]);
00903 pipes[1]=-1;
00904 read(pipes[0], &pid, 1);
00905 }
00906
00907 ex:
00908 if (pipes[0] != -1) close(pipes[0]);
00909 if (pipes[1] != -1) close(pipes[1]);
00910 }
00911
00912
00917 void sigPipe(int num)
00918 {
00919 DEBUGP("got SIGPIPE");
00920 signal(SIGPIPE, SIG_DFL);
00921 }
00922
00923
00928 void *_do_component_tests(int a)
00929 {
00930
00931 static int int_array[10];
00932 static void *voidp_array[10];
00933 static char *charp_array_1[10];
00934 static char *charp_array_2[10];
00935 static char **charpp;
00936 static char buffer[1024];
00937 static struct estat *estat_array[10];
00938
00939 int_array[0]=fileno(stdin);
00940 voidp_array[0]=stdin+fileno(stdout);
00941 buffer[0]=fileno(stderr);
00942 charpp=charp_array_2+4;
00943
00944 switch(a)
00945 {
00946 case 4: return int_array;
00947 case 9: return voidp_array;
00948 case 6: return buffer;
00949 case 2: return charp_array_1;
00950 case 3: return estat_array;
00951 case 7: return charpp;
00952 case 8: return charp_array_2;
00953 }
00954 return NULL;
00955 }
00956 #endif
00957
00958
01053 int main(int argc, char *args[], char *env[])
01054 {
01055 struct estat root = { };
01056 int status, help;
01057 char *cmd;
01058 svn_error_t *status_svn;
01059 int eo_args, i;
01060 void *mem_start, *mem_end;
01061
01062
01063 help=0;
01064 eo_args=1;
01065 environ=env;
01066 program_name=args[0];
01067 #ifdef ENABLE_DEBUG
01068
01069
01070 if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO))
01071 signal(SIGSEGV, sigDebug);
01072
01073 signal(SIGPIPE, sigPipe);
01074
01075
01076 cmd=getenv(FSVS_DEBUG_ENV);
01077 if (cmd)
01078 debuglevel = atoi(cmd);
01079 #endif
01080
01081 signal(SIGUSR1, sigUSR1);
01082 signal(SIGUSR2, sigUSR2);
01083 mem_start=sbrk(0);
01084
01085
01086 #ifdef HAVE_LOCALES
01087
01088
01089
01090 cmd=setlocale(LC_ALL, "");
01091 DEBUGP("LC_ALL gives %s", cmd);
01092
01093
01094
01095
01096
01097 cmd=setlocale(LC_CTYPE, "");
01098 DEBUGP("LC_CTYPE gives %s", cmd);
01099
01100 local_codeset=nl_langinfo(CODESET);
01101 if (!local_codeset)
01102 {
01103 STOPIF( wa__warn(WRN__CHARSET_INVALID, EINVAL,
01104 "Could not retrieve the current character set - assuming UTF-8."),
01105 "nl_langinfo(CODESET) failed - check locale configuration.");
01106 }
01107 else
01108 {
01109 DEBUGP("codeset found to be %s", local_codeset);
01110 if (strcmp(local_codeset, "UTF-8")==0)
01111
01112
01113 local_codeset=NULL;
01114 }
01115
01116 if (!local_codeset)
01117 DEBUGP("codeset: using identity");
01118 #else
01119 DEBUGP("build without locales");
01120 #endif
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133 STOPIF( hlp__chrooter(), NULL);
01134
01135
01136 STOPIF( opt__load_env(environ), NULL);
01137 STOPIF( waa__save_cwd(&start_path, &start_path_len, 0), NULL);
01138
01139
01140 if (!isatty(STDOUT_FILENO))
01141 opt__set_int( OPT__STATUS_COLOR, PRIO_PRE_CMDLINE, 0);
01142
01143
01144
01145 root.repos_rev=0;
01146 root.name=root.strings=".";
01147 root.st.size=0;
01148 root.st.mode=S_IFDIR | 0700;
01149 root.entry_count=0;
01150
01151
01152
01153 root.do_filter_allows=1;
01154 root.do_filter_allows_done=1;
01155
01156
01157 while (1)
01158 {
01159
01160
01161
01162
01163
01164
01165 status=getopt(argc, args, "+a:VhdvCm:F:D:qf:r:W:NRo:u:?");
01166 if (status == -1)
01167 {
01168 DEBUGP("no argument at optind=%d of %d",optind, argc);
01169
01170 if (optind == argc) break;
01171
01172
01173 if (strcmp("--", args[optind-1])==0)
01174 {
01175
01176 while (optind < argc) args[eo_args++] = args[optind++];
01177 break;
01178 }
01179
01180
01181 args[eo_args++]=args[optind++];
01182 continue;
01183 }
01184
01185 switch (status)
01186 {
01187 case '?':
01188 case 'h':
01189 default:
01190 help=1;
01191 break;
01192
01193 case 'W':
01194 STOPIF( wa__set_warn_option(optarg, PRIO_CMDLINE),
01195 "Warning option '%s' is invalid", optarg);
01196 break;
01197
01198 case 'C':
01199 i = hlp__rightmost_0_bit(opt__get_int(OPT__CHANGECHECK));
01200 opt__set_int(OPT__CHANGECHECK, PRIO_CMDLINE,
01201 opt__get_int(OPT__CHANGECHECK) | i);
01202 break;
01203
01204 case 'o':
01205 STOPIF( opt__parse( optarg, NULL, PRIO_CMDLINE, 0),
01206 "!Cannot parse option string '%s'.", optarg);
01207 break;
01208
01209 case 'f':
01210 STOPIF( opt__parse_option(OPT__FILTER, PRIO_CMDLINE, optarg), NULL);
01211 break;
01212
01213 case 'u':
01214
01215
01216
01217
01218
01219
01220
01221
01222 STOPIF( url__store_url_name(optarg), NULL);
01223 break;
01224
01225
01226
01227
01228 case 'R':
01229 opt_recursive++;
01230 break;
01231 case 'N':
01232 opt_recursive--;
01233 break;
01234
01235 case 'F':
01236 if (opt_commitmsg) ac__Usage_this();
01237 opt_commitmsgfile=optarg;
01238 break;
01239 case 'm':
01240 if (opt_commitmsgfile) ac__Usage_this();
01241 opt_commitmsg=optarg;
01242 break;
01243
01244 case 'r':
01245
01246 cmd=strchr(optarg, ':');
01247 if (cmd) *(cmd++)=0;
01248
01249 STOPIF( hlp__parse_rev(optarg, NULL, &opt_target_revision), NULL);
01250 opt_target_revisions_given=1;
01251
01252 if (cmd && *cmd)
01253 {
01254 STOPIF( hlp__parse_rev(cmd, NULL, &opt_target_revision2), NULL);
01255 opt_target_revisions_given=2;
01256 }
01257 break;
01258
01259 #if ENABLE_RELEASE
01260 case 'D':
01261 case 'd':
01262 fprintf(stderr, "This image was compiled as a release "
01263 "(without debugging support).\n"
01264 "-d and -D are not available.\n\n");
01265 exit(1);
01266 #else
01267 case 'D':
01268 opt_debugprefix=optarg;
01269 if (!debuglevel) debuglevel++;
01270
01271 break;
01272 case 'd':
01273
01274
01275
01276
01277 if (debuglevel == 1)
01278 {
01279
01280
01281 _DEBUGP(NULL, 0, NULL, NULL);
01282
01283
01284 opt__set_string(OPT__DEBUG_OUTPUT, PRIO_MUSTHAVE, NULL);
01285 opt__set_int(OPT__DEBUG_BUFFER, PRIO_MUSTHAVE, 0);
01286
01287
01288 DEBUGP("Debugging set to unfiltered console");
01289 }
01290 debuglevel++;
01291 break;
01292 #endif
01293 case 'q':
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303 opt__set_int(OPT__VERBOSE, PRIO_CMDLINE,
01304 opt__verbosity() <= VERBOSITY_QUIET ?
01305 VERBOSITY_VERYQUIET : VERBOSITY_QUIET);
01306 break;
01307
01308 case 'v':
01309
01310 i=opt__get_int(OPT__VERBOSE);
01311 if (i == VERBOSITY_QUIET)
01312 i=VERBOSITY_DEFAULT;
01313 else
01314 i |= hlp__rightmost_0_bit(i);
01315
01316 opt__set_int(OPT__VERBOSE, PRIO_CMDLINE, i);
01317
01318
01319 opt__set_int(OPT__FILTER, PRIO_PRE_CMDLINE, FILTER__ALL);
01320 break;
01321
01322 case 'V':
01323 Version(stdout);
01324 exit(0);
01325 }
01326 }
01327
01328
01329 argc=eo_args;
01330
01331 args[argc]=NULL;
01332
01333 optind=1;
01334
01335
01336
01337 if (opt__get_int(OPT__DEBUG_BUFFER) &&
01338 opt__get_prio(OPT__DEBUG_BUFFER)==PRIO_CMDLINE &&
01339 !debuglevel)
01340 {
01341 debuglevel++;
01342 DEBUGP("debug capturing started by the debug_buffer option.");
01343 }
01344
01345
01346
01347 if (args[optind])
01348 {
01349 cmd=args[optind];
01350 optind++;
01351
01352 STOPIF( act__find_action_by_name(cmd, &action), NULL);
01353 if (help) ac__Usage_this();
01354 }
01355 else
01356 {
01357 if (help) ac__Usage_dflt();
01358 action=action_list+0;
01359 }
01360
01361 DEBUGP("optind=%d per_sts=%d action=%s rec=%d filter=%s verb=0x%x",
01362 optind,
01363 (int)sizeof(root),
01364 action->name[0],
01365 opt_recursive,
01366 st__status_string_fromint( opt__get_int(OPT__FILTER)),
01367 opt__verbosity());
01368
01369 for(eo_args=1; eo_args<argc; eo_args++)
01370 DEBUGP("argument %d: %s", eo_args, args[eo_args]);
01371
01372
01373
01374
01375
01376 STOPIF( waa__init(), NULL);
01377
01378
01379
01380 strcpy(conf_tmp_fn, "config");
01381 STOPIF( opt__load_settings(conf_tmp_path, NULL, PRIO_ETC_FILE ), NULL);
01382
01383
01384 #ifdef ENABLE_DEBUG
01385
01386
01387 STOPIF( wa__warn( WRN__TEST_WARNING, 0, "test warning" ), NULL );
01388
01389
01390
01391 if (debuglevel) _do_component_tests(optind);
01392 #endif
01393
01394
01395
01396
01397
01398 STOPIF( apr_initialize(), "apr_initialize");
01399 STOPIF( apr_pool_create_ex(&global_pool, NULL, NULL, NULL),
01400 "create an apr_pool");
01401 STOPIF_SVNERR( svn_ra_initialize, (global_pool));
01402 STOPIF_SVNERR( cb__init, (global_pool));
01403
01404
01405 STOPIF( action->work(&root, argc-optind, args+optind),
01406 "action %s failed", action->name[0]);
01407
01408
01409 STOPIF( cm__get_source(NULL, NULL, NULL, NULL, status),
01410 NULL);
01411
01412
01413
01414
01415
01416 STOPIF( wa__summary(), NULL);
01417
01418 STOPIF( url__close_sessions(), NULL);
01419
01420 ex:
01421 mem_end=sbrk(0);
01422 DEBUGP("memory stats: %p to %p, %llu KB",
01423 mem_start, mem_end, (t_ull)(mem_end-mem_start)/1024);
01424 if (status == -EPIPE)
01425 DEBUGP("got EPIPE, ignoring.");
01426
01427 _DEBUGP(NULL, status, NULL, NULL);
01428
01429 if (status) return 2;
01430
01431 return 0;
01432 }
01433
01434