X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=blobdiff_plain;f=ircd%2Fm_unzombie.c;fp=ircd%2Fm_unzombie.c;h=32adefaa9c056ab0e1cd0a45251ef09a575c35b6;hp=0000000000000000000000000000000000000000;hb=5fc729d47823a57c8e6e0e3b078522eccd120ca7;hpb=98c74ba6a77e8f110f03252eead8cd37e7ecc83e diff --git a/ircd/m_unzombie.c b/ircd/m_unzombie.c new file mode 100644 index 0000000..32adefa --- /dev/null +++ b/ircd/m_unzombie.c @@ -0,0 +1,81 @@ +/* + * IRC - Internet Relay Chat, ircd/m_unzombie.c + * Copyright (C) 2011 Jan Krueger + * + * 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 1, 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$ + */ + +#include "config.h" + +#include "client.h" +#include "ircd.h" +#include "ircd_log.h" +#include "ircd_reply.h" +#include "ircd_string.h" +#include "msg.h" +#include "numnicks.h" +#include "s_debug.h" +#include "s_misc.h" +#include "s_user.h" +#include "send.h" + +#include +#include + +/** Handle an UNZOMBIE message from a server connection. + * + * \a parv has the following elements: + * \li \a parv[1] is the numnick of the client attaching to the zombie + * \li \a parv[2] is the numnick of the zombie + * + * See @ref m_functions for discussion of the arguments. + * @param[in] cptr Client that sent us the message. + * @param[in] sptr Original source of message. + * @param[in] parc Number of arguments. + * @param[in] parv Argument vector. + */ +int ms_unzombie(struct Client* cptr, struct Client* sptr, int parc, + char* parv[]) +{ + struct Client *acptr; + struct Client *victim; + + if (parc < 3) + return need_more_params(sptr, "UNZOMBIE"); + + if (!IsServer(sptr)) + return protocol_violation(cptr, "UNZOMBIE from non-server %s", + cli_name(sptr)); + + if (!(acptr = findNUser(parv[1]))) + return 0; /* If this is colliding with a QUIT, let the QUIT win */ + + if (!(victim = findNUser(parv[2]))) + /* TODO send error */ + ; + + if (!IsNotConn(victim)) + return protocol_violation(cptr, "UNZOMBIE trying to attach to non-zombie %s", + cli_name(victim)); + assert(IsAccount(victim)); + + unzombie_client(cptr, sptr, acptr, victim); + return 0; +}