Commit 1ea7e221 authored by Per Cederqvist's avatar Per Cederqvist

(foutput_person_0): Adjusted to new API of foutput_text_list.

(foutput_person_2): Use l2g_write instead of foutput_text_list.
(foutput_conference_2): Likewise.
(foutput_conference_1): Adjusted to new API of foutput_text_list.
(foutput_conference_0): Likewise.
(foutput_text_list): The text_list argument is now a pointer to
	Local_to_global instead of a Text_list.  The generated output is
	still the same.
(foutput_ulong): Eliminated a future buffer overrun.  Cleaned up the code.
parent 8484c928
/*
* $Id: ram-output.c,v 0.24 1998/07/08 16:56:08 ceder Exp $
* $Id: ram-output.c,v 0.25 1998/07/26 16:43:56 ceder Exp $
* Copyright (C) 1991, 1993, 1994, 1995, 1996 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -34,7 +34,7 @@
*/
static const char *
rcsid = "$Id: ram-output.c,v 0.24 1998/07/08 16:56:08 ceder Exp $";
rcsid = "$Id: ram-output.c,v 0.25 1998/07/26 16:43:56 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -50,6 +50,7 @@ USE(rcsid);
#include "ram-output.h"
#include "lyskomd.h"
#include "log.h"
#include "local-to-global.h"
static int output_format = 2;
......@@ -120,7 +121,7 @@ foutput_person_0 (FILE *fp,
foutput_priv_bits (fp, person->privileges);
foutput_personal_flags (fp, person->flags);
foutput_text_list (fp, person->created_texts);
foutput_text_list (fp, &person->created_texts);
foutput_mark_list (fp, person->marks);
foutput_membership_list (fp, person->conferences);
......@@ -148,7 +149,7 @@ foutput_person_2 (FILE *fp,
foutput_priv_bits (fp, person->privileges);
foutput_personal_flags (fp, person->flags);
foutput_text_list (fp, person->created_texts);
l2g_write (fp, &person->created_texts);
foutput_mark_list (fp, person->marks);
foutput_membership_list (fp, person->conferences);
......@@ -194,7 +195,7 @@ foutput_conference_2 (FILE *fp,
{
foutput_string(fp, conf_c->name);
foutput_member_list(fp, conf_c->members);
foutput_text_list(fp, conf_c->texts);
l2g_write(fp, &conf_c->texts);
foutput_conf_type(fp, conf_c->type);
foutput_time(fp, conf_c -> creation_time );
......@@ -219,7 +220,7 @@ foutput_conference_1 (FILE *fp,
{
foutput_string(fp, conf_c->name);
foutput_member_list(fp, conf_c->members);
foutput_text_list(fp, conf_c->texts);
foutput_text_list(fp, &conf_c->texts);
foutput_conf_type(fp, conf_c->type);
foutput_time(fp, conf_c -> creation_time );
......@@ -241,7 +242,7 @@ foutput_conference_0 (FILE *fp,
{
foutput_string(fp, conf_c->name);
foutput_member_list(fp, conf_c->members);
foutput_text_list(fp, conf_c->texts);
foutput_text_list(fp, &conf_c->texts);
foutput_conf_type(fp, conf_c->type);
foutput_time(fp, conf_c -> creation_time );
......@@ -560,18 +561,24 @@ foutput_personal_flags(FILE *fp,
void
foutput_text_list(FILE *fp,
Text_list text_list)
const Local_to_global *text_list)
{
unsigned long i;
Local_text_no first;
Local_text_no end;
foutput_ulong((unsigned long)text_list.first_local_no, fp);
foutput_ulong((unsigned long)text_list.no_of_texts, fp);
first = l2g_next_key(text_list, 0);
if (first == 0)
first = 1;
end = l2g_first_appendable_key(text_list);
foutput_ulong((unsigned long)first, fp);
foutput_ulong((unsigned long)(end - first), fp);
if ( text_list.texts != NULL && text_list.no_of_texts > 0 )
if (first < end)
{
fputs(" {", fp);
for ( i = 0; i < text_list.no_of_texts; i++ )
foutput_ulong((unsigned long)text_list.texts[ i ], fp);
while (first < end)
foutput_ulong((unsigned long)l2g_lookup(text_list, first), fp);
fputs(" }", fp);
}
else
......@@ -843,18 +850,20 @@ void
foutput_ulong (unsigned long l,
FILE *fp)
{
static char buf[20];
static char buf[sizeof(unsigned long) * 3 + 1];
char *cp;
putc(' ', fp);
if (l < 10)
putc("0123456789"[l], fp);
else {
cp = buf + 19;
while (l > 0) {
*cp-- = (l % 10) + '0';
else
{
cp = buf + sizeof(buf);
while (l > 0)
{
*--cp = (l % 10) + '0';
l /= 10;
}
fwrite(cp + 1, buf + 19 - cp, 1, fp);
fwrite(cp, buf + sizeof(buf) - cp, 1, fp);
}
}
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