00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __GLOBAL_H__
00010 #define __GLOBAL_H__
00011
00012 #include "config.h"
00013 #include "preproc.h"
00014
00015 #include <sys/stat.h>
00016 #include <sys/types.h>
00017 #include <gdbm.h>
00018 #include <stddef.h>
00019 #include <sys/types.h>
00020 #include <apr_md5.h>
00021 #include <apr_file_io.h>
00022 #include <subversion-1/svn_ra.h>
00023 #include <subversion-1/svn_string.h>
00024 #include <pcre.h>
00025
00026
00033 #define IF_FREE(x) do { if (x) free(x); x=NULL; } while (0)
00034
00035
00036
00039 #define PATH_SEPARATOR ('/')
00040
00043 #define ENVIRONMENT_START ('$')
00044
00047 #define UNUSED __attribute__ ((__unused__))
00048
00049
00052 typedef unsigned char md5_digest_t[APR_MD5_DIGESTSIZE];
00053
00054
00055
00067 typedef unsigned long long t_ull;
00068 typedef long long t_ll;
00069 typedef unsigned long t_ul;
00079 #define PT_SHELL (1)
00080 #define PT_PCRE (2)
00081 #define PT_DEVICE (3)
00082 #define PT_INODE (4)
00083 #define PT_SHELL_ABS (5)
00084
00086 struct ignore_t {
00088 char *pattern;
00089
00091 const char *group_name;
00093 struct grouping_t *group_def;
00094
00098 char *compare_string;
00099
00101 unsigned stats_tested;
00113 unsigned stats_matches;
00114
00115 union {
00116
00117 struct {
00119 pcre *compiled;
00121 pcre_extra *extra;
00122 };
00123
00125 struct {
00127 int major;
00129 int minor;
00131 char compare;
00134 char has_minor;
00135 };
00136
00138 struct {
00140 ino_t inode;
00142 dev_t dev;
00143 };
00144 };
00145
00147 unsigned short mode_match_and;
00149 unsigned short mode_match_cmp;
00150
00152 unsigned int dir_only:1;
00154 unsigned int is_icase:1;
00157 unsigned int is_user_pat:1;
00158
00160
00161 unsigned int type:3;
00162 };
00163
00172 #define PAT_DEV__UNSPECIFIED (0)
00173 #define PAT_DEV__LESS (1)
00174 #define PAT_DEV__EQUAL (2)
00175 #define PAT_DEV__GREATER (4)
00176 #define PAT_DEV___INVALID_MASK (PAT_DEV__LESS | PAT_DEV__GREATER)
00177 #define PAT_DEV__HAVE_MINOR (0x80)
00178
00182 #define INVALID_INTERNAL_NUMBER (-1)
00183
00184 struct url_t {
00186 char *url;
00189 int priority;
00191 int urllen;
00193 svn_revnum_t target_rev;
00196 svn_revnum_t current_target_rev;
00198 svn_revnum_t current_rev;
00200 svn_revnum_t head_rev;
00202 char *name;
00209 int internal_number;
00212 unsigned count;
00215 svn_ra_session_t *session;
00217 apr_pool_t *pool;
00218
00220 int entry_list_count;
00221
00224 int to_be_handled:1;
00226 int current_target_override:1;
00228 unsigned is_readonly:1;
00229 };
00230
00231
00244
00245
00246
00247
00248 struct sstat_t {
00249
00250 union {
00252 struct timespec mtim;
00255 unsigned long long _mtime;
00256 };
00257 union {
00259 struct timespec ctim;
00262 unsigned long long _ctime;
00263 };
00264
00265 union {
00267 off_t size;
00269 dev_t rdev;
00270 };
00271
00273 dev_t dev;
00275 ino_t ino;
00276
00279 mode_t mode;
00280
00282 uid_t uid;
00284 gid_t gid;
00285 };
00286
00287
00288
00297 struct estat {
00300 struct estat *parent;
00302 char *name;
00303
00307 struct sstat_t st;
00308
00311 svn_revnum_t repos_rev;
00313 svn_revnum_t old_rev;
00314
00317 struct url_t *url;
00318
00322 struct estat *old;
00323
00325 union {
00327 struct {
00332 char *decoder;
00335 md5_digest_t md5;
00338 unsigned int has_orig_md5:1;
00342 unsigned int change_flag:2;
00343 };
00349 struct {
00353 char *strings;
00357 struct estat **by_inode;
00362 struct estat **by_name;
00363
00365 AC_CV_C_UINT32_T entry_count;
00366
00372 AC_CV_C_UINT32_T unfinished;
00373
00376 unsigned int other_revs:1;
00380 unsigned int to_be_sorted:1;
00381
00382 #if 0
00383 struct ignore_t **active_ign;
00384 struct ignore_t **subdir_ign;
00385 #endif
00386 };
00387 };
00388
00390 union {
00392 struct {
00394 void *baton;
00395 };
00397 struct {
00399 apr_pool_t *filehandle_pool;
00400 };
00402 struct {
00406 svn_stringbuf_t *stringbuf_tgt;
00407 };
00408 struct {
00410 AC_CV_C_UINT32_T child_index;
00411 };
00412 struct {
00414 AC_CV_C_UINT32_T file_index;
00415 };
00416 };
00417
00418
00421 char *arg;
00422
00425 struct ignore_t *match_pattern;
00426
00432 apr_hash_t *user_prop;
00433
00435 AC_CV_C_UINT32_T flags;
00436
00437
00448 unsigned old_rev_mode_packed:PACKED_MODE_T_NEEDED_BITS;
00450 unsigned new_rev_mode_packed:PACKED_MODE_T_NEEDED_BITS;
00453 unsigned local_mode_packed:PACKED_MODE_T_NEEDED_BITS;
00458 unsigned int entry_status:10;
00459
00461 unsigned int remote_status:10;
00462
00463
00468 unsigned int cache_index:6;
00469
00470
00473 unsigned short path_len:16;
00474
00477 unsigned int was_output:1;
00481 unsigned int decoder_is_correct:1;
00482
00485 unsigned int do_userselected:1;
00490 unsigned int do_child_wanted:1;
00493 unsigned int do_this_entry:1;
00497 unsigned int do_filter_allows:1;
00501 unsigned int do_filter_allows_done:1;
00502
00505 unsigned int to_be_ignored:1;
00506 };
00507
00508
00511 #define S_IFUNDEF (0)
00512
00516 #define S_IFANYSPECIAL S_IFSOCK
00517 #define S_ISANYSPECIAL S_ISSOCK
00518
00520 #define S_IFGARBAGE S_IFIFO
00521 #define S_ISGARBAGE S_ISFIFO
00522
00530 #define RF_UNVERSION (1)
00531
00534 #define RF_ADD (2)
00535
00540 #define RF_CHECK (4)
00541
00544 #define RF_PUSHPROPS (8)
00545
00549 #define RF_COPY_BASE (16)
00550
00551 #define RF_COPY_SUB (32)
00552
00553 #define RF_CONFLICT (64)
00554
00555 #define RF_DONT_WRITE (1 << 18)
00556
00557 #define RF_ISNEW (1 << 19)
00558
00559 #define RF_PRINT (1 << 20)
00560
00562 #define RF___SAVE_MASK (RF_UNVERSION | RF_ADD | RF_CHECK | \
00563 RF_COPY_BASE | RF_COPY_SUB | RF_PUSHPROPS | RF_CONFLICT)
00564
00567 #define RF___COMMIT_MASK (RF_UNVERSION | RF_ADD | RF_COPY_BASE | RF_PUSHPROPS)
00568 #define RF___IS_COPY (RF_COPY_BASE | RF_COPY_SUB)
00569
00570
00571
00576 #define FS_NO_CHANGE (0)
00577 #define FS_NEW (1 << 0)
00578 #define FS_REMOVED (1 << 1)
00579 #define FS_CHANGED (1 << 2)
00580
00582 #define FS_LIKELY (1 << 3)
00583 #define FS_REPLACED (FS_NEW | FS_REMOVED)
00584
00589 #define FS_PROPERTIES (1 << 4)
00590
00591
00593 #define FS_META_MTIME (1 << 5)
00594 #define FS_META_OWNER (1 << 6)
00595 #define FS_META_GROUP (1 << 7)
00596 #define FS_META_UMODE (1 << 8)
00597
00598 #define FS_META_CHANGED (FS_META_MTIME | FS_META_OWNER | \
00599 FS_META_GROUP | FS_META_UMODE)
00600
00604 #define FS_CHILD_CHANGED (1 << 9)
00605
00606 #define FS__CHANGE_MASK (FS_NEW | FS_REMOVED | FS_CHANGED | \
00607 FS_META_CHANGED | FS_PROPERTIES)
00608
00612 #define CF_UNKNOWN (0)
00613 #define CF_CHANGED (1)
00614 #define CF_NOTCHANGED (2)
00615
00621 #define OPS__CREATE (1)
00622
00623 #define OPS__ON_UPD_LIST (2)
00624
00626 #define OPS__FAIL_NOT_LIST (4)
00627
00629 #define OPS__FAIL_NOT_FS (16)
00630
00631
00632
00641 #ifdef ENABLE_RELEASE
00642 #define DEBUGP(...) do { } while (0)
00643 #else
00644
00645 extern void _DEBUGP(const char *file, int line, const char *func, char *format, ...)
00646 __attribute__ ((format (printf, 4, 5) ));
00651 #define DEBUGP(...) do { if (debuglevel) _DEBUGP(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__); } while (0)
00652 #endif
00653
00654
00681 extern int make_STOP_silent;
00683 extern int _STOP(const char *file, int line, const char *function,
00684 int errl, const char *format, ...)
00685 __attribute__ ((format (printf, 5, 6) ));
00692 #define STOPIF_FULLPARM(cond, status, code, go, ... ) \
00693 do \
00694 { \
00695 if (cond) \
00696 { \
00697 status=code; \
00698 _STOP(__FILE__, __LINE__, __PRETTY_FUNCTION__, code, __VA_ARGS__); \
00699 goto go; \
00700 } \
00701 } while (0)
00702
00704 #define STOPIF_CODE_ERR_GOTO(cond, code, ex, ... ) STOPIF_FULLPARM(cond, status, code, ex, __VA_ARGS__)
00705
00715 #define STOPIF_CODE_ERR(cond, code, ... ) STOPIF_CODE_ERR_GOTO(cond, code, ex, __VA_ARGS__)
00716
00717
00718
00719
00720 #define STOPIF(code, ... ) \
00721 do \
00722 { \
00723 status=(code); \
00724 if (status) \
00725 { \
00726 _STOP(__FILE__, __LINE__, __PRETTY_FUNCTION__, status, __VA_ARGS__); \
00727 goto ex; \
00728 } \
00729 } while (0)
00730
00738 #define STOPIF_ENOMEM(cond) STOPIF_CODE_ERR(cond, ENOMEM, NULL)
00739
00744 #define STOPIF_CODE_EPIPE(code, ...) \
00745 do \
00746 { \
00747 if ((code) < 0) \
00748 { \
00749 status=errno; \
00750 if (status == EPIPE) status= -EPIPE; \
00751 STOPIF(status, "Error writing output"); \
00752 } \
00753 } while (0)
00754
00775 #define STOPIF_SVNERR_TEXT(func, parm, fmt, ...) \
00776 do \
00777 { \
00778 status_svn=func parm; \
00779 STOPIF_CODE_ERR( status_svn, status_svn->apr_err, \
00780 fmt ": %s", ## __VA_ARGS__, status_svn->message); \
00781 } while (0)
00782
00783
00784
00785
00786
00787
00788
00789 #define STOPIF_SVNERR(func, parm) STOPIF_SVNERR_TEXT(func, parm, #func)
00790
00791 #define STOP_HANDLE_SVNERR(svnerr) STOPIF_CODE_ERR_GOTO(svnerr, svnerr->apr_err, ex2, (const char*)svnerr->message)
00792
00797 #define RETURN_SVNERR(status) return status ? \
00798 svn_error_create (status, NULL, \
00799 __PRETTY_FUNCTION__) : SVN_NO_ERROR;
00800
00801
00807 #define BUG(...) do { fflush(NULL); debuglevel=1; DEBUGP(__VA_ARGS__); *(int*)42=__LINE__; } while (0)
00808
00817 #define BUG_ON(cond, ...) do { if (cond) BUG( "INTERNAL BUG\n " #cond "\n " __VA_ARGS__); } while (0)
00818
00827 #define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len) do { } while(0)
00828 #define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len) do { } while(0)
00829 #define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len) do { } while(0)
00830
00831 #ifdef ENABLE_DEBUG
00832 #ifdef HAVE_VALGRIND
00833 #undef VALGRIND_MAKE_MEM_DEFINED
00834 #undef VALGRIND_MAKE_MEM_UNDEFINED
00835 #undef VALGRIND_MAKE_MEM_NOACCESS
00836 #include <valgrind/memcheck.h>
00837 #endif
00838 #endif
00839
00852 extern int opt_recursive;
00855 extern int is_import_export;
00857 extern int debuglevel;
00858
00860 extern char *opt_commitmsg;
00862 extern char *opt_commitmsgfile;
00863
00865 extern svn_revnum_t target_revision;
00869 extern svn_revnum_t opt_target_revision;
00871 extern svn_revnum_t opt_target_revision2;
00877 extern int opt_target_revisions_given;
00878
00880 #ifdef HAVE_LOCALES
00881 extern char *local_codeset;
00882 #endif
00883
00885 extern svn_ra_session_t *session;
00886
00889 extern apr_pool_t *global_pool;
00890
00892 extern struct url_t **urllist;
00894 extern int urllist_count;
00896 extern struct url_t *current_url;
00897
00898 extern unsigned approx_entry_count;
00903 extern char propname_mtime[];
00905 extern char propname_owner[];
00907 extern char propname_group[];
00909 extern char propname_umode[];
00911 extern char propname_origmd5[];
00913 extern char propname_special[];
00915 extern char propval_special[];
00916
00918 extern char propval_commitpipe[];
00920 extern char propval_updatepipe[];
00921
00922
00929 extern char parm_dump[],
00930 parm_test[],
00931 parm_load[];
00935 extern char *start_path;
00937 extern int start_path_len;
00938
00945 #define ANSI__BLUE "\x1b[1;34m"
00946 #define ANSI__GREEN "\x1b[1;32m"
00947 #define ANSI__RED "\x1b[1;31m"
00948 #define ANSI__WHITE "\x1b[1;37m"
00949 #define ANSI__NORMAL "\x1b[0;0m"
00950
00953 extern char **environ;
00954
00955 #endif