aboutsummaryrefslogtreecommitdiff
path: root/src/survive_config.h
diff options
context:
space:
mode:
authorultramn <dchapm2@umbc.edu>2017-03-02 19:55:54 -0800
committerultramn <dchapm2@umbc.edu>2017-03-02 19:55:54 -0800
commita59f42935a7472da7b9f162a68b3c55aff128f7e (patch)
treee4bf6314161bbabbde6064d8b7fdb9335a764ca6 /src/survive_config.h
parent1c131c03fe8c5d5ab17193c9f6e7e79d81110d52 (diff)
parent9d1b1d09ed51344c8ca7b4f0a94f5841ee2c509e (diff)
downloadlibsurvive-a59f42935a7472da7b9f162a68b3c55aff128f7e.tar.gz
libsurvive-a59f42935a7472da7b9f162a68b3c55aff128f7e.tar.bz2
Merge branch 'master' of https://github.com/cnlohr/libsurvive
Diffstat (limited to 'src/survive_config.h')
-rw-r--r--src/survive_config.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/survive_config.h b/src/survive_config.h
new file mode 100644
index 0000000..14e2fc6
--- /dev/null
+++ b/src/survive_config.h
@@ -0,0 +1,54 @@
+// (C) 2017 <>< Joshua Allen, Under MIT/x11 License.
+
+
+#ifndef _SURVIVE_CONFIG_H
+#define _SURVIVE_CONFIG_H
+
+#include "survive_internal.h"
+
+typedef enum {
+ CONFIG_UNKNOWN = 0,
+ CONFIG_FLOAT = 1,
+ CONFIG_UINT32 = 2,
+ CONFIG_STRING = 3,
+ CONFIG_FLOAT_ARRAY = 4,
+} cval_type;
+
+
+typedef struct {
+ char *tag;
+ cval_type type;
+ union {
+ uint32_t i;
+ FLT f;
+ } numeric;
+ char *data;
+ uint32_t elements;
+} config_entry;
+
+typedef struct {
+ config_entry *config_entries;
+ uint16_t used_entries;
+ uint16_t max_entries;
+} config_group;
+
+extern config_group global_config_values;
+extern config_group lh_config[2]; //lighthouse configs
+
+
+void config_init();
+void config_open(const char* path, const char* mode);
+void config_close();
+//void config_write_lighthouse(struct BaseStationData* bsd, uint8_t length);
+void config_set_lighthouse(struct BaseStationData* bsd, uint8_t idx);
+
+void config_save(const char* path);
+const FLT config_set_float(config_group *cg, const char *tag, const FLT value);
+const uint32_t config_set_uint32(config_group *cg, const char *tag, const uint32_t value);
+const char* config_set_str(config_group *cg, const char *tag, const char* value);
+
+FLT config_read_float(config_group *cg, const char *tag, const FLT def);
+uint32_t config_read_uint32(config_group *cg, const char *tag, const uint32_t def);
+const char* config_read_str(config_group *cg, const char *tag, const char *def);
+
+#endif \ No newline at end of file