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

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

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

diff --git a/src/common.h b/src/common.h
index 939c9e53..55a20a20 100644
--- 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
index d7eac087..10a12062 100644
--- 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
index bcc9c9aa..375ef8c0 100644
--- 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
index b9299fd4..1ebed1e6 100644
--- 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
index 0a656283..bf41d8a3 100644
--- 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
index b54daeae..dbcbeded 100644
--- 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
index 9b2e28d7..ec9561e3 100644
--- 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
index f2819cf9..94969807 100644
--- 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


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to