/************************************************************************
 * IRC - Internet Relay Chat, modules/m_display.c
 *
 *   Copyright (C) 2000-2003 TR-IRCD Development
 *
 *   Copyright (C) 1990 Jarkko Oikarinen and
 *                      University of Oulu, Co Center
 *
 * This program 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 2, or (at your option)
 * any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "struct.h"
#include "numeric.h"
#include "sys.h"
#include "msg.h"
#include "h.h"
#include "s_conf.h"
#include "confitem.h"

static struct Message _msgtab[] = {
    {MSG_DISPLAY, 0, MAXPARA, M_SLOW, 0L,
     m_unregistered, m_permission, m_display, m_ignore, m_ignore}
};

#ifndef STATIC_MODULES

char *_version = "$Revision: 1.3 $";

void _modinit(void)
{
    mod_add_cmd(_msgtab);
}

void _moddeinit(void)
{
    mod_del_cmd(_msgtab);
}
#else
void m_display_init(void)
{
    mod_add_cmd(_msgtab);
}
#endif

int m_display(aClient *cptr, aClient *sptr, int parc, char *parv[])
{
    char *pass = NULL;
    char passarr[PASSWDLEN];

    if (parc < 3) {
	send_me_numeric(sptr, ERR_NEEDMOREPARAMS, MSG_DISPLAY);
	return 0;
    }

    pass = parv[1];

    if (!IsAdmin(sptr) || (strcmp(calcpass(pass, passarr), ServerInfo.displaypass) != 0)) {
	send_me_numeric(sptr, ERR_NOPRIVILEGES);
	sendto_ops("\2%s\2 failed to display server config file", parv[0]);
	return 0;
    }

    sendto_lev(SPY_LEV, "%^C [%s] is displaying section \2%s\2 of the server config file", sptr,
                   sptr->user->server, parv[2]);
    logevent_call(LogSys.operevent, MSG_DISPLAY, sptr, &parv, parc);
    send_config_file(&(GeneralOpts.conffile), cptr, sptr, parv[2]);
    return 0;
}


syntax highlighted by Code2HTML, v. 0.9.1