brewco/rdrecipes.c

changeset 463
a1da58215b65
parent 460
0b2ea0ec165c
child 464
4a624c071ca9
--- a/brewco/rdrecipes.c	Wed Dec 16 22:54:53 2015 +0100
+++ b/brewco/rdrecipes.c	Thu Dec 17 22:45:54 2015 +0100
@@ -184,23 +184,25 @@
 	    return 1;
 	}
 	for (i = 0; i < 10; i++) {
-	    if (recipe->hops[i].name) {
-	        if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "HOPADDITION")) < 0) {
-		    syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
-		    return 1;
-	    	}
-	    	if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", recipe->hops[i].name)) < 0) {
-		    syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
-		    return 1;
-	    	}
-	    	if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BOILTIME", "%d", recipe->hops[i].boiltime)) < 0) {
-		    syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
-		    return 1;
-	    	}
-	    	if ((rc = xmlTextWriterEndElement(writer)) < 0) {
-		    syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
-		    return 1;
-	    	}
+	    if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "HOPADDITION")) < 0) {
+		syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterStartElement");
+		return 1;
+	    }
+	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", recipe->hops[i].name)) < 0) {
+		syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
+		return 1;
+	    }
+	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SKIP", "%s", recipe->hops[i].skip ? "YES":"NO")) < 0) {
+		syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
+		return 1;
+	    }
+	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BOILTIME", "%d", recipe->hops[i].boiltime)) < 0) {
+		syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterWriteFormatElement");
+		return 1;
+	    }
+	    if ((rc = xmlTextWriterEndElement(writer)) < 0) {
+		syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement");
+		return 1;
 	    }
 	}
 	if ((rc = xmlTextWriterEndElement(writer)) < 0) {
@@ -438,6 +440,16 @@
 			if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"NAME"))) {
 			    recipe->hops[i].name = (char *)xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
 			}
+			if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"SKIP"))) {
+			    key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
+			    for (j = 0; j < 2; j++) {
+				if (! xmlStrcmp(key, (const xmlChar *)SKIPYN[j])) {
+				    recipe->hops[i].skip = j;
+				    break;
+				}
+			    }
+			    xmlFree(key);
+			}
 			if ((!xmlStrcmp(s2cur->name, (const xmlChar *)"BOILTIME"))) {
 			    key = xmlNodeListGetString(doc, s2cur->xmlChildrenNode, 1);
 			    if (sscanf((const char *)key, "%d", &ival) == 1)

mercurial