brewco/rdrecipes.c

Sun, 27 Dec 2015 17:52:26 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 27 Dec 2015 17:52:26 +0100
changeset 477
9167ad4c2e77
parent 473
fdd30e935079
permissions
-rw-r--r--

Renamed Mash-in step to Prepare on the display. Don't run the pump when the mash is added. When preparing the mash, first heat the HLT, and then the MLT so that both have the chance to reach their target temperatures.

459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Copyright (C) 2015
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of the mbsePi-apps
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * mbsePi-apps is distributed in the hope that it will be useful, but
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 #include "brewco.h"
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 #include "rdrecipes.h"
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 #include "util.h"
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 #include "xutil.h"
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 extern int debug;
464
4a624c071ca9 Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
29 extern char *etcpath;
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 a_recipe *recipes = NULL;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 const char SKIPYN[2][4] = { "NO", "YES" };
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 #define MY_ENCODING "utf-8"
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 int do_wrrecipes(void);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 int do_wrrecipes(void)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 int i, rc = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 FILE *fp;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 char *mypath = NULL;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 a_recipe *recipe;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 xmlTextWriterPtr writer;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 xmlBufferPtr buf;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 * Create a new XML buffer, to which the XML document will be written
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 if ((buf = xmlBufferCreate()) == NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 syslog(LOG_NOTICE, "wrrecipes: error creating the xml buffer");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 * Create a new XmlWriter for memory, with no compression.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 if ((writer = xmlNewTextWriterMemory(buf, 0)) == NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 syslog(LOG_NOTICE, "wrrecipes: error creating the xml writer");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 * Use indentation instead of one long line
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 if ((rc = xmlTextWriterSetIndent(writer, 2)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 syslog(LOG_NOTICE, "wrrecipes: error setting Indent");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 * Start the document with the xml default for the version,
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 * encoding ISO 8859-1 and the default for the standalone
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 * declaration.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 if ((rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartDocument");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 * Start an element named "BREWCO". Since thist is the first
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 * element, this will be the root element of the document.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "BREWCO")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "RECIPES")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 for (recipe = recipes; recipe; recipe = recipe->next) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "RECIPE")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", recipe->uuid)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CODE", "%s", recipe->code)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", recipe->name)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BOILTIME", "%d", recipe->boiltime)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 }
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
121 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLTO", "%f", recipe->coolto)) < 0) {
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
122 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
123 return 1;
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
124 }
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STARTTIME", "%d", (int)recipe->starttime)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENDTIME", "%d", (int)recipe->endtime)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 * 8 Mash steps
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "MASHSTEPS")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 for (i =0; i < 8; i++) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "MASHSTEP")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", recipe->mash[i].name)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MIN", "%d", recipe->mash[i].min)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MAX", "%d", recipe->mash[i].max)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CANSKIP", "%s", recipe->mash[i].canskip ? "YES":"NO")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SETPOINT", "%f", recipe->mash[i].setpoint)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SKIP", "%s", recipe->mash[i].skip ? "YES":"NO")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DURATION", "%d", recipe->mash[i].duration)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 * 10 Hop additions
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "HOPADDITIONS")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 for (i = 0; i < 10; i++) {
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
192 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "HOPADDITION")) < 0) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
193 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
194 return 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
195 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
196 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", recipe->hops[i].name)) < 0) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
197 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
198 return 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
199 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
200 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SKIP", "%s", recipe->hops[i].skip ? "YES":"NO")) < 0) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
201 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
202 return 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
203 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
204 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BOILTIME", "%d", recipe->hops[i].boiltime)) < 0) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
205 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
206 return 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
207 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
208 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
209 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
210 return 1;
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 * 3 Hop stands
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "HOPSTANDS")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 for (i = 0; i < 3; i++) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "HOPSTAND")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", recipe->hopstand[i].name)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MIN", "%d", recipe->hopstand[i].min)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MAX", "%d", recipe->hopstand[i].max)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HOLD", "%s", recipe->hopstand[i].hold ? "YES":"NO")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SETPOINT", "%f", recipe->hopstand[i].setpoint)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SKIP", "%s", recipe->hopstand[i].skip ? "YES":"NO")) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DURATION", "%d", recipe->hopstand[i].duration)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
259 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 * Close the element named RECIPE.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 * Close the element named RECIPES.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 * All done, close any open elements
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 if ((rc = xmlTextWriterEndDocument(writer)) < 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndDocument");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 xmlFreeTextWriter(writer);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 * Now write the XML recipes
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 */
464
4a624c071ca9 Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
296 mypath = xstrcpy(etcpath);
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 mypath = xstrcat(mypath, (char *)"recipes.xml");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 if (debug)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 fprintf(stdout, "Writing %s\n", mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 if ((fp = fopen(mypath, "w")) == NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 syslog(LOG_NOTICE, "could not rewrite %s", mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 free(mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307 free(mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 fprintf(fp, "%s", (const char *) buf->content);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 fclose(fp);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 xmlBufferFree(buf);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 return 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 int wrrecipes(void)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 int rc;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 rc = do_wrrecipes();
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 syslog(LOG_NOTICE, "Rewritten recipes, rc=%d", rc);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 return rc;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 int parseRecipe(xmlDocPtr doc, xmlNodePtr cur)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 xmlChar *key;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 xmlNodePtr s1cur, s2cur;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 a_recipe *recipe, *tmp;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 int i, j, ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335 float fval;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337 recipe = (a_recipe *)malloc(sizeof(a_recipe));
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338 memset(recipe, 0, sizeof(a_recipe));
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339 recipe->next = NULL;
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
340 recipe->coolto = 20.0;
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
341
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 cur = cur->xmlChildrenNode;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343 while (cur != NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345 recipe->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 if ((!xmlStrcmp(cur->name, (const xmlChar *)"CODE"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348 recipe->code = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351 recipe->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
352 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BOILTIME"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 recipe->boiltime = ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 }
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
359 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLTO"))) {
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
360 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
361 if (sscanf((const char *)key, "%f", &fval) == 1)
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
362 recipe->coolto = fval;
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
363 xmlFree(key);
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
364 }
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 if ((!xmlStrcmp(cur->name, (const xmlChar *)"STARTTIME"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368 recipe->starttime = (time_t)ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ENDTIME"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374 recipe->endtime = (time_t)ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
375 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
377 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MASHSTEPS"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
378 s1cur = cur->xmlChildrenNode;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
379 i = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
380 while (s1cur != NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
381 if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"MASHSTEP"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
382 s2cur = s1cur->xmlChildrenNode;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
383 while (s2cur != NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
384 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"NAME"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385 recipe->mash[i].name = (char *)xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
387 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"MIN"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
389 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
390 recipe->mash[i].min = ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"MAX"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 recipe->mash[i].max = ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"CANSKIP"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 for (j = 0; j < 2; j++) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 if (! xmlStrcmp(key, (const xmlChar *)SKIPYN[j])) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 recipe->mash[i].canskip = j;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
406 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
407 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
408 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
409 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"SETPOINT"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
410 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
411 if (sscanf((const char *)key, "%f", &fval) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412 recipe->mash[i].setpoint = fval;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
413 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
414 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
415 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"SKIP"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
416 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
417 for (j = 0; j < 2; j++) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
418 if (! xmlStrcmp(key, (const xmlChar *)SKIPYN[j])) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
419 recipe->mash[i].skip = j;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
420 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
421 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"DURATION"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
428 recipe->mash[i].duration = ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 s2cur = s2cur->next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
433 i++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435 s1cur = s1cur->next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
437 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HOPADDITIONS"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440 s1cur = cur->xmlChildrenNode;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441 i = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442 while (s1cur != NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"HOPADDITION"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444 s2cur = s1cur->xmlChildrenNode;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 while (s2cur != NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"NAME"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 recipe->hops[i].name = (char *)xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448 }
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
449 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"SKIP"))) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
450 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
451 for (j = 0; j < 2; j++) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
452 if (! xmlStrcmp(key, (const xmlChar *)SKIPYN[j])) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
453 recipe->hops[i].skip = j;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
454 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
455 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
456 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
457 xmlFree(key);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 460
diff changeset
458 }
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"BOILTIME"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462 recipe->hops[i].boiltime = ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
464 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465 s2cur = s2cur->next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
466 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
467 i++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
468 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469 s1cur = s1cur->next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
470 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
471 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HOPSTANDS"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474 s1cur = cur->xmlChildrenNode;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 i = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476 while (s1cur != NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"HOPSTAND"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 s2cur = s1cur->xmlChildrenNode;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 while (s2cur != NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"NAME"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481 recipe->hopstand[i].name = (char *)xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"MIN"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
486 recipe->hopstand[i].min = ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"MAX"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
490 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492 recipe->hopstand[i].max = ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
493 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"HOLD"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
496 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497 for (j = 0; j < 2; j++) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 if (! xmlStrcmp(key, (const xmlChar *)SKIPYN[j])) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
499 recipe->hopstand[i].hold = j;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"SETPOINT"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 if (sscanf((const char *)key, "%f", &fval) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508 recipe->hopstand[i].setpoint = fval;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"SKIP"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513 for (j = 0; j < 2; j++) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514 if (! xmlStrcmp(key, (const xmlChar *)SKIPYN[j])) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 recipe->hopstand[i].skip = j;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
516 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
520 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521 if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"DURATION"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
522 key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523 if (sscanf((const char *)key, "%d", &ival) == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524 recipe->hopstand[i].duration = ival;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525 xmlFree(key);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527 s2cur = s2cur->next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 i++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
530 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 s1cur = s1cur->next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534 cur = cur->next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537 if (recipes == NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
538 recipes = recipe;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
539 } else {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
540 for (tmp = recipes; tmp; tmp = tmp->next) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
541 if (tmp->next == NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
542 tmp->next = recipe;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
543 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
546 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
548 return 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
550
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
553 int parseRecipes(xmlDocPtr doc, xmlNodePtr cur)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 cur = cur->xmlChildrenNode;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 while (cur != NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557 if ((!xmlStrcmp(cur->name, (const xmlChar *)"RECIPE"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 parseRecipe(doc, cur);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 cur = cur->next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 return 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
564
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
565
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 * Returns:
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 * 0 - All is well, recipes loaded.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570 * 1 - Something went wrong
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 int rdrecipes(void)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 int i;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
575 char *mypath;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
576 xmlDocPtr doc;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
577 xmlNodePtr cur;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
578 a_recipe *recipe;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581 * Search config file
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582 */
464
4a624c071ca9 Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
583 mypath = xstrcpy(etcpath);
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 mypath = xstrcat(mypath, (char *)"recipes.xml");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
585
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
586 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587 * Free possible old recipes list
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
588 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589 for (recipe = recipes; recipe; recipe = recipe->next) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 if (recipe->uuid)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
591 free(recipe->uuid);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
592 if (recipe->code)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
593 free(recipe->code);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594 if (recipe->name)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
595 free(recipe->name);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
596 for (i = 0; i < 8; i++)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
597 if (recipe->mash[i].name)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
598 free(recipe->mash[i].name);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
599 for (i = 0; i < 10; i++)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
600 if (recipe->hops[i].name)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
601 free(recipe->hops[i].name);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602 for (i = 0; i < 3; i++)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603 if (recipe->hopstand[i].name)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604 free(recipe->hopstand[i].name);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 free(recipe);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
607 recipes = NULL;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
608
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
609 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610 * See if we have a recipes file.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 if (file_exist(mypath, W_OK)) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613 syslog(LOG_NOTICE, "rdrecipes: %s not found, good.", mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
614 free(mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
615 return 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
618 if ((doc = xmlParseFile(mypath)) == NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
619 syslog(LOG_NOTICE, "rdrecipes: %s not found, we may need some.", mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 free(mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621 return 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
622 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
623 syslog(LOG_NOTICE, "rdrecipes: using %s", mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625 if ((cur = xmlDocGetRootElement(doc)) == NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626 syslog(LOG_NOTICE, "XML file %s empty.", mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
627 xmlFreeDoc(doc);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
628 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
629 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 if (xmlStrcmp(cur->name, (const xmlChar*)"BREWCO")) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631 syslog(LOG_NOTICE, "XML file %s is not a valid configuration file.", mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
632 xmlFreeDoc(doc);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
633 return 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
635
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
636 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
637 * Parse recipes
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
638 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 cur = cur->xmlChildrenNode;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
640 while (cur != NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
641 if ((!xmlStrcmp(cur->name, (const xmlChar *)"RECIPES"))) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
642 parseRecipes(doc, cur);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 cur = cur->next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 xmlFreeDoc(doc);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 free(mypath);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 mypath = NULL;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 return 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
654
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
655

mercurial