diff options
Diffstat (limited to 'config.h')
-rw-r--r-- | config.h | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -1,10 +1,11 @@ #ifndef CONFIG_H #define CONFIG_H +#include <stddef.h> + typedef struct config_opt config_opt; typedef union config_val config_val; typedef enum config_type config_type; -typedef void (*config_func)(config_opt *, config_val); enum config_type { TYPE_NONE, @@ -19,7 +20,7 @@ struct config_opt { const char *name; /* Name of the config option. */ const char *desc; /* Description of the config option. */ config_type type; /* Datatype of the config option. */ - config_func func; /* Function of the config option. */ + size_t offset; /* Offset of the member of the config option in the config struct. */ }; union config_val { @@ -31,13 +32,13 @@ union config_val { static const config_opt config_opts[] = { /* {"name", "desc", type, &func} */ - {"git-root", "Root of git server (can also be a url).", TYPE_STRING, &get_git_root}, - {"socket-type", "Socket type to use (options: unix, network. default: network).", TYPE_STRING, &get_sock_type}, - {"socket", "Path, IP address, or domain name of socket.", TYPE_STRING, &get_sock}, - {"port", "Port to listen on (network socket only).", TYPE_INT, &get_sock_port}, - {"merge-type", "Type of merge (options: 0 = Merge individually, 1 = Merge into one).", TYPE_INT, &get_merge_type}, - {"pr-root", "Directory to store pull requests in.", TYPE_STRING, &pr_root}, - {"key-file", "Path to file containing gpg/pgp public keys of each maintainer.", TYPE_STRING, &get_key_path}, + {"git-root", "Root of git server (can also be a url).", TYPE_STRING, offsetof(config, git_root)}, + {"socket-type", "Socket type to use (options: unix, network. default: network).", TYPE_STRING, offsetof(config, sock_type)}, + {"socket", "Path, IP address, or domain name of socket.", TYPE_STRING, offsetof(config, sock)}, + {"port", "Port to listen on (network socket only).", TYPE_INT, offsetof(config, sock_port)}, + {"merge-type", "Type of merge (options: 0 = Merge individually, 1 = Merge into one).", TYPE_INT, offsetof(config, merge_type)}, + {"pr-root", "Directory to store pull requests in.", TYPE_STRING, offsetof(config, pr_root)}, + {"key-file", "Path to file containing gpg/pgp public keys of each maintainer.", TYPE_STRING, offsetof(config, key_path)}, {NULL, NULL, TYPE_NONE, NULL}, }; |