X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/d2543f8c583922066a9e589db4662f8147d04a45..4e82e7cac76280026adbe913d5cedb7e54cfb41d:/dbck/fix.qc diff --git a/dbck/fix.qc b/dbck/fix.qc index 6637a662..6a05e78f 100644 --- a/dbck/fix.qc +++ b/dbck/fix.qc @@ -1,6 +1,6 @@ /* $Header$ * - * User interface routines for dbck (SMS database consistency checker) + * User interface routines for dbck (Moira database consistency checker) * * (c) Copyright 1988 by the Massachusetts Institute of Technology. * For copying and distribution information, please see the file @@ -8,10 +8,12 @@ */ #include -#include +#include #include #include "dbck.h" +static char fix_qc_rcsid[] = "$Header$"; + ##char *_table; ##char *_idfield; @@ -27,6 +29,7 @@ printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies"); else printf("Not deleted\n"); + modified(_table); ##} @@ -64,40 +67,18 @@ int id; printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies"); else printf("Not fixed\n"); + modified(table); ##} -generic_fix(sq, pfunc, msg, ffunc, preen) -struct save_queue *sq; -char *msg; -int (*pfunc)(), (*ffunc)(); -int preen; -{ - int id; - - while (sq_get_data(sq, &id)) { - if ((*pfunc)(id) == 0 && singe_fix(msg, preen)) - (*ffunc)(id); - } - sq_destroy(sq); -} - - int single_fix(msg, preen) char *msg; int preen; { - int lmode; - - lmode = mode; - if (mode == MODE_PREEN) { - if (preen) - lmode = MODE_YES; - else - lmode = MODE_NO; - } + if (mode == MODE_PREEN) + return(preen); - switch (lmode) { + switch (mode) { case MODE_ASK: if (!prompt(msg)) break; @@ -111,6 +92,22 @@ int preen; } +generic_fix(sq, pfunc, msg, ffunc, preen) +struct save_queue *sq; +char *msg; +int (*pfunc)(), (*ffunc)(); +int preen; +{ + int id; + + while (sq_get_data(sq, &id)) { + if ((*pfunc)(id) == 0 && single_fix(msg, preen)) + (*ffunc)(id); + } + sq_destroy(sq); +} + + int prompt(msg) char *msg; { @@ -129,12 +126,14 @@ char *msg; if (prompt("Are you sure you want to quit")) { if (prompt("Save database changes")) { ## end transaction -## replace values (value = dcmenable) -## where values.name = "dcm_enable" -## exit + cleanup(); exit(0); } else { - cleanup(); +## abort +## replace values (value = dcmenable) +## where values.name = "dcm_enable" +## exit + exit(1); } } } @@ -166,12 +165,12 @@ int set_next_object_id(object, table) ## repeat retrieve (value = v.#value) where v.#name = @name ## inquire_equel(rowcount = "rowcount") if (rowcount != 1) - return(SMS_NO_ID); + return(MR_NO_ID); ## retrieve (exists = any(tbl.name where tbl.name = value)) ## inquire_equel(rowcount = "rowcount") if (rowcount != 1) - return(SMS_NO_ID); + return(MR_NO_ID); while (exists) { value++; if (value > MAX_ID_VALUE) @@ -179,9 +178,10 @@ int set_next_object_id(object, table) ## retrieve (exists = any(tbl.name where tbl.name = value)) } - printf("setting ID %s to %d", name, value); + printf("setting ID %s to %d\n", name, value); ## repeat replace v (#value = @value) where v.#name = @name - return(SMS_SUCCESS); + modified("values"); + return(MR_SUCCESS); ##} @@ -203,5 +203,6 @@ int set_next_object_id(object, table) printf("Fixed\n"); else printf("Not fixed, rowcount = %d\n", rowcount); + modified(table); return(id); ##}