Move some string functions from core to logic (bug 4406 part 4, r=fyren).

This commit is contained in:
David Anderson
2010-05-14 19:28:10 -07:00
parent b5b002aa4b
commit 1cdacf69be
12 changed files with 128 additions and 44 deletions
+1
View File
@@ -35,6 +35,7 @@ files = [
'MemoryUtils.cpp',
'smn_admin.cpp',
'smn_banning.cpp',
'stringutil.cpp',
'sm_crc32.cpp'
]
if AMBuild.target['platform'] == 'windows':
+1
View File
@@ -31,6 +31,7 @@ OBJECTS = \
MemoryUtils.cpp \
smn_admin.cpp \
smn_banning.cpp \
stringutil.cpp \
smn_players.cpp
##############################################
+3 -1
View File
@@ -38,6 +38,7 @@
#include "Profiler.h"
#include "sm_crc32.h"
#include "MemoryUtils.h"
#include "stringutil.h"
sm_core_t smcore;
IHandleSys *handlesys;
@@ -63,7 +64,8 @@ static sm_logic_t logic =
g_pThreader,
sm_profiler,
&g_MemUtils,
UTIL_CRC32
UTIL_CRC32,
stristr
};
static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
+2 -1
View File
@@ -42,7 +42,7 @@ using namespace SourceMod;
* Add 1 to the RHS of this expression to bump the intercom file
* This is to prevent mismatching core/logic binaries
*/
#define SM_LOGIC_MAGIC (0x0F47C0DE - 8)
#define SM_LOGIC_MAGIC (0x0F47C0DE - 9)
#if defined SM_LOGIC
class IVEngineServer
@@ -118,6 +118,7 @@ struct sm_logic_t
IProfiler *profiler;
IMemoryUtils *memutils;
unsigned int (*CRC32)(const void *, size_t);
const char *(*stristr)(const char *, const char *);
};
typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic);
+67
View File
@@ -0,0 +1,67 @@
/**
* vim: set ts=4 sw=4 tw=99 et :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include <string.h>
#include <ctype.h>
#include "stringutil.h"
const char *stristr(const char *str, const char *substr)
{
if (!*substr)
{
return ((char *)str);
}
char *needle = (char *)substr;
char *prevloc = (char *)str;
char *haystack = (char *)str;
while (*haystack)
{
if (tolower(*haystack) == tolower(*needle))
{
haystack++;
if (!*++needle)
{
return prevloc;
}
}
else
{
haystack = ++prevloc;
needle = (char *)substr;
}
}
return NULL;
}
+38
View File
@@ -0,0 +1,38 @@
/**
* vim: set ts=4 sw=4 tw=99 et :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SOURCEMOD_COMMON_STRINGUTIL_H_
#define _INCLUDE_SOURCEMOD_COMMON_STRINGUTIL_H_
const char *stristr(const char *str, const char *substr);
#endif /* _INCLUDE_SOURCEMOD_COMMON_STRINGUTIL_H_ */