ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.0.0beta2/modules/m_user.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (13 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_user.c
File size: 3589 byte(s)
Log Message:
- cleanup module loader. Make module api more flexible

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_user.c: Sends username information.
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "handlers.h"
27 #include "client.h"
28 #include "irc_string.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "s_user.h"
32 #include "send.h"
33 #include "msg.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 /* stash for later */
64 strlcpy(source_p->localClient->client_host, host, sizeof(source_p->localClient->client_host));
65 strlcpy(source_p->localClient->client_server, server, sizeof(source_p->localClient->client_server));
66
67 if (!IsGotId(source_p))
68 strlcpy(source_p->username, username, sizeof(source_p->username));
69
70 if (!source_p->localClient->registration)
71 register_local_user(source_p);
72 }
73
74 /*
75 ** mr_user
76 ** parv[0] = sender prefix
77 ** parv[1] = username (login name, account)
78 ** parv[2] = client host name (used only from other servers)
79 ** parv[3] = server host name (used only from other servers)
80 ** parv[4] = users real name info
81 */
82 static void
83 mr_user(struct Client *client_p, struct Client *source_p,
84 int parc, char *parv[])
85 {
86 char *p = NULL;
87
88 if (source_p->localClient->listener->flags & LISTENER_SERVER)
89 {
90 exit_client(source_p, &me, "Use a different port");
91 return;
92 }
93
94 if ((p = strchr(parv[1], '@')) != NULL)
95 *p = '\0';
96
97 if (EmptyString(parv[4]))
98 {
99 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name,
100 source_p->name[0] ? source_p->name : "*", "USER");
101 return;
102 }
103
104 do_local_user(source_p,
105 parv[1], /* username */
106 parv[2], /* host */
107 parv[3], /* server */
108 parv[4] /* users real name */ );
109 }
110
111 static struct Message user_msgtab = {
112 "USER", 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
113 { mr_user, m_registered, m_ignore, m_ignore, m_registered, m_ignore }
114 };
115
116 static void
117 module_init(void)
118 {
119 mod_add_cmd(&user_msgtab);
120 }
121
122 static void
123 module_exit(void)
124 {
125 mod_del_cmd(&user_msgtab);
126 }
127
128 struct module module_entry = {
129 .node = { NULL, NULL, NULL },
130 .name = NULL,
131 .version = "$Revision$",
132 .handle = NULL,
133 .modinit = module_init,
134 .modexit = module_exit,
135 .flags = 0
136 };

Properties

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