summaryrefslogtreecommitdiff
path: root/modules/core/m_message.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/m_message.c')
-rw-r--r--modules/core/m_message.c125
1 files changed, 25 insertions, 100 deletions
diff --git a/modules/core/m_message.c b/modules/core/m_message.c
index cb2d29c..9e10aa6 100644
--- a/modules/core/m_message.c
+++ b/modules/core/m_message.c
@@ -99,45 +99,6 @@ duplicate_ptr(const void *ptr)
return 0;
}
-/*
- * find_userhost - find a user@host (server or user).
- * inputs - user name to look for
- * - host name to look for
- * - pointer to count of number of matches found
- * outputs - pointer to client if found
- * - count is updated
- * side effects - none
- *
- */
-static struct Client *
-find_userhost(char *user, char *host, int *count)
-{
- struct Client *res = NULL;
- dlink_node *lc2ptr = NULL;
-
- *count = 0;
-
- if (collapse(user))
- {
- DLINK_FOREACH(lc2ptr, local_client_list.head)
- {
- struct Client *c2ptr = lc2ptr->data;
-
- if (!IsClient(c2ptr))
- continue;
-
- if ((!host || !match(host, c2ptr->host)) &&
- !irccmp(user, c2ptr->username))
- {
- (*count)++;
- res = c2ptr;
- }
- }
- }
-
- return res;
-}
-
/* flood_attack_client()
*
* inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
@@ -481,86 +442,50 @@ msg_client(int p_or_n, const char *command, struct Client *source_p,
*/
static void
handle_special(int p_or_n, const char *command, struct Client *client_p,
- struct Client *source_p, char *nick, char *text)
+ struct Client *source_p, char *nick, const char *text)
{
struct Client *target_p;
- char *host;
- char *server;
- char *s;
- int count;
+ const char *server = NULL, *s = NULL;
/*
* user[%host]@server addressed?
*/
if ((server = strchr(nick, '@')))
{
- count = 0;
-
- if ((host = strchr(nick, '%')) && !HasUMode(source_p, UMODE_OPER))
+ if ((target_p = hash_find_server(server + 1)) == NULL)
{
- sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
+ sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
ID_or_name(&me, client_p),
- ID_or_name(source_p, client_p));
+ ID_or_name(source_p, client_p), server + 1);
return;
}
- if ((target_p = hash_find_server(server + 1)))
+ if (!HasUMode(source_p, UMODE_OPER) && strchr(nick, '%'))
{
- if (!IsMe(target_p))
- {
- /*
- * Not destined for a user on me :-(
- */
- sendto_one(target_p, ":%s %s %s :%s",
- ID_or_name(source_p, target_p),
- command, nick, text);
- if ((p_or_n != NOTICE) && MyClient(source_p))
- source_p->localClient->last_privmsg = CurrentTime;
-
- return;
- }
-
- *server = '\0';
-
- if (host != NULL)
- *host++ = '\0';
+ sendto_one(source_p, form_str(ERR_NOSUCHNICK),
+ ID_or_name(&me, client_p),
+ ID_or_name(source_p, client_p), nick);
+ return;
+ }
+ if (!IsMe(target_p))
+ {
/*
- * Look for users which match the destination host
- * (no host == wildcard) and if one and one only is
- * found connected to me, deliver message!
+ * Not destined for a user on me :-(
*/
- if ((target_p = find_userhost(nick, host, &count)))
- {
- if (server != NULL)
- *server = '@';
- if (host != NULL)
- *--host = '%';
+ sendto_one(target_p, ":%s %s %s :%s",
+ ID_or_name(source_p, target_p),
+ command, nick, text);
- if (count == 1)
- {
- sendto_one(target_p, ":%s!%s@%s %s %s :%s",
- source_p->name, source_p->username,
- source_p->host, command, nick, text);
+ if ((p_or_n != NOTICE) && MyClient(source_p))
+ source_p->localClient->last_privmsg = CurrentTime;
- if ((p_or_n != NOTICE) && MyClient(source_p))
- source_p->localClient->last_privmsg = CurrentTime;
- }
- else
- sendto_one(source_p, form_str(ERR_TOOMANYTARGETS),
- ID_or_name(&me, client_p),
- ID_or_name(source_p, client_p), nick,
- ConfigFileEntry.max_targets);
- }
+ return;
}
- else if (server && *(server + 1) && (target_p == NULL))
- sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
- ID_or_name(&me, client_p),
- ID_or_name(source_p, client_p), server + 1);
- else if (server && (target_p == NULL))
- sendto_one(source_p, form_str(ERR_NOSUCHNICK),
- ID_or_name(&me, client_p),
- ID_or_name(source_p, client_p), nick);
+
+ sendto_one(source_p, form_str(ERR_NOSUCHNICK),
+ ID_or_name(&me, client_p),
+ ID_or_name(source_p, client_p), nick);
return;
}
@@ -582,7 +507,7 @@ handle_special(int p_or_n, const char *command, struct Client *client_p,
{
if ((*(nick + 1) == '$' || *(nick + 1) == '#'))
++nick;
- else if (MyClient(source_p) && HasUMode(source_p, UMODE_OPER))
+ else if (MyClient(source_p))
{
sendto_one(source_p,
":%s NOTICE %s :The command %s %s is no longer supported, please use $%s",