151 |
151 |
152 /* |
152 /* |
153 * Create a new XML buffer, to which the XML document will be written |
153 * Create a new XML buffer, to which the XML document will be written |
154 */ |
154 */ |
155 if ((buf = xmlBufferCreate()) == NULL) { |
155 if ((buf = xmlBufferCreate()) == NULL) { |
156 syslog(LOG_WARNING, "wrconfig: error creating the xml buffer"); |
156 syslog(LOG_NOTICE, "wrconfig: error creating the xml buffer"); |
157 return 1; |
157 return 1; |
158 } |
158 } |
159 |
159 |
160 /* |
160 /* |
161 * Create a new XmlWriter for memory, with no compression. |
161 * Create a new XmlWriter for memory, with no compression. |
162 */ |
162 */ |
163 if ((writer = xmlNewTextWriterMemory(buf, 0)) == NULL) { |
163 if ((writer = xmlNewTextWriterMemory(buf, 0)) == NULL) { |
164 syslog(LOG_WARNING, "wrconfig: error creating the xml writer"); |
164 syslog(LOG_NOTICE, "wrconfig: error creating the xml writer"); |
165 return 1; |
165 return 1; |
166 } |
166 } |
167 |
167 |
168 /* |
168 /* |
169 * Use indentation instead of one long line |
169 * Use indentation instead of one long line |
170 */ |
170 */ |
171 if ((rc = xmlTextWriterSetIndent(writer, 2)) < 0) { |
171 if ((rc = xmlTextWriterSetIndent(writer, 2)) < 0) { |
172 syslog(LOG_WARNING, "wrconfig: error setting Indent"); |
172 syslog(LOG_NOTICE, "wrconfig: error setting Indent"); |
173 return 1; |
173 return 1; |
174 } |
174 } |
175 |
175 |
176 /* |
176 /* |
177 * Start the document with the xml default for the version, |
177 * Start the document with the xml default for the version, |
178 * encoding ISO 8859-1 and the default for the standalone |
178 * encoding ISO 8859-1 and the default for the standalone |
179 * declaration. |
179 * declaration. |
180 */ |
180 */ |
181 if ((rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) < 0) { |
181 if ((rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) < 0) { |
182 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartDocument"); |
182 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartDocument"); |
183 return 1; |
183 return 1; |
184 } |
184 } |
185 |
185 |
186 /* |
186 /* |
187 * Start an element named "THERMFERM". Since thist is the first |
187 * Start an element named "THERMFERM". Since thist is the first |
188 * element, this will be the root element of the document. |
188 * element, this will be the root element of the document. |
189 */ |
189 */ |
190 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "THERMFERM")) < 0) { |
190 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "THERMFERM")) < 0) { |
191 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
191 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
192 return 1; |
192 return 1; |
193 } |
193 } |
194 |
194 |
195 /* |
195 /* |
196 * Add an attribute with name "VERSION" and value "1" to THERMFERM. |
196 * Add an attribute with name "VERSION" and value "1" to THERMFERM. |
197 */ |
197 */ |
198 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
198 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
199 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
199 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
200 return 1; |
200 return 1; |
201 } |
201 } |
202 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) { |
202 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) { |
203 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
203 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
204 return 1; |
204 return 1; |
205 } |
205 } |
206 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMPFORMAT", "%c", Config.tempFormat)) < 0) { |
206 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMPFORMAT", "%c", Config.tempFormat)) < 0) { |
207 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
207 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
208 return 1; |
208 return 1; |
209 } |
209 } |
210 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_ADDRESS", "%s", Config.temp_address)) < 0) { |
210 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_ADDRESS", "%s", Config.temp_address)) < 0) { |
211 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
211 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
212 return 1; |
212 return 1; |
213 } |
213 } |
214 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_STATE", "%d", Config.temp_state)) < 0) { |
214 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_STATE", "%d", Config.temp_state)) < 0) { |
215 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
215 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
216 return 1; |
216 return 1; |
217 } |
217 } |
218 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_VALUE", "%d", Config.temp_value)) < 0) { |
218 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_VALUE", "%d", Config.temp_value)) < 0) { |
219 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
219 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
220 return 1; |
220 return 1; |
221 } |
221 } |
222 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_ADDRESS", "%s", Config.hum_address)) < 0) { |
222 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_ADDRESS", "%s", Config.hum_address)) < 0) { |
223 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
223 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
224 return 1; |
224 return 1; |
225 } |
225 } |
226 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_STATE", "%d", Config.hum_state)) < 0) { |
226 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_STATE", "%d", Config.hum_state)) < 0) { |
227 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
227 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
228 return 1; |
228 return 1; |
229 } |
229 } |
230 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_VALUE", "%d", Config.hum_value)) < 0) { |
230 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_VALUE", "%d", Config.hum_value)) < 0) { |
231 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
231 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
232 return 1; |
232 return 1; |
233 } |
233 } |
234 |
234 |
235 #ifdef HAVE_WIRINGPI_H |
235 #ifdef HAVE_WIRINGPI_H |
236 /* |
236 /* |
237 * Start an element named "LCDS" as child of THERMFERM. |
237 * Start an element named "LCDS" as child of THERMFERM. |
238 */ |
238 */ |
239 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCDS")) < 0) { |
239 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCDS")) < 0) { |
240 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
240 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
241 return 1; |
241 return 1; |
242 } |
242 } |
243 /* |
243 /* |
244 * Start one LCD. It is possible to connect 7 LCD displays on the i2c bus. |
244 * Start one LCD. It is possible to connect 7 LCD displays on the i2c bus. |
245 * However this program doesn't use more then one yet. |
245 * However this program doesn't use more then one yet. |
246 */ |
246 */ |
247 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCD")) < 0) { |
247 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCD")) < 0) { |
248 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
248 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
249 return 1; |
249 return 1; |
250 } |
250 } |
251 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
251 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
252 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
252 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
253 return 1; |
253 return 1; |
254 } |
254 } |
255 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "0x%x", Config.lcd_address)) < 0) { |
255 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "0x%x", Config.lcd_address)) < 0) { |
256 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
256 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
257 return 1; |
257 return 1; |
258 } |
258 } |
259 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COLUMNS", "%d", Config.lcd_cols)) < 0) { |
259 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COLUMNS", "%d", Config.lcd_cols)) < 0) { |
260 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
260 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
261 return 1; |
261 return 1; |
262 } |
262 } |
263 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ROWS", "%d", Config.lcd_rows)) < 0) { |
263 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ROWS", "%d", Config.lcd_rows)) < 0) { |
264 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
264 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
265 return 1; |
265 return 1; |
266 } |
266 } |
267 /* |
267 /* |
268 * Close the element named LCD. |
268 * Close the element named LCD. |
269 */ |
269 */ |
270 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
270 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
271 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
271 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
272 return 1; |
272 return 1; |
273 } |
273 } |
274 /* |
274 /* |
275 * Close the element LCDS. |
275 * Close the element LCDS. |
276 */ |
276 */ |
277 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
277 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
278 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
278 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
279 return 1; |
279 return 1; |
280 } |
280 } |
281 #endif |
281 #endif |
282 |
282 |
283 /* |
283 /* |
284 * Fermenter units |
284 * Fermenter units |
285 */ |
285 */ |
286 if (Config.units) { |
286 if (Config.units) { |
287 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "FERMENTERS")) < 0) { |
287 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "FERMENTERS")) < 0) { |
288 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
288 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
289 return 1; |
289 return 1; |
290 } |
290 } |
291 for (tmp3 = Config.units; tmp3; tmp3 = tmp3->next) { |
291 for (tmp3 = Config.units; tmp3; tmp3 = tmp3->next) { |
292 /* |
292 /* |
293 * Only configuration items are written, measured values and states |
293 * Only configuration items are written, measured values and states |
294 * are written to a state file. |
294 * are written to a state file. |
295 */ |
295 */ |
296 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "UNIT")) < 0) { |
296 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "UNIT")) < 0) { |
297 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
297 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
298 return 1; |
298 return 1; |
299 } |
299 } |
300 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
300 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
301 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
301 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
302 return 1; |
302 return 1; |
303 } |
303 } |
304 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp3->uuid)) < 0) { |
304 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp3->uuid)) < 0) { |
305 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
305 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
306 return 1; |
306 return 1; |
307 } |
307 } |
308 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp3->name)) < 0) { |
308 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp3->name)) < 0) { |
309 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
309 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
310 return 1; |
310 return 1; |
311 } |
311 } |
312 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME", "%.1f", tmp3->volume)) < 0) { |
312 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME", "%.1f", tmp3->volume)) < 0) { |
313 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
313 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
314 return 1; |
314 return 1; |
315 } |
315 } |
316 if (tmp3->air_address) { |
316 if (tmp3->air_address) { |
317 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", tmp3->air_address)) < 0)) { |
317 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", tmp3->air_address)) < 0)) { |
318 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
318 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
319 return 1; |
319 return 1; |
320 } |
320 } |
321 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_STATE", "%d", tmp3->air_state)) < 0)) { |
321 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_STATE", "%d", tmp3->air_state)) < 0)) { |
322 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
322 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
323 return 1; |
323 return 1; |
324 } |
324 } |
325 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", tmp3->air_temperature)) < 0)) { |
325 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", tmp3->air_temperature)) < 0)) { |
326 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
326 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
327 return 1; |
327 return 1; |
328 } |
328 } |
329 } |
329 } |
330 if (tmp3->beer_address) { |
330 if (tmp3->beer_address) { |
331 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) { |
331 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) { |
332 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
332 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
333 return 1; |
333 return 1; |
334 } |
334 } |
335 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_STATE", "%d", tmp3->beer_state)) < 0)) { |
335 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_STATE", "%d", tmp3->beer_state)) < 0)) { |
336 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
336 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
337 return 1; |
337 return 1; |
338 } |
338 } |
339 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) { |
339 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) { |
340 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
340 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
341 return 1; |
341 return 1; |
342 } |
342 } |
343 } |
343 } |
344 if (tmp3->heater_address) { |
344 if (tmp3->heater_address) { |
345 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) { |
345 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) { |
346 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
346 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
347 return 1; |
347 return 1; |
348 } |
348 } |
349 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", tmp3->heater_state)) < 0)) { |
349 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", tmp3->heater_state)) < 0)) { |
350 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
350 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
351 return 1; |
351 return 1; |
352 } |
352 } |
353 } |
353 } |
354 if (tmp3->cooler_address) { |
354 if (tmp3->cooler_address) { |
355 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_ADDRESS", "%s", tmp3->cooler_address)) < 0)) { |
355 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_ADDRESS", "%s", tmp3->cooler_address)) < 0)) { |
356 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
356 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
357 return 1; |
357 return 1; |
358 } |
358 } |
359 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", tmp3->cooler_state)) < 0)) { |
359 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", tmp3->cooler_state)) < 0)) { |
360 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
360 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
361 return 1; |
361 return 1; |
362 } |
362 } |
363 } |
363 } |
364 if (tmp3->fan_address) { |
364 if (tmp3->fan_address) { |
365 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_ADDRESS", "%s", tmp3->fan_address)) < 0)) { |
365 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_ADDRESS", "%s", tmp3->fan_address)) < 0)) { |
366 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
366 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
367 return 1; |
367 return 1; |
368 } |
368 } |
369 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_STATE", "%d", tmp3->fan_state)) < 0)) { |
369 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_STATE", "%d", tmp3->fan_state)) < 0)) { |
370 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
370 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
371 return 1; |
371 return 1; |
372 } |
372 } |
373 } |
373 } |
374 if (tmp3->door_address) { |
374 if (tmp3->door_address) { |
375 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) { |
375 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) { |
376 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
376 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
377 return 1; |
377 return 1; |
378 } |
378 } |
379 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) { |
379 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) { |
380 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
380 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
381 return 1; |
381 return 1; |
382 } |
382 } |
383 } |
383 } |
384 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) { |
384 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) { |
385 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
385 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
386 return 1; |
386 return 1; |
387 } |
387 } |
388 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", tmp3->beer_set)) < 0) { |
388 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", tmp3->beer_set)) < 0) { |
389 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
389 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
390 return 1; |
390 return 1; |
391 } |
391 } |
392 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_SET", "%.1f", tmp3->fridge_set)) < 0) { |
392 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_SET", "%.1f", tmp3->fridge_set)) < 0) { |
393 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
393 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
394 return 1; |
394 return 1; |
395 } |
395 } |
396 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MIN", "%.1f", tmp3->temp_set_min)) < 0) { |
396 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MIN", "%.1f", tmp3->temp_set_min)) < 0) { |
397 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
397 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
398 return 1; |
398 return 1; |
399 } |
399 } |
400 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", tmp3->temp_set_max)) < 0) { |
400 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", tmp3->temp_set_max)) < 0) { |
401 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
401 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
402 return 1; |
402 return 1; |
403 } |
403 } |
404 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.1f", tmp3->idle_rangeL)) < 0) { |
404 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.1f", tmp3->idle_rangeL)) < 0) { |
405 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
405 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
406 return 1; |
406 return 1; |
407 } |
407 } |
408 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.1f", tmp3->idle_rangeH)) < 0) { |
408 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.1f", tmp3->idle_rangeH)) < 0) { |
409 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
409 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
410 return 1; |
410 return 1; |
411 } |
411 } |
412 if (tmp3->profile) { |
412 if (tmp3->profile) { |
413 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) { |
413 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) { |
414 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
414 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
415 return 1; |
415 return 1; |
416 } |
416 } |
417 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STARTED", "%d", (unsigned int)tmp3->prof_started)) < 0) { |
417 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STARTED", "%d", (unsigned int)tmp3->prof_started)) < 0) { |
418 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
418 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
419 return 1; |
419 return 1; |
420 } |
420 } |
421 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PAUSED", "%d", (unsigned int)tmp3->prof_paused)) < 0) { |
421 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PAUSED", "%d", (unsigned int)tmp3->prof_paused)) < 0) { |
422 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
422 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
423 return 1; |
423 return 1; |
424 } |
424 } |
425 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STATE", "%s", PROFSTATE[tmp3->prof_state] )) < 0) { |
425 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STATE", "%s", PROFSTATE[tmp3->prof_state] )) < 0) { |
426 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
426 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
427 return 1; |
427 return 1; |
428 } |
428 } |
429 } |
429 } |
430 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
430 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
431 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
431 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
432 return 1; |
432 return 1; |
433 } |
433 } |
434 } |
434 } |
435 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
435 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
436 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
436 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
437 return 1; |
437 return 1; |
438 } |
438 } |
439 } |
439 } |
440 |
440 |
441 /* |
441 /* |
442 * Fermenting profiles |
442 * Fermenting profiles |
443 */ |
443 */ |
444 if (Config.profiles) { |
444 if (Config.profiles) { |
445 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILES")) < 0) { |
445 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILES")) < 0) { |
446 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
446 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
447 return 1; |
447 return 1; |
448 } |
448 } |
449 for (tmp4 = Config.profiles; tmp4; tmp4 = tmp4->next) { |
449 for (tmp4 = Config.profiles; tmp4; tmp4 = tmp4->next) { |
450 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILE")) < 0) { |
450 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILE")) < 0) { |
451 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
451 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
452 return 1; |
452 return 1; |
453 } |
453 } |
454 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
454 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
455 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
455 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
456 return 1; |
456 return 1; |
457 } |
457 } |
458 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp4->uuid)) < 0) { |
458 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp4->uuid)) < 0) { |
459 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
459 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
460 return 1; |
460 return 1; |
461 } |
461 } |
462 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp4->name)) < 0) { |
462 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp4->name)) < 0) { |
463 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
463 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
464 return 1; |
464 return 1; |
465 } |
465 } |
466 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUSY", "%d", tmp4->busy)) < 0) { |
466 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUSY", "%d", tmp4->busy)) < 0) { |
467 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
467 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
468 return 1; |
468 return 1; |
469 } |
469 } |
470 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP", "%.1f", tmp4->inittemp)) < 0) { |
470 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP", "%.1f", tmp4->inittemp)) < 0) { |
471 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
471 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
472 return 1; |
472 return 1; |
473 } |
473 } |
474 if (tmp4->steps) { |
474 if (tmp4->steps) { |
475 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEPS")) < 0) { |
475 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEPS")) < 0) { |
476 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
476 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
477 return 1; |
477 return 1; |
478 } |
478 } |
479 for (tmp5 = tmp4->steps; tmp5; tmp5 = tmp5->next) { |
479 for (tmp5 = tmp4->steps; tmp5; tmp5 = tmp5->next) { |
480 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEP")) < 0) { |
480 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEP")) < 0) { |
481 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
481 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
482 return 1; |
482 return 1; |
483 } |
483 } |
484 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
484 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
485 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
485 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
486 return 1; |
486 return 1; |
487 } |
487 } |
488 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "RESTTIME", "%d", tmp5->resttime)) < 0) { |
488 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "RESTTIME", "%d", tmp5->resttime)) < 0) { |
489 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
489 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
490 return 1; |
490 return 1; |
491 } |
491 } |
492 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STEPTIME", "%d", tmp5->steptime)) < 0) { |
492 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STEPTIME", "%d", tmp5->steptime)) < 0) { |
493 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
493 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
494 return 1; |
494 return 1; |
495 } |
495 } |
496 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET", "%.1f", tmp5->target)) < 0) { |
496 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET", "%.1f", tmp5->target)) < 0) { |
497 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
497 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
498 return 1; |
498 return 1; |
499 } |
499 } |
500 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
500 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
501 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
501 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
502 return 1; |
502 return 1; |
503 } |
503 } |
504 } |
504 } |
505 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
505 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
506 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
506 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
507 return 1; |
507 return 1; |
508 } |
508 } |
509 } |
509 } |
510 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
510 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
511 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
511 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
512 return 1; |
512 return 1; |
513 } |
513 } |
514 } |
514 } |
515 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
515 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
516 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
516 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
517 return 1; |
517 return 1; |
518 } |
518 } |
519 } |
519 } |
520 |
520 |
521 if (Config.devices) { |
521 if (Config.devices) { |
522 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICES")) < 0) { |
522 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICES")) < 0) { |
523 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
523 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
524 return 1; |
524 return 1; |
525 } |
525 } |
526 #ifdef HAVE_WIRINGPI_H |
526 #ifdef HAVE_WIRINGPI_H |
527 piLock(LOCK_DEVICES); |
527 piLock(LOCK_DEVICES); |
528 #endif |
528 #endif |
529 for (device = Config.devices; device; device = device->next) { |
529 for (device = Config.devices; device; device = device->next) { |
530 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICE")) < 0) { |
530 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICE")) < 0) { |
531 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
531 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
532 return 1; |
532 return 1; |
533 } |
533 } |
534 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", device->version)) < 0) { |
534 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", device->version)) < 0) { |
535 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
535 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
536 return 1; |
536 return 1; |
537 } |
537 } |
538 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", device->uuid)) < 0) { |
538 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", device->uuid)) < 0) { |
539 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
539 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
540 return 1; |
540 return 1; |
541 } |
541 } |
542 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TYPE", "%s", DEVTYPE[device->type])) < 0) { |
542 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TYPE", "%s", DEVTYPE[device->type])) < 0) { |
543 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
543 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
544 return 1; |
544 return 1; |
545 } |
545 } |
546 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DIRECTION", "%s", DEVDIR[device->direction])) < 0) { |
546 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DIRECTION", "%s", DEVDIR[device->direction])) < 0) { |
547 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
547 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
548 return 1; |
548 return 1; |
549 } |
549 } |
550 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VALUE", "%d", device->value)) < 0) { |
550 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VALUE", "%d", device->value)) < 0) { |
551 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
551 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
552 return 1; |
552 return 1; |
553 } |
553 } |
554 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "OFFSET", "%d", device->offset)) < 0) { |
554 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "OFFSET", "%d", device->offset)) < 0) { |
555 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
555 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
556 return 1; |
556 return 1; |
557 } |
557 } |
558 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRESENT", "%s", DEVPRESENT[device->present])) < 0) { |
558 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRESENT", "%s", DEVPRESENT[device->present])) < 0) { |
559 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
559 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
560 return 1; |
560 return 1; |
561 } |
561 } |
562 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "%s", device->address)) < 0) { |
562 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "%s", device->address)) < 0) { |
563 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
563 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
564 return 1; |
564 return 1; |
565 } |
565 } |
566 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SUBDEVICE", "%d", device->subdevice)) < 0) { |
566 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SUBDEVICE", "%d", device->subdevice)) < 0) { |
567 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
567 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
568 return 1; |
568 return 1; |
569 } |
569 } |
570 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "GPIOPIN", "%d", device->gpiopin)) < 0) { |
570 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "GPIOPIN", "%d", device->gpiopin)) < 0) { |
571 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
571 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
572 return 1; |
572 return 1; |
573 } |
573 } |
574 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DESCRIPTION", "%s", device->description)) < 0) { |
574 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DESCRIPTION", "%s", device->description)) < 0) { |
575 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
575 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
576 return 1; |
576 return 1; |
577 } |
577 } |
578 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INUSE", "%d", device->inuse)) < 0) { |
578 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INUSE", "%d", device->inuse)) < 0) { |
579 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
579 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
580 return 1; |
580 return 1; |
581 } |
581 } |
582 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COMMENT", "%s", device->comment)) < 0) { |
582 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COMMENT", "%s", device->comment)) < 0) { |
583 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
583 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
584 return 1; |
584 return 1; |
585 } |
585 } |
586 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%d", (int)device->timestamp)) < 0) { |
586 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%d", (int)device->timestamp)) < 0) { |
587 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
587 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
588 return 1; |
588 return 1; |
589 } |
589 } |
590 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
590 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
591 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
591 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
592 return 1; |
592 return 1; |
593 } |
593 } |
594 } |
594 } |
595 #ifdef HAVE_WIRINGPI_H |
595 #ifdef HAVE_WIRINGPI_H |
596 piUnlock(LOCK_DEVICES); |
596 piUnlock(LOCK_DEVICES); |
597 #endif |
597 #endif |
598 |
598 |
599 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
599 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
600 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
600 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
601 return 1; |
601 return 1; |
602 } |
602 } |
603 } |
603 } |
604 |
604 |
605 #ifdef USE_SIMULATOR |
605 #ifdef USE_SIMULATOR |
606 if (Config.simulators) { |
606 if (Config.simulators) { |
607 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "SIMULATORS")) < 0) { |
607 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "SIMULATORS")) < 0) { |
608 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
608 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
609 return 1; |
609 return 1; |
610 } |
610 } |
611 for (simulator = Config.simulators; simulator; simulator = simulator->next) { |
611 for (simulator = Config.simulators; simulator; simulator = simulator->next) { |
612 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "SIMULATOR")) < 0) { |
612 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "SIMULATOR")) < 0) { |
613 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterStartElement"); |
613 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
614 return 1; |
614 return 1; |
615 } |
615 } |
616 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", simulator->version)) < 0) { |
616 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", simulator->version)) < 0) { |
617 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
617 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
618 return 1; |
618 return 1; |
619 } |
619 } |
620 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", simulator->uuid)) < 0) { |
620 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", simulator->uuid)) < 0) { |
621 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
621 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
622 return 1; |
622 return 1; |
623 } |
623 } |
624 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", simulator->name)) < 0) { |
624 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", simulator->name)) < 0) { |
625 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
625 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
626 return 1; |
626 return 1; |
627 } |
627 } |
628 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME_AIR", "%d", simulator->volume_air)) < 0) { |
628 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME_AIR", "%d", simulator->volume_air)) < 0) { |
629 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
629 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
630 return 1; |
630 return 1; |
631 } |
631 } |
632 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME_BEER", "%d", simulator->volume_beer)) < 0) { |
632 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME_BEER", "%d", simulator->volume_beer)) < 0) { |
633 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
633 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
634 return 1; |
634 return 1; |
635 } |
635 } |
636 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ROOM_TEMPERATURE", "%.1f", simulator->room_temperature)) < 0) { |
636 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ROOM_TEMPERATURE", "%.1f", simulator->room_temperature)) < 0) { |
637 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
637 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
638 return 1; |
638 return 1; |
639 } |
639 } |
640 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%f", simulator->air_temperature)) < 0) { |
640 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%f", simulator->air_temperature)) < 0) { |
641 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
641 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
642 return 1; |
642 return 1; |
643 } |
643 } |
644 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%f", simulator->beer_temperature)) < 0) { |
644 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%f", simulator->beer_temperature)) < 0) { |
645 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
645 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
646 return 1; |
646 return 1; |
647 } |
647 } |
648 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_TEMP", "%f", simulator->cooler_temp)) < 0) { |
648 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_TEMP", "%f", simulator->cooler_temp)) < 0) { |
649 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
649 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
650 return 1; |
650 return 1; |
651 } |
651 } |
652 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_TIME", "%d", simulator->cooler_time)) < 0) { |
652 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_TIME", "%d", simulator->cooler_time)) < 0) { |
653 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
653 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
654 return 1; |
654 return 1; |
655 } |
655 } |
656 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_SIZE", "%.3f", simulator->cooler_size)) < 0) { |
656 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_SIZE", "%.3f", simulator->cooler_size)) < 0) { |
657 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
657 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
658 return 1; |
658 return 1; |
659 } |
659 } |
660 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_TEMP", "%f", simulator->heater_temp)) < 0) { |
660 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_TEMP", "%f", simulator->heater_temp)) < 0) { |
661 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
661 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
662 return 1; |
662 return 1; |
663 } |
663 } |
664 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_TIME", "%d", simulator->heater_time)) < 0) { |
664 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_TIME", "%d", simulator->heater_time)) < 0) { |
665 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
665 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
666 return 1; |
666 return 1; |
667 } |
667 } |
668 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_SIZE", "%.3f", simulator->heater_size)) < 0) { |
668 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_SIZE", "%.3f", simulator->heater_size)) < 0) { |
669 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
669 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
670 return 1; |
670 return 1; |
671 } |
671 } |
672 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", simulator->heater_state)) < 0) { |
672 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", simulator->heater_state)) < 0) { |
673 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
673 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
674 return 1; |
674 return 1; |
675 } |
675 } |
676 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", simulator->cooler_state)) < 0) { |
676 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", simulator->cooler_state)) < 0) { |
677 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
677 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
678 return 1; |
678 return 1; |
679 } |
679 } |
680 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIGO_ISOLATION", "%.3f", simulator->frigo_isolation)) < 0) { |
680 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIGO_ISOLATION", "%.3f", simulator->frigo_isolation)) < 0) { |
681 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
681 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
682 return 1; |
682 return 1; |
683 } |
683 } |
684 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_YEAST_HEAT", "%f", simulator->s_yeast_heat)) < 0) { |
684 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_YEAST_HEAT", "%f", simulator->s_yeast_heat)) < 0) { |
685 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
685 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
686 return 1; |
686 return 1; |
687 } |
687 } |
688 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_YEAST_STARTED", "%d", (int)simulator->s_yeast_started)) < 0) { |
688 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_YEAST_STARTED", "%d", (int)simulator->s_yeast_started)) < 0) { |
689 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
689 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
690 return 1; |
690 return 1; |
691 } |
691 } |
692 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_COOL_TEMP", "%f", simulator->s_cool_temp)) < 0) { |
692 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_COOL_TEMP", "%f", simulator->s_cool_temp)) < 0) { |
693 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
693 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
694 return 1; |
694 return 1; |
695 } |
695 } |
696 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_HEAT_TEMP", "%f", simulator->s_heat_temp)) < 0) { |
696 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_HEAT_TEMP", "%f", simulator->s_heat_temp)) < 0) { |
697 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
697 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
698 return 1; |
698 return 1; |
699 } |
699 } |
700 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_COOL_CHANGED", "%d", (int)simulator->s_cool_changed)) < 0) { |
700 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_COOL_CHANGED", "%d", (int)simulator->s_cool_changed)) < 0) { |
701 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
701 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
702 return 1; |
702 return 1; |
703 } |
703 } |
704 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_HEAT_CHANGED", "%d", (int)simulator->s_heat_changed)) < 0) { |
704 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_HEAT_CHANGED", "%d", (int)simulator->s_heat_changed)) < 0) { |
705 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterWriteElement"); |
705 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
706 return 1; |
706 return 1; |
707 } |
707 } |
708 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
708 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
709 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
709 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
710 return 1; |
710 return 1; |
711 } |
711 } |
712 } |
712 } |
713 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
713 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
714 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndElement"); |
714 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
715 return 1; |
715 return 1; |
716 } |
716 } |
717 } |
717 } |
718 #endif |
718 #endif |
719 |
719 |
720 /* |
720 /* |
721 * All done, close any open elements |
721 * All done, close any open elements |
722 */ |
722 */ |
723 if ((rc = xmlTextWriterEndDocument(writer)) < 0) { |
723 if ((rc = xmlTextWriterEndDocument(writer)) < 0) { |
724 syslog(LOG_WARNING, "wrconfig: error at xmlTextWriterEndDocument"); |
724 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndDocument"); |
725 return 1; |
725 return 1; |
726 } |
726 } |
727 xmlFreeTextWriter(writer); |
727 xmlFreeTextWriter(writer); |
728 |
728 |
729 /* |
729 /* |