initial import of linux support

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40356
This commit is contained in:
David Anderson 2007-01-25 09:19:38 +00:00
parent 25ed99ac60
commit 3e936bbd88
26 changed files with 203 additions and 83 deletions

View File

@ -70,4 +70,5 @@ int CDbgReporter::_GetPluginIndex(IPluginContext *ctx)
iter->Release();
return -1;
}
}

View File

@ -16,4 +16,5 @@ private:
int _GetPluginIndex(IPluginContext *ctx);
};
#endif // _INCLUDE_SOURCEMOD_CDBGREPORTER_H_
#endif // _INCLUDE_SOURCEMOD_CDBGREPORTER_H_

View File

@ -2,7 +2,7 @@
#include "sourcemod.h"
#include "sourcemm_api.h"
#include "CLogger.h"
#include "systems/Librarysys.h"
#include "systems/LibrarySys.h"
#include "sm_version.h"
CLogger g_Logger;
@ -128,6 +128,11 @@ void CLogger::InitLogger(LoggingMode mode, bool startlogging)
m_DailyPrintHdr = true;
break;
}
default:
{
/* do nothing... */
break;
}
}
}
@ -280,6 +285,11 @@ void CLogger::MapChange(const char *mapname)
_NewMapFile();
break;
}
default:
{
/* Do nothing... */
break;
}
}
if (m_ErrMapStart)

View File

