blob: 45176a50c61eaa7a14ffaf0e4947901c680f05a9 (
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
49
50
51
52
|
#ifndef INC_UTILS_H
#define INC_UTILS_H
#include <libestr.h>
enum cnfobjType {
CNFOBJ_ACTION,
CNFOBJ_GLOBAL,
CNFOBJ_INPUT,
CNFOBJ_MODULE,
CNFOBJ_INVALID = 0
};
static inline char*
cnfobjType2str(enum cnfobjType ot)
{
switch(ot) {
case CNFOBJ_ACTION:
return "action";
break;
case CNFOBJ_GLOBAL:
return "global";
break;
case CNFOBJ_INPUT:
return "input";
break;
case CNFOBJ_MODULE:
return "module";
break;
default:return "error: invalid cnfobjType";
}
}
struct cnfobj {
enum cnfobjType objType;
struct nvlst *nvlst;
};
struct nvlst {
struct nvlst *next;
es_str_t *name;
es_str_t *value;
};
void readConfFile(FILE *fp, es_str_t **str);
struct nvlst* nvlstNew(es_str_t *name, es_str_t *value);
void nvlstDestruct(struct nvlst *lst);
void nvlstPrint(struct nvlst *lst);
struct cnfobj* cnfobjNew(enum cnfobjType objType, struct nvlst *lst);
void cnfobjDestruct(struct cnfobj *o);
void cnfobjPrint(struct cnfobj *o);
#endif
|