global.h File Reference

Global definitions. More...

#include "config.h"
#include "preproc.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <gdbm.h>
#include <stddef.h>
#include <apr_md5.h>
#include <apr_file_io.h>
#include <subversion-1/svn_ra.h>
#include <subversion-1/svn_string.h>
#include <pcre.h>
#include <valgrind/memcheck.h>
Include dependency graph for global.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ignore_t
 Data storage for ignore patterns. More...
struct  url_t
 All the data FSVS must know about an URL. More...
struct  sstat_t
 A shortened struct stat64. More...
struct  estat
 The central structure for data storage. More...

Defines

#define IF_FREE(x)   do { if (x) free(x); x=NULL; } while (0)
 If this pointer is non-NULL, free() it and set it to NULL, to avoid repeated free()ing.
#define UNUSED   __attribute__ ((__unused__))
 We have some functions which don't use all parameters.
#define INVALID_INTERNAL_NUMBER   (-1)
 The special value used for a not-yet-valid url_t::internal_number.
#define RF_UNVERSION   (1)
 This item will be unversioned, ie remotely deleted and locally purged from the tree, but not from the filesystem.
#define RF_ADD   (2)
 Such an entry will be sent to the repository as a new item.
#define RF_CHECK   (4)
 This entry should be checked for modifications.
#define RF_PUSHPROPS   (8)
 Properties have changed locally, must be committed.
#define RF_COPY_BASE   (16)
 Set if this entry was marked as copy.
#define RF_COPY_SUB   (32)
 Set if this entry got implicitly copied (sub-entry).
#define RF_CONFLICT   (64)
 Has this entry a conflict?
#define RF_DONT_WRITE   (1 << 18)
 This entry may not be written by waa__output_tree().
#define RF_ISNEW   (1 << 19)
 Whether this entry was just created by ops__traverse().
#define RF_PRINT   (1 << 20)
 Print this entry, even if not changed.
#define RF___SAVE_MASK
 Which of the flags above should be stored in the WAA.
#define RF___COMMIT_MASK   (RF_UNVERSION | RF_ADD | RF_COPY_BASE | RF_PUSHPROPS)
 Mask for commit-relevant flags.
#define RF___IS_COPY   (RF_COPY_BASE | RF_COPY_SUB)
#define CF_UNKNOWN   (0)
#define CF_CHANGED   (1)
#define CF_NOTCHANGED   (2)
#define OPS__CREATE   (1)
 Non-existing paths should be created.
#define OPS__ON_UPD_LIST   (2)
 Newly created entries should be put on the update list.
#define OPS__FAIL_NOT_LIST   (4)
 Whether this entry has to exist in the cached tree -- normally that means it must not be created.
#define OPS__FAIL_NOT_FS   (16)
 With this flag ops__traverse returns ENOENT if the entry does not exist in the local filesystem.
#define DEBUGP(...)   do { if (debuglevel) _DEBUGP(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__); } while (0)
 The macro used for printing debug messages.



#define PATH_SEPARATOR   ('/')
 The system-specific character to delimit directories.
#define ENVIRONMENT_START   ('$')
 The system-specific character to be used before environment variables.
#define S_IFUNDEF   (0)
#define S_IFANYSPECIAL   S_IFSOCK
 All sockets get filtered out when the directory gets read, so we can safely reuse that value for the case where we don't know what kind of special entry that is (eg when receiving "svn:special" from the repository).
#define S_ISANYSPECIAL   S_ISSOCK
#define S_IFGARBAGE   S_IFIFO
 These values are used to say that such an entry is lying around and has to be removed first.
#define S_ISGARBAGE   S_ISFIFO
#define ANSI__BLUE   "\x1b[1;34m"
 ANSI color sequences, for colorized outputs.
#define ANSI__GREEN   "\x1b[1;32m"
#define ANSI__RED   "\x1b[1;31m"
#define ANSI__WHITE   "\x1b[1;37m"
#define ANSI__NORMAL   "\x1b[0;0m"
Pattern types.

The ignore/take specifications can be in several forms; please see the doc/IGNORING documentation.



#define PT_SHELL   (1)
#define PT_PCRE   (2)
#define PT_DEVICE   (3)
#define PT_INODE   (4)
#define PT_SHELL_ABS   (5)
#define PAT_DEV__UNSPECIFIED   (0)
 Whether the device compare should be for equal, lesser or higher devices.
