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);
...@@ -455,190 +455,115 @@ confirm(const char *question) ...@@ -455,190 +455,115 @@ confirm(const char *question)
static long static long
check_misc_infos(Text_no tno, check_misc_any_recipient(Text_no tno,
Text_stat *tstat) Text_stat *tstat,
const char *pretty_type,
Conf_no rcpt,
Local_text_no lno,
Misc_info *previous,
const Misc_info **misc)
{ {
const Misc_info * misc = tstat->misc_items;
Misc_info * previous;
Misc_info_group group;
Conference *c; Conference *c;
Text_stat *t; long errors = 0;
Local_text_no conf_min; Local_text_no conf_min;
Local_text_no conf_max; Local_text_no conf_max;
long errors=0; c = cached_get_conf_stat(rcpt);
if (c == NULL && rcpt == 0)
while (previous = (Misc_info *)misc,
group = parse_next_misc(&misc,
tstat->misc_items + tstat->no_of_misc),
group.type != m_end_of_list && group.type != m_error )
{ {
switch ( group.type ) kom_log("Conference 0 is a %s of text %lu.\n",
{ pretty_type, (unsigned long)tno);
case m_recpt:
c = cached_get_conf_stat (group.recipient);
if ( c == NULL && group.recipient == 0 )
{
kom_log ("Conference 0 is recipient to text %lu.\n",
(unsigned long)tno);
if (rflag || confirm("Repair by deleting misc_item? ")) if (rflag || confirm("Repair by deleting misc_item? "))
{ {
delete_misc(tstat, previous); delete_misc(tstat, previous);
kom_log("Repaired: Conference 0 is no longer a %s.\n",
pretty_type);
mark_text_as_changed(tno); mark_text_as_changed(tno);
modifications++; modifications++;
kom_log("Repaired: Conference 0 is no longer a recipient.\n"); *misc = previous;
misc = previous;
} }
else else
errors++; errors++;
break; return errors;
} }
if ( c == NULL ) if (c == NULL)
break; return errors;
/* Check loc_no */ /* Check loc_no */
conf_min = l2g_lookup(&c->texts, 0); conf_min = l2g_lookup(&c->texts, 0);
conf_max = l2g_first_appendable_key(&c->texts); conf_max = l2g_first_appendable_key(&c->texts);
if (group.local_no < conf_min) if (lno < conf_min)
{ {
kom_log("Text %lu: Recipient %lu<%lu> loc_no is less than %lu\n", kom_log("Text %lu: %s %lu<%lu>: loc_no is less than %lu\n",
(unsigned long)tno, (unsigned long)group.recipient, (unsigned long)tno,
(unsigned long)group.local_no, pretty_type,
(unsigned long)rcpt,
(unsigned long)lno,
(unsigned long)conf_min); (unsigned long)conf_min);
errors++; errors++;
} }
else if (group.local_no >= conf_max) else if (lno >= conf_max)
{ {
kom_log("Text %lu: Recipient %lu<%lu> loc_no >= %lu\n", kom_log("Text %lu: %s %lu<%lu>: loc_no is greater than %lu\n",
(unsigned long)tno, (unsigned long)group.recipient, (unsigned long)tno,
(unsigned long)group.local_no, pretty_type,
(unsigned long)rcpt,
(unsigned long)lno,
(unsigned long)conf_max); (unsigned long)conf_max);
errors++; errors++;
} }
else if (l2g_lookup(&c->texts, group.local_no) != tno) else if (l2g_lookup(&c->texts, lno) != tno)
{ {
kom_log("Text %lu: Recipient %lu<%lu>: %s to %lu.\n", kom_log("Text %lu: %s %lu<%lu>: that local number is mapped to %lu.\n",
(unsigned long)tno, (unsigned long)group.recipient, (unsigned long)tno,
(unsigned long)group.local_no, pretty_type,
"that local number is mapped", (unsigned long)rcpt,
(unsigned long)l2g_lookup(&c->texts, group.local_no)); (unsigned long)lno,
(unsigned long)l2g_lookup(&c->texts, lno));
errors++; errors++;
} }
break; return errors;
}
case m_cc_recpt:
c = cached_get_conf_stat (group.cc_recipient);
if ( c == NULL && group.cc_recipient == 0 )
{
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) static long
{ check_misc_infos(Text_no tno,
kom_log("Text %lu: CC_Recipient %lu<%lu> is less than %lu\n", Text_stat *tstat)
(unsigned long)tno, (unsigned long)group.cc_recipient, {
(unsigned long)group.local_no, const Misc_info * misc = tstat->misc_items;
(unsigned long)conf_min); Misc_info * previous;
errors++; Misc_info_group group;
} Text_stat *t;
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; long errors=0;
case m_bcc_recpt: while (previous = (Misc_info *)misc,
c = cached_get_conf_stat (group.bcc_recipient); group = parse_next_misc(&misc,
if ( c == NULL && group.bcc_recipient == 0 ) tstat->misc_items + tstat->no_of_misc),
group.type != m_end_of_list && group.type != m_error )
{ {
kom_log ("Conference 0 is bcc_recipient to text %lu.\n", switch ( group.type )
(unsigned long)tno);
if (rflag || confirm("Repair by deleting misc_item? "))
{ {
delete_misc(tstat, previous); case m_recpt:
mark_text_as_changed(tno); check_misc_any_recipient(tno, tstat, "recipient",
modifications++; group.recipient, group.local_no,
kom_log("Repaired: Conf 0 is no longer a bcc_recipient.\n"); previous, &misc);
misc = previous;
}
else
errors++;
break; break;
}
if ( c == NULL ) case m_cc_recpt:
check_misc_any_recipient(tno, tstat, "cc_recipient",
group.cc_recipient, group.local_no,
previous, &misc);
break; break;
/* Check loc_no */ case m_bcc_recpt:
conf_min = l2g_lookup(&c->texts, 0); check_misc_any_recipient(tno, tstat, "bcc_recipient",
conf_max = l2g_first_appendable_key(&c->texts); group.bcc_recipient, group.local_no,
previous, &misc);
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