Commit 80e0f3fa authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(foutput_read_ranges_0): New static function that handles the new

	range-based representation of memberships.
(foutput_membership_0): Use it.
(foutput_membership_2): Use it.
parent 1a4899dc
/*
* $Id: ram-output.c,v 0.40 2002/03/29 22:29:44 ceder Exp $
* $Id: ram-output.c,v 0.41 2002/11/06 18:41:05 ceder Exp $
* Copyright (C) 1991, 1993-1999, 2001-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -455,70 +455,82 @@ foutput_membership_type(FILE *fp,
putc(type.reserved5 + '0', fp);
}
static void
foutput_read_ranges_0(FILE *fp,
Membership *mship)
{
if (mship->read_ranges == NULL && mship->no_of_read_ranges != 0 )
{
kom_log("foutput_read_ranges_0(): no_of_read_ranges forced to 0"
" in a membership in %lu.\n", (unsigned long)mship->conf_no);
mship->no_of_read_ranges = 0;
}
if (mship->no_of_read_ranges == 0)
fprintf(fp, " 0 0 *");
else
{
struct read_range *begin;
struct read_range *end;
begin = &mship->read_ranges[0];
end = begin + mship->no_of_read_ranges;
if (begin->first_read == 1)
{
fprintf(fp, " %lu", begin->last_read);
begin++;
}
else
fprintf(fp, " 0");
if (begin == end)
fprintf(fp, " 0 *");
else
{
unsigned long no_of_read = 0;
const struct read_range *ptr;
for (ptr = begin; ptr < end; ++ptr)
no_of_read += ptr->last_read - ptr->first_read + 1;
fprintf(fp, " %lu {", no_of_read);
for (ptr = begin; ptr < end; ++ptr)
{
Local_text_no lno;
for (lno = ptr->first_read; lno <= ptr->last_read; lno++)
fprintf(fp, " %lu", (unsigned long)lno);
}
fprintf(fp, " }");
}
}
}
static void
foutput_membership_0(FILE *fp,
Membership *mship)
{
int i;
foutput_time(fp, mship->last_time_read );
if ( mship->read_texts == NULL && mship->no_of_read != 0 )
{
kom_log("%s(): no_of_read forced to 0 in a membership in %lu.\n",
"foutput_membership", (unsigned long)mship->conf_no);
mship->no_of_read = 0;
}
fprintf(fp, " %lu %lu %lu %lu",
fprintf(fp, " %lu %lu",
(unsigned long)mship->conf_no,
(unsigned long)mship->priority,
(unsigned long)mship->last_text_read,
(unsigned long)mship->no_of_read);
if ( mship->read_texts != NULL && mship->no_of_read > 0)
{
fprintf(fp, " {");
for ( i = 0; i < mship->no_of_read; i++)
fprintf(fp, " %lu", (unsigned long)mship->read_texts[ i ]);
fprintf(fp, " }");
}
else
fprintf(fp, " *");
(unsigned long)mship->priority);
foutput_read_ranges_0(fp, mship);
}
static void
foutput_membership_2(FILE *fp,
Membership *mship)
{
int i;
foutput_time(fp, mship->last_time_read );
if ( mship->read_texts == NULL && mship->no_of_read != 0 )
{
kom_log("%s(): no_of_read forced to 0 in a membership in %lu.\n",
"foutput_membership", (unsigned long)mship->conf_no);
mship->no_of_read = 0;
}
fprintf(fp, " %lu %lu %lu %lu",
fprintf(fp, " %lu %lu",
(unsigned long)mship->conf_no,
(unsigned long)mship->priority,
(unsigned long)mship->last_text_read,
(unsigned long)mship->no_of_read);
if ( mship->read_texts != NULL && mship->no_of_read > 0)
{
fprintf(fp, " {");
for ( i = 0; i < mship->no_of_read; i++)
fprintf(fp, " %lu", (unsigned long)mship->read_texts[ i ]);
fprintf(fp, " }");
}
else
fprintf(fp, " *");
(unsigned long)mship->priority);
foutput_read_ranges_0(fp, mship);
fprintf(fp, " %lu", (unsigned long)mship->added_by);
foutput_time(fp, mship->added_at);
foutput_membership_type(fp, mship->type);
......
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