ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_svsnick.c
Revision: 5346
Committed: Sun Jan 11 12:41:14 2015 UTC (9 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 4425 byte(s)
Log Message:
- Update copyright years

File Contents

# User Rev Content
1 michael 1165 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 michael 1165 *
4 michael 2820 * Copyright (c) 1999 Bahamut development team.
5 michael 5346 * Copyright (c) 2011-2015 ircd-hybrid development team
6 michael 1165 *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19 michael 4564 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20 michael 1165 * USA
21     */
22    
23     /*! \file m_svsnick.c
24 michael 1221 * \brief Includes required functions for processing the SVSNICK command.
25 michael 1165 * \version $Id$
26     */
27    
28 michael 2820
29 michael 1165 #include "stdinc.h"
30     #include "client.h"
31     #include "ircd.h"
32     #include "channel_mode.h"
33     #include "send.h"
34     #include "parse.h"
35     #include "modules.h"
36     #include "irc_string.h"
37 michael 3347 #include "user.h"
38 michael 1165 #include "hash.h"
39     #include "watch.h"
40     #include "whowas.h"
41    
42    
43 michael 3300 /*! \brief SVSNICK command handler
44 michael 1165 *
45     * \param source_p Pointer to allocated Client struct from which the message
46     * originally comes from. This can be a local or remote client.
47     * \param parc Integer holding the number of supplied arguments.
48     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
49     * pointers.
50     * \note Valid arguments for this command are:
51 michael 3096 * - parv[0] = command
52 michael 1165 * - parv[1] = old nickname
53     * - parv[2] = new nickname
54     * - parv[3] = timestamp
55     */
56 michael 2820 static int
57 michael 3156 ms_svsnick(struct Client *source_p, int parc, char *parv[])
58 michael 1165 {
59     struct Client *target_p = NULL, *exists_p = NULL;
60    
61 michael 1221 if (!HasFlag(source_p, FLAGS_SERVICE) || !valid_nickname(parv[2], 1))
62 michael 2820 return 0;
63 michael 1165
64 michael 3966 if ((target_p = find_person(source_p, parv[1])) == NULL)
65 michael 2820 return 0;
66 michael 1165
67 michael 3966 if (!MyConnect(target_p))
68     {
69     if (target_p->from == source_p->from)
70     {
71     sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
72     "Received wrong-direction SVSNICK "
73     "for %s (behind %s) from %s",
74     target_p->name, source_p->from->name,
75     get_client_name(source_p, HIDE_IP));
76     return 0;
77     }
78    
79     sendto_one(target_p, ":%s SVSNICK %s %s %s", source_p->id,
80     target_p->id, parv[2], parv[3]);
81 michael 2820 return 0;
82 michael 3966 }
83 michael 1165
84 michael 1169 if ((exists_p = hash_find_client(parv[2])))
85 michael 1165 {
86 michael 3138 if (target_p == exists_p)
87     {
88     if (!strcmp(target_p->name, parv[2]))
89     return 0;
90     }
91     else if (IsUnknown(exists_p))
92 michael 3171 exit_client(exists_p, "SVSNICK Override");
93 michael 1165 else
94     {
95 michael 3171 exit_client(target_p, "SVSNICK Collide");
96 michael 2820 return 0;
97 michael 1165 }
98     }
99    
100     target_p->tsinfo = atoi(parv[3]);
101     clear_ban_cache_client(target_p);
102     watch_check_hash(target_p, RPL_LOGOFF);
103    
104     if (HasUMode(target_p, UMODE_REGISTERED))
105     {
106     unsigned int oldmodes = target_p->umodes;
107 michael 3246 char modebuf[IRCD_BUFSIZE] = "";
108 michael 1165
109     DelUMode(target_p, UMODE_REGISTERED);
110 michael 4021 send_umode(target_p, target_p, oldmodes, modebuf);
111 michael 1165 }
112    
113 michael 1734 sendto_common_channels_local(target_p, 1, 0, ":%s!%s@%s NICK :%s",
114 michael 1165 target_p->name, target_p->username,
115     target_p->host, parv[2]);
116    
117 michael 2300 whowas_add_history(target_p, 1);
118 michael 1165
119 michael 4963 sendto_server(NULL, 0, 0, ":%s NICK %s :%lu",
120 michael 3186 target_p->id, parv[2], (unsigned long)target_p->tsinfo);
121 michael 1165 hash_del_client(target_p);
122     strlcpy(target_p->name, parv[2], sizeof(target_p->name));
123     hash_add_client(target_p);
124    
125     watch_check_hash(target_p, RPL_LOGON);
126    
127 michael 4589 fd_note(&target_p->connection->fd, "Nick: %s", parv[2]);
128 michael 2820 return 0;
129 michael 1165 }
130 michael 1230
131 michael 2820 static struct Message svsnick_msgtab =
132     {
133 michael 4546 "SVSNICK", NULL, 0, 0, 4, MAXPARA, MFLG_SLOW, 0,
134 michael 3597 { m_ignore, m_ignore, ms_svsnick, m_ignore, m_ignore, m_ignore }
135 michael 1230 };
136    
137     static void
138     module_init(void)
139     {
140     mod_add_cmd(&svsnick_msgtab);
141     }
142    
143     static void
144     module_exit(void)
145     {
146     mod_del_cmd(&svsnick_msgtab);
147     }
148    
149 michael 2820 struct module module_entry =
150     {
151 michael 1230 .node = { NULL, NULL, NULL },
152     .name = NULL,
153     .version = "$Revision$",
154     .handle = NULL,
155     .modinit = module_init,
156     .modexit = module_exit,
157     .flags = 0
158     };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision