thermferm/rdconfig.c

changeset 540
5a26429abbf8
parent 534
92b546d4a839
child 553
4091d4fe217f
equal deleted inserted replaced
539:300b5c4cd977 540:5a26429abbf8
73 free(Config.mqtt_username); 73 free(Config.mqtt_username);
74 Config.mqtt_username = NULL; 74 Config.mqtt_username = NULL;
75 if (Config.mqtt_password) 75 if (Config.mqtt_password)
76 free(Config.mqtt_password); 76 free(Config.mqtt_password);
77 Config.mqtt_password = NULL; 77 Config.mqtt_password = NULL;
78 if (Config.uuid)
79 free(Config.uuid);
80 Config.uuid = NULL;
78 81
79 for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) { 82 for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) {
80 if (tmp2->uuid) 83 if (tmp2->uuid)
81 free(tmp2->uuid); 84 free(tmp2->uuid);
82 if (tmp2->name) 85 if (tmp2->name)
214 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { 217 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
215 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 218 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
216 return 1; 219 return 1;
217 } 220 }
218 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", Config.name)) < 0) { 221 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", Config.name)) < 0) {
222 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
223 return 1;
224 }
225 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", Config.uuid)) < 0) {
219 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 226 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
220 return 1; 227 return 1;
221 } 228 }
222 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) { 229 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) {
223 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 230 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
2217 Config.mqtt_username = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 2224 Config.mqtt_username = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
2218 } 2225 }
2219 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_PASS"))) { 2226 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_PASS"))) {
2220 Config.mqtt_password = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 2227 Config.mqtt_password = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
2221 } 2228 }
2229 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) {
2230 Config.uuid= (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
2231 }
2222 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCDS"))) { 2232 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCDS"))) {
2223 parseLCDs(doc, cur); 2233 parseLCDs(doc, cur);
2224 } 2234 }
2225 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FERMENTERS"))) { 2235 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FERMENTERS"))) {
2226 parseFermenters(doc, cur); 2236 parseFermenters(doc, cur);
2241 xmlFreeDoc(doc); 2251 xmlFreeDoc(doc);
2242 2252
2243 free(mypath); 2253 free(mypath);
2244 mypath = NULL; 2254 mypath = NULL;
2245 2255
2256 /*
2257 * If the system uuid is not set, do it now.
2258 */
2259 if (Config.uuid == NULL) {
2260 uuid_t uu;
2261
2262 Config.uuid = malloc(37);
2263 uuid_generate(uu);
2264 uuid_unparse(uu, Config.uuid);
2265 }
2266
2246 return rc; 2267 return rc;
2247 } 2268 }
2248 2269
2249 2270
2250 2271

mercurial