#define PAT_DEV__LESS   (1)
#define PAT_DEV__EQUAL   (2)
#define PAT_DEV__GREATER   (4)
#define PAT_DEV___INVALID_MASK   (PAT_DEV__LESS | PAT_DEV__GREATER)
#define PAT_DEV__HAVE_MINOR   (0x80)
File statii.



#define FS_NO_CHANGE   (0)
#define FS_NEW   (1 << 0)
#define FS_REMOVED   (1 << 1)
#define FS_CHANGED   (1 << 2)
#define FS_LIKELY   (1 << 3)
 This flag says that it's an "approximate" answer, - no hashing has been done.
#define FS_REPLACED   (FS_NEW | FS_REMOVED)
#define FS_PROPERTIES   (1 << 4)
 Flag for update/commit.
#define FS_META_MTIME   (1 << 5)
 Meta-data flags.
#define FS_META_OWNER   (1 << 6)
#define FS_META_GROUP   (1 << 7)
#define FS_META_UMODE   (1 << 8)
#define FS_META_CHANGED
#define FS_CHILD_CHANGED   (1 << 9)
 This flag on a directory entry says that the directory itself was not changed, but some child, so the children of this directory have to be checked for modifications.
#define FS__CHANGE_MASK
Runtime check macros



#define BUG(...)   do { fflush(NULL); debuglevel=1; DEBUGP(__VA_ARGS__); *(int*)42=__LINE__; } while (0)
 Makes the program abort.
#define BUG_ON(cond,...)   do { if (cond) BUG( "INTERNAL BUG\n " #cond "\n " __VA_ARGS__); } while (0)
 The same as BUG(), but conditionalized.
Valgrind memory addressing checking.

These are copied from valgrind/memcheck.h; they will be overridden by the correct valgrind definitions if the valgrind headers are found and fsvs is configured with --enable-debug.



#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr, _qzz_len)   do { } while(0)
#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr, _qzz_len)   do { } while(0)
#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr, _qzz_len)   do { } while(0)

Typedefs

typedef unsigned char md5_digest_t [APR_MD5_DIGESTSIZE]
 A type for holding an MD5 digest.
typedef unsigned long long t_ull
typedef long long t_ll
typedef unsigned long t_ul

Functions

