isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 98f4fd45864c4ffac5b1c310f7efa53187d54a84
parent 0f2220634dcbb2248134d4dc3b4b61d3eed0c016
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Sun, 24 Apr 2022 14:30:10 +0200

shuffle around global variables

the new organization clarifies the ownership, making things more
self-contained. this will potentially help with unit testing.

Diffstat:
Msrc/common.h | 9++-------
Msrc/config.c | 6++++++
Msrc/config.h | 2++
Msrc/main.c | 18------------------
Msrc/sync.c | 6++++++
Msrc/sync.h | 6++++++
Msrc/tst_timers.c | 4----
Msrc/util.c | 8++++++++
8 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/src/common.h b/src/common.h @@ -96,21 +96,16 @@ typedef unsigned long ulong; #define DEBUG_ANY (DEBUG_MAILDIR | DEBUG_NET | DEBUG_SYNC | DEBUG_MAIN | DEBUG_DRV) #define DEBUG_ALL (DEBUG_ANY | DEBUG_CRASH) +// Global options extern int DFlags; extern int JLimit; extern int UseFSync; -extern char FieldDelimiter; +// Global constants (inited by main()) extern int Pid; extern char Hostname[256]; extern const char *Home; -extern uint BufferLimit; - -extern int new_total[2], new_done[2]; -extern int flags_total[2], flags_done[2]; -extern int trash_total[2], trash_done[2]; - void stats( void ); /* util.c */ diff --git a/src/config.c b/src/config.c @@ -19,6 +19,12 @@ #include <stdlib.h> #include <stdio.h> +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__CYGWIN__) +char FieldDelimiter = ';'; +#else +char FieldDelimiter = ':'; +#endif + static store_conf_t *stores; char * diff --git a/src/config.h b/src/config.h @@ -21,6 +21,8 @@ typedef struct { char *cmd, *val, *rest; } conffile_t; +extern char FieldDelimiter; + #define ARG_OPTIONAL 0 #define ARG_REQUIRED 1 diff --git a/src/main.c b/src/main.c @@ -19,26 +19,8 @@ # include <sys/prctl.h> #endif -int DFlags; -int JLimit; -int UseFSync = 1; -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__CYGWIN__) -char FieldDelimiter = ';'; -#else -char FieldDelimiter = ':'; -#endif - -int Pid; /* for maildir and imap */ -char Hostname[256]; /* for maildir */ -const char *Home; /* for config */ - -uint BufferLimit = 10 * 1024 * 1024; - static int chans_total, chans_done; static int boxes_total, boxes_done; -int new_total[2], new_done[2]; -int flags_total[2], flags_done[2]; -int trash_total[2], trash_done[2]; static void ATTR_NORETURN version( void ) diff --git a/src/sync.c b/src/sync.c @@ -30,6 +30,12 @@ channel_conf_t global_conf; channel_conf_t *channels; group_conf_t *groups; +uint BufferLimit = 10 * 1024 * 1024; + +int new_total[2], new_done[2]; +int flags_total[2], flags_done[2]; +int trash_total[2], trash_done[2]; + const char *str_fn[] = { "far side", "near side" }, *str_hl[] = { "push", "pull" }; static void ATTR_PRINTFLIKE(1, 2) diff --git a/src/sync.h b/src/sync.h @@ -53,6 +53,12 @@ extern channel_conf_t global_conf; extern channel_conf_t *channels; extern group_conf_t *groups; +extern uint BufferLimit; + +extern int new_total[2], new_done[2]; +extern int flags_total[2], flags_done[2]; +extern int trash_total[2], trash_done[2]; + extern const char *str_fn[2], *str_hl[2]; #define SYNC_OK 0 /* assumed to be 0 */ diff --git a/src/tst_timers.c b/src/tst_timers.c @@ -10,10 +10,6 @@ #include <stdlib.h> #include <time.h> -/* Just to satisfy the references in util.c */ -int DFlags; -const char *Home; - typedef struct { int id; int first, other, morph_at, morph_to; diff --git a/src/util.c b/src/util.c @@ -17,6 +17,14 @@ #include <ctype.h> #include <pwd.h> +int DFlags; +int JLimit; +int UseFSync = 1; + +int Pid; +char Hostname[256]; +const char *Home; + static int need_nl; void