Commit 1a4899dc authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(prot_a_output_read_texts): New static function that handles the new

	range-based representation of memberships.
(prot_a_output_membership_old): Use it.
parent 1de9ac5f
/*
* $Id: prot-a-output.c,v 0.54 2002/03/29 22:29:45 ceder Exp $
* $Id: prot-a-output.c,v 0.55 2002/11/06 18:40:52 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -120,29 +120,70 @@ void prot_a_output_membership(Connection *fp,
prot_a_output_membership_type(fp, mship->type);
}
static void
prot_a_output_read_texts(Connection *fp,
const Membership *mship)
{
if (mship->read_ranges == 0)
isc_puts(" 0 0 *", fp->isc_session);
else
{
struct read_range *begin;
struct read_range *end;
assert(mship->read_ranges != NULL);
assert(mship->no_of_read_ranges > 0);
begin = &mship->read_ranges[0];
end = begin + mship->no_of_read_ranges;
if (begin->first_read == 1)
{
prot_a_output_ul(fp, begin->last_read);
begin++;
}
else
isc_puts(" 0", fp->isc_session);
if (begin == end)
isc_puts(" 0 *", fp->isc_session);
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;
prot_a_output_ul(fp, no_of_read);
if (mship->skip_read_texts)
isc_puts(" *", fp->isc_session);
else
{
isc_puts(" {", fp->isc_session);
for (ptr = begin; ptr < end; ++ptr)
{
Local_text_no lno;
for (lno = ptr->first_read; lno <= ptr->last_read; lno++)
prot_a_output_ul(fp, lno);
}
isc_puts(" }", fp->isc_session);
}
}
}
}
void
prot_a_output_membership_old(Connection *fp,
const Membership *mship)
{
int i;
prot_a_output_time(fp, mship->last_time_read );
prot_a_output_ul(fp, mship->conf_no);
prot_a_output_ul(fp, mship->priority);
prot_a_output_ul(fp, mship->last_text_read);
prot_a_output_ul(fp, mship->no_of_read);
if ( mship->read_texts != NULL && mship->no_of_read > 0)
{
isc_puts(" {", fp->isc_session);
for ( i = 0; i < mship->no_of_read; i++)
prot_a_output_ul(fp, mship->read_texts[i]);
isc_puts(" }", fp->isc_session);
}
else
isc_puts(" *", fp->isc_session);
prot_a_output_read_texts(fp, mship);
}
......
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