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
+1 -1
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());
+7 -3
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();)
{
+2 -2
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];
+21 -18
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)
{
+2 -2
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];
+1 -1
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;
+3 -4
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())
{