Index: gui.c =================================================================== RCS file: /usr/cvsroot/gastman/gui.c,v retrieving revision 1.13 diff -u -r1.13 gui.c --- gui.c 17 Jul 2004 04:26:51 -0000 1.13 +++ gui.c 29 Mar 2005 23:24:34 -0000 @@ -913,17 +913,21 @@ static int check_entity(char *entity) { FILE *f; - char buf[256]; - int res = 0; + char buf[256], *buf2, *var; + int res = -1; f = open_config_file("confirms.txt", "r"); while(f && !feof(f)) { fgets(buf, sizeof(buf), f); if (!feof(f) && strlen(buf)) { /* Trim trailing \n */ buf[strlen(buf) -1] = '\0'; - if (!strcmp(entity, buf)) { - res = 1; - break; + buf2 = buf; + var = strsep(&buf2, "="); + if (!strcmp(entity, var)) { + if (*buf2) { + res = atoi(buf2); + break; + } } } @@ -932,12 +936,12 @@ return res; } -static int add_entity(char *entity) +static int add_entity(char *entity, int val) { FILE *f; f = open_config_file("confirms.txt", "a"); if (f) { - fprintf(f, "%s\n", entity); + fprintf(f, "%s=%d\n", entity, val); fclose(f); } return 0; @@ -1186,14 +1190,14 @@ GtkWidget *tw; GtkWidget *defw = NULL; char rtext[256]; - int x; + int x, entitydef; choice = -1; remember = 0; if (entity) { - if (check_entity(entity)) { + if ((entitydef = check_entity(entity)) > -1) { printf("Using default answer for '%s'\n", entity); - return def; + return entitydef; } } if (!choices) { @@ -1235,8 +1239,8 @@ while(dialog) gtk_main_iteration_do(1); if (remember) { - if (!check_entity(entity)) - add_entity(entity); + if (check_entity(entity) == -1) + add_entity(entity, choice); } if (window) gtk_widget_set_sensitive(window, TRUE);