1 | #ifndef OWNCONFIG_H |
---|
2 | #define OWNCONFIG_H |
---|
3 | |
---|
4 | struct clist* addownconfigtmp(char *key, char *value) |
---|
5 | { |
---|
6 | return addlisttmp(ownconfig, key, value); |
---|
7 | } |
---|
8 | |
---|
9 | struct clist* addownconfigdef(char *key, char *value) |
---|
10 | { |
---|
11 | return addlistdef(ownconfig, key, value); |
---|
12 | } |
---|
13 | |
---|
14 | struct clist* addownconfig(char *key, char *value) |
---|
15 | { |
---|
16 | struct clist* node = NULL; |
---|
17 | |
---|
18 | node = addlist(ownconfig, key, value); |
---|
19 | if(node != NULL) |
---|
20 | status.writeownconfig = 1; |
---|
21 | |
---|
22 | return node; |
---|
23 | } |
---|
24 | |
---|
25 | struct clist* addownconfigscreentmp(char *key, struct skin *node) |
---|
26 | { |
---|
27 | struct clist* ret = NULL; |
---|
28 | |
---|
29 | if(key != NULL && node != NULL && node->ret != NULL) |
---|
30 | ret = addownconfigtmp(key, node->ret); |
---|
31 | |
---|
32 | return ret; |
---|
33 | } |
---|
34 | |
---|
35 | struct clist* addownconfigscreenqtmp(char *key, struct skin *node) |
---|
36 | { |
---|
37 | struct clist* ret = NULL; |
---|
38 | |
---|
39 | if(key != NULL && node != NULL && node->ret != NULL) |
---|
40 | ret = addownconfigtmp(key, string_quote(node->ret)); |
---|
41 | |
---|
42 | return ret; |
---|
43 | } |
---|
44 | |
---|
45 | struct clist* addownconfigscreentmpcheck(char *key, struct skin *node, char* check) |
---|
46 | { |
---|
47 | if(ostrcmp(node->ret, check) == 0) |
---|
48 | return addownconfigtmp(key, ""); |
---|
49 | else |
---|
50 | return addownconfigscreentmp(key, node); |
---|
51 | } |
---|
52 | |
---|
53 | struct clist* addownconfigscreen(char *key, struct skin *node) |
---|
54 | { |
---|
55 | struct clist* ret = NULL; |
---|
56 | |
---|
57 | if(key != NULL && node != NULL && node->ret != NULL) |
---|
58 | ret = addownconfig(key, node->ret); |
---|
59 | |
---|
60 | return ret; |
---|
61 | } |
---|
62 | |
---|
63 | struct clist* addownconfigint(char *key, int value) |
---|
64 | { |
---|
65 | char* fileline = NULL; |
---|
66 | struct clist* ret = NULL; |
---|
67 | |
---|
68 | fileline = oitoa(value); |
---|
69 | ret = addownconfig(key, fileline); |
---|
70 | |
---|
71 | free(fileline); |
---|
72 | return ret; |
---|
73 | } |
---|
74 | |
---|
75 | int writeownconfigtmp() |
---|
76 | { |
---|
77 | int ret = 0; |
---|
78 | |
---|
79 | if(writelisttmp(ownconfig) == 0) |
---|
80 | status.writeownconfig = 1; |
---|
81 | |
---|
82 | return ret; |
---|
83 | } |
---|
84 | |
---|
85 | int writeownconfig(const char *filename) |
---|
86 | { |
---|
87 | return writelist(ownconfig, filename); |
---|
88 | } |
---|
89 | |
---|
90 | char* getownconfig(char *key) |
---|
91 | { |
---|
92 | return getlist(ownconfig, key, NULL); |
---|
93 | } |
---|
94 | |
---|
95 | char* getownconfigq(char *key) |
---|
96 | { |
---|
97 | char *ret = NULL; |
---|
98 | |
---|
99 | ret = ostrcat(ret, getlist(ownconfig, key, NULL), 1, 0); |
---|
100 | |
---|
101 | if(ret != NULL) |
---|
102 | { |
---|
103 | if(ret[0] == '\"') ret[0] = ' '; |
---|
104 | if(ret[strlen(ret) - 1] == '\"') ret[strlen(ret) - 1] = ' '; |
---|
105 | string_remove_whitechars(ret); |
---|
106 | } |
---|
107 | |
---|
108 | return ret; |
---|
109 | } |
---|
110 | |
---|
111 | int getownconfigint(char *key) |
---|
112 | { |
---|
113 | char *ret = NULL; |
---|
114 | |
---|
115 | ret = getlist(ownconfig, key, NULL); |
---|
116 | if(ret != NULL) |
---|
117 | return atoi(ret); |
---|
118 | else |
---|
119 | return 0; |
---|
120 | } |
---|
121 | |
---|
122 | void delownconfigtmpall() |
---|
123 | { |
---|
124 | dellisttmpall(ownconfig); |
---|
125 | } |
---|
126 | |
---|
127 | void delownconfigtmp(char *key) |
---|
128 | { |
---|
129 | dellisttmp(ownconfig, key); |
---|
130 | } |
---|
131 | |
---|
132 | void delownconfig(char *key) |
---|
133 | { |
---|
134 | status.writeownconfig = 1; |
---|
135 | dellist(ownconfig, key, 0); |
---|
136 | } |
---|
137 | |
---|
138 | void freeownconfig() |
---|
139 | { |
---|
140 | freelist(ownconfig); |
---|
141 | } |
---|
142 | |
---|
143 | int reloadownconfig(char *filename) |
---|
144 | { |
---|
145 | int ret = 0; |
---|
146 | |
---|
147 | freeownconfig(); |
---|
148 | ret = readconfig(filename, ownconfig); |
---|
149 | if(ret != 0) |
---|
150 | { |
---|
151 | err("readownconfig fail"); |
---|
152 | return 1; |
---|
153 | } |
---|
154 | |
---|
155 | return 0; |
---|
156 | } |
---|
157 | |
---|
158 | #endif |
---|