summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/users.cpp21
-rw-r--r--win/inspircd_win32wrapper.cpp65
-rw-r--r--win/inspircd_win32wrapper.h3
3 files changed, 6 insertions, 83 deletions
diff --git a/src/users.cpp b/src/users.cpp
index c5a76a803..2045a8482 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -693,10 +693,6 @@ void User::FlushWriteBuf()
void User::Oper(const std::string &opertype, const std::string &opername)
{
- char* mycmd;
- char* savept;
- char* savept2;
-
if (this->IsModeSet('o'))
this->UnOper();
@@ -724,21 +720,18 @@ void User::Oper(const std::string &opertype, const std::string &opername)
AllowedChanModes.reset();
this->AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want.
- char* Classes = strdup(iter_opertype->second);
- char* myclass = strtok_r(Classes," ",&savept);
- while (myclass)
+ std::string myclass, mycmd;
+ irc::spacesepstream Classes(iter_opertype->second);
+ while (Classes.GetToken(myclass))
{
- operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass);
+ operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass.c_str());
if (iter_operclass != ServerInstance->Config->operclass.end())
{
- char* CommandList = strdup(iter_operclass->second.commandlist);
- mycmd = strtok_r(CommandList," ",&savept2);
- while (mycmd)
+ irc::spacesepstream CommandList(iter_operclass->second.commandlist);
+ while (CommandList.GetToken(mycmd))
{
this->AllowedOperCommands->insert(std::make_pair(mycmd, true));
- mycmd = strtok_r(NULL," ",&savept2);
}
- free(CommandList);
for (unsigned char* c = (unsigned char*)iter_operclass->second.umodelist; *c; ++c)
{
if (*c == '*')
@@ -762,9 +755,7 @@ void User::Oper(const std::string &opertype, const std::string &opername)
}
}
}
- myclass = strtok_r(NULL," ",&savept);
}
- free(Classes);
}
FOREACH_MOD(I_OnPostOper,OnPostOper(this, opertype, opername));
diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp
index 0b738d538..03d89a7aa 100644
--- a/win/inspircd_win32wrapper.cpp
+++ b/win/inspircd_win32wrapper.cpp
@@ -91,71 +91,6 @@ int inet_pton(int af, const char *src, void *dst)
return rv;
}
-char * strtok_r(char *_String, const char *_Control, char **_Context)
-{
- unsigned char *str;
- const unsigned char *ctl = (const unsigned char*)_Control;
- unsigned char map[32];
-
- if (_Context == 0 || !_Control)
- return 0;
-
- if (!(_String != NULL || *_Context != NULL))
- return 0;
-
- memset(map, 0, 32);
-
- do {
- map[*ctl >> 3] |= (1 << (*ctl & 7));
- } while (*ctl++);
-
- /* If string is NULL, set str to the saved
- * pointer (i.e., continue breaking tokens out of the string
- * from the last strtok call) */
- if (_String != NULL)
- {
- str = (unsigned char*)_String;
- }
- else
- {
- str = (unsigned char*)*_Context;
- }
-
- /* Find beginning of token (skip over leading delimiters). Note that
- * there is no token iff this loop sets str to point to the terminal
- * null (*str == 0) */
- while ((map[*str >> 3] & (1 << (*str & 7))) && *str != 0)
- {
- str++;
- }
-
- _String = (char*)str;
-
- /* Find the end of the token. If it is not the end of the string,
- * put a null there. */
- for ( ; *str != 0 ; str++ )
- {
- if (map[*str >> 3] & (1 << (*str & 7)))
- {
- *str++ = 0;
- break;
- }
- }
-
- /* Update context */
- *_Context = (char*)str;
-
- /* Determine if a token has been found. */
- if (_String == (char*)str)
- {
- return NULL;
- }
- else
- {
- return _String;
- }
-}
-
void setcolor(int color_code)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color_code);
diff --git a/win/inspircd_win32wrapper.h b/win/inspircd_win32wrapper.h
index 8b7b7d924..4bc364881 100644
--- a/win/inspircd_win32wrapper.h
+++ b/win/inspircd_win32wrapper.h
@@ -114,9 +114,6 @@ CoreExport const char * inet_ntop(int af, const void * src, char * dst, socklen_
/* Since when does the ISO C++ standard *remove* C functions?! */
#define mkdir(file,mode) _mkdir(file)
-/* Recursive token function doesn't exist in VC++ */
-CoreExport char * strtok_r(char *_String, const char *_Control, char **_Context);
-
/* Unix-style sleep (argument is in seconds) */
__inline void sleep(int seconds) { Sleep(seconds * 1000); }