Commit 4fefe06b authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(add_text_in_conf): Adjusted to the fact that the texts member of

	Conference is now a l2g.
(do_sub_recpt): Likewise.
(set_loc_no): Removed.
(adjust_text_list): Removed.
(do_delete_text): Adjusted to the fact that the created_texts
 	member of Person is now a l2g.
(do_create_text): Likewise.
(get_map): The result argument now points to a
 	l2g_iterator_as_text_list instead of a Text_list.  Adjusted to the
 	fact that the texts member of Conference is now a l2g.
parent 51bda745
/* /*
* $Id: text.c,v 0.49 1998/07/08 17:08:58 ceder Exp $ * $Id: text.c,v 0.50 1998/07/26 16:42:24 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association.
* *
* This file is part of the LysKOM server. * This file is part of the LysKOM server.
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
*/ */
static const char * static const char *
rcsid = "$Id: text.c,v 0.49 1998/07/08 17:08:58 ceder Exp $"; rcsid = "$Id: text.c,v 0.50 1998/07/26 16:42:24 ceder Exp $";
#include "rcs.h" #include "rcs.h"
USE(rcsid); USE(rcsid);
...@@ -65,6 +65,7 @@ USE(rcsid); ...@@ -65,6 +65,7 @@ USE(rcsid);
#include "kom-memory.h" #include "kom-memory.h"
#include "aux-items.h" #include "aux-items.h"
#include "internal-services.h" #include "internal-services.h"
#include "local-to-global.h"
/* /*
...@@ -94,41 +95,17 @@ static Local_text_no ...@@ -94,41 +95,17 @@ static Local_text_no
add_text_in_conf(Conference * conf_c, add_text_in_conf(Conference * conf_c,
Text_no text_no) Text_no text_no)
{ {
Text_list * t; Local_text_no res;
time( & conf_c->last_written ); time( & conf_c->last_written );
/* Add number last on the text_list */ /* Add number last on the text_list */
t = &(conf_c->texts); res = l2g_first_appendable_key(&conf_c->texts);
t->texts = srealloc(t->texts, ++(t->no_of_texts) * sizeof(Text_no)); l2g_append(&conf_c->texts, res, text_no);
t->texts[ t->no_of_texts - 1 ] = text_no; return res;
return t->first_local_no + t->no_of_texts - 1;
} }
/*
* Set the global text_no of a certain local text_no if that local text_no
* exists in the conf. No action is taken if the local text_no doesn't exist.
* This function is probably only used to set the number to zero when a text
* is deleted.
*/
static void
set_loc_no (Conference * conf_c,
Local_text_no lno,
Text_no text_no)
{
if ( lno < conf_c->texts.first_local_no
|| lno > conf_c->texts.first_local_no + conf_c->texts.no_of_texts )
{
return; /* Doesn't exist in conf.stat. */
}
conf_c->texts.texts[ lno - conf_c->texts.first_local_no ] = text_no;
return;
}
/* /*
* Count how many recipients and cc_recipients a text has. * Count how many recipients and cc_recipients a text has.
*/ */
...@@ -554,38 +531,6 @@ do_delete_misc (u_short * no_of_misc, ...@@ -554,38 +531,6 @@ do_delete_misc (u_short * no_of_misc,
} }
} }
/*
* Delete leading zeroes from the text_list.
* Returns TRUE if some zeroes was deleted.
*/
static Bool
adjust_text_list(Text_list *text_list)
{
u_long zeroes;
u_long i;
for (zeroes = 0;
zeroes < text_list->no_of_texts && text_list->texts[ zeroes ] == 0;
zeroes++)
;
if ( zeroes > 0 )
{
text_list->no_of_texts -= zeroes;
text_list->first_local_no += zeroes;
for ( i = 0; i < text_list->no_of_texts; i++)
text_list->texts[ i ] = text_list->texts[ i + zeroes ];
text_list->texts = srealloc(text_list->texts,
(text_list->no_of_texts
* sizeof(Text_no)));
}
return (zeroes > 0) ? TRUE : FALSE;
}
/* /*
* Delete a recipient from a text. Does not fail if the recipient doesn't * Delete a recipient from a text. Does not fail if the recipient doesn't
* exist - that is not an error. * exist - that is not an error.
...@@ -616,9 +561,8 @@ do_sub_recpt (Text_no text_no, ...@@ -616,9 +561,8 @@ do_sub_recpt (Text_no text_no,
if ( conf_s != NULL ) if ( conf_s != NULL )
{ {
/* Only if the conference exists: */ /* Only if the conference exists: */
set_loc_no( conf_s, l2g_delete(&conf_s->texts,
text_s->misc_items[ i+1 ].datum.local_no, 0 ); text_s->misc_items[ i+1 ].datum.local_no);
adjust_text_list (&conf_s->texts);
mark_conference_as_changed (conf_no); mark_conference_as_changed (conf_no);
} }
...@@ -634,8 +578,8 @@ do_sub_recpt (Text_no text_no, ...@@ -634,8 +578,8 @@ do_sub_recpt (Text_no text_no,
{ {
if ( conf_s != NULL ) if ( conf_s != NULL )
{ {
set_loc_no( conf_s, l2g_delete(&conf_s->texts,
text_s->misc_items[ i+1 ].datum.local_no, 0 ); text_s->misc_items[ i+1 ].datum.local_no);
mark_conference_as_changed( conf_no ); mark_conference_as_changed( conf_no );
} }
...@@ -651,8 +595,8 @@ do_sub_recpt (Text_no text_no, ...@@ -651,8 +595,8 @@ do_sub_recpt (Text_no text_no,
{ {
if ( conf_s != NULL ) if ( conf_s != NULL )
{ {
set_loc_no( conf_s, l2g_delete(&conf_s->texts,
text_s->misc_items[ i+1 ].datum.local_no, 0 ); text_s->misc_items[ i+1 ].datum.local_no);
mark_conference_as_changed( conf_no ); mark_conference_as_changed( conf_no );
} }
...@@ -1492,8 +1436,6 @@ do_delete_text(Text_no text_no, ...@@ -1492,8 +1436,6 @@ do_delete_text(Text_no text_no,
Text_stat *text_s) Text_stat *text_s)
{ {
Person *author; Person *author;
Bool found = FALSE;
u_long i;
if ( text_s == NULL ) if ( text_s == NULL )
GET_T_STAT(text_s, text_no, FAILURE); GET_T_STAT(text_s, text_no, FAILURE);
...@@ -1501,23 +1443,7 @@ do_delete_text(Text_no text_no, ...@@ -1501,23 +1443,7 @@ do_delete_text(Text_no text_no,
send_async_deleted_text(text_no, text_s); send_async_deleted_text(text_no, text_s);
if ((author = cached_get_person_stat (text_s->author)) != NULL) if ((author = cached_get_person_stat (text_s->author)) != NULL)
{ l2g_delete_global_in_sorted(&author->created_texts, text_no);
/* Delete this text from created_texts. */
for ( i = 0; i < author->created_texts.no_of_texts; i++ )
if ( author->created_texts.texts[ i ] == text_no )
{
author->created_texts.texts[ i ] = 0;
adjust_text_list (&author->created_texts);
mark_person_as_changed (text_s->author);
found = TRUE;
break;
}
if ( !found )
log("ERROR: %s: do_delete_text(): %s",
__FILE__, "text not found in authors created_texts.");
}
while ( text_s->no_of_misc > 0 ) while ( text_s->no_of_misc > 0 )
{ {
...@@ -2456,11 +2382,9 @@ do_create_text(const String message, ...@@ -2456,11 +2382,9 @@ do_create_text(const String message,
if (!anonymous) if (!anonymous)
{ {
ACT_P->created_texts.texts l2g_append(&ACT_P->created_texts,
= srealloc(ACT_P->created_texts.texts, l2g_first_appendable_key(&ACT_P->created_texts),
++(ACT_P->created_texts.no_of_texts) * sizeof(Text_no)); text);
ACT_P->created_texts.texts[ ACT_P->created_texts.no_of_texts - 1 ] =
text;
ACT_P->created_lines += t_stat->no_of_lines; ACT_P->created_lines += t_stat->no_of_lines;
ACT_P->created_bytes += t_stat->no_of_chars; ACT_P->created_bytes += t_stat->no_of_chars;
...@@ -3049,10 +2973,12 @@ extern Success ...@@ -3049,10 +2973,12 @@ extern Success
get_map (Conf_no conf_no, get_map (Conf_no conf_no,
Local_text_no first_local_no, Local_text_no first_local_no,
Local_text_no no_of_texts, Local_text_no no_of_texts,
Text_list * result) L2g_iterator_as_text_list * result)
{ {
Conference * conf_c; Conference * conf_c;
Local_text_no highest_wanted_no, highest; Local_text_no highest_wanted_no, highest;
Local_text_no res_first;
int res_nr;
Access acc; Access acc;
CHK_LOGIN(FAILURE); CHK_LOGIN(FAILURE);
...@@ -3074,7 +3000,7 @@ get_map (Conf_no conf_no, ...@@ -3074,7 +3000,7 @@ get_map (Conf_no conf_no,
return FAILURE; return FAILURE;
} }
highest = conf_c->texts.first_local_no + conf_c->texts.no_of_texts; highest = l2g_first_appendable_key(&conf_c->texts) - 1;
if ( first_local_no >= highest ) if ( first_local_no >= highest )
{ {
...@@ -3082,18 +3008,18 @@ get_map (Conf_no conf_no, ...@@ -3082,18 +3008,18 @@ get_map (Conf_no conf_no,
kom_errno = KOM_NO_SUCH_LOCAL_TEXT; kom_errno = KOM_NO_SUCH_LOCAL_TEXT;
return FAILURE; return FAILURE;
} }
result->first_local_no = max(conf_c->texts.first_local_no, res_first = l2g_next_key(&conf_c->texts, 0);
first_local_no); res_first = max(res_first, first_local_no);
highest_wanted_no = min(highest, first_local_no + no_of_texts); highest_wanted_no = min(highest, first_local_no + no_of_texts);
if ( highest_wanted_no >= result->first_local_no ) if (highest_wanted_no >= res_first)
result->no_of_texts = highest_wanted_no - result->first_local_no; res_nr = highest_wanted_no - res_first;
else else
result->no_of_texts = 0; res_nr = 0;
result->texts = &conf_c->texts.texts[ result->first_local_no l2gi_searchsome(result, &conf_c->texts,
- conf_c->texts.first_local_no ]; res_first, res_first + res_nr - 1);
return OK; return OK;
} }
......
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