40 const char PIDMODE[3][5] = { "NONE", "AUTO", "BOO" }; |
40 const char PIDMODE[3][5] = { "NONE", "AUTO", "BOO" }; |
41 |
41 |
42 |
42 |
43 void killconfig(void) |
43 void killconfig(void) |
44 { |
44 { |
45 units_list *tmp2; |
45 units_list *tmp2, *oldtmp2; |
46 profiles_list *tmp3; |
46 profiles_list *tmp3, *oldtmp3; |
47 prof_step *tmp4; |
47 prof_step *tmp4, *oldtmp4; |
48 devices_list *device; |
48 devices_list *device, *olddev; |
49 #ifdef USE_SIMULATOR |
49 #ifdef USE_SIMULATOR |
50 simulator_list *simulator; |
50 simulator_list *simulator, *oldsim; |
51 #endif |
51 #endif |
52 |
52 |
53 if (Config.name) |
53 if (Config.name) |
54 free(Config.name); |
54 free(Config.name); |
55 Config.name = NULL; |
55 Config.name = NULL; |
77 Config.mqtt_password = NULL; |
77 Config.mqtt_password = NULL; |
78 if (Config.uuid) |
78 if (Config.uuid) |
79 free(Config.uuid); |
79 free(Config.uuid); |
80 Config.uuid = NULL; |
80 Config.uuid = NULL; |
81 |
81 |
82 for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) { |
82 for (tmp2 = Config.units; tmp2; tmp2 = oldtmp2) { |
|
83 oldtmp2 = tmp2->next; |
83 if (tmp2->uuid) |
84 if (tmp2->uuid) |
84 free(tmp2->uuid); |
85 free(tmp2->uuid); |
85 if (tmp2->product_uuid) |
86 if (tmp2->product_uuid) |
86 free(tmp2->product_uuid); |
87 free(tmp2->product_uuid); |
87 if (tmp2->product_code) |
88 if (tmp2->product_code) |
106 free(tmp2->door_address); |
107 free(tmp2->door_address); |
107 if (tmp2->psu_address) |
108 if (tmp2->psu_address) |
108 free(tmp2->psu_address); |
109 free(tmp2->psu_address); |
109 if (tmp2->profile) |
110 if (tmp2->profile) |
110 free(tmp2->profile); |
111 free(tmp2->profile); |
|
112 if (tmp2->PID_cool) |
|
113 free(tmp2->PID_cool); |
|
114 if (tmp2->PID_heat) |
|
115 free(tmp2->PID_heat); |
111 free(tmp2); |
116 free(tmp2); |
112 } |
117 } |
113 Config.units = NULL; |
118 Config.units = NULL; |
114 |
119 |
115 for (tmp3 = Config.profiles; tmp3; tmp3 = tmp3->next) { |
120 for (tmp3 = Config.profiles; tmp3; tmp3 = oldtmp3) { |
|
121 oldtmp3 = tmp3->next; |
116 if (tmp3->uuid) |
122 if (tmp3->uuid) |
117 free(tmp3->uuid); |
123 free(tmp3->uuid); |
118 if (tmp3->name) |
124 if (tmp3->name) |
119 free(tmp3->name); |
125 free(tmp3->name); |
120 if (tmp3->steps) { |
126 if (tmp3->steps) { |
121 for (tmp4 = tmp3->steps; tmp4; tmp4 = tmp4->next) { |
127 for (tmp4 = tmp3->steps; tmp4; tmp4 = oldtmp4) { |
|
128 oldtmp4 = tmp4->next; |
122 free(tmp4); |
129 free(tmp4); |
123 } |
130 } |
124 } |
131 } |
125 free(tmp3); |
132 free(tmp3); |
126 } |
133 } |
127 Config.profiles = NULL; |
134 Config.profiles = NULL; |
128 |
135 |
129 for (device = Config.devices; device; device = device->next) { |
136 for (device = Config.devices; device; device = olddev) { |
|
137 olddev = device->next; |
130 if (device->uuid) |
138 if (device->uuid) |
131 free(device->uuid); |
139 free(device->uuid); |
132 if (device->address) |
140 if (device->address) |
133 free(device->address); |
141 free(device->address); |
134 if (device->description) |
142 if (device->description) |
2264 if (sscanf((const char *)key, "%d", &ival) == 1) |
2273 if (sscanf((const char *)key, "%d", &ival) == 1) |
2265 Config.next_unit = ival; |
2274 Config.next_unit = ival; |
2266 xmlFree(key); |
2275 xmlFree(key); |
2267 } |
2276 } |
2268 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_HOST"))) { |
2277 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_HOST"))) { |
|
2278 if (Config.mqtt_host) |
|
2279 free(Config.mqtt_host); |
2269 Config.mqtt_host = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
2280 Config.mqtt_host = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
2270 } |
2281 } |
2271 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_PORT"))) { |
2282 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_PORT"))) { |
2272 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
2283 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
2273 if (sscanf((const char *)key, "%d", &ival) == 1) |
2284 if (sscanf((const char *)key, "%d", &ival) == 1) |