summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-05 20:05:40 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-05 20:05:40 -0400
commit2a9a76b3e7ebfa4c56a0f37074e90bdb7a90533a (patch)
treea1e06fab8ad4c680efd53018d84cab65d0d778e5
parent12b62753744a4d91b16dc08746fa127e3b00929f (diff)
Move the config option stuff into `config.h`.
-rw-r--r--config.c31
-rw-r--r--config.h35
2 files changed, 36 insertions, 30 deletions
diff --git a/config.c b/config.c
index 15689a6..fc5f6bd 100644
--- a/config.c
+++ b/config.c
@@ -2,36 +2,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-
-typedef struct config_opt config_opt;
-typedef enum config_type config_type;
-typedef void (*config_func)(config_opt *, void *);
-
-enum config_type {
- TYPE_INT,
- TYPE_STRING,
- TYPE_FLOAT,
- TYPE_BOOL,
-};
-
-
-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. */
-};
-
-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},
-};
+#include "config.h"
char *read_file(const char *filename, long *size) {
/* Open the file. */
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..9993680
--- /dev/null
+++ b/config.h
@@ -0,0 +1,35 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+typedef struct config_opt config_opt;
+typedef enum config_type config_type;
+typedef void (*config_func)(config_opt *, void *);
+
+enum config_type {
+ TYPE_INT,
+ TYPE_STRING,
+ TYPE_FLOAT,
+ TYPE_BOOL,
+};
+
+
+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. */
+};
+
+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},
+};
+
+extern config *parse_config(const char *filename);
+#endif