/************************************************************************
 *   IRC - Internet Relay Chat, modules/m_burst.c
 *
 *   Copyright (C) 2000-2003 TR-IRCD Development
 *
 *   Copyright (C) 1990 Jarkko Oikarinen and
 *                      University of Oulu, Co Center
 *
 *   See file AUTHORS in IRC package for additional names of
 *   the programmers.
 *
 *   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.
 */
    /*
     * $Id: m_burst.c,v 1.4 2004/02/24 15:00:27 tr-ircd Exp $ 
     */

#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include "h.h"

static struct Message _msgtab[] = {
    {MSG_BURST, 0, MAXPARA, M_SLOW, 0L,
     m_unregistered, m_ignore, m_ignore, m_burst, m_ignore}
};

static char *token = TOK1_BURST;

#ifndef STATIC_MODULES

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

void _modinit(void)
{
    mod_add_cmd(_msgtab);
    tok1_msgtab[(u_char) *token].msg = _msgtab;
}

void _moddeinit(void)
{
    mod_del_cmd(_msgtab);
    tok1_msgtab[(u_char) *token].msg = NULL;
}
#else
void m_burst_init(void)
{
    mod_add_cmd(_msgtab);
    tok1_msgtab[(u_char) *token].msg = _msgtab;
}
#endif

/*
 * m_burst
 *      parv[0] = sender prefix
 *      parv[1] = SendQ if an EOB
 */
int m_burst(aClient *cptr, aClient *sptr, int parc, char *parv[])
{

    if (sptr != cptr || parc > 2)
	return 0;
    if (parc == 2) {		/* This is an EOB */
	sptr->flags &= ~(FLAGS_EOBRECV);
	if (sptr->flags & (FLAGS_SOBSENT | FLAGS_BURST))
	    return 0;

	/*
	 * we've already sent our EOB.. we synched first
	 * * no need to check IsBurst because we shouldn't receive a BURST if they're not BURST capab 
	 */

	sendto_gnotice("from %C: synch to %s in %d %s at %s sendq",
		       &me, *parv, (timeofday - sptr->firsttime),
		       (timeofday - sptr->firsttime) == 1 ? "sec" : "secs", parv[1]);
	sendto_serv_butone(NULL, &me, TOK1_GNOTICE,
			   ":synch to %s in %d %s at %s sendq",
			   sptr->name, (timeofday - sptr->firsttime),
			   (timeofday - sptr->firsttime) == 1 ? "sec" : "secs", parv[1]);

    } else {			/* SOB.. lock HTM if defined by admin */
	sptr->flags |= FLAGS_EOBRECV;
    }
    return 0;
}


syntax highlighted by Code2HTML, v. 0.9.1