forked from mist-devel/mist-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathini_parser.h
54 lines (40 loc) · 1014 Bytes
/
ini_parser.h
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
49
50
51
52
53
// ini_parser.h
// 2015, rok.krajnc@gmail.com
#ifndef __INI_PARSER_H__
#define __INI_PARSER_H__
// float support adds over 20kBytes to the firmware size
// #define INI_ENABLE_FLOAT
//// includes ////
#include <inttypes.h>
//// type definitions ////
typedef struct {
int id;
char* name;
} ini_section_t;
typedef enum {UINT8=0, INT8, UINT16, INT16, UINT32, INT32, UINT64, INT64,
#ifdef INI_ENABLE_FLOAT
FLOAT,
#endif
STRING, CUSTOM_HANDLER} ini_vartypes_t;
#define INI_LOAD 0
#define INI_SAVE 1
typedef char custom_handler_t(char*, char, int);
typedef struct {
char* name;
void* var;
ini_vartypes_t type;
uint64_t min;
uint64_t max;
int section_id;
} ini_var_t;
typedef struct {
const char* filename;
const ini_section_t* sections;
const ini_var_t* vars;
int nsections;
int nvars;
} ini_cfg_t;
//// functions ////
void ini_parse(const ini_cfg_t* cfg, const char *alter_section, int tag);
void ini_save(const ini_cfg_t* cfg, int tag);
#endif // __INI_PARSER_H__