shuffle around global variables

the new organization clarifies the ownership, making things more
self-contained. this will potentially help with unit testing.
This commit is contained in:
Oswald Buddenhagen 2022-04-24 14:30:10 +02:00
parent 0f2220634d
commit 98f4fd4586
8 changed files with 30 additions and 29 deletions

View File

@ -96,21 +96,16 @@ typedef unsigned long ulong;
#define DEBUG_ANY (DEBUG_MAILDIR | DEBUG_NET | DEBUG_SYNC | DEBUG_MAIN | DEBUG_DRV) #define DEBUG_ANY (DEBUG_MAILDIR | DEBUG_NET | DEBUG_SYNC | DEBUG_MAIN | DEBUG_DRV)
#define DEBUG_ALL (DEBUG_ANY | DEBUG_CRASH) #define DEBUG_ALL (DEBUG_ANY | DEBUG_CRASH)
// Global options
extern int DFlags; extern int DFlags;
extern int JLimit; extern int JLimit;
extern int UseFSync; extern int UseFSync;
extern char FieldDelimiter;
// Global constants (inited by main())
extern int Pid; extern int Pid;
extern char Hostname[256]; extern char Hostname[256];
extern const char *Home; 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 ); void stats( void );
/* util.c */ /* util.c */

View File

@ -19,6 +19,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.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; static store_conf_t *stores;
char * char *

View File

@ -21,6 +21,8 @@ typedef struct {
char *cmd, *val, *rest; char *cmd, *val, *rest;
} conffile_t; } conffile_t;
extern char FieldDelimiter;
#define ARG_OPTIONAL 0 #define ARG_OPTIONAL 0
#define ARG_REQUIRED 1 #define ARG_REQUIRED 1

View File

@ -19,26 +19,8 @@
# include <sys/prctl.h> # include <sys/prctl.h>
#endif #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 chans_total, chans_done;
static int boxes_total, boxes_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 static void ATTR_NORETURN
version( void ) version( void )

View File

@ -30,6 +30,12 @@ channel_conf_t global_conf;
channel_conf_t *channels; channel_conf_t *channels;
group_conf_t *groups; 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" }; const char *str_fn[] = { "far side", "near side" }, *str_hl[] = { "push", "pull" };
static void ATTR_PRINTFLIKE(1, 2) static void ATTR_PRINTFLIKE(1, 2)

View File

@ -53,6 +53,12 @@ extern channel_conf_t global_conf;
extern channel_conf_t *channels; extern channel_conf_t *channels;
extern group_conf_t *groups; 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]; extern const char *str_fn[2], *str_hl[2];
#define SYNC_OK 0 /* assumed to be 0 */ #define SYNC_OK 0 /* assumed to be 0 */

View File

@ -10,10 +10,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
/* Just to satisfy the references in util.c */
int DFlags;
const char *Home;
typedef struct { typedef struct {
int id; int id;
int first, other, morph_at, morph_to; int first, other, morph_at, morph_to;

View File

@ -17,6 +17,14 @@
#include <ctype.h> #include <ctype.h>
#include <pwd.h> #include <pwd.h>
int DFlags;
int JLimit;
int UseFSync = 1;
int Pid;
char Hostname[256];
const char *Home;
static int need_nl; static int need_nl;
void void