ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_change.c
Revision: 76
Committed: Tue Oct 4 19:38:49 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 6639 byte(s)
Log Message:
- fixed contrib #includes

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_change.c: Allows changing user/host/real of connected clients.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
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     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     /* List of ircd includes from ../include/ */
26     #include "stdinc.h"
27     #include "handlers.h"
28     #include "client.h"
29     #include "common.h" /* FALSE bleah */
30     #include "ircd.h"
31     #include "numeric.h"
32     #include "s_conf.h"
33     #include "s_serv.h"
34     #include "send.h"
35     #include "msg.h"
36     #include "parse.h"
37     #include "modules.h"
38     #include "s_user.h"
39     #include "hash.h"
40    
41     static void mo_chgident(struct Client *, struct Client *, int, char *[]);
42     static void mo_chghost(struct Client *, struct Client *, int, char *[]);
43     static void mo_chgname(struct Client *, struct Client *, int, char *[]);
44    
45     struct Message chgident_msgtab = {
46     "CHGIDENT", 0, 0, 2, 0, MFLG_SLOW, 0,
47     {m_unregistered, m_not_oper, mo_chgident, mo_chgident, mo_chgident, m_ignore}
48     };
49    
50     struct Message chghost_msgtab = {
51     "CHGHOST", 0, 0, 2, 0, MFLG_SLOW, 0,
52     {m_unregistered, m_not_oper, mo_chghost, mo_chghost, mo_chghost, m_ignore}
53     };
54    
55     struct Message chgname_msgtab = {
56     "CHGNAME", 0, 0, 2, 0, MFLG_SLOW, 0,
57     {m_unregistered, m_not_oper, mo_chgname, mo_chgname, mo_chgname, m_ignore}
58     };
59    
60     #ifndef STATIC_MODULES
61     void
62     _modinit(void)
63     {
64     mod_add_cmd(&chgident_msgtab);
65     mod_add_cmd(&chghost_msgtab);
66     mod_add_cmd(&chgname_msgtab);
67     }
68    
69     void
70     _moddeinit(void)
71     {
72     mod_del_cmd(&chgname_msgtab);
73     mod_del_cmd(&chghost_msgtab);
74     mod_del_cmd(&chgident_msgtab);
75     }
76    
77 knight 31 const char *_version = "$Revision$";
78 adx 30 #endif
79    
80     static void
81     mo_chgident(struct Client *client_p, struct Client *source_p,
82     int parc, char *parv[])
83     {
84     struct Client *target_p = NULL;
85    
86     if (MyConnect(source_p) && !IsOperAdmin(source_p))
87     {
88     sendto_one(source_p, form_str(ERR_NOPRIVS),
89     me.name, parv[0], "CHGIDENT");
90     return;
91     }
92    
93     if (EmptyString(parv[2]))
94     {
95     parv[2] = parv[1];
96    
97     target_p = source_p;
98     if (!IsClient(target_p))
99     return;
100     }
101     else {
102     target_p = find_client(parv[1]);
103    
104     if (target_p == NULL || !IsClient(target_p))
105     {
106     sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]);
107     return;
108     }
109     }
110    
111     if (strlen(parv[2]) > USERLEN || !*parv[2] || !valid_username(parv[2]))
112     {
113     sendto_one(source_p, ":%s NOTICE %s :Invalid username", me.name, parv[0]);
114     return;
115     }
116    
117     strcpy(target_p->username, parv[2]);
118    
119     if (MyClient(source_p))
120     {
121     sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
122     ":%s ENCAP * CHGIDENT %s %s",
123     parv[0], target_p->name, parv[2]);
124     sendto_one(source_p, ":%s NOTICE %s :%s changed to %s@%s",
125     me.name, parv[0], target_p->name, target_p->username,
126     target_p->host);
127     }
128    
129     if (MyConnect(target_p) && IsClient(source_p))
130     sendto_one(target_p, ":%s NOTICE %s :You are now %s@%s",
131     me.name, target_p->name, target_p->username, target_p->host);
132     }
133    
134     static void
135     mo_chghost(struct Client *client_p, struct Client *source_p,
136     int parc, char *parv[])
137     {
138     struct Client *target_p = NULL;
139    
140     if (MyConnect(source_p) && !IsOperAdmin(source_p))
141     {
142     sendto_one(source_p, form_str(ERR_NOPRIVS),
143     me.name, parv[0], "CHGHOST");
144     return;
145     }
146    
147     if (EmptyString(parv[2]))
148     {
149     parv[2] = parv[1];
150    
151     target_p = source_p;
152     if (!IsClient(target_p))
153     return;
154     }
155     else {
156     target_p = find_client(parv[1]);
157     if (target_p == NULL || !IsClient(target_p))
158     {
159     sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]);
160     return;
161     }
162     }
163    
164     if (strlen(parv[2]) > HOSTLEN || !*parv[2] || !valid_hostname(parv[2]))
165     {
166     sendto_one(source_p, ":%s NOTICE %s :Invalid hostname", me.name, parv[0]);
167     return;
168     }
169    
170     strcpy(target_p->host, parv[2]);
171    
172     if (MyClient(source_p))
173     {
174     sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
175     ":%s ENCAP * CHGHOST %s %s",
176     parv[0], target_p->name, parv[2]);
177     sendto_one(source_p, ":%s NOTICE %s :%s changed to %s@%s",
178     me.name, parv[0], target_p->name, target_p->username,
179     target_p->host);
180     }
181    
182     if (MyConnect(target_p) && IsClient(source_p))
183     sendto_one(target_p, ":%s NOTICE %s :You are now %s@%s",
184     me.name, target_p->name, target_p->username, target_p->host);
185     }
186    
187     static void
188     mo_chgname(struct Client *client_p, struct Client *source_p,
189     int parc, char *parv[])
190     {
191     struct Client *target_p = NULL;
192    
193     if (MyConnect(source_p) && !IsOperAdmin(source_p))
194     {
195     sendto_one(source_p, form_str(ERR_NOPRIVS),
196     me.name, parv[0], "CHGNAME");
197     return;
198     }
199    
200     if (EmptyString(parv[2]))
201     {
202     parv[2] = parv[1];
203     target_p = source_p;
204     }
205     else if ((target_p = find_client(parv[1])) == NULL)
206     {
207     sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]);
208     return;
209     }
210    
211     if (strlen(parv[2]) > REALLEN || !*parv[2])
212     {
213     sendto_one(source_p, ":%s NOTICE %s :Invalid realname", me.name, parv[0]);
214     return;
215     }
216    
217     if (parc > 3 && MyClient(source_p))
218     sendto_one(source_p, ":%s NOTICE %s :Warning -- too many parameters "
219     "for CHGNAME. You are probably missing a : before the new "
220     "IRC name.", me.name, parv[0]);
221    
222     strcpy(target_p->info, parv[2]);
223    
224     if (MyClient(source_p))
225     {
226     sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
227     ":%s ENCAP * CHGNAME %s :%s",
228     parv[0], target_p->name, parv[2]);
229     sendto_one(source_p, ":%s NOTICE %s :%s realname changed to [%s]",
230     me.name, parv[0], target_p->name, target_p->info);
231     }
232    
233     if (MyClient(target_p) && IsClient(source_p))
234     sendto_one(target_p, ":%s NOTICE %s :Your realname is now [%s]",
235     me.name, target_p->name, target_p->info);
236     }

Properties

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