]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Simplify the daemon parameter definitions
authorWayne Davison <wayne@opencoder.net>
Wed, 1 Jul 2020 01:16:55 +0000 (18:16 -0700)
committerWayne Davison <wayne@opencoder.net>
Wed, 1 Jul 2020 02:30:28 +0000 (19:30 -0700)
The code now derives all the struct defines, default value assignments,
parser-param defines, and lp_foo() accessor functions from a single list
of daemon parameters.

.gitignore
Makefile.in
NEWS.md
daemon-parm.awk [new file with mode: 0755]
daemon-parm.txt [new file with mode: 0644]
loadparm.c

index 5817ccd590e43cbd2407ce3fc38e4ff4f80c9d13..b8e90ca4f8c3c7de59114e9db7d00b6a08e72b39 100644 (file)
@@ -21,6 +21,7 @@ aclocal.m4
 /help-rsync*.h
 /default-cvsignore.h
 /default-dont-compress.h
+/daemon-parm.h
 /.md2man-works
 /autom4te*.cache
 /confdefs.h
index f5c788db9ae840c69d6adae3ee5fbf8f7e6a69a2..672fcc47cf6694906051a083d286426b14aaa3f7 100644 (file)
@@ -101,7 +101,7 @@ $(CHECK_OBJS): $(HEADERS)
 tls.o xattrs.o: lib/sysxattrs.h
 options.o: latest-year.h help-rsync.h help-rsyncd.h
 exclude.o: default-cvsignore.h
-loadparm.o: default-dont-compress.h
+loadparm.o: default-dont-compress.h daemon-parm.h
 
 flist.o: rounding.h
 
@@ -111,6 +111,9 @@ default-cvsignore.h default-dont-compress.h: rsync.1.md define-from-md.awk
 help-rsync.h help-rsyncd.h: rsync.1.md help-from-md.awk
        $(AWK) -f $(srcdir)/help-from-md.awk -v hfile=$@ $(srcdir)/rsync.1.md
 
+daemon-parm.h: daemon-parm.txt daemon-parm.awk
+       $(AWK) -f $(srcdir)/daemon-parm.awk $(srcdir)/daemon-parm.txt
+
 rounding.h: rounding.c rsync.h proto.h
        @for r in 0 1 3; do \
            if $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o rounding -DEXTRA_ROUNDING=$$r -I. $(srcdir)/rounding.c >rounding.out 2>&1; then \
@@ -228,8 +231,8 @@ proto: proto.h-tstamp
 proto.h: proto.h-tstamp
        @if test -f proto.h; then :; else cp -p $(srcdir)/proto.h .; fi
 
-proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c config.h
-       $(AWK) -f $(srcdir)/mkproto.awk $(srcdir)/*.c $(srcdir)/lib/compat.c
+proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c config.h daemon-parm.h
+       $(AWK) -f $(srcdir)/mkproto.awk $(srcdir)/*.c $(srcdir)/lib/compat.c daemon-parm.h
 
 .PHONY: man
 man: rsync.1 rsync-ssl.1 rsyncd.conf.5
diff --git a/NEWS.md b/NEWS.md
index 1d6dea697ece042cdfe093aae839257914495000..d922e8fb55efddfb67d047f7965678e1259e298b 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -61,6 +61,9 @@ Protocol: 31 (unchanged)
  - Moved the version number out of configure.ac into its own version.h file so
    that we don't need to reconfigure just because the version number changes.
 
+ - Moved the daemon parameter list into daemon-parm.txt so that an awk script
+   can create the interrelated structs and accessors that loadparm.c needs.
+
 ------------------------------------------------------------------------------
 <a name="3.2.1"></a>
 
diff --git a/daemon-parm.awk b/daemon-parm.awk
new file mode 100755 (executable)
index 0000000..efc1547
--- /dev/null
@@ -0,0 +1,114 @@
+#!/usr/bin/awk -f
+
+# The caller must pass arg: daemon-parm.txt
+# The resulting code is output into daemon-parm.h
+
+BEGIN {
+    heading = "/* DO NOT EDIT THIS FILE!  It is auto-generated from a list of values in " ARGV[1] "! */"
+    sect = psect = defines = accessors = prior_ptype = ""
+    values = "\nstatic const all_vars Defaults = {\n    { /* Globals: */\n"
+    params = "\nstatic struct parm_struct parm_table[] = {"
+    exp_line = "\n/********** EXP **********/\n"
+    tdstruct = "typedef struct {"
+}
+
+/^\s*$/ { next }
+/^#/ { next }
+
+/^Globals:/ {
+    if (defines != "") {
+       print "The Globals section must come first!"
+       defines = ""
+       exit
+    }
+    defines = tdstruct
+    exps = exp_values = exp_line
+    sect = "GLOBAL"
+    psect = ", P_GLOBAL, &Vars.g."
+    next
+}
+
+/^Locals:/ {
+    if (sect == "") {
+       print "The Locals section must come after the Globals!"
+       exit
+    }
+    defines = defines exps "} global_vars;\n\n" tdstruct
+    values = values exp_values "\n    }, { /* Locals: */\n"
+    exps = exp_values = exp_line
+    sect = "LOCAL"
+    psect = ", P_LOCAL, &Vars.l."
+    next
+}
+
+/^(STRING|PATH|INTEGER|ENUM|BOOL)/ {
+    ptype = $1
+    name = $2
+    $1 = $2 = ""
+    sub(/^[ \t]+/, "")
+
+    if (ptype != prior_ptype) {
+       defines = defines "\n/********** " ptype " **********/\n"
+       values = values "\n/********** " ptype " **********/\n"
+       params = params "\n"
+       accessors = accessors "\n"
+       prior_ptype = ptype
+    }
+
+    if (ptype == "STRING" || ptype == "PATH") {
+       atype = "STRING"
+       vtype = "char*"
+    } else if (ptype == "BOOL") {
+       atype = vtype = "BOOL"
+    } else {
+       atype = "INTEGER"
+       vtype = "int"
+    }
+
+    # We have 2 variables that don't match their conf string. Oh well...
+    if (name == "bind_address")
+       spname = "address"
+    else if (name == "rsync_port")
+       spname = "port"
+    else {
+       spname = name
+       gsub(/_/, " ", spname)
+       gsub(/-/, "", name)
+    }
+
+    if (ptype == "ENUM")
+       enum = "enum_" name
+    else
+       enum = "NULL"
+
+    defines = defines "\t" vtype " " name ";\n"
+    values = values "\t" $0 ", /* " name " */\n"
+    params = params " {\"" spname "\", P_" ptype psect name ", " enum ", 0},\n"
+    accessors = accessors "FN_" sect "_" atype "(lp_" name ", " name ")\n"
+
+    if (vtype == "char*") {
+       exps = exps "\tBOOL " name "_EXP;\n"
+       exp_values = exp_values "\tFalse, /* " name "_EXP */\n"
+    }
+
+    next
+}
+
+/./ {
+    print "Extraneous line:" $0
+    defines = ""
+    exit
+}
+
+END {
+    if (sect != "" && defines != "") {
+       defines = defines exps "} local_vars;\n\n"
+       defines = defines tdstruct "\n\tglobal_vars g;\n\tlocal_vars l;\n} all_vars;\n"
+       values = values exp_values "\n    }\n};\n\nstatic all_vars Vars;\n"
+       params = params "\n {NULL, P_BOOL, P_NONE, NULL, NULL, 0}\n};\n"
+       print heading "\n\n" defines values params accessors > "daemon-parm.h"
+    } else {
+       print "Failed to parse the data in " ARGV[1]
+       exit 1
+    }
+}
diff --git a/daemon-parm.txt b/daemon-parm.txt
new file mode 100644 (file)
index 0000000..36ae511
--- /dev/null
@@ -0,0 +1,65 @@
+Globals: ================================================================
+
+STRING bind_address            NULL
+STRING daemon_chroot           NULL
+STRING daemon_gid              NULL
+STRING daemon_uid              NULL
+STRING motd_file               NULL
+STRING pid_file                NULL
+STRING socket_options          NULL
+
+INTEGER        listen_backlog          5
+INTEGER        rsync_port              0
+
+BOOL   proxy_protocol          False
+
+Locals: =================================================================
+
+STRING auth_users              NULL
+STRING charset                 NULL
+STRING comment                 NULL
+STRING dont_compress           DEFAULT_DONT_COMPRESS
+STRING early_exec              NULL
+STRING exclude                 NULL
+STRING exclude_from            NULL
+STRING filter                  NULL
+STRING gid                     NULL
+STRING hosts_allow             NULL
+STRING hosts_deny              NULL
+STRING include                 NULL
+STRING include_from            NULL
+STRING incoming_chmod          NULL
+STRING lock_file               DEFAULT_LOCK_FILE
+STRING log_file                NULL
+STRING log_format              "%o %h [%a] %m (%u) %f %l"
+STRING name                    NULL
+STRING outgoing_chmod          NULL
+STRING post-xfer_exec          NULL
+STRING pre-xfer_exec           NULL
+STRING refuse_options          NULL
+STRING secrets_file            NULL
+STRING syslog_tag              "rsyncd"
+STRING uid                     NULL
+
+PATH   path                    NULL
+PATH   temp_dir                NULL
+
+INTEGER        max_connections         0
+INTEGER        max_verbosity           1
+INTEGER        timeout                 0
+
+ENUM   syslog_facility         LOG_DAEMON
+
+BOOL   fake_super              False
+BOOL   forward_lookup          True
+BOOL   ignore_errors           False
+BOOL   ignore_nonreadable      False
+BOOL   list                    True
+BOOL   munge_symlinks          (BOOL)-1
+BOOL   numeric_ids             (BOOL)-1
+BOOL   read_only               True
+BOOL   reverse_lookup          True
+BOOL   strict_modes            True
+BOOL   transfer_logging        False
+BOOL   use_chroot              True
+BOOL   write_only              False
index 180cf82957dd3ed51314ba9d5ce5b18541abdae4..5e532da2018b30e8b843a3389053871051b31e82 100644 (file)
@@ -87,234 +87,6 @@ struct parm_struct {
 #define LP_SNUM_OK(i) ((i) >= 0 && (i) < (int)section_list.count)
 #define SECTION_PTR(s, p) (((char*)(s)) + (ptrdiff_t)(((char*)(p))-(char*)&Vars.l))
 
-/* This structure describes global (ie., server-wide) parameters. */
-typedef struct {
-       char *bind_address;
-       char *daemon_chroot;
-       char *daemon_gid;
-       char *daemon_uid;
-       char *motd_file;
-       char *pid_file;
-       char *socket_options;
-
-       /* Each _EXP var tracks if the associated char* var has been expanded yet or not. */
-       BOOL bind_address_EXP;
-       BOOL daemon_chroot_EXP;
-       BOOL daemon_gid_EXP;
-       BOOL daemon_uid_EXP;
-       BOOL motd_file_EXP;
-       BOOL pid_file_EXP;
-       BOOL socket_options_EXP;
-
-       int listen_backlog;
-       int rsync_port;
-
-       BOOL proxy_protocol;
-} global_vars;
-
-/* This structure describes a single section.  Their order must match the
- * initializers below, which you can accomplish by keeping each sub-section
- * sorted.  (e.g. in vim, just visually select each subsection and use !sort.)
- * NOTE: the char* variables MUST all remain at the start of the struct! */
-typedef struct {
-       char *auth_users;
-       char *charset;
-       char *comment;
-       char *dont_compress;
-       char *early_exec;
-       char *exclude;
-       char *exclude_from;
-       char *filter;
-       char *gid;
-       char *hosts_allow;
-       char *hosts_deny;
-       char *include;
-       char *include_from;
-       char *incoming_chmod;
-       char *lock_file;
-       char *log_file;
-       char *log_format;
-       char *name;
-       char *outgoing_chmod;
-       char *path;
-       char *postxfer_exec;
-       char *prexfer_exec;
-       char *refuse_options;
-       char *secrets_file;
-       char *syslog_tag;
-       char *temp_dir;
-       char *uid;
-
-       /* Each _EXP var tracks if the associated char* var has been expanded yet or not. */
-       BOOL auth_users_EXP;
-       BOOL charset_EXP;
-       BOOL comment_EXP;
-       BOOL dont_compress_EXP;
-       BOOL early_exec_EXP;
-       BOOL exclude_EXP;
-       BOOL exclude_from_EXP;
-       BOOL filter_EXP;
-       BOOL gid_EXP;
-       BOOL hosts_allow_EXP;
-       BOOL hosts_deny_EXP;
-       BOOL include_EXP;
-       BOOL include_from_EXP;
-       BOOL incoming_chmod_EXP;
-       BOOL lock_file_EXP;
-       BOOL log_file_EXP;
-       BOOL log_format_EXP;
-       BOOL name_EXP;
-       BOOL outgoing_chmod_EXP;
-       BOOL path_EXP;
-       BOOL postxfer_exec_EXP;
-       BOOL prexfer_exec_EXP;
-       BOOL refuse_options_EXP;
-       BOOL secrets_file_EXP;
-       BOOL syslog_tag_EXP;
-       BOOL temp_dir_EXP;
-       BOOL uid_EXP;
-
-       int max_connections;
-       int max_verbosity;
-       int syslog_facility;
-       int timeout;
-
-       BOOL fake_super;
-       BOOL forward_lookup;
-       BOOL ignore_errors;
-       BOOL ignore_nonreadable;
-       BOOL list;
-       BOOL munge_symlinks;
-       BOOL numeric_ids;
-       BOOL read_only;
-       BOOL reverse_lookup;
-       BOOL strict_modes;
-       BOOL transfer_logging;
-       BOOL use_chroot;
-       BOOL write_only;
-} local_vars;
-
-/* This structure describes the global variables (g) as well as the globally
- * specified values of the local variables (l), which are used when modules
- * don't specify their own values. */
-typedef struct {
-       global_vars g;
-       local_vars l;
-} all_vars;
-
-/* The application defaults for all the variables.  "Defaults" is
- * used to re-initialize "Vars" before each config-file read.
- *
- * In order to keep these sorted in the same way as the structure
- * above, use the variable name in the leading comment, including a
- * trailing ';' (to avoid a sorting problem with trailing digits). */
-static const all_vars Defaults = {
- /* ==== global_vars ==== */
- {
- /* bind_address; */           NULL,
- /* daemon_chroot; */          NULL,
- /* daemon_gid; */             NULL,
- /* daemon_uid; */             NULL,
- /* motd_file; */              NULL,
- /* pid_file; */               NULL,
- /* socket_options; */         NULL,
-
- /* bind_address_EXP; */       False,
- /* daemon_chroot_EXP; */      False,
- /* daemon_gid_EXP; */         False,
- /* daemon_uid_EXP; */         False,
- /* motd_file_EXP; */          False,
- /* pid_file_EXP; */           False,
- /* socket_options_EXP; */     False,
-
- /* listen_backlog; */         5,
- /* rsync_port; */             0,
-
- /* proxy_protocol; */         False,
- },
-
- /* ==== local_vars ==== */
- {
- /* auth_users; */             NULL,
- /* charset; */                NULL,
- /* comment; */                NULL,
- /* dont_compress; */          DEFAULT_DONT_COMPRESS,
- /* early_exec; */             NULL,
- /* exclude; */                NULL,
- /* exclude_from; */           NULL,
- /* filter; */                 NULL,
- /* gid; */                    NULL,
- /* hosts_allow; */            NULL,
- /* hosts_deny; */             NULL,
- /* include; */                        NULL,
- /* include_from; */           NULL,
- /* incoming_chmod; */         NULL,
- /* lock_file; */              DEFAULT_LOCK_FILE,
- /* log_file; */               NULL,
- /* log_format; */             "%o %h [%a] %m (%u) %f %l",
- /* name; */                   NULL,
- /* outgoing_chmod; */         NULL,
- /* path; */                   NULL,
- /* postxfer_exec; */          NULL,
- /* prexfer_exec; */           NULL,
- /* refuse_options; */         NULL,
- /* secrets_file; */           NULL,
- /* syslog_tag; */             "rsyncd",
- /* temp_dir; */               NULL,
- /* uid; */                    NULL,
-
- /* auth_users_EXP; */         False,
- /* charset_EXP; */            False,
- /* comment_EXP; */            False,
- /* dont_compress_EXP; */      False,
- /* early_exec_EXP; */         False,
- /* exclude_EXP; */            False,
- /* exclude_from_EXP; */       False,
- /* filter_EXP; */             False,
- /* gid_EXP; */                        False,
- /* hosts_allow_EXP; */                False,
- /* hosts_deny_EXP; */         False,
- /* include_EXP; */            False,
- /* include_from_EXP; */       False,
- /* incoming_chmod_EXP; */     False,
- /* lock_file_EXP; */          False,
- /* log_file_EXP; */           False,
- /* log_format_EXP; */         False,
- /* name_EXP; */               False,
- /* outgoing_chmod_EXP; */     False,
- /* path_EXP; */               False,
- /* postxfer_exec_EXP; */      False,
- /* prexfer_exec_EXP; */       False,
- /* refuse_options_EXP; */     False,
- /* secrets_file_EXP; */       False,
- /* syslog_tag_EXP; */         False,
- /* temp_dir_EXP; */           False,
- /* uid_EXP; */                        False,
-
- /* max_connections; */                0,
- /* max_verbosity; */          1,
- /* syslog_facility; */                LOG_DAEMON,
- /* timeout; */                        0,
-
- /* fake_super; */             False,
- /* forward_lookup; */         True,
- /* ignore_errors; */          False,
- /* ignore_nonreadable; */     False,
- /* list; */                   True,
- /* munge_symlinks; */         (BOOL)-1,
- /* numeric_ids; */            (BOOL)-1,
- /* read_only; */              True,
- /* reverse_lookup; */         True,
- /* strict_modes; */           True,
- /* transfer_logging; */       False,
- /* use_chroot; */             True,
- /* write_only; */             False,
- }
-};
-
-/* The currently configured values for all the variables. */
-static all_vars Vars;
-
 /* Stack of "Vars" values used by the &include directive. */
 static item_list Vars_stack = EMPTY_ITEM_LIST;
 
@@ -324,9 +96,7 @@ static item_list section_list = EMPTY_ITEM_LIST;
 static int iSectionIndex = -1;
 static BOOL bInGlobalSection = True;
 
-#define NUMPARAMETERS (sizeof (parm_table) / sizeof (struct parm_struct))
-
-static struct enum_list enum_facilities[] = {
+static struct enum_list enum_syslog_facility[] = {
 #ifdef LOG_AUTH
        { LOG_AUTH, "auth" },
 #endif
@@ -393,74 +163,6 @@ static struct enum_list enum_facilities[] = {
        { -1, NULL }
 };
 
-static struct parm_struct parm_table[] =
-{
- {"address",           P_STRING, P_GLOBAL,&Vars.g.bind_address,        NULL,0},
- {"daemon chroot",     P_STRING, P_GLOBAL,&Vars.g.daemon_chroot,       NULL,0},
- {"daemon gid",        P_STRING, P_GLOBAL,&Vars.g.daemon_gid,          NULL,0},
- {"daemon uid",        P_STRING, P_GLOBAL,&Vars.g.daemon_uid,          NULL,0},
- {"listen backlog",    P_INTEGER,P_GLOBAL,&Vars.g.listen_backlog,      NULL,0},
- {"motd file",         P_STRING, P_GLOBAL,&Vars.g.motd_file,           NULL,0},
- {"pid file",          P_STRING, P_GLOBAL,&Vars.g.pid_file,            NULL,0},
- {"port",              P_INTEGER,P_GLOBAL,&Vars.g.rsync_port,          NULL,0},
- {"proxy protocol",    P_BOOL,   P_LOCAL, &Vars.g.proxy_protocol,      NULL,0},
- {"socket options",    P_STRING, P_GLOBAL,&Vars.g.socket_options,      NULL,0},
-
- {"auth users",        P_STRING, P_LOCAL, &Vars.l.auth_users,          NULL,0},
- {"charset",           P_STRING, P_LOCAL, &Vars.l.charset,             NULL,0},
- {"comment",           P_STRING, P_LOCAL, &Vars.l.comment,             NULL,0},
- {"dont compress",     P_STRING, P_LOCAL, &Vars.l.dont_compress,       NULL,0},
- {"early exec",        P_STRING, P_LOCAL, &Vars.l.early_exec,          NULL,0},
- {"exclude from",      P_STRING, P_LOCAL, &Vars.l.exclude_from,        NULL,0},
- {"exclude",           P_STRING, P_LOCAL, &Vars.l.exclude,             NULL,0},
- {"fake super",        P_BOOL,   P_LOCAL, &Vars.l.fake_super,          NULL,0},
- {"filter",            P_STRING, P_LOCAL, &Vars.l.filter,              NULL,0},
- {"forward lookup",    P_BOOL,   P_LOCAL, &Vars.l.forward_lookup,      NULL,0},
- {"gid",               P_STRING, P_LOCAL, &Vars.l.gid,                 NULL,0},
- {"hosts allow",       P_STRING, P_LOCAL, &Vars.l.hosts_allow,         NULL,0},
- {"hosts deny",        P_STRING, P_LOCAL, &Vars.l.hosts_deny,          NULL,0},
- {"ignore errors",     P_BOOL,   P_LOCAL, &Vars.l.ignore_errors,       NULL,0},
- {"ignore nonreadable",P_BOOL,   P_LOCAL, &Vars.l.ignore_nonreadable,  NULL,0},
- {"include from",      P_STRING, P_LOCAL, &Vars.l.include_from,        NULL,0},
- {"include",           P_STRING, P_LOCAL, &Vars.l.include,             NULL,0},
- {"incoming chmod",    P_STRING, P_LOCAL, &Vars.l.incoming_chmod,      NULL,0},
- {"list",              P_BOOL,   P_LOCAL, &Vars.l.list,                NULL,0},
- {"lock file",         P_STRING, P_LOCAL, &Vars.l.lock_file,           NULL,0},
- {"log file",          P_STRING, P_LOCAL, &Vars.l.log_file,            NULL,0},
- {"log format",        P_STRING, P_LOCAL, &Vars.l.log_format,          NULL,0},
- {"max connections",   P_INTEGER,P_LOCAL, &Vars.l.max_connections,     NULL,0},
- {"max verbosity",     P_INTEGER,P_LOCAL, &Vars.l.max_verbosity,       NULL,0},
- {"munge symlinks",    P_BOOL,   P_LOCAL, &Vars.l.munge_symlinks,      NULL,0},
- {"name",              P_STRING, P_LOCAL, &Vars.l.name,                NULL,0},
- {"numeric ids",       P_BOOL,   P_LOCAL, &Vars.l.numeric_ids,         NULL,0},
- {"outgoing chmod",    P_STRING, P_LOCAL, &Vars.l.outgoing_chmod,      NULL,0},
- {"path",              P_PATH,   P_LOCAL, &Vars.l.path,                NULL,0},
-#ifdef HAVE_PUTENV
- {"post-xfer exec",    P_STRING, P_LOCAL, &Vars.l.postxfer_exec,       NULL,0},
- {"pre-xfer exec",     P_STRING, P_LOCAL, &Vars.l.prexfer_exec,        NULL,0},
-#endif
- {"read only",         P_BOOL,   P_LOCAL, &Vars.l.read_only,           NULL,0},
- {"refuse options",    P_STRING, P_LOCAL, &Vars.l.refuse_options,      NULL,0},
- {"reverse lookup",    P_BOOL,   P_LOCAL, &Vars.l.reverse_lookup,      NULL,0},
- {"secrets file",      P_STRING, P_LOCAL, &Vars.l.secrets_file,        NULL,0},
- {"strict modes",      P_BOOL,   P_LOCAL, &Vars.l.strict_modes,        NULL,0},
- {"syslog facility",   P_ENUM,   P_LOCAL, &Vars.l.syslog_facility,     enum_facilities,0},
- {"syslog tag",        P_STRING, P_LOCAL, &Vars.l.syslog_tag,          NULL,0},
- {"temp dir",          P_PATH,   P_LOCAL, &Vars.l.temp_dir,            NULL,0},
- {"timeout",           P_INTEGER,P_LOCAL, &Vars.l.timeout,             NULL,0},
- {"transfer logging",  P_BOOL,   P_LOCAL, &Vars.l.transfer_logging,    NULL,0},
- {"uid",               P_STRING, P_LOCAL, &Vars.l.uid,                 NULL,0},
- {"use chroot",        P_BOOL,   P_LOCAL, &Vars.l.use_chroot,          NULL,0},
- {"write only",        P_BOOL,   P_LOCAL, &Vars.l.write_only,          NULL,0},
- {NULL,                P_BOOL,   P_NONE,  NULL,                        NULL,0}
-};
-
-/* Initialise the Default all_vars structure. */
-void reset_daemon_vars(void)
-{
-       memcpy(&Vars, &Defaults, sizeof Vars);
-}
-
 /* Expand %VAR% references.  Any unknown vars or unrecognized
  * syntax leaves the raw chars unchanged. */
 static char *expand_vars(const char *str)
@@ -509,6 +211,8 @@ static char *expand_vars(const char *str)
        return buf;
 }
 
+/* Each "char* foo" has an associated "BOOL foo_EXP" that tracks if the string has been expanded yet or not. */
+
 /* NOTE: use this function and all the FN_{GLOBAL,LOCAL} ones WITHOUT a trailing semicolon! */
 #define RETURN_EXPANDED(val) {if (!val ## _EXP) {val = expand_vars(val); val ## _EXP = True;} return val ? val : "";}
 
@@ -533,65 +237,24 @@ static char *expand_vars(const char *str)
 #define FN_LOCAL_INTEGER(fn_name, val) \
  int fn_name(int i) {return LP_SNUM_OK(i)? iSECTION(i).val : Vars.l.val;}
 
-FN_GLOBAL_STRING(lp_bind_address, bind_address)
-FN_GLOBAL_STRING(lp_daemon_chroot, daemon_chroot)
-FN_GLOBAL_STRING(lp_daemon_gid, daemon_gid)
-FN_GLOBAL_STRING(lp_daemon_uid, daemon_uid)
-FN_GLOBAL_STRING(lp_motd_file, motd_file)
-FN_GLOBAL_STRING(lp_pid_file, pid_file)
-FN_GLOBAL_STRING(lp_socket_options, socket_options)
-
-FN_GLOBAL_INTEGER(lp_listen_backlog, listen_backlog)
-FN_GLOBAL_INTEGER(lp_rsync_port, rsync_port)
-
-FN_GLOBAL_BOOL(lp_proxy_protocol, proxy_protocol)
-
-FN_LOCAL_STRING(lp_auth_users, auth_users)
-FN_LOCAL_STRING(lp_charset, charset)
-FN_LOCAL_STRING(lp_comment, comment)
-FN_LOCAL_STRING(lp_dont_compress, dont_compress)
-FN_LOCAL_STRING(lp_early_exec, early_exec)
-FN_LOCAL_STRING(lp_exclude, exclude)
-FN_LOCAL_STRING(lp_exclude_from, exclude_from)
-FN_LOCAL_STRING(lp_filter, filter)
-FN_LOCAL_STRING(lp_gid, gid)
-FN_LOCAL_STRING(lp_hosts_allow, hosts_allow)
-FN_LOCAL_STRING(lp_hosts_deny, hosts_deny)
-FN_LOCAL_STRING(lp_include, include)
-FN_LOCAL_STRING(lp_include_from, include_from)
-FN_LOCAL_STRING(lp_incoming_chmod, incoming_chmod)
-FN_LOCAL_STRING(lp_lock_file, lock_file)
-FN_LOCAL_STRING(lp_log_file, log_file)
-FN_LOCAL_STRING(lp_log_format, log_format)
-FN_LOCAL_STRING(lp_name, name)
-FN_LOCAL_STRING(lp_outgoing_chmod, outgoing_chmod)
-FN_LOCAL_STRING(lp_path, path)
-FN_LOCAL_STRING(lp_postxfer_exec, postxfer_exec)
-FN_LOCAL_STRING(lp_prexfer_exec, prexfer_exec)
-FN_LOCAL_STRING(lp_refuse_options, refuse_options)
-FN_LOCAL_STRING(lp_secrets_file, secrets_file)
-FN_LOCAL_STRING(lp_syslog_tag, syslog_tag)
-FN_LOCAL_STRING(lp_temp_dir, temp_dir)
-FN_LOCAL_STRING(lp_uid, uid)
-
-FN_LOCAL_INTEGER(lp_max_connections, max_connections)
-FN_LOCAL_INTEGER(lp_max_verbosity, max_verbosity)
-FN_LOCAL_INTEGER(lp_syslog_facility, syslog_facility)
-FN_LOCAL_INTEGER(lp_timeout, timeout)
-
-FN_LOCAL_BOOL(lp_fake_super, fake_super)
-FN_LOCAL_BOOL(lp_forward_lookup, forward_lookup)
-FN_LOCAL_BOOL(lp_ignore_errors, ignore_errors)
-FN_LOCAL_BOOL(lp_ignore_nonreadable, ignore_nonreadable)
-FN_LOCAL_BOOL(lp_list, list)
-FN_LOCAL_BOOL(lp_munge_symlinks, munge_symlinks)
-FN_LOCAL_BOOL(lp_numeric_ids, numeric_ids)
-FN_LOCAL_BOOL(lp_read_only, read_only)
-FN_LOCAL_BOOL(lp_reverse_lookup, reverse_lookup)
-FN_LOCAL_BOOL(lp_strict_modes, strict_modes)
-FN_LOCAL_BOOL(lp_transfer_logging, transfer_logging)
-FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
-FN_LOCAL_BOOL(lp_write_only, write_only)
+/* The following include file contains:
+ *
+ * typedef global_vars - describes global (ie., server-wide) parameters.
+ * typedef local_vars - describes a single section.
+ * typedef all_vars - a combination of global_vars & local_vars.
+ * all_vars Defaults - the default values for all the variables.
+ * all_vars Vars - tThe currently configured values for all the variables.
+ * struct parm_struct parm_table - the strings & variables for the parser.
+ * FN_{LOCAL,GLOBAL}_{TYPE}() definition for all the lp_var_name() accessors.
+ */
+
+#include "daemon-parm.h"
+
+/* Initialise the Default all_vars structure. */
+void reset_daemon_vars(void)
+{
+       memcpy(&Vars, &Defaults, sizeof Vars);
+}
 
 /* Assign a copy of v to *s.  Handles NULL strings.  We don't worry
  * about overwriting a malloc'd string because the long-running