summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-06 10:43:34 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-06 10:43:34 +0000
commit1d994c544474da53159257d9097997c0744a48a5 (patch)
tree1933ef85eb507645ed17f32ed5d69cd1fc2e3cb2 /src
parentd4bcf45eb3ef838d878971dbcd585510729fcff1 (diff)
Added support for SVS-style Server class methods for modules
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@400 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/InspIRCd.layout36
-rw-r--r--src/inspircd.cpp39
-rw-r--r--src/modules.cpp23
3 files changed, 73 insertions, 25 deletions
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout
index bc21c54cb..b50480645 100644
--- a/src/InspIRCd.layout
+++ b/src/InspIRCd.layout
@@ -1,5 +1,5 @@
[Editors]
-Focused=1
+Focused=4
Order=7,3,2,6,25,24,4,5,0,-1,1
[Editor_0]
@@ -12,10 +12,10 @@ LeftChar=1
[Editor_1]
Open=1
-Top=1
-CursorCol=2
-CursorRow=3279
-TopLine=3279
+Top=0
+CursorCol=17
+CursorRow=1314
+TopLine=1295
LeftChar=1
[Editor_2]
@@ -36,10 +36,10 @@ LeftChar=1
[Editor_4]
Open=1
-Top=0
-CursorCol=51
-CursorRow=143
-TopLine=123
+Top=1
+CursorCol=63
+CursorRow=117
+TopLine=90
LeftChar=1
[Editor_5]
@@ -67,7 +67,7 @@ TopLine=6
LeftChar=1
[Editor_8]
-Open=0
+Open=1
Top=0
CursorCol=1
CursorRow=1
@@ -141,9 +141,9 @@ LeftChar=1
[Editor_17]
Open=1
Top=0
-CursorCol=52
-CursorRow=78
-TopLine=1
+CursorCol=51
+CursorRow=105
+TopLine=54
LeftChar=1
[Editor_18]
@@ -165,10 +165,10 @@ LeftChar=1
[Editor_20]
Open=1
Top=0
-CursorCol=14
-CursorRow=384
-TopLine=339
-LeftChar=3
+CursorCol=64
+CursorRow=187
+TopLine=146
+LeftChar=1
[Editor_21]
Open=1
@@ -213,7 +213,7 @@ Open=1
Top=0
CursorCol=1
CursorRow=13
-TopLine=2
+TopLine=23
LeftChar=1
[Editor_27]
Open=1
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 78d84c22e..1e4a8abc3 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -1298,10 +1298,9 @@ int usercount(chanrec *c)
/* add a channel to a user, creating the record for it if needed and linking
* it to the user record */
-chanrec* add_channel(userrec *user, char* cname, char* key)
+chanrec* add_channel(userrec *user, const char* cn, const char* key)
{
-
- if ((!user) || (!cname))
+ if ((!user) || (!cn))
{
log(DEFAULT,"*** BUG *** add_channel was given an invalid parameter");
return 0;
@@ -1310,6 +1309,9 @@ chanrec* add_channel(userrec *user, char* cname, char* key)
int i = 0;
chanrec* Ptr;
int created = 0;
+ char cname[MAXBUF];
+
+ strncpy(cname,cn,MAXBUF);
// we MUST declare this wherever we use FOREACH_RESULT
int MOD_RESULT = 0;
@@ -1482,7 +1484,7 @@ chanrec* add_channel(userrec *user, char* cname, char* key)
/* remove a channel from a users record, and remove the record from memory
* if the channel has become empty */
-chanrec* del_channel(userrec *user, char* cname, char* reason)
+chanrec* del_channel(userrec *user, const char* cname, const char* reason)
{
if ((!user) || (!cname))
{
@@ -3155,9 +3157,13 @@ void handle_restart(char **parameters, int pcnt, userrec *user)
}
-void kill_link(userrec *user,char* reason)
+void kill_link(userrec *user,const char* r)
{
user_hash::iterator iter = clientlist.find(user->nick);
+
+ char reason[MAXBUF];
+
+ strncpy(reason,r,MAXBUF);
if (strlen(reason)>MAXQUIT)
{
@@ -4470,7 +4476,7 @@ void handle_oper(char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"491 %s :Invalid oper credentials",user->nick);
WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
}
-
+
void handle_nick(char **parameters, int pcnt, userrec *user)
{
if (pcnt < 1)
@@ -4549,6 +4555,27 @@ void handle_nick(char **parameters, int pcnt, userrec *user)
log(DEBUG,"exit nickchange: %s",user->nick);
}
+void force_nickchange(userrec* user,const char* newnick)
+{
+ char nick[MAXBUF];
+ strcpy(nick,"");
+
+ 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 i = 0;
diff --git a/src/modules.cpp b/src/modules.cpp
index 5bea5133f..caacd9afc 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -114,7 +114,7 @@ void Module::OnPacketTransmit(char *p) { }
void Module::OnPacketReceive(char *p) { }
void Module::OnRehash() { }
void Module::OnServerRaw(std::string &raw, bool inbound) { }
-int Module::OnUserPreJoin(userrec* user, chanrec* chan, char* cname) { return 0; }
+int Module::OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) { return 0; }
bool Module::OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params) { }
Version Module::GetVersion() { return Version(1,0,0,0); }
void Module::OnOper(userrec* user) { };
@@ -143,6 +143,27 @@ void Server::SendToModeMask(std::string modes, int flags, std::string text)
WriteMode(modes.c_str(),flags,"%s",text.c_str());
}
+chanrec* Server::JoinUserToChannel(userrec* user, std::string cname, std::string key)
+{
+ return add_channel(user,cname.c_str(),key.c_str());
+}
+
+chanrec* Server::PartUserFromChannel(userrec* user, std::string cname, std::string reason)
+{
+ return del_channel(user,cname.c_str(),reason.c_str());
+}
+
+void Server::ChangeUserNick(userrec* user, std::string nickname)
+{
+ force_nickchange(user,nickname.c_str());
+}
+
+void Server::QuitUser(userrec* user, std::string reason)
+{
+ kill_link(user,reason.c_str());
+}
+
+
void Server::Log(int level, std::string s)
{
log(level,"%s",s.c_str());