/************************************************************************ * IRC - Internet Relay Chat, modules/m_ping.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 softwmare; 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_ping.c,v 1.3 2003/06/14 13:55:51 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 char *token = TOK1_PING; static struct Message _msgtab[] = { {MSG_PING, 0, MAXPARA, M_SLOW, 0L, m_unregistered, m_ping, m_ping, m_ping, m_ping} }; #ifndef STATIC_MODULES char *_version = "$Revision: 1.3 $"; 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_ping_init(void) { mod_add_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = _msgtab; } #endif /* * * m_ping * parv[0] = sender prefix * parv[1] = origin * * parv[2] = destination */ int m_ping(aClient *cptr, aClient *sptr, int parc, char *parv[]) { aClient *acptr; char *origin, *destination; if (parc < 2 || *parv[1] == '\0') { send_me_numeric(sptr, ERR_NOORIGIN); return 0; } origin = parv[1]; destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */ acptr = find_client(origin); if (!acptr) acptr = find_server(origin); if (acptr && acptr != sptr) origin = cptr->name; if (!BadPtr(destination) && irc_strcmp(destination, me.name) != 0) { if ((acptr = find_server(destination))) sendto_one(acptr, ":%C %s %s :%s", sptr, MSG_PING, origin, destination); else { send_me_numeric(sptr, ERR_NOSUCHSERVER, destination); return 0; } } else sendto_one_server(sptr, &me, TOK1_PONG, "%s :%s", (destination) ? destination : me.name, origin); return 0; }