]> jfr.im git - irc/rqf/shadowircd.git/blob - modules/m_user.c
SVN Id removal part two
[irc/rqf/shadowircd.git] / modules / m_user.c
1 /*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_user.c: Sends username information.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
24 */
25
26 #include "stdinc.h"
27 #include "client.h"
28 #include "match.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "s_user.h"
32 #include "send.h"
33 #include "s_conf.h"
34 #include "msg.h"
35 #include "parse.h"
36 #include "modules.h"
37 #include "blacklist.h"
38
39 static int mr_user(struct Client *, struct Client *, int, const char **);
40
41 struct Message user_msgtab = {
42 "USER", 0, 0, 0, MFLG_SLOW,
43 {{mr_user, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
44 };
45
46 mapi_clist_av1 user_clist[] = { &user_msgtab, NULL };
47 DECLARE_MODULE_AV1(user, NULL, NULL, user_clist, NULL, NULL, "$Revision: 3416 $");
48
49 static int do_local_user(struct Client *client_p, struct Client *source_p,
50 const char *username, const char *realname);
51
52 /* mr_user()
53 * parv[1] = username (login name, account)
54 * parv[2] = client host name (ignored)
55 * parv[3] = server host name (ignored)
56 * parv[4] = users gecos
57 */
58 static int
59 mr_user(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
60 {
61 static char buf[BUFSIZE];
62 char *p;
63
64 if (strlen(client_p->id) == 3)
65 {
66 exit_client(client_p, client_p, client_p, "Mixing client and server protocol");
67 return 0;
68 }
69
70 if((p = strchr(parv[1], '@')))
71 *p = '\0';
72
73 rb_snprintf(buf, sizeof(buf), "%s %s", parv[2], parv[3]);
74 rb_free(source_p->localClient->fullcaps);
75 source_p->localClient->fullcaps = rb_strdup(buf);
76
77 do_local_user(client_p, source_p, parv[1], parv[4]);
78 return 0;
79 }
80
81 static int
82 do_local_user(struct Client *client_p, struct Client *source_p,
83 const char *username, const char *realname)
84 {
85 struct User *user;
86
87 s_assert(NULL != source_p);
88 s_assert(source_p->username != username);
89
90 user = make_user(source_p);
91
92 if (!(source_p->flags & FLAGS_SENTUSER))
93 {
94 lookup_blacklists(source_p);
95 source_p->flags |= FLAGS_SENTUSER;
96 }
97
98 rb_strlcpy(source_p->info, realname, sizeof(source_p->info));
99
100 if(!IsGotId(source_p))
101 {
102 /* This is in this location for a reason..If there is no identd
103 * and ping cookies are enabled..we need to have a copy of this
104 */
105 rb_strlcpy(source_p->username, username, sizeof(source_p->username));
106 }
107
108 if(source_p->name[0])
109 {
110 /* NICK already received, now I have USER... */
111 return register_local_user(client_p, source_p, username);
112 }
113
114 return 0;
115 }