@ -14,20 +14,20 @@ static int g_ws_chartable[255] = {0};
CTextParsers::CTextParsers()
{
g_ini_chartable1['_'] = 1;
g_ini_chartable1['-'] = 1;
g_ini_chartable1[','] = 1;
g_ini_chartable1['+'] = 1;
g_ini_chartable1['.'] = 1;
g_ini_chartable1['$'] = 1;
g_ini_chartable1['?'] = 1;
g_ini_chartable1['/'] = 1;
g_ws_chartable['\n'] = 1;
g_ws_chartable['\v'] = 1;
g_ws_chartable['\r'] = 1;
g_ws_chartable['\t'] = 1;
g_ws_chartable['\f'] = 1;
g_ws_chartable[' '] = 1;
g_ini_chartable1[(unsigned)'_'] = 1;
g_ini_chartable1[(unsigned)'-'] = 1;
g_ini_chartable1[(unsigned)','] = 1;
g_ini_chartable1[(unsigned)'+'] = 1;
g_ini_chartable1[(unsigned)'.'] = 1;
g_ini_chartable1[(unsigned)'$'] = 1;
g_ini_chartable1[(unsigned)'?'] = 1;
g_ini_chartable1[(unsigned)'/'] = 1;
g_ws_chartable[(unsigned)'\n'] = 1;
g_ws_chartable[(unsigned)'\v'] = 1;
g_ws_chartable[(unsigned)'\r'] = 1;
g_ws_chartable[(unsigned)'\t'] = 1;
g_ws_chartable[(unsigned)'\f'] = 1;
g_ws_chartable[(unsigned)' '] = 1;
}
void CTextParsers::OnSourceModAllInitialized()
@ -121,10 +121,10 @@ SMCParseError CTextParsers::ParseFile_SMC(const char *file, ITextListener_SMC *s
struct StringInfo
{
StringInfo() : quoted(false), ptr(NULL), end(NULL), special(false) { }
bool quoted;
char *ptr;
char *end;
bool special;
bool quoted;
};
const char *FixupString(StringInfo &data)
@ -366,13 +366,13 @@ SMCParseError CTextParsers::ParseStream_SMC(void *stream,
}
} else {
/* Check if we're whitespace or not */
if (!g_ws_chartable[c])
if (!g_ws_chartable[(unsigned)c])
{
bool restage = false;
/* Check various special tokens:
* ;
* //
* /*
* / *
* {
* }
*/
@ -402,7 +402,7 @@ SMCParseError CTextParsers::ParseStream_SMC(void *stream,
ignoring = true;
ml_comment = true;
/* yes, we restage, meaning that:
* STR/*stuff* /ING (space because ml comments don't nest in C++)
* STR/ *stuff* /ING (space because ml comments don't nest in C++)
* will not generate 'STRING', but rather 'STR' and 'ING'.
* This should be a rare occurrence and is done here for convenience.
*/
@ -656,7 +656,7 @@ bool CTextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listen
***************************************************/
/* First strip beginning whitespace */
while (*ptr != '\0' && g_ws_chartable[*ptr] != 0)
while (*ptr != '\0' && g_ws_chartable[(unsigned)*ptr] != 0)
{
ptr++;
}
@ -709,7 +709,7 @@ bool CTextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listen
/* Lastly, strip ending whitespace off */
for (size_t i=len-1; i>=0 && i<len; i--)
{
if (g_ws_chartable[ptr[i]])
if (g_ws_chartable[(unsigned)ptr[i]])
{
ptr[i] = '\0';
len--;
@ -750,7 +750,7 @@ bool CTextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listen
i += _GetUTF8CharBytes(&ptr[i]) - 1;
}
} else {
alnum = (isalnum(c) != 0) || (g_ini_chartable1[c] != 0);
alnum = (isalnum(c) != 0) || (g_ini_chartable1[(unsigned)c] != 0);
}
if (!alnum)
{
@ -803,12 +803,12 @@ bool CTextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listen
i += _GetUTF8CharBytes(&ptr[i]) - 1;
}
} else {
alnum = (isalnum(c) != 0) || (g_ini_chartable1[c] != 0);
alnum = (isalnum(c) != 0) || (g_ini_chartable1[(unsigned)c] != 0);
}
if (!alnum)
{
if (g_ws_chartable[c])
if (g_ws_chartable[(unsigned)c])
{
/* if it's a space, keep track of the first occurring space */
if (!first_space)
@ -847,7 +847,7 @@ bool CTextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listen
if (val_ptr)
{
/* eat up spaces! there shouldn't be any h*/
while ((*val_ptr != '\0') && g_ws_chartable[*val_ptr] != 0)
while ((*val_ptr != '\0') && g_ws_chartable[(unsigned)*val_ptr] != 0)
{
val_ptr++;
}

View File

@ -1,5 +1,6 @@
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include "CTranslator.h"
#include "CLogger.h"
#include "CTextParsers.h"
@ -336,7 +337,7 @@ SMCParseResult CPhraseFile::ReadSMC_KeyValue(const char *key, const char *value,
*out_ptr++ = '%';
}
/* Check length ... */
if (out_ptr - fmt_buf >= sizeof(fmt_buf) - 1)
if ((unsigned)(out_ptr - fmt_buf) >= sizeof(fmt_buf) - 1)
{
ParseWarning("Format property contains format string that exceeds maximum length on line %d, phrase will be ignored.",
m_CurLine);

90
core/Makefile Normal file
View File

@ -0,0 +1,90 @@
#(C)2004-2006 SourceMM Development Team
# Makefile written by David "BAILOPAN" Anderson
SMM_BASE = ../../../sourcemm
SMM_TRUNK = $(SMM_BASE)/trunk
HL2SDK = $(SMM_BASE)/hl2sdk
SMSDK = ..
SRCDS = ~/srcds
### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
DEBUG_FLAGS = -g -ggdb3
CPP = gcc-4.1
BINARY = sourcemod_mm.so
HL2PUB = $(HL2SDK)/public
HL2LIB = $(HL2SDK)/linux_sdk
OBJECTS = sourcemm_api.cpp sourcemod.cpp AdminCache.cpp CDbgReporter.cpp CLogger.cpp \
CPlayer.cpp CPlayerManager.cpp CTextParsers.cpp CTranslator.cpp \
sm_autonatives.cpp sm_memtable.cpp sm_srvcmds.cpp sm_trie.cpp \
sm_stringutil.cpp smn_filesystem.cpp smn_float.cpp smn_handles.cpp \
smn_player.cpp smn_string.cpp smn_textparse.cpp \
systems/ExtensionSys.cpp systems/ForwardSys.cpp systems/HandleSys.cpp \
systems/LibrarySys.cpp systems/PluginInfoDatabase.cpp \
systems/PluginSys.cpp systems/ShareSys.cpp vm/sp_vm_basecontext.cpp \
vm/sp_vm_engine.cpp vm/sp_vm_function.cpp
OBJECTS += zlib/adler32.c zlib/compress.c zlib/crc32.c zlib/deflate.c zlib/gzio.c \
zlib/infback.c zlib/inffast.c zlib/inflate.c zlib/inftrees.c zlib/trees.c \
zlib/uncompr.c zlib/zutil.c
LINK = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -static-libgcc
INCLUDE = -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
-I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SMM_TRUNK) -I$(SMM_TRUNK)/sourcehook -I$(SMM_TRUNK)/sourcemm \
-I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \
-Isystems
ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS = $(DEBUG_FLAGS)
else
BIN_DIR = Release
CFLAGS = $(OPT_FLAGS)
endif
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
CFLAGS += -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -fPIC -msse -DSOURCEMOD_BUILD
CPPFLAGS = -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
ifeq "$(GCC_VERSION)" "4"
CPPFLAGS += $(GCC4_FLAGS)
endif
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
$(BIN_DIR)/%.o: %.c
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
all:
mkdir -p $(BIN_DIR)/systems
mkdir -p $(BIN_DIR)/vm
mkdir -p $(BIN_DIR)/zlib
ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
$(MAKE) sourcemod
rm -rf $(BINARY)
ln -sf $(BIN_DIR)/$(BINARY) $(BINARY)
sourcemod: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) all DEBUG=true
default: all
clean:
rm -rf Release/*.o
rm -rf Release/$(BINARY)
rm -rf Debug/*.o
rm -rf Debug/$(BINARY)

View File

@ -644,4 +644,5 @@ size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
va_end(ap);
return (len >= maxlength) ? (maxlength - 1) : len;
}
}

View File

@ -268,7 +268,7 @@ static cell_t sm_FileExists(IPluginContext *pContext, const cell_t *params)
return 1;
}
return 0;
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
struct stat s;
if (stat(realpath, &s) != 0)
{
@ -304,7 +304,7 @@ static cell_t sm_RenameFile(IPluginContext *pContext, const cell_t *params)
#ifdef PLATFORM_WINDOWS
return (MoveFileA(old_realpath, new_realpath)) ? 1 : 0;
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
return (rename(old_realpath, new_realpath)) ? 0 : 1;
#endif
}
@ -332,7 +332,7 @@ static cell_t sm_DirExists(IPluginContext *pContext, const cell_t *params)
return 1;
}
return 0;
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
struct stat s;
if (stat(realpath, &s) != 0)
{
@ -369,7 +369,7 @@ static cell_t sm_FileSize(IPluginContext *pContext, const cell_t *params)
return static_cast<cell_t>(s.st_size);
}
return -1;
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
struct stat s;
if (stat(realpath, &s) != 0)
{
@ -465,7 +465,7 @@ static cell_t sm_LogToGame(IPluginContext *pContext, const cell_t *params)
static cell_t sm_LogMessage(IPluginContext *pContext, const cell_t *params)
{
char buffer[1024];
size_t len = g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 1);
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 1);
IPlugin *pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
g_Logger.LogMessage("[%s] %s", pPlugin->GetFilename(), buffer);
@ -476,7 +476,7 @@ static cell_t sm_LogMessage(IPluginContext *pContext, const cell_t *params)
static cell_t sm_LogError(IPluginContext *pContext, const cell_t *params)
{
char buffer[1024];
size_t len = g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 1);
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 1);
IPlugin *pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
g_Logger.LogError("[%s] %s", pPlugin->GetFilename(), buffer);

View File

@ -1,5 +1,6 @@
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "sm_autonatives.h"
#include "sp_vm_api.h"
#include "sp_typeutil.h"
@ -255,4 +256,4 @@ REGISTER_NATIVES(floatnatives)
{"ArcSine", sm_ArcSine},
{"ArcTangent2", sm_ArcTangent2},
{NULL, NULL}
};
};

View File

@ -199,4 +199,5 @@ REGISTER_NATIVES(playernatives)
{"PrintToServer", sm_PrintToServer},
{"PrintToConsole", sm_PrintToConsole},
{NULL, NULL}
};
};

View File

@ -10,7 +10,7 @@ inline const char *_strstr(const char *str, const char *substr)
{
#ifdef PLATFORM_WINDOWS
return strstr(str, substr);
#elif PLATFORM_LINUX
#elif defined PLATFORM_LINUX
return (const char *)strstr(str, substr);
#endif
}

View File

@ -707,7 +707,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmd, unsigned int argco
if (argcount > 4 && pExt->unload_code)
{
const char *unload = g_RootMenu.GetArgument(4);
if (pExt->unload_code == atoi(unload))
if (pExt->unload_code == (unsigned)atoi(unload))
{
char filename[PLATFORM_MAX_PATH+1];
snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());

View File

@ -1,4 +1,6 @@
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include "ForwardSys.h"
#include "PluginSys.h"
#include "ShareSys.h"
@ -179,7 +181,7 @@ CForward *CForward::CreateForward(const char *name, ExecType et, unsigned int nu
{
for (unsigned int i=0; i<num_params; i++)
{
_types[i] = va_arg(ap, ParamType);
_types[i] = (ParamType)va_arg(ap, int);
if (_types[i] == Param_VarArgs && (i != num_params - 1))
{
return NULL;
@ -245,7 +247,6 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
cell_t high_result = 0;
int err;
unsigned int failed=0, success=0;
unsigned int save_numcopy = 0;
unsigned int num_params = m_curparam;
FwdParamInfo temp_info[SP_MAX_EXEC_PARAMS];
FwdParamInfo *param;
@ -343,6 +344,10 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
}
break;
}
default:
{
break;
}
}
}
}
@ -584,7 +589,6 @@ bool CForward::RemoveFunction(IPluginFunction *func)
{
bool found = false;
FuncIter iter;
IPluginFunction *pNext = NULL;
for (iter=m_functions.begin(); iter!=m_functions.end();)
{

View File

@ -2,6 +2,7 @@
#include "ShareSys.h"
#include "PluginSys.h"
#include <assert.h>
#include <string.h>
HandleSystem g_HandleSys;
@ -408,7 +409,6 @@ HandleError HandleSystem::GetHandle(Handle_t handle,
}
QHandle *pHandle = &m_Handles[index];
QHandleType *pType = &m_Types[pHandle->type];
if (!pHandle->set
|| (pHandle->set == HandleSet_Freed && !ignoreFree))
@ -694,7 +694,7 @@ void HandleSystem::ReleasePrimHandle(unsigned int index)
if (set == HandleSet_Identity)
{
/* Extra work to do. We need to find everything connected to this identity and release it. */
unsigned int ch_index, old_index = 0;
unsigned int ch_index;
while ((ch_index = pHandle->ch_next) != 0)
{
pLocal = &m_Handles[ch_index];

View File

@ -1,4 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sm_platform.h>
#include "LibrarySys.h"
LibrarySystem g_LibSys;
@ -9,7 +12,7 @@ CLibrary::~CLibrary()
{
#if defined PLATFORM_WINDOWS
FreeLibrary(m_lib);
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
dlclose(m_lib);
#endif
m_lib = NULL;
@ -30,7 +33,7 @@ void *CLibrary::GetSymbolAddress(const char *symname)
{
#if defined PLATFORM_WINDOWS
return GetProcAddress(m_lib, symname);
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
return dlsym(m_lib, symname);
#endif
}
@ -51,12 +54,12 @@ CDirectory::CDirectory(const char *path)
{
m_fd.cFileName[0] = '\0';
}
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
m_dir = opendir(path);
if (IsValid())
{
/* :TODO: we need to read past "." and ".."! */
ep = readdir(dp);
ep = readdir(m_dir);
snprintf(m_origpath, PLATFORM_MAX_PATH, "%s", path);
} else {
ep = NULL;
@ -70,7 +73,7 @@ CDirectory::~CDirectory()
{
#if defined PLATFORM_WINDOWS
FindClose(m_dir);
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
closedir(m_dir);
#endif
}
@ -84,8 +87,8 @@ void CDirectory::NextEntry()
FindClose(m_dir);
m_dir = INVALID_HANDLE_VALUE;
}
#else if defined PLATFORM_POSIX
if ((ep=readdir(m_dir) == NULL)
#elif defined PLATFORM_POSIX
if ((ep=readdir(m_dir)) == NULL)
{
closedir(m_dir);
m_dir = NULL;
@ -102,10 +105,10 @@ bool CDirectory::IsEntryDirectory()
{
#if defined PLATFORM_WINDOWS
return ((m_fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
#else if defined PLATFORM_LINUX
#elif defined PLATFORM_LINUX
char temppath[PLATFORM_MAX_PATH];
snprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
return g_LibrarySys.IsPathDirectory(temppath);
return g_LibSys.IsPathDirectory(temppath);
#endif
}
@ -113,10 +116,10 @@ bool CDirectory::IsEntryFile()
{
#if defined PLATFORM_WINDOWS
return !(m_fd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE));
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
char temppath[PLATFORM_MAX_PATH];
snprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
return g_LibrarySys.IsPathFile(temppath);
return g_LibSys.IsPathFile(temppath);
#endif
}
@ -124,7 +127,7 @@ const char *CDirectory::GetEntryName()
{
#if defined PLATFORM_WINDOWS
return m_fd.cFileName;
#else if defined PLATFORM_LINUX
#elif defined PLATFORM_LINUX
return ep ? ep->d_name : "";
#endif
}
@ -138,7 +141,7 @@ bool CDirectory::IsValid()
{
#if defined PLATFORM_WINDOWS
return (m_dir != INVALID_HANDLE_VALUE);
#else if defined PLATFORM_LINUX
#elif defined PLATFORM_LINUX
return (m_dir != NULL);
#endif
}
@ -155,7 +158,7 @@ bool LibrarySystem::PathExists(const char *path)
DWORD attr = GetFileAttributesA(path);
return (attr != INVALID_FILE_ATTRIBUTES);
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
struct stat s;
return (stat(path, &s) == 0);
@ -178,7 +181,7 @@ bool LibrarySystem::IsPathFile(const char *path)
}
return true;
#else if defined PLATFORM_LINUX
#elif defined PLATFORM_LINUX
struct stat s;
if (stat(path, &s) != 0)
@ -205,7 +208,7 @@ bool LibrarySystem::IsPathDirectory(const char *path)
return true;
}
#else if defined PLATFORM_LINUX
#elif defined PLATFORM_LINUX
struct stat s;
if (stat(path, &s) != 0)
@ -249,7 +252,7 @@ void LibrarySystem::GetPlatformError(char *error, size_t err_max)
(LPSTR)error,
err_max,
NULL);
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
snprintf(error, err_max, "%s", strerror(errno));
#endif
}
@ -270,7 +273,7 @@ ILibrary *LibrarySystem::OpenLibrary(const char *path, char *error, size_t err_m
GetPlatformError(error, err_max);
return false;
}
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
lib = dlopen(path, RTLD_NOW);
if (!lib)
{

View File

@ -8,7 +8,7 @@ using namespace SourceMod;
#if defined PLATFORM_WINDOWS
typedef HMODULE LibraryHandle;
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
typedef void * LibraryHandle;
#endif
@ -30,7 +30,7 @@ private:
#if defined PLATFORM_WINDOWS
HANDLE m_dir;
WIN32_FIND_DATAA m_fd;
#else if defined PLATFORM_LINUX
#elif defined PLATFORM_POSIX
DIR *m_dir;
struct dirent *ep;
char m_origpath[PLATFORM_MAX_PATH];

View File

@ -64,7 +64,7 @@ private:
int m_errmsg;
bool in_plugins;
bool in_options;
unsigned int m_infodb;
int m_infodb;
size_t m_infodb_count;
size_t m_infodb_size;
int cur_plugin;

View File

@ -456,7 +456,7 @@ time_t CPlugin::GetFileTimeStamp()
#ifdef PLATFORM_WINDOWS
struct _stat s;
if (_stat(path, &s) != 0)
#else if defined PLATFORM_POSIX
#elif defined PLATFORM_POSIX
struct stat s;
if (stat(path, &s) != 0)
#endif
@ -1165,7 +1165,7 @@ bool CPluginManager::TestAliasMatch(const char *alias, const char *localpath)
if (*aliasptr == '*')
{
/* First, see if this is the last character */
if (aliasptr - alias == alias_len - 1)
if ((unsigned)(aliasptr - alias) == alias_len - 1)
{
/* If so, there's no need to match anything else */
return true;
@ -1369,7 +1369,7 @@ void CPluginManager::OnRootConsoleCommand(const char *command, unsigned int argc
assert(pl->GetStatus() != Plugin_Created);
int len = 0;
const sm_plugininfo_t *info = pl->GetPublicInfo();
if (pl->GetStatus() != Pl_Running)
if (pl->GetStatus() != Plugin_Running)
{
len += UTIL_Format(buffer, sizeof(buffer), " %02d <%s>", id, GetStatusText(pl->GetStatus()));
} else {
@ -1448,7 +1448,6 @@ void CPluginManager::OnRootConsoleCommand(const char *command, unsigned int argc
return;
}
int id = 1;
int num = atoi(g_RootMenu.GetArgument(3));
if (num < 1 || num > (int)GetPluginCount())
{

View File

@ -285,7 +285,7 @@ int BaseContext::HeapPop(cell_t local_addr)
addr = (cell_t *)(ctx->memory + local_addr);
cellcount = (*addr) * sizeof(cell_t);
/* check if this memory count looks valid */
if (ctx->hp - cellcount - sizeof(cell_t) != local_addr)
if ((signed)(ctx->hp - cellcount - sizeof(cell_t)) != local_addr)
{
return SP_ERROR_INVALID_ADDRESS;
}
@ -596,8 +596,6 @@ int BaseContext::PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t ar
int BaseContext::LocalToString(cell_t local_addr, char **addr)
{
int len = 0;
if (((local_addr >= ctx->hp) && (local_addr < ctx->sp)) || (local_addr < 0) || ((ucell_t)local_addr >= ctx->mem_size))
{
return SP_ERROR_INVALID_ADDRESS;
@ -855,7 +853,7 @@ IPluginFunction *BaseContext::GetFunctionById(funcid_t func_id)
m_priv_funcs[func_id] = new CFunction(save, this);
pFunc = m_priv_funcs[func_id];
}
#endif 0
#endif
assert(false);
}

View File

@ -10,7 +10,7 @@
#if defined WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else if defined __GNUC__
#elif defined __GNUC__
#include <sys/mman.h>
#endif
@ -85,7 +85,7 @@ void *SourcePawnEngine::ExecAlloc(size_t size)
{
#if defined WIN32
return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#else if defined __GNUC__
#elif defined __GNUC__
void *base = memalign(sysconf(_SC_PAGESIZE), size);
if (mprotect(base, size, PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
{
@ -100,7 +100,7 @@ void SourcePawnEngine::ExecFree(void *address)
{
#if defined WIN32
VirtualFree(address, 0, MEM_RELEASE);
#else if defined __GNUC__
#elif defined __GNUC__
free(address);
#endif
}

View File

@ -27,10 +27,10 @@ public:
virtual void ResetTrace();
virtual const char *GetLastNative(uint32_t *index);
private:
int m_Error;
const char *m_pMsg;
TracedCall *m_pStart;
TracedCall *m_pIterator;
const char *m_pMsg;
int m_Error;
uint32_t m_Native;
};

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <string.h>
#include "PluginSys.h"
/********************

View File

@ -106,7 +106,7 @@ namespace SourceMod
*
* The SMC file format is defined as:
* WHITESPACE: 0x20, \n, \t, \r
* IDENTIFIER: Any ASCII character EXCLUDING ", {, }, ;, //, /*, or WHITESPACE.
* IDENTIFIER: Any ASCII character EXCLUDING ", {, }, ;, //, / *, or WHITESPACE.
* STRING: Any set of symbols enclosed in quotes.
* Note: if a STRING does not have quotes, it is parsed as an IDENTIFIER.
*
@ -138,7 +138,7 @@ namespace SourceMod
* unless they are inside literal strings:
* ;<TEXT>
* //<TEXT>
* /*<TEXT> */
* / *<TEXT> */
enum SMCParseResult
{

View File

@ -24,11 +24,14 @@
#define PLATFORM_SEP_CHAR '\\'
#define PLATFORM_SEP_ALTCHAR '/'
#define PLATFORM_EXTERN_C extern "C" __declspec(dllexport)
#else if defined __linux__
#elif defined __linux__
#define PLATFORM_LINUX
#define PLATFORM_POSIX
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
#include <dlfcn.h>
#include <sys/stat.h>
#define PLATFORM_MAX_PATH PATH_MAX
#define PLATFORM_LIB_EXT "so"
#define PLATFORM_SEP_CHAR '/'
@ -36,4 +39,8 @@
#define PLATFORM_EXTERN_C extern "C" __attribute__((visibility("default")))
#endif
#if !defined SOURCEMOD_BUILD
#define SOURCEMOD_BUILD
#endif
#endif //_INCLUDE_SOURCEMOD_PLATFORM_H_

View File

@ -12,4 +12,5 @@ inline float sp_ctof(cell_t val)
return *(float *)&val;
}
#endif //_INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
#endif //_INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_

View File

@ -7,10 +7,11 @@
#if defined WIN32
#define EXPORT_LINK extern "C" __declspec(dllexport)
#else if defined __GNUC__
#elif defined __GNUC__
#define EXPORT_LINK extern "C" __attribute__((visibility("default")))
#endif
typedef SourcePawn::IVirtualMachine *(*SP_GETVM_FUNC)(SourcePawn::ISourcePawnEngine *);
#endif //_INCLUDE_SOURCEPAWN_VM_BASE_H_