summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-15 14:19:37 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-15 14:19:37 +0000
commit0a31bcd5ae19e94827aec1a475ede69501b8230e (patch)
treecb9154b53f93c4bbc231fdbd5b180aed1fe39c91
parenta938e996fe7a6f42d3f5151b41d094930ec3a192 (diff)
Moved rehashnick and force_nickchange to users.cpp
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2478 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/inspircd.h2
-rw-r--r--include/users.h2
-rw-r--r--src/inspircd.cpp66
-rw-r--r--src/users.cpp64
4 files changed, 66 insertions, 68 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 34ad92cb3..1dd734787 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -114,11 +114,9 @@ class InspIRCd
};
/* prototypes */
-void force_nickchange(userrec* user,const char* newnick);
void call_handler(std::string &commandname,char **parameters, int pcnt, userrec *user);
bool is_valid_cmd(std::string &commandname, int pcnt, userrec * user);
int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins);
-userrec* ReHashNick(char* Old, char* New);
/* userrec optimization stuff */
void AddServerName(std::string servername);
const char* FindServerNamePtr(std::string servername);
diff --git a/include/users.h b/include/users.h
index ee15f4845..b5532f1e2 100644
--- a/include/users.h
+++ b/include/users.h
@@ -353,5 +353,7 @@ void AddWhoWas(userrec* u);
void AddClient(int socket, char* host, int port, bool iscached, char* ip);
void FullConnectUser(userrec* user);
void ConnectUser(userrec *user);
+userrec* ReHashNick(char* Old, char* New);
+void force_nickchange(userrec* user,const char* newnick);
#endif
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index b8e15396a..568b285c4 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -378,35 +378,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
return;
}
-/* re-allocates a nick in the user_hash after they change nicknames,
- * returns a pointer to the new user as it may have moved */
-
-userrec* ReHashNick(char* Old, char* New)
-{
- //user_hash::iterator newnick;
- user_hash::iterator oldnick = clientlist.find(Old);
-
- log(DEBUG,"ReHashNick: %s %s",Old,New);
-
- if (!strcasecmp(Old,New))
- {
- log(DEBUG,"old nick is new nick, skipping");
- return oldnick->second;
- }
-
- if (oldnick == clientlist.end()) return NULL; /* doesnt exist */
-
- log(DEBUG,"ReHashNick: Found hashed nick %s",Old);
-
- userrec* olduser = oldnick->second;
- clientlist[New] = olduser;
- clientlist.erase(oldnick);
-
- log(DEBUG,"ReHashNick: Nick rehashed as %s",New);
-
- return clientlist[New];
-}
-
#ifdef THREADED_DNS
void* dns_task(void* arg)
{
@@ -530,43 +501,6 @@ void call_handler(std::string &commandname,char **parameters, int pcnt, userrec
}
}
-
-void force_nickchange(userrec* user,const char* newnick)
-{
- char nick[MAXBUF];
- int MOD_RESULT = 0;
-
- strcpy(nick,"");
-
- FOREACH_RESULT(OnUserPreNick(user,newnick));
- if (MOD_RESULT) {
- stats->statsCollisions++;
- kill_link(user,"Nickname collision");
- return;
- }
- if (matches_qline(newnick))
- {
- stats->statsCollisions++;
- kill_link(user,"Nickname collision");
- return;
- }
-
- if (user)
- {
- if (newnick)
- {
- strncpy(nick,newnick,MAXBUF);
- }
- if (user->registered == 7)
- {
- char* pars[1];
- pars[0] = nick;
- handle_nick(pars,1,user);
- }
- }
-}
-
-
int process_parameters(char **command_p,char *parameters)
{
int j = 0;
diff --git a/src/users.cpp b/src/users.cpp
index 8e5d996da..57091aea1 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -714,3 +714,67 @@ void ConnectUser(userrec *user)
}
}
+/* re-allocates a nick in the user_hash after they change nicknames,
+ * returns a pointer to the new user as it may have moved */
+
+userrec* ReHashNick(char* Old, char* New)
+{
+ //user_hash::iterator newnick;
+ user_hash::iterator oldnick = clientlist.find(Old);
+
+ log(DEBUG,"ReHashNick: %s %s",Old,New);
+
+ if (!strcasecmp(Old,New))
+ {
+ log(DEBUG,"old nick is new nick, skipping");
+ return oldnick->second;
+ }
+
+ if (oldnick == clientlist.end()) return NULL; /* doesnt exist */
+
+ log(DEBUG,"ReHashNick: Found hashed nick %s",Old);
+
+ userrec* olduser = oldnick->second;
+ clientlist[New] = olduser;
+ clientlist.erase(oldnick);
+
+ log(DEBUG,"ReHashNick: Nick rehashed as %s",New);
+
+ return clientlist[New];
+}
+
+void force_nickchange(userrec* user,const char* newnick)
+{
+ char nick[MAXBUF];
+ int MOD_RESULT = 0;
+
+ strcpy(nick,"");
+
+ FOREACH_RESULT(OnUserPreNick(user,newnick));
+ if (MOD_RESULT) {
+ stats->statsCollisions++;
+ kill_link(user,"Nickname collision");
+ return;
+ }
+ if (matches_qline(newnick))
+ {
+ stats->statsCollisions++;
+ kill_link(user,"Nickname collision");
+ return;
+ }
+
+ if (user)
+ {
+ if (newnick)
+ {
+ strncpy(nick,newnick,MAXBUF);
+ }
+ if (user->registered == 7)
+ {
+ char* pars[1];
+ pars[0] = nick;
+ handle_nick(pars,1,user);
+ }
+ }
+}
+