Implemented initial support for zombie mode by Jan Krüger <jk@jk.gs>
[ircu2.10.12-pk.git] / ircd / m_zombie.c
1 /*
2  * IRC - Internet Relay Chat, ircd/m_zombie.c
3  * Copyright (C) 2011 Jan Krueger <jk@jk.gs>
4  *
5  * See file AUTHORS in IRC package for additional names of
6  * the programmers.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 1, or (at your option)
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * $Id$
23  */
24
25 #include "config.h"
26
27 #include "client.h"
28 #include "ircd.h"
29 #include "ircd_log.h"
30 #include "ircd_reply.h"
31 #include "ircd_string.h"
32 #include "msg.h"
33 #include "numnicks.h"
34 #include "s_debug.h"
35 #include "s_misc.h"
36 #include "s_user.h"
37 #include "send.h"
38
39 #include <stdlib.h>
40 #include <string.h>
41
42 /** Handle a ZOMBIE message from a server connection.
43  *
44  * \a parv has the following elements:
45  * \li \a parv[1] is the numnick of the client to act on
46  *
47  * See @ref m_functions for discussion of the arguments.
48  * @param[in] cptr Client that sent us the message.
49  * @param[in] sptr Original source of message.
50  * @param[in] parc Number of arguments.
51  * @param[in] parv Argument vector.
52  */
53 int ms_zombie(struct Client* cptr, struct Client* sptr, int parc,
54                char* parv[])
55 {
56   struct Client *acptr;
57
58   if (parc < 2)
59     return need_more_params(sptr, "ZOMBIE");
60
61   if (!IsServer(sptr))
62     return protocol_violation(cptr, "ZOMBIE from non-server %s",
63                               cli_name(sptr));
64
65   if (!(acptr = findNUser(parv[1])))
66     return 0; /* Ignore for a user that QUIT; probably crossed (however unlikely) */
67
68   if (!IsAccount(acptr))
69     return protocol_violation(cptr, "ZOMBIE for user without account (%s)",
70                               cli_name(acptr));
71
72   zombie_client(cptr, sptr, acptr);
73   return 0;
74 }