Commit 9edfa964 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(report_bad_aux): New static function.

(is_member_in_linked_recpt): New argument: tno.  All callers
	updated.  For now, do nothing special with cross-reference;
	until but 23 is fixed that would be pointless.  Report bad
	aux-items with report_bad_aux.  Added missing breaks.
(interested_party): New argument: tno.  All callers updated.
parent 660e68cd
/*
* $Id: text.c,v 0.101 2003/01/13 11:24:02 ceder Exp $
* $Id: text.c,v 0.102 2003/01/17 09:29:54 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -66,6 +66,7 @@
#include "local-to-global.h"
#include "server-time.h"
#include "text.h"
#include "string-malloc.h"
/*
......@@ -88,6 +89,7 @@ filter_secret_info(Text_stat *result,
static Bool
interested_party(const Connection *cptr,
Text_no tno,
const Text_stat *text_s);
/*
* Static functions
......@@ -472,6 +474,25 @@ is_member_in_recpt_of(const Person *person,
}
static void
report_bad_aux(Text_no tno,
String *data,
int tag,
const char *reason)
{
static Text_no last = 0;
if (tno == last)
return;
last = tno;
char *d = s_crea_c_str(*data);
kom_log("Bad aux-item %d found in text %ld: \"%s\": %s.\n",
tag, (unsigned long)tno, d, reason);
string_free(d);
}
/*
* Check if person is a member in any of the recipients of a text that
* is linked to this text. If skip_passive is true, ignore passive
......@@ -479,13 +500,16 @@ is_member_in_recpt_of(const Person *person,
*/
static Bool
is_member_in_linked_recpt(const Person *person,
Text_no tno,
const Text_stat *text_s,
Bool skip_passive)
{
int i;
Text_no linked_nr;
String *data;
#if 0
String copy;
#endif
String_size end;
for (i = 0; i < text_s->no_of_misc; i++)
......@@ -525,36 +549,60 @@ is_member_in_linked_recpt(const Person *person,
switch (text_s->aux_item_list.items[i].tag)
{
case aux_cross_reference:
/* FIXME (bug 23): Until there is a mirroring aux-item,
there is no point doing this. */
#if 0
/* Data is "T", optional space, a text number, a space, and
some junk we don't care about. */
if (s_strlen(*data) < 2 || data->string[0] != 'T')
if (s_strlen(*data) < 2)
{
report_bad_aux(tno, data, "cross-reference", "too short");
continue;
}
if (data->string[0] != 'T')
continue;
copy = s_fsubstr(*data, 1, END_OF_STRING);
linked_nr = s_strtol(copy, &end);
if (end == -1)
{
report_bad_aux(tno, data, "cross-reference",
"no number found");
continue;
if (end >= s_strlen(copy))
continue;
if (copy.string[end] != ' ')
}
if (end < s_strlen(copy) && copy.string[end] != ' ')
{
report_bad_aux(tno, data, "cross-reference",
"trailing garbage");
continue;
}
if (is_member_in_recpt_of(person, linked_nr, skip_passive) == TRUE)
return TRUE;
#endif
break;
case aux_mx_mime_belongs_to:
case aux_mx_mime_part_in:
/* Data is a single text number. */
linked_nr = s_strtol(*data, &end);
if (end == -1)
{
report_bad_aux(tno, data, text_s->aux_item_list.items[i].tag,
"bad number");
continue;
}
if (end != s_strlen(*data))
{
report_bad_aux(tno, data, text_s->aux_item_list.items[i].tag,
"trailing garbage");
continue;
}
if (is_member_in_recpt_of(person, linked_nr, skip_passive) == TRUE)
return TRUE;
break;
case aux_faq_for_conf:
/* Data is a conference number. 0 means the entire system. */
......@@ -567,6 +615,7 @@ is_member_in_linked_recpt(const Person *person,
if (linked_nr == 0
|| is_member_in(person, linked_nr, skip_passive) == TRUE)
return TRUE;
break;
default:
break;
......@@ -669,7 +718,7 @@ send_async_sub_recipient(Text_no text_no,
while ((i = traverse_connections(i)) != 0)
{
cptr = get_conn_by_number(i);
if (interested_party(cptr, text_s)
if (interested_party(cptr, text_no, text_s)
&& text_read_access(cptr, text_no, text_s))
{
Text_stat copy;
......@@ -1259,7 +1308,8 @@ filter_secret_info(Text_stat *result,
static Bool
interested_party(const Connection *cptr,
const Text_stat *text_s)
Text_no tno,
const Text_stat *text_s)
{
if (cptr->person == NULL)
return FALSE;
......@@ -1267,7 +1317,7 @@ interested_party(const Connection *cptr,
if (is_member_in_recpt(cptr->person, text_s, TRUE) == TRUE)
return TRUE;
if (is_member_in_linked_recpt(cptr->person, text_s, TRUE) == TRUE)
if (is_member_in_linked_recpt(cptr->person, tno, text_s, TRUE) == TRUE)
return TRUE;
return FALSE;
......@@ -1291,7 +1341,7 @@ send_async_deleted_text(Text_no text_no,
while ((i = traverse_connections(i)) != 0)
{
cptr = get_conn_by_number(i);
if (interested_party(cptr, text_s)
if (interested_party(cptr, text_no, text_s)
&& text_read_access(cptr, text_no, text_s))
{
filter_secret_info(&filtered, text_s, cptr, TRUE);
......@@ -2075,7 +2125,7 @@ send_async_new_text_old(Text_no text_no,
* since it is allocated with tmp_alloc we do not need to free
* the memory now.
*/
if (interested_party(cptr, text_s)
if (interested_party(cptr, text_no, text_s)
&& text_read_access(cptr, text_no, text_s))
{
filter_secret_info(&filtered, text_s, cptr, FALSE);
......@@ -2103,7 +2153,7 @@ send_async_new_text(Text_no text_no,
* since it is allocated with tmp_alloc we do not need to free
* the memory now.
*/
if (interested_party(cptr, text_s)
if (interested_party(cptr, text_no, text_s)
&& text_read_access(cptr, text_no, text_s))
{
filter_secret_info(&filtered, text_s, cptr, TRUE);
......@@ -2625,7 +2675,7 @@ send_async_add_recipient(Text_no text_no,
while ((i = traverse_connections(i)) != 0)
{
cptr = get_conn_by_number(i);
if (interested_party(cptr, text_s)
if (interested_party(cptr, text_no, text_s)
&& text_read_access(cptr, text_no, text_s))
{
Text_stat copy;
......
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