thermferm/rdconfig.c

changeset 235
885ad8d52126
parent 217
2922d439ff63
child 240
6bdda35b4a13
equal deleted inserted replaced
234:b69438db19ec 235:885ad8d52126
135 135
136 /* 136 /*
137 * Create a new XML buffer, to which the XML document will be written 137 * Create a new XML buffer, to which the XML document will be written
138 */ 138 */
139 if ((buf = xmlBufferCreate()) == NULL) { 139 if ((buf = xmlBufferCreate()) == NULL) {
140 syslog(LOG_NOTICE, "wrconfig: error creating the xml buffer"); 140 syslog(LOG_WARNING, "wrconfig: error creating the xml buffer");
141 return 1; 141 return 1;
142 } 142 }
143 143
144 /* 144 /*
145 * Create a new XmlWriter for memory, with no compression. 145 * Create a new XmlWriter for memory, with no compression.
146 */ 146 */
147 if ((writer = xmlNewTextWriterMemory(buf, 0)) == NULL) { 147 if ((writer = xmlNewTextWriterMemory(buf, 0)) == NULL) {
148 syslog(LOG_NOTICE, "wrconfig: error creating the xml writer"); 148 syslog(LOG_WARNING, "wrconfig: error creating the xml writer");
149 return 1; 149 return 1;
150 } 150 }
151 151
152 /* 152 /*
153 * Use indentation instead of one long line 153 * Use indentation instead of one long line
154 */ 154 */
155 if ((rc = xmlTextWriterSetIndent(writer, 2)) < 0) { 155 if ((rc = xmlTextWriterSetIndent(writer, 2)) < 0) {
156 syslog(LOG_NOTICE, "wrconfig: error setting Indent"); 156 syslog(LOG_WARNING, "wrconfig: error setting Indent");
157 return 1; 157 return 1;
158 } 158 }
159 159
160 /* 160 /*
161 * Start the document with the xml default for the version, 161 * Start the document with the xml default for the version,
162 * encoding ISO 8859-1 and the default for the standalone 162 * encoding ISO 8859-1 and the default for the standalone
163 * declaration. 163 * declaration.
164 */ 164 */
165 if ((rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) < 0) { 165 if ((rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) < 0) {
166 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartDocument"); 166 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartDocument");
167 return 1; 167 return 1;
168 } 168 }
169 169
170 /* 170 /*
171 * Start an element named "THERMFERM". Since thist is the first 171 * Start an element named "THERMFERM". Since thist is the first
172 * element, this will be the root element of the document. 172 * element, this will be the root element of the document.
173 */ 173 */
174 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "THERMFERM")) < 0) { 174 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "THERMFERM")) < 0) {
175 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 175 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
176 return 1; 176 return 1;
177 } 177 }
178 178
179 /* 179 /*
180 * Add an attribute with name "VERSION" and value "1" to THERMFERM. 180 * Add an attribute with name "VERSION" and value "1" to THERMFERM.
181 */ 181 */
182 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { 182 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
183 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 183 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
184 return 1; 184 return 1;
185 } 185 }
186 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) { 186 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) {
187 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 187 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
188 return 1; 188 return 1;
189 } 189 }
190 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMPFORMAT", "%c", Config.tempFormat)) < 0) { 190 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMPFORMAT", "%c", Config.tempFormat)) < 0) {
191 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 191 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
192 return 1; 192 return 1;
193 } 193 }
194 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_ADDRESS", "%s", Config.temp_address)) < 0) { 194 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_ADDRESS", "%s", Config.temp_address)) < 0) {
195 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 195 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
196 return 1; 196 return 1;
197 } 197 }
198 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_STATE", "%d", Config.temp_state)) < 0) { 198 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_STATE", "%d", Config.temp_state)) < 0) {
199 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 199 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
200 return 1; 200 return 1;
201 } 201 }
202 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_VALUE", "%d", Config.temp_value)) < 0) { 202 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_VALUE", "%d", Config.temp_value)) < 0) {
203 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 203 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
204 return 1; 204 return 1;
205 } 205 }
206 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_ADDRESS", "%s", Config.hum_address)) < 0) { 206 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_ADDRESS", "%s", Config.hum_address)) < 0) {
207 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 207 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
208 return 1; 208 return 1;
209 } 209 }
210 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_STATE", "%d", Config.hum_state)) < 0) { 210 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_STATE", "%d", Config.hum_state)) < 0) {
211 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 211 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
212 return 1; 212 return 1;
213 } 213 }
214 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_VALUE", "%d", Config.hum_value)) < 0) { 214 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_VALUE", "%d", Config.hum_value)) < 0) {
215 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 215 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
216 return 1; 216 return 1;
217 } 217 }
218 218
219 #ifdef HAVE_WIRINGPI_H 219 #ifdef HAVE_WIRINGPI_H
220 /* 220 /*
221 * Start an element named "LCDS" as child of THERMFERM. 221 * Start an element named "LCDS" as child of THERMFERM.
222 */ 222 */
223 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCDS")) < 0) { 223 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCDS")) < 0) {
224 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 224 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
225 return 1; 225 return 1;
226 } 226 }
227 /* 227 /*
228 * Start one LCD. It is possible to connect 7 LCD displays on the i2c bus. 228 * Start one LCD. It is possible to connect 7 LCD displays on the i2c bus.
229 * However this program doesn't use more then one yet. 229 * However this program doesn't use more then one yet.
230 */ 230 */
231 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCD")) < 0) { 231 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCD")) < 0) {
232 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 232 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
233 return 1; 233 return 1;
234 } 234 }
235 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { 235 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
236 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 236 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
237 return 1; 237 return 1;
238 } 238 }
239 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "0x%x", Config.lcd_address)) < 0) { 239 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "0x%x", Config.lcd_address)) < 0) {
240 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 240 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
241 return 1; 241 return 1;
242 } 242 }
243 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COLUMNS", "%d", Config.lcd_cols)) < 0) { 243 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COLUMNS", "%d", Config.lcd_cols)) < 0) {
244 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 244 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
245 return 1; 245 return 1;
246 } 246 }
247 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ROWS", "%d", Config.lcd_rows)) < 0) { 247 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ROWS", "%d", Config.lcd_rows)) < 0) {
248 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 248 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
249 return 1; 249 return 1;
250 } 250 }
251 /* 251 /*
252 * Close the element named LCD. 252 * Close the element named LCD.
253 */ 253 */
254 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 254 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
255 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 255 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
256 return 1; 256 return 1;
257 } 257 }
258 /* 258 /*
259 * Close the element LCDS. 259 * Close the element LCDS.
260 */ 260 */
261 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 261 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
262 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 262 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
263 return 1; 263 return 1;
264 } 264 }
265 #endif 265 #endif
266 266
267 /* 267 /*
268 * Fermenter units 268 * Fermenter units
269 */ 269 */
270 if (Config.units) { 270 if (Config.units) {
271 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "FERMENTERS")) < 0) { 271 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "FERMENTERS")) < 0) {
272 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 272 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
273 return 1; 273 return 1;
274 } 274 }
275 for (tmp3 = Config.units; tmp3; tmp3 = tmp3->next) { 275 for (tmp3 = Config.units; tmp3; tmp3 = tmp3->next) {
276 /* 276 /*
277 * Only configuration items are written, measured values and states 277 * Only configuration items are written, measured values and states
278 * are written to a state file. 278 * are written to a state file.
279 */ 279 */
280 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "UNIT")) < 0) { 280 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "UNIT")) < 0) {
281 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 281 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
282 return 1; 282 return 1;
283 } 283 }
284 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { 284 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
285 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 285 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
286 return 1; 286 return 1;
287 } 287 }
288 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp3->uuid)) < 0) { 288 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp3->uuid)) < 0) {
289 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 289 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
290 return 1; 290 return 1;
291 } 291 }
292 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp3->name)) < 0) { 292 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp3->name)) < 0) {
293 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 293 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
294 return 1; 294 return 1;
295 } 295 }
296 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME", "%.1f", tmp3->volume)) < 0) { 296 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME", "%.1f", tmp3->volume)) < 0) {
297 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 297 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
298 return 1; 298 return 1;
299 } 299 }
300 if (tmp3->air_address) { 300 if (tmp3->air_address) {
301 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", tmp3->air_address)) < 0)) { 301 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", tmp3->air_address)) < 0)) {
302 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 302 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
303 return 1; 303 return 1;
304 } 304 }
305 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_STATE", "%d", tmp3->air_state)) < 0)) { 305 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_STATE", "%d", tmp3->air_state)) < 0)) {
306 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 306 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
307 return 1; 307 return 1;
308 } 308 }
309 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", tmp3->air_temperature)) < 0)) { 309 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", tmp3->air_temperature)) < 0)) {
310 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 310 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
311 return 1; 311 return 1;
312 } 312 }
313 } 313 }
314 if (tmp3->beer_address) { 314 if (tmp3->beer_address) {
315 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) { 315 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) {
316 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 316 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
317 return 1; 317 return 1;
318 } 318 }
319 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_STATE", "%d", tmp3->beer_state)) < 0)) { 319 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_STATE", "%d", tmp3->beer_state)) < 0)) {
320 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 320 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
321 return 1; 321 return 1;
322 } 322 }
323 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) { 323 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) {
324 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 324 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
325 return 1; 325 return 1;
326 } 326 }
327 } 327 }
328 if (tmp3->heater_address) { 328 if (tmp3->heater_address) {
329 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) { 329 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) {
330 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 330 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
331 return 1; 331 return 1;
332 } 332 }
333 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", tmp3->heater_state)) < 0)) { 333 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", tmp3->heater_state)) < 0)) {
334 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 334 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
335 return 1; 335 return 1;
336 } 336 }
337 } 337 }
338 if (tmp3->cooler_address) { 338 if (tmp3->cooler_address) {
339 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_ADDRESS", "%s", tmp3->cooler_address)) < 0)) { 339 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_ADDRESS", "%s", tmp3->cooler_address)) < 0)) {
340 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 340 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
341 return 1; 341 return 1;
342 } 342 }
343 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", tmp3->cooler_state)) < 0)) { 343 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", tmp3->cooler_state)) < 0)) {
344 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 344 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
345 return 1; 345 return 1;
346 } 346 }
347 } 347 }
348 if (tmp3->fan_address) { 348 if (tmp3->fan_address) {
349 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_ADDRESS", "%s", tmp3->fan_address)) < 0)) { 349 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_ADDRESS", "%s", tmp3->fan_address)) < 0)) {
350 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 350 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
351 return 1; 351 return 1;
352 } 352 }
353 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_STATE", "%d", tmp3->fan_state)) < 0)) { 353 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_STATE", "%d", tmp3->fan_state)) < 0)) {
354 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 354 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
355 return 1; 355 return 1;
356 } 356 }
357 } 357 }
358 if (tmp3->door_address) { 358 if (tmp3->door_address) {
359 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) { 359 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) {
360 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 360 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
361 return 1; 361 return 1;
362 } 362 }
363 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) { 363 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) {
364 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 364 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
365 return 1; 365 return 1;
366 } 366 }
367 } 367 }
368 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) { 368 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) {
369 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 369 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
370 return 1; 370 return 1;
371 } 371 }
372 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", tmp3->beer_set)) < 0) { 372 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", tmp3->beer_set)) < 0) {
373 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 373 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
374 return 1; 374 return 1;
375 } 375 }
376 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_SET", "%.1f", tmp3->fridge_set)) < 0) { 376 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_SET", "%.1f", tmp3->fridge_set)) < 0) {
377 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 377 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
378 return 1; 378 return 1;
379 } 379 }
380 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MIN", "%.1f", tmp3->temp_set_min)) < 0) { 380 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MIN", "%.1f", tmp3->temp_set_min)) < 0) {
381 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 381 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
382 return 1; 382 return 1;
383 } 383 }
384 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", tmp3->temp_set_max)) < 0) { 384 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", tmp3->temp_set_max)) < 0) {
385 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 385 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
386 return 1; 386 return 1;
387 } 387 }
388 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.1f", tmp3->idle_rangeL)) < 0) { 388 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.1f", tmp3->idle_rangeL)) < 0) {
389 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 389 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
390 return 1; 390 return 1;
391 } 391 }
392 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.1f", tmp3->idle_rangeH)) < 0) { 392 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.1f", tmp3->idle_rangeH)) < 0) {
393 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 393 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
394 return 1; 394 return 1;
395 } 395 }
396 if (tmp3->profile) { 396 if (tmp3->profile) {
397 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) { 397 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) {
398 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 398 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
399 return 1; 399 return 1;
400 } 400 }
401 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STARTED", "%d", (unsigned int)tmp3->prof_started)) < 0) { 401 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STARTED", "%d", (unsigned int)tmp3->prof_started)) < 0) {
402 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 402 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
403 return 1; 403 return 1;
404 } 404 }
405 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PAUSED", "%d", (unsigned int)tmp3->prof_paused)) < 0) { 405 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PAUSED", "%d", (unsigned int)tmp3->prof_paused)) < 0) {
406 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 406 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
407 return 1; 407 return 1;
408 } 408 }
409 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STATE", "%s", PROFSTATE[tmp3->prof_state] )) < 0) { 409 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STATE", "%s", PROFSTATE[tmp3->prof_state] )) < 0) {
410 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 410 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
411 return 1; 411 return 1;
412 } 412 }
413 } 413 }
414 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 414 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
415 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 415 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
416 return 1; 416 return 1;
417 } 417 }
418 } 418 }
419 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 419 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
420 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 420 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
421 return 1; 421 return 1;
422 } 422 }
423 } 423 }
424 424
425 /* 425 /*
426 * Fermenting profiles 426 * Fermenting profiles
427 */ 427 */
428 if (Config.profiles) { 428 if (Config.profiles) {
429 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILES")) < 0) { 429 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILES")) < 0) {
430 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 430 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
431 return 1; 431 return 1;
432 } 432 }
433 for (tmp4 = Config.profiles; tmp4; tmp4 = tmp4->next) { 433 for (tmp4 = Config.profiles; tmp4; tmp4 = tmp4->next) {
434 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILE")) < 0) { 434 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILE")) < 0) {
435 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 435 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
436 return 1; 436 return 1;
437 } 437 }
438 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { 438 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
439 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 439 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
440 return 1; 440 return 1;
441 } 441 }
442 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp4->uuid)) < 0) { 442 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp4->uuid)) < 0) {
443 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 443 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
444 return 1; 444 return 1;
445 } 445 }
446 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp4->name)) < 0) { 446 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp4->name)) < 0) {
447 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 447 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
448 return 1; 448 return 1;
449 } 449 }
450 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUSY", "%d", tmp4->busy)) < 0) { 450 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUSY", "%d", tmp4->busy)) < 0) {
451 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 451 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
452 return 1; 452 return 1;
453 } 453 }
454 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP", "%.1f", tmp4->inittemp)) < 0) { 454 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP", "%.1f", tmp4->inittemp)) < 0) {
455 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 455 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
456 return 1; 456 return 1;
457 } 457 }
458 if (tmp4->steps) { 458 if (tmp4->steps) {
459 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEPS")) < 0) { 459 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEPS")) < 0) {
460 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 460 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
461 return 1; 461 return 1;
462 } 462 }
463 for (tmp5 = tmp4->steps; tmp5; tmp5 = tmp5->next) { 463 for (tmp5 = tmp4->steps; tmp5; tmp5 = tmp5->next) {
464 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEP")) < 0) { 464 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEP")) < 0) {
465 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 465 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
466 return 1; 466 return 1;
467 } 467 }
468 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { 468 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
469 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 469 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
470 return 1; 470 return 1;
471 } 471 }
472 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "RESTTIME", "%d", tmp5->resttime)) < 0) { 472 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "RESTTIME", "%d", tmp5->resttime)) < 0) {
473 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 473 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
474 return 1; 474 return 1;
475 } 475 }
476 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STEPTIME", "%d", tmp5->steptime)) < 0) { 476 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STEPTIME", "%d", tmp5->steptime)) < 0) {
477 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 477 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
478 return 1; 478 return 1;
479 } 479 }
480 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET", "%.1f", tmp5->target)) < 0) { 480 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET", "%.1f", tmp5->target)) < 0) {
481 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 481 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
482 return 1; 482 return 1;
483 } 483 }
484 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 484 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
485 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 485 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
486 return 1; 486 return 1;
487 } 487 }
488 } 488 }
489 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 489 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
490 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 490 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
491 return 1; 491 return 1;
492 } 492 }
493 } 493 }
494 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 494 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
495 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 495 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
496 return 1; 496 return 1;
497 } 497 }
498 } 498 }
499 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 499 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
500 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 500 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
501 return 1; 501 return 1;
502 } 502 }
503 } 503 }
504 504
505 if (Config.devices) { 505 if (Config.devices) {
506 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICES")) < 0) { 506 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICES")) < 0) {
507 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 507 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
508 return 1; 508 return 1;
509 } 509 }
510 for (device = Config.devices; device; device = device->next) { 510 for (device = Config.devices; device; device = device->next) {
511 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICE")) < 0) { 511 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICE")) < 0) {
512 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); 512 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement");
513 return 1; 513 return 1;
514 } 514 }
515 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", device->version)) < 0) { 515 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", device->version)) < 0) {
516 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 516 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
517 return 1; 517 return 1;
518 } 518 }
519 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", device->uuid)) < 0) { 519 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", device->uuid)) < 0) {
520 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 520 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
521 return 1; 521 return 1;
522 } 522 }
523 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TYPE", "%s", DEVTYPE[device->type])) < 0) { 523 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TYPE", "%s", DEVTYPE[device->type])) < 0) {
524 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 524 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
525 return 1; 525 return 1;
526 } 526 }
527 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DIRECTION", "%s", DEVDIR[device->direction])) < 0) { 527 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DIRECTION", "%s", DEVDIR[device->direction])) < 0) {
528 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 528 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
529 return 1; 529 return 1;
530 } 530 }
531 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VALUE", "%d", device->value)) < 0) { 531 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VALUE", "%d", device->value)) < 0) {
532 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 532 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
533 return 1; 533 return 1;
534 } 534 }
535 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "OFFSET", "%d", device->offset)) < 0) { 535 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "OFFSET", "%d", device->offset)) < 0) {
536 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 536 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
537 return 1; 537 return 1;
538 } 538 }
539 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRESENT", "%s", DEVPRESENT[device->present])) < 0) { 539 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRESENT", "%s", DEVPRESENT[device->present])) < 0) {
540 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 540 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement");
541 return 1; 541 return 1;
542 } 542 }
543 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "%s", device->address)) < 0) { 543 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "%s", device->address)) < 0) {
544 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 544 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
545 return 1; 545 return 1;
546 } 546 }
547 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SUBDEVICE", "%d", device->subdevice)) < 0) { 547 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SUBDEVICE", "%d", device->subdevice)) < 0) {
548 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 548 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
549 return 1; 549 return 1;
550 } 550 }
551 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "GPIOPIN", "%d", device->gpiopin)) < 0) { 551 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "GPIOPIN", "%d", device->gpiopin)) < 0) {
552 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 552 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
553 return 1; 553 return 1;
554 } 554 }
555 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DESCRIPTION", "%s", device->description)) < 0) { 555 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DESCRIPTION", "%s", device->description)) < 0) {
556 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 556 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
557 return 1; 557 return 1;
558 } 558 }
559 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INUSE", "%d", device->inuse)) < 0) { 559 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INUSE", "%d", device->inuse)) < 0) {
560 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 560 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
561 return 1; 561 return 1;
562 } 562 }
563 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COMMENT", "%s", device->comment)) < 0) { 563 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COMMENT", "%s", device->comment)) < 0) {
564 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 564 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
565 return 1; 565 return 1;
566 } 566 }
567 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%d", (int)device->timestamp)) < 0) { 567 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%d", (int)device->timestamp)) < 0) {
568 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 568 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement");
569 return 1; 569 return 1;
570 } 570 }
571 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 571 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
572 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 572 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
573 return 1; 573 return 1;
574 } 574 }
575 } 575 }
576 576
577 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 577 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
578 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 578 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement");
579 return 1; 579 return 1;
580 } 580 }
581 } 581 }
582 582
583 /* 583 /*
584 * All done, close any open elements 584 * All done, close any open elements
585 */ 585 */
586 if ((rc = xmlTextWriterEndDocument(writer)) < 0) { 586 if ((rc = xmlTextWriterEndDocument(writer)) < 0) {
587 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndDocument"); 587 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndDocument");
588 return 1; 588 return 1;
589 } 589 }
590 xmlFreeTextWriter(writer); 590 xmlFreeTextWriter(writer);
591 591
592 /* 592 /*
603 603
604 if (debug) 604 if (debug)
605 fprintf(stdout, "Writing %s\n", mypath); 605 fprintf(stdout, "Writing %s\n", mypath);
606 606
607 if ((fp = fopen(mypath, "w")) == NULL) { 607 if ((fp = fopen(mypath, "w")) == NULL) {
608 syslog(LOG_NOTICE, "could not rewrite %s", mypath); 608 syslog(LOG_WARNING, "could not rewrite %s", mypath);
609 return 1; 609 return 1;
610 } 610 }
611 611
612 fprintf(fp, "%s", (const char *) buf->content); 612 fprintf(fp, "%s", (const char *) buf->content);
613 fclose(fp); 613 fclose(fp);
621 int wrconfig(void) 621 int wrconfig(void)
622 { 622 {
623 int rc; 623 int rc;
624 624
625 rc = do_wrconfig(); 625 rc = do_wrconfig();
626 syslog(LOG_NOTICE, "Rewritten configuration, rc=%d", rc); 626 syslog(LOG_WARNING, "Rewritten configuration, rc=%d", rc);
627 return rc; 627 return rc;
628 } 628 }
629 629
630 630
631 631
1173 xmlDocPtr doc; 1173 xmlDocPtr doc;
1174 xmlNodePtr cur; 1174 xmlNodePtr cur;
1175 xmlChar *key; 1175 xmlChar *key;
1176 1176
1177 killconfig(); 1177 killconfig();
1178 syslog(LOG_NOTICE, "HOME='%s' USER='%s' LOGNAME='%s'", MBSE_SS(getenv((char *)"HOME")), MBSE_SS(getenv((char *)"USER")), MBSE_SS(getenv((char *)"LOGNAME"))); 1178 syslog(LOG_WARNING, "HOME='%s' USER='%s' LOGNAME='%s'", MBSE_SS(getenv((char *)"HOME")), MBSE_SS(getenv((char *)"USER")), MBSE_SS(getenv((char *)"LOGNAME")));
1179 1179
1180 /* 1180 /*
1181 * Search config file 1181 * Search config file
1182 */ 1182 */
1183 if (getenv((char *)"USER") == NULL) { 1183 if (getenv((char *)"USER") == NULL) {
1199 * Try /usr/local/etc 1199 * Try /usr/local/etc
1200 */ 1200 */
1201 free(mypath); 1201 free(mypath);
1202 mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/thermferm.xml"); 1202 mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/thermferm.xml");
1203 if ((doc = xmlParseFile(mypath)) == NULL) { 1203 if ((doc = xmlParseFile(mypath)) == NULL) {
1204 syslog(LOG_NOTICE, "rdconfig: could not find thermferm.xml"); 1204 syslog(LOG_WARNING, "rdconfig: could not find thermferm.xml");
1205 return 1; 1205 return 1;
1206 } 1206 }
1207 } 1207 }
1208 } 1208 }
1209 syslog(LOG_NOTICE, "rdconfig: using %s", mypath); 1209 syslog(LOG_WARNING, "rdconfig: using %s", mypath);
1210 1210
1211 if ((cur = xmlDocGetRootElement(doc)) == NULL) { 1211 if ((cur = xmlDocGetRootElement(doc)) == NULL) {
1212 syslog(LOG_NOTICE, "XML file %s empty.", mypath); 1212 syslog(LOG_WARNING, "XML file %s empty.", mypath);
1213 xmlFreeDoc(doc); 1213 xmlFreeDoc(doc);
1214 return 1; 1214 return 1;
1215 } 1215 }
1216 if (xmlStrcmp(cur->name, (const xmlChar*)"THERMFERM")) { 1216 if (xmlStrcmp(cur->name, (const xmlChar*)"THERMFERM")) {
1217 syslog(LOG_NOTICE, "XML file %s is not a valid configuration file.", mypath); 1217 syslog(LOG_WARNING, "XML file %s is not a valid configuration file.", mypath);
1218 xmlFreeDoc(doc); 1218 xmlFreeDoc(doc);
1219 return 1; 1219 return 1;
1220 } 1220 }
1221 1221
1222 /* 1222 /*
1226 while (cur != NULL) { 1226 while (cur != NULL) {
1227 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { 1227 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
1228 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1228 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1229 if (xmlStrcmp(key, (const xmlChar *)"1")) { 1229 if (xmlStrcmp(key, (const xmlChar *)"1")) {
1230 xmlFree(key); 1230 xmlFree(key);
1231 syslog(LOG_NOTICE, "XML file %s is not a valid version", mypath); 1231 syslog(LOG_WARNING, "XML file %s is not a valid version", mypath);
1232 return 1; 1232 return 1;
1233 } 1233 }
1234 xmlFree(key); 1234 xmlFree(key);
1235 } 1235 }
1236 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LISTEN_PORT"))) { 1236 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LISTEN_PORT"))) {

mercurial