Commit 05da7bdb authored by Per Cederqvist's avatar Per Cederqvist
Browse files

commit of work in progress

parent c1f21f03
/*
* $Id: dbck.c,v 0.60 2000/09/02 19:49:45 ceder Exp $
* $Id: dbck.c,v 0.60.2.1 2000/09/06 17:43:14 ceder Exp $
* Copyright (C) 1991-1999 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -35,7 +35,7 @@
static const char *
rcsid = "$Id: dbck.c,v 0.60 2000/09/02 19:49:45 ceder Exp $";
rcsid = "$Id: dbck.c,v 0.60.2.1 2000/09/06 17:43:14 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -155,6 +155,11 @@ static int dump_text_numbers=0;
int modifications = 0;
/* Some attempts to repair the database may introduce new problems.
This flag is set whenever that happens. If it is set on normal
exit the user is asked to re-run dbck. */
static int recommend_rerun = 0;
typedef struct {
int created_confs;
} Person_scratchpad;
......@@ -431,29 +436,59 @@ delete_misc (Text_stat *tstat,
static int
confirm(const char *question)
{
if ( iflag )
int ans = -1;
if (iflag)
{
fputs(question, stdout);
fputs(" (y/n) ", stdout);
while(1)
switch(getchar())
while (ans == -1)
{
fputs(question, stdout);
fputs(" (y/n) ", stdout);
fflush(stdout);
switch (getchar())
{
case 'y':
case 'Y':
return 1;
ans = 1;
break;
case 'n':
case 'N':
case EOF:
return 0;
ans = 0;
break;
default:
break;
}
while ((c = getchar()) != '\n' && c != EOF)
{
switch (c)
{
case ' ':
case '\t':
break;
default:
ans = -1;
break;
}
}
}
return ans;
}
else
return 0;
}
static int
multi_choice(const char *q1, ...)
{
FIXME
}
static long
check_misc_any_recipient(Text_no tno,
Text_stat *tstat,
......@@ -497,13 +532,43 @@ check_misc_any_recipient(Text_no tno,
if (lno < conf_min)
{
const char *set_loc_no = "Map the local number to this text";
kom_log("Text %lu: %s %lu<%lu>: loc_no is less than %lu\n",
(unsigned long)tno,
pretty_type,
(unsigned long)rcpt,
(unsigned long)lno,
(unsigned long)conf_min);
errors++;
if (lno < 1)
set_loc_no = NULL;
switch (multi_choice("Assign the text a new local number",
"Remove the misc-info",
set_loc_no,
(char*)NULL))
{
case 1:
case 2:
delete_misc(tstat, previous);
kom_log("Repaired: Conference %ld is no longer a %s.\n",
(unsigned long)rcpt, pretty_type);
mark_text_as_changed(tno);
modifications++;
*misc = previous;
break;
case 3:
assert(lno > 0);
l2g_expensive_set(&c->texts, lno, tno);
recommend_rerun = 1;
break;
default:
kom_log("Internal error at " __FILE__ ":" __LINE__ "\n");
/* FALLTHROUGH */
case 0:
errors++;
}
}
else if (lno >= conf_max)
{
......@@ -1696,6 +1761,8 @@ main (int argc,
{
kom_log("Found %d errors; performed %d modifications.\n",
errors, modifications);
if (recommend_rerun)
kom_log("Some additional problems may remain.\n");
fflush(stdout);
fflush(stderr);
if (confirm ("garb texts anyhow?"))
......@@ -1713,6 +1780,10 @@ main (int argc,
if (have_lock)
unlock_db();
if (recommend_rerun)
kom_log("Some problems may have been introduced during this dbck"
" session.\nPlease rerun dbck.\n");
/* Don't actually die until something is entered on stdin in debug
mode. This is mainly here for the benefit of the test suite,
but is could also be useful to be able to attach a debugger and
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment