source: titan/titan/ownconfig.h @ 15272

Last change on this file since 15272 was 10500, checked in by nit, 11 years ago

[titan] save list with mutex, add message queue

File size: 2.7 KB
Line 
1#ifndef OWNCONFIG_H
2#define OWNCONFIG_H
3
4struct clist* addownconfigtmp(char *key, char *value)
5{
6        return addlisttmp(ownconfig, key, value);
7}
8
9struct clist* addownconfigdef(char *key, char *value)
10{
11        return addlistdef(ownconfig, key, value);
12}
13
14struct 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
25struct 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
35struct 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
45struct 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
53struct 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
63struct clist* addownconfigint(char *key, int value)
64{
65        debug(1000, "in");
66        char* fileline = NULL;
67        struct clist* ret = NULL;
68
69        fileline = oitoa(value);
70        ret = addownconfig(key, fileline);
71
72        free(fileline);
73        debug(1000, "out");
74        return ret;
75}
76
77int writeownconfigtmp()
78{
79        int ret = 0;
80
81        if(writelisttmp(ownconfig) == 0)
82                status.writeownconfig = 1;
83
84        return ret;
85}
86
87int writeownconfig(const char *filename)
88{
89        return writelist(ownconfig, filename);
90}
91
92char* getownconfig(char *key)
93{
94        return getlist(ownconfig, key, NULL);
95}
96
97char* getownconfigq(char *key)
98{
99        char *ret = NULL;
100
101        ret = ostrcat(ret, getlist(ownconfig, key, NULL), 1, 0);
102
103        if(ret != NULL)
104        {
105                if(ret[0] == '\"') ret[0] = ' ';
106                if(ret[strlen(ret) - 1] == '\"') ret[strlen(ret) - 1] = ' ';
107                string_remove_whitechars(ret);
108        }
109
110        return ret;
111}
112
113int getownconfigint(char *key)
114{
115        char *ret = NULL;
116
117        ret = getlist(ownconfig, key, NULL);
118        if(ret != NULL)
119                return atoi(ret);
120        else
121                return 0;
122}
123
124void delownconfigtmpall()
125{
126        dellisttmpall(ownconfig);
127}
128
129void delownconfigtmp(char *key)
130{
131        dellisttmp(ownconfig, key);
132}
133
134void delownconfig(char *key)
135{
136        status.writeownconfig = 1;
137        dellist(ownconfig, key, 0);
138}
139
140void freeownconfig()
141{
142        freelist(ownconfig);
143}
144
145int reloadownconfig(char *filename)
146{
147        debug(1000, "in");
148        int ret = 0;
149
150        freeownconfig();
151        ret = readconfig(filename, ownconfig);
152        if(ret != 0)
153        {
154                debug(1000, "out -> readownconfig fail");
155                return 1;
156        }
157
158        debug(1000, "out");
159        return 0;
160}
161
162#endif
Note: See TracBrowser for help on using the repository browser.