summaryrefslogtreecommitdiff
path: root/mcserverproxy/config-parser.h
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-23 16:25:36 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-23 16:25:36 +0200
commit8c27290245b7bcc7cd2f72f3b4a7562294b43bbe (patch)
tree54bae7909a94bfc598df7b88d9794742daf0bb31 /mcserverproxy/config-parser.h
parent973ae757342b91e3e6aafd07e0c0a24af84aad98 (diff)
Split directories better
Diffstat (limited to 'mcserverproxy/config-parser.h')
-rw-r--r--mcserverproxy/config-parser.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/mcserverproxy/config-parser.h b/mcserverproxy/config-parser.h
new file mode 100644
index 0000000..3a117a3
--- /dev/null
+++ b/mcserverproxy/config-parser.h
@@ -0,0 +1,59 @@
+#ifndef fooconfigparserhfoo
+#define fooconfigparserhfoo
+
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <signal.h>
+
+enum cfg_value_type {
+ CFG_VAL_TYPE_INVALID,
+ CFG_VAL_TYPE_STRING,
+ CFG_VAL_TYPE_UINT16,
+ CFG_VAL_TYPE_ADDRS,
+ CFG_VAL_TYPE_ASYNC_ADDRS,
+ CFG_VAL_TYPE_BOOL,
+};
+
+struct dns_async;
+
+typedef void (dns_cb_t)(struct dns_async *);
+
+struct dns_async {
+ char name[FQDN_STR_LEN + 1];
+ char port[PORT_STR_LEN + 1];
+ struct addrinfo req;
+ struct gaicb gcb;
+ struct sigevent sev;
+ dns_cb_t *cb;
+ void *priv;
+ struct list_head list;
+};
+
+struct cfg_key_value_map {
+ const char *key_name;
+ int key_value;
+ enum cfg_value_type value_type;
+};
+
+struct cfg_value {
+ enum cfg_value_type type;
+ union {
+ const char *str;
+ uint16_t uint16;
+ struct list_head saddrs;
+ struct dns_async *dns_async;
+ bool boolean;
+ };
+};
+
+bool config_parse_line(const char *filename, char **buf,
+ struct cfg_key_value_map *kvmap,
+ int *rkey, const char **rkeyname,
+ struct cfg_value *rvalue);
+
+bool config_parse_header(const char *filename,
+ const char *title, char **buf);
+
+#endif