void _DEBUGP (const char *file, int line, const char *func, char *format,...) __attribute__((format(printf
 Declaration of the debug function.

Variables

int opt_recursive
 Flag for recursive/non-recursive behaviour.
int is_import_export
 If this is an import/export command (eg restoration after harddisk crash), we don't use the WAA for data storage.
int debuglevel
 Whether debug messages are wanted.
char * opt_commitmsg
 A pointer to the commit message; possibly a mmap()ped file.
char * opt_commitmsgfile
 The file name of the commit message file.
svn_revnum_t target_revision
 The revision we're getting from the repository.
svn_revnum_t opt_target_revision
 The revision the user wants to get at (-r parameter).
svn_revnum_t opt_target_revision2
 The second revision number the user specified.
int opt_target_revisions_given
 How many revisions the user specified on the commandline (0, 1 or 2).
char * local_codeset
 The local character encoding, according to LC_ALL or LC_CTYPE).
svn_ra_session_t * session
 The session handle for RA operations.
apr_pool_t * global_pool
 The first allocated APR pool.
struct url_t ** urllist
 The array of URLs.
int urllist_count
 Number of URLs we have.
struct url_tcurrent_url
 Pointer to current URL.
unsigned approx_entry_count
 How many entries we have; this is used to show the user some kind of progress report, in percent.
char propname_mtime []
 Modification time - svn:text-time.
char propname_owner []
 Owner - svn:owner.
char propname_group []
 Group - svn:group.
char propname_umode []
 Unix mode - svn:unix-mode.
char propname_origmd5 []
 Original MD5 for encoded entries.
char propname_special []
 Flag for special entry.
char propval_special []
 The value for the special property; normally "*".
char propval_commitpipe []
 Commit-pipe program.
char propval_updatepipe []
 Update-pipe program.
char parm_dump []
 -.
char parm_test []
char parm_load []
char * start_path
 Remember where we started.
int start_path_len
 How much bytes the start_path has.
char ** environ
 For Solaris.

Error-printing and -handling functions.

Except for the subversion-library wrapper macros they need exactly this function layout:

   int some_function( ... some args ... )
   {
     int status;

     STOPIF( function_call(1, 2, "a"), 
       "String describing the error situation with %s",
       "parameters as needed");

   ex:
     cleanups();
     return status;
   }

It works by checking the return value; if it is not zero, a goto ex is done. At this mark some cleanup is possible.



#define STOPIF_FULLPARM(cond, status, code, go,...)
 Completely customizable error call macro.
#define STOPIF_CODE_ERR_GOTO(cond, code, ex,...)   STOPIF_FULLPARM(cond, status, code, ex, __VA_ARGS__)
 Another error call macro.
#define STOPIF_CODE_ERR(cond, code,...)   STOPIF_CODE_ERR_GOTO(cond, code, ex, __VA_ARGS__)
 Error call macro for system functions.
#define STOPIF(code,...)
#define STOPIF_ENOMEM(cond)   STOPIF_CODE_ERR(cond, ENOMEM, NULL)
 A simplified error call macro for returning ENOMEM.
#define STOPIF_CODE_EPIPE(code,...)
 An error return macro that is used for user output - special handling EPIPE to get a silent return.
#define STOPIF_SVNERR_TEXT(func, parm, fmt,...)
 The master error macro for calling subversion functions.
#define STOPIF_SVNERR(func, parm)   STOPIF_SVNERR_TEXT(func, parm, #func)
#define STOP_HANDLE_SVNERR(svnerr)   STOPIF_CODE_ERR_GOTO(svnerr, svnerr->apr_err, ex2, (const char*)svnerr->message)
 Convert the svn_error_t into a message and a returnable integer.
#define RETURN_SVNERR(status)
 The opposite to STOP_HANDLE_SVNERR(); this converts an status to the svn_error_t.
int make_STOP_silent
 A flag to turn error printing temporarily off.
int _STOP (const char *file, int line, const char *function, int errl, const char *format,...) __attribute__((format(printf
 Master error function.

Detailed Description

Global definitions.

Here are things defined that are needed in almost every action.

Definition in file global.h.


Define Documentation

#define ANSI__BLUE   "\x1b[1;34m"

ANSI color sequences, for colorized outputs.

I tried using ncurses - but that messes with the terminal upon initialization. I couldn't find a sane way to make that work. Anybody?

Todo:
We assume light text on dark background here.

Definition at line 945 of file global.h.

Referenced by log___divider(), and st___color().

#define ANSI__GREEN   "\x1b[1;32m"

Definition at line 946 of file global.h.

Referenced by log__receiver(), and st___color().

#define ANSI__NORMAL   "\x1b[0;0m"

Definition at line 949 of file global.h.

Referenced by log__receiver(), log__work(), and st__print_status().

#define ANSI__RED   "\x1b[1;31m"

Definition at line 947 of file global.h.

Referenced by st___color().

#define ANSI__WHITE   "\x1b[1;37m"

Definition at line 948 of file global.h.

#define ENVIRONMENT_START   ('$')

The system-specific character to be used before environment variables.

For DOS-compatibility printing that behind the name would be necessary, too - therefore it's not automatic per configure.

Definition at line 43 of file global.h.

Referenced by hlp__format_path(), and hlp__match_path_envs().

#define IF_FREE (  )     do { if (x) free(x); x=NULL; } while (0)
#define INVALID_INTERNAL_NUMBER   (-1)

The special value used for a not-yet-valid url_t::internal_number.

Definition at line 182 of file global.h.

Referenced by url___set_internal_nums(), and url__parse().

#define OPS__CREATE   (1)

Non-existing paths should be created.

Flags defining the behaviour of \ref ops__traverse()

and sub-calls.

Definition at line 621 of file global.h.

Referenced by cm___make_copy(), ops__traverse(), prp__s_work(), and waa__partial_update().

#define OPS__FAIL_NOT_FS   (16)

With this flag ops__traverse returns ENOENT if the entry does not exist in the local filesystem.

Definition at line 629 of file global.h.

#define OPS__FAIL_NOT_LIST   (4)

Whether this entry has to exist in the cached tree -- normally that means it must not be created.

Definition at line 626 of file global.h.

Referenced by cat__work(), cm__uncopy(), ops__traverse(), prp__s_work(), and waa__partial_update().

#define OPS__ON_UPD_LIST   (2)

Newly created entries should be put on the update list.

Definition at line 623 of file global.h.

Referenced by ops__traverse(), and waa__partial_update().

#define PAT_DEV___INVALID_MASK   (PAT_DEV__LESS | PAT_DEV__GREATER)

Definition at line 176 of file global.h.

#define PAT_DEV__EQUAL   (2)

Definition at line 174 of file global.h.

Referenced by ign___init_pattern_into(), and ign__is_ignore().

#define PAT_DEV__GREATER   (4)

Definition at line 175 of file global.h.

Referenced by ign___init_pattern_into(), and ign__is_ignore().

#define PAT_DEV__HAVE_MINOR   (0x80)

Definition at line 177 of file global.h.

#define PAT_DEV__LESS   (1)

Definition at line 173 of file global.h.

Referenced by ign___init_pattern_into(), and ign__is_ignore().

#define PAT_DEV__UNSPECIFIED   (0)

Whether the device compare should be for equal, lesser or higher devices.

If the device numbers get completely randomized (was discussed on linux-kernel some time ago) this will be useless; we'll have to add another pattern type like eg. all devices with a major number like the device node /dev/ram0 to make sense again.

Definition at line 172 of file global.h.

Referenced by ign___init_pattern_into().

#define PATH_SEPARATOR   ('/')
#define PT_DEVICE   (3)

Definition at line 81 of file global.h.

Referenced by ign___init_pattern_into(), and ign__is_ignore().

#define PT_INODE   (4)

Definition at line 82 of file global.h.

Referenced by ign___init_pattern_into(), and ign__is_ignore().

#define PT_PCRE   (2)

Definition at line 80 of file global.h.

Referenced by ign___init_pattern_into(), ign__compile_pattern(), and ign__is_ignore().

#define PT_SHELL   (1)

Definition at line 79 of file global.h.

Referenced by ign___init_pattern_into(), ign__compile_pattern(), and ign__is_ignore().

#define PT_SHELL_ABS   (5)

Definition at line 83 of file global.h.

Referenced by ign___init_pattern_into(), ign__compile_pattern(), and ign__is_ignore().

#define UNUSED   __attribute__ ((__unused__))

We have some functions which don't use all parameters.

Definition at line 47 of file global.h.

Referenced by cb___absent_directory(), cb___absent_file(), cb___set_target_revision(), ci__callback(), ign__is_ignore(), up__abort_edit(), up__absent_directory(), up__absent_file(), and up__close_edit().


Typedef Documentation

typedef unsigned char md5_digest_t[APR_MD5_DIGESTSIZE]

A type for holding an MD5 digest.

Only the digest, not the working data set.

Definition at line 52 of file global.h.


Variable Documentation

char** environ

For Solaris.

Definition at line 360 of file fsvs.c.

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

Group - svn:group.

Definition at line 308 of file props.c.

Referenced by ci___set_props(), and up__parse_prop().

Modification time - svn:text-time.

Property names from the subversion name-space

FSVS has a number of reserved property names, where it stores the meta-data and other per-entry data in the repository.

Property names from the subversion name-space

Such names are already in use in the mtime and meta-data branches of subversion; we use the values defined in svn_props.h (if any), or use the originally used values to be compatible.

These start all with the string defined in SVN_PROP_PREFIX, which is svn: .

Definition at line 304 of file props.c.

Referenced by ci___set_props(), and up__parse_prop().

Original MD5 for encoded entries.

Definition at line 310 of file props.c.

Referenced by ci__nondir(), and up__parse_prop().

Owner - svn:owner.

Definition at line 306 of file props.c.

Referenced by ci___set_props(), and up__parse_prop().

Flag for special entry.

Flag for special entry.

Subversion defines that for symlinks; we use that for devices, too.

Definition at line 315 of file props.c.

Referenced by ci__nondir(), rev__install_file(), and up__parse_prop().

Unix mode - svn:unix-mode.

Definition at line 312 of file props.c.

Referenced by ci___set_props(), and up__parse_prop().

Commit-pipe program.

Commit-pipe program.

This will get the local file as STDIN, and its output goes to the repository. See FSVS_PROP_COMMIT_PIPE.

Definition at line 322 of file props.c.

Referenced by ci___send_user_props().

The value for the special property; normally "*".

Definition at line 317 of file props.c.

Referenced by ci__nondir(), and up__parse_prop().

Update-pipe program.

Update-pipe program.

This will get the repository file as STDIN, and its output goes to a local temporary file, which gets installed. See FSVS_PROP_UPDATE_PIPE.

Definition at line 327 of file props.c.

Referenced by rev__get_text_to_stream(), sync___recurse(), up__fetch_decoder(), and up__parse_prop().

char* start_path

Remember where we started.

Definition at line 347 of file fsvs.c.

Referenced by hlp__pathcopy(), ign__work(), main(), and waa__find_common_base2().

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