Browse Source

shuffle around global variables

the new organization clarifies the ownership, making things more
self-contained. this will potentially help with unit testing.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
98f4fd4586
  1. 9
      src/common.h
  2. 6
      src/config.c
  3. 2
      src/config.h
  4. 18
      src/main.c
  5. 6
      src/sync.c
  6. 6
      src/sync.h
  7. 4
      src/tst_timers.c
  8. 8
      src/util.c

9
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 */

6
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 *

2
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

18
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 )

6
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)

6
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 */

4
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;

8
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

Loading…
Cancel
Save