Select Git revision
-
Henrik (Grubba) Grubbström authored
Rev: src/modules/system/system.c:1.18
Henrik (Grubba) Grubbström authoredRev: src/modules/system/system.c:1.18
prot-a-output.c 13.87 KiB
/*
* $Id: prot-a-output.c,v 0.13 1993/10/10 17:04:52 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
*
* LysKOM is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* LysKOM is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with LysKOM; see the file COPYING. If not, write to
* Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
* or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
*
* Please mail bug reports to bug-lyskom@lysator.liu.se.
*/
/*
* prot-a-output.c - write objects through a mux connection.
*
* Written by ceder 1990-07-13
*/
static char *rcsid = "$Id: prot-a-output.c,v 0.13 1993/10/10 17:04:52 ceder Exp $";
#include "rcs.h"
USE(rcsid);
#include <time.h>
#include <setjmp.h>
#include "kom-types.h"
#include "isc-interface.h"
#include "com.h"
#include "connections.h"
#include "mux.h"
#include "prot-a-output.h"
#include "lyskomd.h"
void
prot_a_output_person (Connection *fp,
Person *person)
{
prot_a_output_string (fp, person->username);
prot_a_output_priv_bits (fp, person->privileges);
prot_a_output_personal_flags (fp, person->flags);
prot_a_output_time(fp, person->last_login);
mux_printf (fp, " %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
(u_long) person -> user_area,
(u_long) person -> total_time_present, /* This is not a time,
* but a number of seconds.
*/
(u_long) person -> sessions,
(u_long) person -> created_lines,
(u_long) person -> created_bytes,
(u_long) person -> read_texts,
(u_long) person -> no_of_text_fetches,
(u_long) person -> created_persons,
(u_long) person -> created_confs,
(u_long) person -> created_texts.first_local_no,
(u_long) person -> created_texts.no_of_texts,
(u_long) person -> marks.no_of_marks,
(u_long) person -> conferences.no_of_confs);
}
void
prot_a_output_membership(Connection *fp,
const Membership *mship)
{
int i;
prot_a_output_time(fp, mship->last_time_read );
mux_printf(fp, " %lu %lu %lu %lu",
(u_long)mship->conf_no,
(u_long)mship->priority,
(u_long)mship->last_text_read,
(u_long)mship->no_of_read);
if ( mship->read_texts != NULL && mship->no_of_read > 0)
{
mux_printf(fp, " {");
for ( i = 0; i < mship->no_of_read; i++)
mux_printf(fp, " %lu", (u_long)mship->read_texts[ i ]);
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_membership_list (Connection * fp,
Membership_list mlist)
{
int i;
mux_printf(fp, " %lu", (u_long)mlist.no_of_confs);
if ( mlist.confs != NULL && mlist.no_of_confs > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < mlist.no_of_confs; i++)
prot_a_output_membership(fp, mlist.confs + i);
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_conf_list(Connection *fp,
Conf_list_old conf_list)
{
int i;
mux_printf(fp, " %lu", (u_long)conf_list.no_of_conf_nos);
if ( conf_list.conf_nos != NULL && conf_list.no_of_conf_nos > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < conf_list.no_of_conf_nos; i++ )
mux_printf(fp, " %lu", (u_long)conf_list.conf_nos[ i ]);
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
if ( conf_list.type_of_conf != NULL && conf_list.no_of_conf_nos > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < conf_list.no_of_conf_nos; i++ )
prot_a_output_conf_type(fp, conf_list.type_of_conf[ i ]);
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_conf_no_list(Connection *fp,
Conf_no_list conf_no_list)
{
int i;
mux_printf(fp, " %lu", (u_long)conf_no_list.no_of_confs);
if ( conf_no_list.conf_nos != NULL && conf_no_list.no_of_confs > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < conf_no_list.no_of_confs; i++ )
mux_printf(fp, " %lu", (u_long)conf_no_list.conf_nos[ i ]);
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_conference (Connection *fp,
Conference *conf_c)
{
prot_a_output_string(fp, conf_c->name);
prot_a_output_conf_type(fp, conf_c->type);
prot_a_output_time(fp, conf_c -> creation_time );
prot_a_output_time(fp, conf_c -> last_written );
mux_printf (fp, " %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
(u_long) conf_c -> creator,
(u_long) conf_c -> presentation,
(u_long) conf_c -> supervisor,
(u_long) conf_c -> permitted_submitters,
(u_long) conf_c -> super_conf,
(u_long) conf_c -> msg_of_day,
(u_long) conf_c -> nice,
(u_long) conf_c -> members.no_of_members,
(u_long) conf_c -> texts.first_local_no,
(u_long) conf_c -> texts.no_of_texts);
}
void
prot_a_output_mark_list(Connection *fp,
Mark_list mark_list)
{
int i;
mux_printf(fp, " %lu", (u_long)mark_list.no_of_marks);
if ( mark_list.marks != NULL && mark_list.no_of_marks > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < mark_list.no_of_marks; i++ )
prot_a_output_mark(fp, mark_list.marks[ i ]);
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_text_stat(Connection *fp,
Text_stat *t_stat)
{
int i;
prot_a_output_time(fp, t_stat->creation_time);
mux_printf(fp, " %lu %lu %lu %lu %lu",
(u_long)t_stat->author,
(u_long)t_stat->no_of_lines,
(u_long)t_stat->no_of_chars,
(u_long)t_stat->no_of_marks,
(u_long)t_stat->no_of_misc);
if ( t_stat->misc_items != NULL && t_stat->no_of_misc > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < t_stat->no_of_misc; i++ )
prot_a_output_misc_info(fp, t_stat->misc_items[ i ]);
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_text_list(Connection *fp,
Text_list text_list)
{
int i;
mux_printf(fp, " %lu %lu",
(u_long)text_list.first_local_no,
(u_long)text_list.no_of_texts);
if ( text_list.texts != NULL && text_list.no_of_texts > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < text_list.no_of_texts; i++ )
mux_printf(fp, " %lu", (u_long)text_list.texts[ i ]);
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
static void
prot_a_output_who_info_ident(Connection *fp,
Who_info_ident *info)
{
mux_printf(fp, " %lu %lu %lu",
(u_long)info->person,
(u_long)info->working_conference,
(u_long)info->session_no);
prot_a_output_string(fp, info->what_am_i_doing);
prot_a_output_string(fp, info->username);
prot_a_output_string(fp, info->hostname);
prot_a_output_string(fp, info->ident_user);
}
void
prot_a_output_who_info(Connection *fp,
Who_info *info)
{
mux_printf(fp, " %lu %lu %lu",
(u_long)info->person,
(u_long)info->working_conference,
(u_long)info->session_no);
prot_a_output_string(fp, info->what_am_i_doing);
prot_a_output_string(fp, info->username);
}
void
prot_a_output_who_info_list(Connection *fp,
Who_info_list info)
{
int i;
mux_printf(fp, " %lu", (u_long)info.no_of_persons);
if ( info.info != NULL && info.no_of_persons > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < info.no_of_persons; i++ )
{
prot_a_output_who_info(fp, &info.info[ i ]);
/* The username is specially alloced in who_is_on() in
session.c. */
s_clear(&info.info[i].username);
}
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_who_info_ident_list(Connection *fp,
Who_info_ident_list info)
{
int i;
mux_printf(fp, " %lu", (u_long)info.no_of_persons);
if ( info.info != NULL && info.no_of_persons > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < info.no_of_persons; i++ )
{
prot_a_output_who_info_ident(fp, &info.info[ i ]);
}
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_who_info_list_old(Connection *fp,
Who_info_list_old info)
{
int i;
mux_printf(fp, " %lu", (u_long)info.no_of_persons);
if ( info.info != NULL && info.no_of_persons > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < info.no_of_persons; i++ )
{
mux_printf(fp, " %lu %lu",
(u_long)info.info[ i ].person,
(u_long)info.info[ i ].working_conference);
prot_a_output_string(fp, info.info[ i ].what_am_i_doing);
}
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_session_info(Connection *fp,
Session_info *info)
{
mux_printf(fp, " %lu %lu %lu",
(u_long)info->person,
(u_long)info->working_conference,
(u_long)info->session);
prot_a_output_string(fp, info->what_am_i_doing);
prot_a_output_string(fp, info->username);
mux_printf(fp, " %lu", (u_long)info->idle_time);
prot_a_output_time(fp, info->connection_time);
}
void
prot_a_output_session_info_ident(Connection *fp,
Session_info_ident *info)
{
mux_printf(fp, " %lu %lu %lu",
(u_long)info->person,
(u_long)info->working_conference,
(u_long)info->session);
prot_a_output_string(fp, info->what_am_i_doing);
prot_a_output_string(fp, info->username);
prot_a_output_string(fp, info->hostname);
prot_a_output_string(fp, info->ident_user);
mux_printf(fp, " %lu", (u_long)info->idle_time);
prot_a_output_time(fp, info->connection_time);
}
void
prot_a_output_info(Connection *fp,
Info *info)
{
mux_printf(fp, " %lu %lu %lu %lu %lu %lu",
(u_long)info->version,
(u_long)info->conf_pres_conf,
(u_long)info->pers_pres_conf,
(u_long)info->motd_conf,
(u_long)info->kom_news_conf,
(u_long)info->motd_of_lyskom);
}
extern void
prot_a_output_string(Connection *fp,
String str)
{
mux_printf(fp, " %luH", (u_long)str.len);
mux_write(fp, str.string, str.len);
}
extern void
prot_a_output_priv_bits(Connection *fp,
Priv_bits bits)
{
mux_putc(' ', fp);
mux_putc(bits.wheel + '0', fp);
mux_putc(bits.admin + '0', fp);
mux_putc(bits.statistic + '0', fp);
mux_putc(bits.create_pers + '0', fp);
mux_putc(bits.create_conf + '0', fp);
mux_putc(bits.change_name + '0', fp);
mux_putc(bits.extern_gw + '0', fp);
mux_putc(bits.flg8 + '0', fp);
mux_putc(bits.flg9 + '0', fp);
mux_putc(bits.flg10 + '0', fp);
mux_putc(bits.flg11 + '0', fp);
mux_putc(bits.flg12 + '0', fp);
mux_putc(bits.flg13 + '0', fp);
mux_putc(bits.flg14 + '0', fp);
mux_putc(bits.flg15 + '0', fp);
mux_putc(bits.flg16 + '0', fp);
}
extern void
prot_a_output_personal_flags(Connection *fp,
Personal_flags flags)
{
mux_putc(' ', fp);
mux_putc(flags.unread_is_secret + '0', fp);
mux_putc(flags.flg2 + '0', fp);
mux_putc(flags.flg3 + '0', fp);
mux_putc(flags.flg4 + '0', fp);
mux_putc(flags.flg5 + '0', fp);
mux_putc(flags.flg6 + '0', fp);
mux_putc(flags.flg7 + '0', fp);
mux_putc(flags.flg8 + '0', fp);
}
extern void
prot_a_output_conf_type(Connection *fp,
Conf_type type)
{
mux_putc(' ', fp);
mux_putc(type.rd_prot + '0', fp);
mux_putc(type.original + '0', fp);
mux_putc(type.secret + '0', fp);
mux_putc(type.letter_box + '0', fp);
}
extern void
prot_a_output_member_list(Connection *fp,
Member_list m_list)
{
int i;
mux_printf(fp, " %lu", (u_long)m_list.no_of_members);
if ( m_list.members != NULL && m_list.no_of_members > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < m_list.no_of_members; i++ )
prot_a_output_member(fp, m_list.members[ i ]);
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_member(Connection *fp,
Member member)
{
mux_printf(fp, " %lu", (u_long)member.member);
}
extern void
prot_a_output_mark(Connection *fp,
Mark mark)
{
mux_printf(fp, " %lu %lu", (u_long)mark.text_no, (u_long)mark.mark_type);
}
extern void
prot_a_output_misc_info(Connection *fp,
Misc_info misc)
{
mux_printf(fp, " %lu", (u_long)misc.type);
switch(misc.type)
{
case recpt:
mux_printf(fp, " %lu", (u_long)misc.datum.recipient);
break;
case cc_recpt:
mux_printf(fp, " %lu", (u_long)misc.datum.cc_recipient);
break;
case loc_no:
mux_printf(fp, " %lu", (u_long)misc.datum.local_no);
break;
case rec_time:
prot_a_output_time(fp, misc.datum.received_at);
break;
case comm_to:
mux_printf(fp, " %lu", (u_long)misc.datum.comment_to);
break;
case comm_in:
mux_printf(fp, " %lu", (u_long)misc.datum.commented_in);
break;
case footn_to:
mux_printf(fp, " %lu", (u_long)misc.datum.footnote_to);
break;
case footn_in:
mux_printf(fp, " %lu", (u_long)misc.datum.footnoted_in);
break;
case sent_by:
mux_printf(fp, " %lu", (u_long)misc.datum.sender);
break;
case sent_at:
prot_a_output_time(fp, misc.datum.sent_at);
break;
#ifndef COMPILE_CHECKS
default:
restart_kom("prot_a_output_misc_info: Illegal misc\n");
#endif
}
}
void
prot_a_output_time(Connection *fp,
time_t clock)
{
struct tm *time;
time = localtime( &clock );
mux_printf(fp, " %lu %lu %lu %lu %lu %lu %lu %lu %lu",
(u_long) time -> tm_sec,
(u_long) time -> tm_min,
(u_long) time -> tm_hour,
(u_long) time -> tm_mday,
(u_long) time -> tm_mon,
(u_long) time -> tm_year,
(u_long) time -> tm_wday,
(u_long) time -> tm_yday,
(u_long) time -> tm_isdst);
}
void
prot_a_output_session_no(Connection *fp,
Session_no session_no)
{
mux_printf(fp, " %lu", (u_long) session_no);
}
void
prot_a_output_text_no(Connection *fp,
Text_no text)
{
mux_printf(fp, " %lu", (u_long) text);
}