brewco/setup.c

changeset 447
b48368855ec4
parent 446
78e9d5234d15
child 448
7fe45f6e4f48
--- a/brewco/setup.c	Sat Dec 05 21:46:22 2015 +0100
+++ b/brewco/setup.c	Sun Dec 06 12:34:44 2015 +0100
@@ -26,6 +26,7 @@
 #include "prompt.h"
 #include "xutil.h"
 #include "keyboard.h"
+#include "rdconfig.h"
 
 
 extern int		my_shutdown;
@@ -158,11 +159,14 @@
 {
     int		index = 1, key;
     char	pmpt[81];
+    uLong	ocrc, ncrc;
 
     if (debug)
     	fprintf(stdout, "Start edit brewsystem %d %s\n", unit->number, unit->uuid);
 
     prompt(0, NULL);
+    ncrc = ocrc = crc32(0L, Z_NULL, 0);
+    ocrc = crc32(ocrc, (const Bytef *) unit, sizeof(units_list));
 
     for (;;) {
 
@@ -245,8 +249,14 @@
 	}
 
 	key = keywait();
-	if ((key == KEY_RETURN) || my_shutdown)
+	if ((key == KEY_RETURN) || my_shutdown) {
+	    ncrc = crc32(ncrc, (const Bytef *)unit, sizeof(units_list));
+	    if (ocrc != ncrc)
+		wrconfig();
+	    if (debug)
+		fprintf(stdout, "End edit brewsystem %d %s\n", unit->number, unit->uuid);
 	    return;
+	}
 
 	if ((key == KEY_UP) && (index > 1))
 	    index--;
@@ -298,9 +308,6 @@
 	    }
 	}
     }
-
-    if (debug)
-	fprintf(stdout, "End edit brewsystem %d %s\n", unit->number, unit->uuid);
 }
 
 

mercurial