1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file m_user.c |
23 |
* \brief Includes required functions for processing the USER command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "client.h" |
29 |
#include "irc_string.h" |
30 |
#include "ircd.h" |
31 |
#include "numeric.h" |
32 |
#include "s_user.h" |
33 |
#include "send.h" |
34 |
#include "parse.h" |
35 |
#include "modules.h" |
36 |
#include "listener.h" |
37 |
|
38 |
|
39 |
/* do_local_user() |
40 |
* |
41 |
* inputs - |
42 |
* output - NONE |
43 |
* side effects - |
44 |
*/ |
45 |
static void |
46 |
do_local_user(struct Client *source_p, |
47 |
const char *username, const char *host, const char *server, |
48 |
const char *realname) |
49 |
{ |
50 |
assert(source_p != NULL); |
51 |
assert(source_p->username != username); |
52 |
assert(IsUnknown(source_p)); |
53 |
|
54 |
source_p->localClient->registration &= ~REG_NEED_USER; |
55 |
|
56 |
/* |
57 |
* don't take the clients word for it, ever |
58 |
*/ |
59 |
source_p->servptr = &me; |
60 |
|
61 |
strlcpy(source_p->info, realname, sizeof(source_p->info)); |
62 |
|
63 |
if (!IsGotId(source_p)) |
64 |
strlcpy(source_p->username, username, sizeof(source_p->username)); |
65 |
|
66 |
if (!source_p->localClient->registration) |
67 |
register_local_user(source_p); |
68 |
} |
69 |
|
70 |
/* |
71 |
** mr_user |
72 |
** parv[0] = sender prefix |
73 |
** parv[1] = username (login name, account) |
74 |
** parv[2] = client host name (used only from other servers) |
75 |
** parv[3] = server host name (used only from other servers) |
76 |
** parv[4] = users real name info |
77 |
*/ |
78 |
static int |
79 |
mr_user(struct Client *client_p, struct Client *source_p, |
80 |
int parc, char *parv[]) |
81 |
{ |
82 |
char *p = NULL; |
83 |
|
84 |
if (source_p->localClient->listener->flags & LISTENER_SERVER) |
85 |
{ |
86 |
exit_client(source_p, &me, "Use a different port"); |
87 |
return 0; |
88 |
} |
89 |
|
90 |
if ((p = strchr(parv[1], '@')) != NULL) |
91 |
*p = '\0'; |
92 |
|
93 |
if (EmptyString(parv[4])) |
94 |
{ |
95 |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, |
96 |
source_p->name[0] ? source_p->name : "*", "USER"); |
97 |
return 0; |
98 |
} |
99 |
|
100 |
do_local_user(source_p, |
101 |
parv[1], /* username */ |
102 |
parv[2], /* host */ |
103 |
parv[3], /* server */ |
104 |
parv[4] /* users real name */ ); |
105 |
return 0; |
106 |
} |
107 |
|
108 |
static struct Message user_msgtab = |
109 |
{ |
110 |
"USER", 0, 0, 5, MAXPARA, MFLG_SLOW, 0, |
111 |
{ mr_user, m_registered, m_ignore, m_ignore, m_registered, m_ignore } |
112 |
}; |
113 |
|
114 |
static void |
115 |
module_init(void) |
116 |
{ |
117 |
mod_add_cmd(&user_msgtab); |
118 |
} |
119 |
|
120 |
static void |
121 |
module_exit(void) |
122 |
{ |
123 |
mod_del_cmd(&user_msgtab); |
124 |
} |
125 |
|
126 |
struct module module_entry = |
127 |
{ |
128 |
.node = { NULL, NULL, NULL }, |
129 |
.name = NULL, |
130 |
.version = "$Revision$", |
131 |
.handle = NULL, |
132 |
.modinit = module_init, |
133 |
.modexit = module_exit, |
134 |
.flags = 0 |
135 |
}; |