Jim's latest fixes (DPRINTF/realloc/strtok_r) merged by hand because I
[iwhd.git] / repo.h
blob23ad4af0b7d31f679976ee6aec2bac5a5753336f
1 #define MY_PORT 9090
3 #if defined(GLOBALS_IMPL)
4 #define GLOBAL(type,name,value) type name = value;
5 #else
6 #define GLOBAL(type,name,value) extern type name;
7 #endif
9 /*
10 * Front-end modes and global usage
12 * The front end might be in one of three modes: FS, repod, or S3. FS mode
13 * is distinguished from the other two by having proxy_host=NULL. (In fact
14 * what the "-f" flag does is set cfg_file=NULL, which suppresses parsing of
15 * the config file; it's the parser that sets proxy_host to some other value.)
16 * If proxy_host!=NULL then proxy_port and s3mode are also valid. If s3mode
17 * in turn is non-zero then proxy_key and proxy_secret are also valid. I've
18 * marked the relevant globals with the modes where they're valid.
20 * NONE OF THIS affects the back ends used for replication. There can be
21 * multiple such back ends, each individually repod or S3 mode with their
22 * own keys/secrets.
25 GLOBAL(int, verbose, 0)
26 GLOBAL(char *, cfg_file, "repo.json")
27 GLOBAL(const char *, proxy_host, NULL) /* always */
28 GLOBAL(unsigned short, proxy_port, MY_PORT+1) /* repod/S3 */
29 GLOBAL(const char *, proxy_key, "foo") /* S3 only */
30 GLOBAL(const char *, proxy_secret, "bar") /* S3 only */
31 GLOBAL(unsigned int, s3mode, 0) /* repod/S3 */
32 GLOBAL(const char *, db_host, "localhost")
33 GLOBAL(unsigned short, db_port, 27017)
34 GLOBAL(char *, me, "here")
36 #define I2P(x) ((void *)(long)(x))
37 #define P2I(x) ((int)(long)(x))
39 #define DPRINTF(fmt,args...) do { \
40 if (verbose) { \
41 printf(fmt,##args); \
42 } \
43 } while (0)
45 #ifndef __attribute__
46 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
47 # define __attribute__(x) /* empty */
48 # endif
49 #endif
51 #ifndef ATTRIBUTE_UNUSED
52 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
53 #endif