Sun, 20 Dec 2015 20:37:40 +0100
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.
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 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | 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
|
122 | 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
|
123 | 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
|
124 | } |
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 "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
|
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 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | * 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
|
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 | 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
|
134 | 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
|
135 | 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
|
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 | 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
|
138 | 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
|
139 | 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
|
140 | 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
|
141 | } |
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 = 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
|
143 | 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
|
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 "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
|
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 "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
|
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 "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
|
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 "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
|
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 "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
|
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 "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
|
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 = 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
|
171 | 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
|
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 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | 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
|
176 | 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
|
177 | 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
|
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 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | * 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
|
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 | 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
|
184 | 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
|
185 | 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
|
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 | for (i = 0; i < 10; i++) { |
463
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
188 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "HOPADDITION")) < 0) { |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
189 | syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement"); |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
190 | return 1; |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
191 | } |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
192 | 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
|
193 | syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement"); |
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 "SKIP", "%s", recipe->hops[i].skip ? "YES":"NO")) < 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 "BOILTIME", "%d", recipe->hops[i].boiltime)) < 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 = xmlTextWriterEndElement(writer)) < 0) { |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
205 | syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement"); |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
206 | 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
|
207 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | 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
|
210 | 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
|
211 | 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
|
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 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | * 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
|
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 | 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
|
218 | 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
|
219 | 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
|
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 | 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
|
222 | 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
|
223 | 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
|
224 | 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
|
225 | } |
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 = 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
|
227 | 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
|
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 "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
|
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 "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
|
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 "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
|
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 "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
|
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 "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
|
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 "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
|
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 = 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
|
255 | 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
|
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 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
259 | 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
|
260 | 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
|
261 | 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
|
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 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
264 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
265 | * 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
|
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 | 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
|
268 | 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
|
269 | 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
|
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 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
272 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
273 | * 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
|
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 | 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
|
276 | 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
|
277 | 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
|
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 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
280 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
281 | * 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
|
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 | 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
|
284 | 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
|
285 | 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
|
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 | 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
|
288 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
289 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
290 | * 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
|
291 | */ |
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
|
292 | 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
|
293 | 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
|
294 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
295 | 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
|
296 | 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
|
297 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
298 | 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
|
299 | 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
|
300 | 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
|
301 | 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
|
302 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
303 | 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
|
304 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
305 | 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
|
306 | 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
|
307 | 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
|
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 | 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
|
310 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
311 | |
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 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
314 | 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
|
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 | 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
|
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 | 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
|
319 | 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
|
320 | 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
|
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 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
323 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
324 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
325 | 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
|
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 | 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
|
328 | 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
|
329 | 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
|
330 | 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
|
331 | 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
|
332 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
333 | 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
|
334 | 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
|
335 | recipe->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
|
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 | 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
|
338 | 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
|
339 | 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
|
340 | 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
|
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 | 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
|
343 | 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
|
344 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
345 | 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
|
346 | 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
|
347 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
348 | 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
|
349 | 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
|
350 | 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
|
351 | 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
|
352 | 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
|
353 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
354 | 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
|
355 | 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
|
356 | 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
|
357 | 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
|
358 | 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
|
359 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
360 | 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
|
361 | 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
|
362 | 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
|
363 | 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
|
364 | 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
|
365 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
366 | 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
|
367 | 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
|
368 | 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
|
369 | 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
|
370 | 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
|
371 | 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
|
372 | 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
|
373 | 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
|
374 | 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
|
375 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
376 | 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
|
377 | 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
|
378 | 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
|
379 | 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
|
380 | 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
|
381 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
382 | 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
|
383 | 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
|
384 | 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
|
385 | 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
|
386 | 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
|
387 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
388 | 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
|
389 | 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
|
390 | 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
|
391 | 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
|
392 | 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
|
393 | break; |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
394 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
395 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
396 | 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
|
397 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
398 | 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
|
399 | 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
|
400 | 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
|
401 | 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
|
402 | 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
|
403 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
404 | 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
|
405 | 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
|
406 | 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
|
407 | 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
|
408 | 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
|
409 | break; |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
410 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
411 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
412 | 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
|
413 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
414 | 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
|
415 | 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
|
416 | 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
|
417 | 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
|
418 | 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
|
419 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
420 | 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
|
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 | i++; |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
423 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
424 | 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
|
425 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
426 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
427 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
428 | 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
|
429 | 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
|
430 | 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
|
431 | 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
|
432 | 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
|
433 | 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
|
434 | 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
|
435 | 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
|
436 | 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
|
437 | } |
463
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
438 | if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"SKIP"))) { |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
439 | key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1); |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
440 | for (j = 0; j < 2; j++) { |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
441 | if (! xmlStrcmp(key, (const xmlChar *)SKIPYN[j])) { |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
442 | recipe->hops[i].skip = j; |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
443 | break; |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
444 | } |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
445 | } |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
446 | xmlFree(key); |
a1da58215b65
Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
447 | } |
459
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
448 | 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
|
449 | 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
|
450 | 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
|
451 | 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
|
452 | 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
|
453 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
454 | 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
|
455 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
456 | i++; |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
457 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
458 | 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
|
459 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
460 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
461 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
462 | 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
|
463 | 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
|
464 | 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
|
465 | 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
|
466 | 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
|
467 | 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
|
468 | 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
|
469 | 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
|
470 | 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
|
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 | 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
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | 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
|
477 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
478 | 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
|
479 | 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
|
480 | 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
|
481 | 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
|
482 | 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
|
483 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
484 | 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
|
485 | 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
|
486 | 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
|
487 | 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
|
488 | 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
|
489 | break; |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
490 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
491 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
492 | 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
|
493 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
494 | 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
|
495 | 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
|
496 | 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
|
497 | 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
|
498 | 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
|
499 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
500 | 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
|
501 | 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
|
502 | 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
|
503 | 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
|
504 | 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
|
505 | break; |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
506 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
507 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
508 | 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
|
509 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
510 | 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
|
511 | 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
|
512 | 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
|
513 | 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
|
514 | 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
|
515 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
516 | 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
|
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 | i++; |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
519 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
520 | 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
|
521 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
522 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
523 | 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
|
524 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
525 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
526 | 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
|
527 | 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
|
528 | } else { |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
529 | 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
|
530 | 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
|
531 | 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
|
532 | break; |
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 | } |
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 | 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
|
538 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
539 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
540 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
541 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
542 | 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
|
543 | { |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
544 | 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
|
545 | 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
|
546 | 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
|
547 | 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
|
548 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
549 | 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
|
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 | 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
|
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 | |
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 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
556 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
557 | * Returns: |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
558 | * 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
|
559 | * 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
|
560 | */ |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
561 | 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
|
562 | { |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
563 | 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
|
564 | 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
|
565 | 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
|
566 | 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
|
567 | 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
|
568 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
569 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
570 | * 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
|
571 | */ |
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
|
572 | 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
|
573 | 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
|
574 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
575 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
576 | * 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
|
577 | */ |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
578 | 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
|
579 | 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
|
580 | 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
|
581 | 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
|
582 | 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
|
583 | 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
|
584 | 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
|
585 | 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
|
586 | 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
|
587 | 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
|
588 | 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
|
589 | 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
|
590 | 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
|
591 | 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
|
592 | 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
|
593 | 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
|
594 | 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
|
595 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
596 | 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
|
597 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
598 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
599 | * 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
|
600 | */ |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
601 | 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
|
602 | 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
|
603 | 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
|
604 | 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
|
605 | } |
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 | 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
|
608 | 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
|
609 | 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
|
610 | 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
|
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 | 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
|
613 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
614 | 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
|
615 | 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
|
616 | 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
|
617 | 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
|
618 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
619 | 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
|
620 | 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
|
621 | 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
|
622 | 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
|
623 | } |
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 | /* |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
626 | * 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
|
627 | */ |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
628 | 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
|
629 | 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
|
630 | 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
|
631 | 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
|
632 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
633 | 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
|
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 | 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
|
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 | 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
|
638 | 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
|
639 | |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
640 | 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
|
641 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
642 | |
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 |