summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-10 17:28:16 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-10 17:28:16 +0000
commita835ec27fcc72faaeb9350867c801a9cd9f3d576 (patch)
tree24a3afa43d2e9cc05b70d584e4aeb1d0820b827c /src/modules
parent0942fe7405f0ff38038f7445c241fdae0bd7d1a2 (diff)
Port to templated GetExt()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4286 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_safelist.cpp19
-rw-r--r--src/modules/m_services_account.cpp44
2 files changed, 35 insertions, 28 deletions
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp
index 0ba1f28a1..c20414340 100644
--- a/src/modules/m_safelist.cpp
+++ b/src/modules/m_safelist.cpp
@@ -76,7 +76,8 @@ class ListTimer : public InspTimer
* - If not, spool more channels
*/
userrec* u = (userrec*)(*iter);
- ListData* ld = (ListData*)u->GetExt("safelist_cache");
+ ListData* ld;
+ u->GetExt("safelist_cache", ld);
if (ld->list_position > Srv->GetChannelCount())
{
u->Shrink("safelist_cache");
@@ -185,7 +186,8 @@ class ModuleSafeList : public Module
int HandleList(char** parameters, int pcnt, userrec* user)
{
/* First, let's check if the user is currently /list'ing */
- ListData *ld = (ListData*)user->GetExt("safelist_cache");
+ ListData *ld;
+ user->GetExt("safelist_cache", ld);
if (ld)
{
@@ -193,7 +195,8 @@ class ModuleSafeList : public Module
return 1;
}
- time_t* last_list_time = (time_t*)user->GetExt("safelist_last");
+ time_t* last_list_time;
+ user->GetExt("safelist_last", last_list_time);
if (last_list_time)
{
if (TIME < (*last_list_time)+60)
@@ -210,12 +213,12 @@ class ModuleSafeList : public Module
* start at channel 0! ;)
*/
ld = new ListData(0,TIME);
- user->Extend("safelist_cache", (char*)ld);
+ user->Extend("safelist_cache", ld);
listusers.push_back(user);
time_t* llt = new time_t;
*llt = TIME;
- user->Extend("safelist_last",(char*)llt);
+ user->Extend("safelist_last", llt);
return 1;
}
@@ -225,7 +228,8 @@ class ModuleSafeList : public Module
if(target_type == TYPE_USER)
{
userrec* u = (userrec*)item;
- ListData* ld = (ListData*)u->GetExt("safelist_cache");
+ ListData* ld;
+ u->GetExt("safelist_cache", ld);
if (ld)
{
u->Shrink("safelist_cache");
@@ -240,7 +244,8 @@ class ModuleSafeList : public Module
break;
}
}
- time_t* last_list_time = (time_t*)u->GetExt("safelist_last");
+ time_t* last_list_time;
+ u->GetExt("safelist_last", last_list_time);
if (last_list_time)
{
DELETE(last_list_time);
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index 2fceb6780..64ea36c48 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -136,12 +136,12 @@ class ModuleServicesAccount : public Module
/* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */
virtual void OnWhois(userrec* source, userrec* dest)
{
- char *account = dest->GetExt("accountname");
+ std::string *account;
+ dest->GetExt("accountname", account);
if (account)
{
- std::string* accountn = (std::string*)account;
- WriteServ(source->fd, "330 %s %s %s :is logged in as", source->nick, dest->nick, accountn->c_str());
+ WriteServ(source->fd, "330 %s %s %s :is logged in as", source->nick, dest->nick, account->c_str());
}
}
@@ -153,7 +153,8 @@ class ModuleServicesAccount : public Module
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- char *account = user->GetExt("accountname");
+ std::string *account;
+ user->GetExt("accountname", account);
if (target_type == TYPE_CHANNEL)
{
@@ -199,7 +200,8 @@ class ModuleServicesAccount : public Module
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
{
- char *account = user->GetExt("accountname");
+ std::string *account;
+ user->GetExt("accountname", account);
if (chan)
{
@@ -232,11 +234,10 @@ class ModuleServicesAccount : public Module
if (extname == "accountname")
{
// check if this user has an swhois field to send
- char* field = user->GetExt("accountname");
- if (field)
+ std::string* account;
+ user->GetExt("accountname", account);
+ if (account)
{
- // get our extdata out with a cast
- std::string* account = (std::string*)field;
// call this function in the linking module, let it format the data how it
// sees fit, and send it on its way. We dont need or want to know how.
proto->ProtoSendMetaData(opaque,TYPE_USER,user,extname,*account);
@@ -247,10 +248,10 @@ class ModuleServicesAccount : public Module
// when a user quits, tidy up their metadata
virtual void OnUserQuit(userrec* user, const std::string &message)
{
- char* field = user->GetExt("accountname");
- if (field)
+ std::string* account;
+ user->GetExt("accountname", account);
+ if (account)
{
- std::string* account = (std::string*)field;
user->Shrink("accountname");
delete account;
}
@@ -262,10 +263,10 @@ class ModuleServicesAccount : public Module
if (target_type == TYPE_USER)
{
userrec* user = (userrec*)item;
- char* field = user->GetExt("accountname");
- if (field)
+ std::string* account;
+ user->GetExt("accountname", account);
+ if (account)
{
- std::string* account = (std::string*)field;
user->Shrink("accountname");
delete account;
}
@@ -288,10 +289,10 @@ class ModuleServicesAccount : public Module
/* logging them out? */
if (extdata == "")
{
- char* field = dest->GetExt("accountname");
- if (field)
+ std::string* account;
+ dest->GetExt("accountname", account);
+ if (account)
{
- std::string* account = (std::string*)field;
dest->Shrink("accountname");
delete account;
}
@@ -299,10 +300,11 @@ class ModuleServicesAccount : public Module
else
{
// if they dont already have an accountname field, accept the remote server's
- if (!dest->GetExt("accountname"))
+ std::string* text;
+ if (!dest->GetExt("accountname", text))
{
- std::string* text = new std::string(extdata);
- dest->Extend("accountname",(char*)text);
+ text = new std::string(extdata);
+ dest->Extend("accountname", text);
}
}
}