ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_user.c
Revision: 3109
Committed: Thu Mar 6 19:25:12 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 3326 byte(s)
Log Message:
- Applied Adam's sendto_one_numeric() changes

File Contents

# Content
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] = command
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_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "USER");
96 return 0;
97 }
98
99 do_local_user(source_p,
100 parv[1], /* username */
101 parv[2], /* host */
102 parv[3], /* server */
103 parv[4] /* users real name */ );
104 return 0;
105 }
106
107 static struct Message user_msgtab =
108 {
109 "USER", 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
110 { mr_user, m_registered, m_ignore, m_ignore, m_registered, m_ignore }
111 };
112
113 static void
114 module_init(void)
115 {
116 mod_add_cmd(&user_msgtab);
117 }
118
119 static void
120 module_exit(void)
121 {
122 mod_del_cmd(&user_msgtab);
123 }
124
125 struct module module_entry =
126 {
127 .node = { NULL, NULL, NULL },
128 .name = NULL,
129 .version = "$Revision$",
130 .handle = NULL,
131 .modinit = module_init,
132 .modexit = module_exit,
133 .flags = 0
134 };

Properties

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