aboutsummaryrefslogtreecommitdiff
path: root/src/survive_config.h
blob: 3e62ec8fe91142f025a6123964527c2a6c85f5d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// (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 union {
		uint32_t i;
		FLT f;
	} Numeric;
*/
typedef struct {
	char *tag;
	cval_type type;
	union {
		uint32_t i;
		FLT f;
	} numeric;
	char *data;
	uint32_t elements;
} config_val;

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(const char *tag, const FLT value);
const uint32_t config_set_uint32(const char *tag, const uint32_t value);
const char* config_set_str(const char *tag, const char* value);
FLT config_read_float(const char *tag, const FLT value, const FLT def);

uint32_t config_read_uint32(const char *tag, const uint32_t value, const uint32_t def);
const char* config_read_str(const char *tag, const char *value, const char *def_str);

#endif