summaryrefslogtreecommitdiff
path: root/config.h
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-06 13:21:17 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-06 13:21:17 -0400
commitb5eebeef24c64020d84211f26e51cce70e402576 (patch)
tree4f69369347dd695a30d1302336371812739e3163 /config.h
parentfafa513041fb13f679dfe107749aa2a8223040e3 (diff)
Added a new union called `config_val`.
This is so that I don't have to cast the variable as a `void *`, and make it easier to read. I also added `TYPE_NONE` to the `config_type` enum for denoting that the config option doesn't take a value.
Diffstat (limited to 'config.h')
-rw-r--r--config.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/config.h b/config.h
index 9993680..5dbc531 100644
--- a/config.h
+++ b/config.h
@@ -2,17 +2,18 @@
#define CONFIG_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 *, void *);
+typedef void (*config_func)(config_opt *, config_val);
enum config_type {
TYPE_INT,
TYPE_STRING,
TYPE_FLOAT,
TYPE_BOOL,
+ TYPE_NONE,
};
-
struct config_opt {
const char *name; /* Name of the config option. */
const char *desc; /* Description of the config option. */
@@ -20,6 +21,13 @@ struct config_opt {
config_func func; /* Function of the config option. */
};
+union config_val {
+ int i; /* Integer. */
+ char *str; /* String. */
+ float f; /* Float. */
+ int b : 1; /* Bool. */
+};
+
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},