Commit ba539f30 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(check_misc_any_recipient): New static function.

(check_misc_infos): Use it, to avoid repeating the same code inline
	three times.
parent 963f8e5e
/* /*
* $Id: dbck.c,v 0.58 1999/07/02 00:14:02 byers Exp $ * $Id: dbck.c,v 0.59 1999/09/19 20:34:24 ceder Exp $
* Copyright (C) 1991-1999 Lysator Academic Computer Association. * Copyright (C) 1991-1999 Lysator Academic Computer Association.
* *
* This file is part of the LysKOM server. * This file is part of the LysKOM server.
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
static const char * static const char *
rcsid = "$Id: dbck.c,v 0.58 1999/07/02 00:14:02 byers Exp $"; rcsid = "$Id: dbck.c,v 0.59 1999/09/19 20:34:24 ceder Exp $";
#include "rcs.h" #include "rcs.h"
USE(rcsid); USE(rcsid);
...@@ -452,7 +452,83 @@ confirm(const char *question) ...@@ -452,7 +452,83 @@ confirm(const char *question)
else else
return 0; return 0;
} }
static long
check_misc_any_recipient(Text_no tno,
Text_stat *tstat,
const char *pretty_type,
Conf_no rcpt,
Local_text_no lno,
Misc_info *previous,
const Misc_info **misc)
{
Conference *c;
long errors = 0;
Local_text_no conf_min;
Local_text_no conf_max;
c = cached_get_conf_stat(rcpt);
if (c == NULL && rcpt == 0)
{
kom_log("Conference 0 is a %s of text %lu.\n",
pretty_type, (unsigned long)tno);
if (rflag || confirm("Repair by deleting misc_item? "))
{
delete_misc(tstat, previous);
kom_log("Repaired: Conference 0 is no longer a %s.\n",
pretty_type);
mark_text_as_changed(tno);
modifications++;
*misc = previous;
}
else
errors++;
return errors;
}
if (c == NULL)
return errors;
/* Check loc_no */
conf_min = l2g_lookup(&c->texts, 0);
conf_max = l2g_first_appendable_key(&c->texts);
if (lno < conf_min)
{
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++;
}
else if (lno >= conf_max)
{
kom_log("Text %lu: %s %lu<%lu>: loc_no is greater than %lu\n",
(unsigned long)tno,
pretty_type,
(unsigned long)rcpt,
(unsigned long)lno,
(unsigned long)conf_max);
errors++;
}
else if (l2g_lookup(&c->texts, lno) != tno)
{
kom_log("Text %lu: %s %lu<%lu>: that local number is mapped to %lu.\n",
(unsigned long)tno,
pretty_type,
(unsigned long)rcpt,
(unsigned long)lno,
(unsigned long)l2g_lookup(&c->texts, lno));
errors++;
}
return errors;
}
static long static long
check_misc_infos(Text_no tno, check_misc_infos(Text_no tno,
...@@ -461,10 +537,7 @@ check_misc_infos(Text_no tno, ...@@ -461,10 +537,7 @@ check_misc_infos(Text_no tno,
const Misc_info * misc = tstat->misc_items; const Misc_info * misc = tstat->misc_items;
Misc_info * previous; Misc_info * previous;
Misc_info_group group; Misc_info_group group;
Conference *c;
Text_stat *t; Text_stat *t;
Local_text_no conf_min;
Local_text_no conf_max;
long errors=0; long errors=0;
...@@ -476,169 +549,21 @@ check_misc_infos(Text_no tno, ...@@ -476,169 +549,21 @@ check_misc_infos(Text_no tno,
switch ( group.type ) switch ( group.type )
{ {
case m_recpt: case m_recpt:
c = cached_get_conf_stat (group.recipient); check_misc_any_recipient(tno, tstat, "recipient",
if ( c == NULL && group.recipient == 0 ) group.recipient, group.local_no,
{ previous, &misc);
kom_log ("Conference 0 is recipient to text %lu.\n",
(unsigned long)tno);
if (rflag || confirm("Repair by deleting misc_item? "))
{
delete_misc(tstat, previous);
mark_text_as_changed(tno);
modifications++;
kom_log("Repaired: Conference 0 is no longer a recipient.\n");
misc = previous;
}
else
errors++;
break;
}
if ( c == NULL )
break;
/* Check loc_no */
conf_min = l2g_lookup(&c->texts, 0);
conf_max = l2g_first_appendable_key(&c->texts);
if (group.local_no < conf_min)
{
kom_log("Text %lu: Recipient %lu<%lu> loc_no is less than %lu\n",
(unsigned long)tno, (unsigned long)group.recipient,
(unsigned long)group.local_no,
(unsigned long)conf_min);
errors++;
}
else if (group.local_no >= conf_max)
{
kom_log("Text %lu: Recipient %lu<%lu> loc_no >= %lu\n",
(unsigned long)tno, (unsigned long)group.recipient,
(unsigned long)group.local_no,
(unsigned long)conf_max);
errors++;
}
else if (l2g_lookup(&c->texts, group.local_no) != tno)
{
kom_log("Text %lu: Recipient %lu<%lu>: %s to %lu.\n",
(unsigned long)tno, (unsigned long)group.recipient,
(unsigned long)group.local_no,
"that local number is mapped",
(unsigned long)l2g_lookup(&c->texts, group.local_no));
errors++;
}
break; break;
case m_cc_recpt: case m_cc_recpt:
c = cached_get_conf_stat (group.cc_recipient); check_misc_any_recipient(tno, tstat, "cc_recipient",
if ( c == NULL && group.cc_recipient == 0 ) group.cc_recipient, group.local_no,
{ previous, &misc);
kom_log ("Conference 0 is cc_recipient to text %lu.\n",
(unsigned long)tno);
if (rflag || confirm("Repair by deleting misc_item? "))
{
delete_misc(tstat, previous);
mark_text_as_changed(tno);
modifications++;
kom_log("Repaired: Conf 0 is no longer a cc_recipient.\n");
misc = previous;
}
else
errors++;
break;
}
if ( c == NULL )
break;
/* Check loc_no */
conf_min = l2g_lookup(&c->texts, 0);
conf_max = l2g_first_appendable_key(&c->texts);
if (group.local_no < conf_min)
{
kom_log("Text %lu: CC_Recipient %lu<%lu> is less than %lu\n",
(unsigned long)tno, (unsigned long)group.cc_recipient,
(unsigned long)group.local_no,
(unsigned long)conf_min);
errors++;
}
else if (group.local_no >= conf_max)
{
kom_log("Text %lu: CC_Recipient %lu<%lu> loc_no >= %lu\n",
(unsigned long)tno, (unsigned long)group.cc_recipient,
(unsigned long)group.local_no,
(unsigned long)conf_max);
errors++;
}
else if (l2g_lookup(&c->texts, group.local_no) != tno)
{
kom_log("Text %lu: CC_Recipient %lu<%lu>: %s to %lu.\n",
(unsigned long)tno, (unsigned long)group.cc_recipient,
(unsigned long)group.local_no,
"that local number is mapped",
(unsigned long)l2g_lookup(&c->texts, group.local_no));
errors++;
}
break; break;
case m_bcc_recpt: case m_bcc_recpt:
c = cached_get_conf_stat (group.bcc_recipient); check_misc_any_recipient(tno, tstat, "bcc_recipient",
if ( c == NULL && group.bcc_recipient == 0 ) group.bcc_recipient, group.local_no,
{ previous, &misc);
kom_log ("Conference 0 is bcc_recipient to text %lu.\n",
(unsigned long)tno);
if (rflag || confirm("Repair by deleting misc_item? "))
{
delete_misc(tstat, previous);
mark_text_as_changed(tno);
modifications++;
kom_log("Repaired: Conf 0 is no longer a bcc_recipient.\n");
misc = previous;
}
else
errors++;
break;
}
if ( c == NULL )
break;
/* Check loc_no */
conf_min = l2g_lookup(&c->texts, 0);
conf_max = l2g_first_appendable_key(&c->texts);
if (group.local_no < conf_min)
{
kom_log("Text %lu: BCC_Recipient %lu<%lu> is less than %lu\n",
(unsigned long)tno, (unsigned long)group.bcc_recipient,
(unsigned long)group.local_no,
(unsigned long)conf_min);
errors++;
}
else if (group.local_no >= conf_max)
{
kom_log("Text %lu: BCC_Recipient %lu<%lu> loc_no >= %lu\n",
(unsigned long)tno, (unsigned long)group.bcc_recipient,
(unsigned long)group.local_no,
(unsigned long)conf_max);
errors++;
}
else if (l2g_lookup(&c->texts, group.local_no) != tno)
{
kom_log("Text %lu: BCC_Recipient %lu<%lu>: %s to %lu.\n",
(unsigned long)tno, (unsigned long)group.bcc_recipient,
(unsigned long)group.local_no,
"that local number is mapped",
(unsigned long)l2g_lookup(&c->texts,
group.local_no));
errors++;
}
break; break;
case m_comm_to: case m_comm_to:
......
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