core/smn_core.cpp
author David Anderson <dvander@alliedmods.net>
Wed Oct 28 00:37:34 2009 -0700 (2009-10-28)
changeset 2841 dde3dd0b4b8b
parent 2471 194be299b700
child 2901 f5a1cf24f505
permissions -rw-r--r--
Added feature testing functionality (bug 4021, r=pred).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #include <time.h>
    33 #include <string.h>
    34 #include <stdlib.h>
    35 #include "sm_stringutil.h"
    36 #include "sm_globals.h"
    37 #include "sourcemod.h"
    38 #include "PluginSys.h"
    39 #include "HandleSys.h"
    40 #include "LibrarySys.h"
    41 #include "TimerSys.h"
    42 #include "ForwardSys.h"
    43 #include "Logger.h"
    44 #include "ExtensionSys.h"
    45 #include <sm_trie_tpl.h>
    46 
    47 #if defined PLATFORM_WINDOWS
    48 #include <windows.h>
    49 #elif defined PLATFORM_LINUX
    50 #include <limits.h>
    51 #include <unistd.h>
    52 #include <sys/times.h>
    53 #endif
    54 
    55 HandleType_t g_PlIter;
    56 ConVar sm_datetime_format("sm_datetime_format", "%m/%d/%Y - %H:%M:%S", 0, "Default formatting time rules");
    57 IForward *g_OnLogAction = NULL;
    58 
    59 class CoreNativeHelpers : 
    60 	public SMGlobalClass,
    61 	public IHandleTypeDispatch
    62 {
    63 public:
    64 	void OnSourceModAllInitialized()
    65 	{
    66 		HandleAccess hacc;
    67 		g_HandleSys.InitAccessDefaults(NULL,  &hacc);
    68 		hacc.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER;
    69 
    70 		g_PlIter = g_HandleSys.CreateType("PluginIterator", this, 0, NULL, NULL, g_pCoreIdent, NULL);
    71 
    72 		g_OnLogAction = g_Forwards.CreateForward("OnLogAction", 
    73 			ET_Hook, 
    74 			5, 
    75 			NULL,
    76 			Param_Cell,
    77 			Param_Cell,
    78 			Param_Cell,
    79 			Param_Cell,
    80 			Param_String);
    81 	}
    82 	void OnHandleDestroy(HandleType_t type, void *object)
    83 	{
    84 		IPluginIterator *iter = (IPluginIterator *)object;
    85 		iter->Release();
    86 	}
    87 	void OnSourceModShutdown()
    88 	{
    89 		g_Forwards.ReleaseForward(g_OnLogAction);
    90 		g_HandleSys.RemoveType(g_PlIter, g_pCoreIdent);
    91 	}
    92 } g_CoreNativeHelpers;
    93 
    94 void LogAction(Handle_t hndl, int type, int client, int target, const char *message)
    95 {
    96 	if (g_OnLogAction->GetFunctionCount())
    97 	{
    98 		cell_t result = 0;
    99 		g_OnLogAction->PushCell(hndl);
   100 		g_OnLogAction->PushCell(type);
   101 		g_OnLogAction->PushCell(client);
   102 		g_OnLogAction->PushCell(target);
   103 		g_OnLogAction->PushString(message);
   104 		g_OnLogAction->Execute(&result);
   105 
   106 		if (result >= (ResultType)Pl_Handled)
   107 		{
   108 			return;
   109 		}
   110 	}
   111 
   112 	const char *logtag = "SM";
   113 	if (type == 2)
   114 	{
   115 		HandleError err;
   116 		IPlugin *pPlugin = g_PluginSys.PluginFromHandle(hndl, &err);
   117 		if (pPlugin)
   118 		{
   119 			logtag = pPlugin->GetFilename();
   120 		}
   121 	}
   122 
   123 	g_Logger.LogMessage("[%s] %s", logtag, message);
   124 }
   125 
   126 static cell_t ThrowError(IPluginContext *pContext, const cell_t *params)
   127 {
   128 	char buffer[512];
   129 
   130 	g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
   131 
   132 	g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 1);
   133 
   134 	if (pContext->GetLastNativeError() == SP_ERROR_NONE)
   135 	{
   136 		pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", buffer);
   137 	}
   138 
   139 	return 0;
   140 }
   141 
   142 static cell_t GetTime(IPluginContext *pContext, const cell_t *params)
   143 {
   144 	time_t t = GetAdjustedTime();
   145 	cell_t *addr;
   146 	pContext->LocalToPhysAddr(params[1], &addr);
   147 
   148 	*(time_t *)addr = t;
   149 
   150 	return static_cast<cell_t>(t);
   151 }
   152 
   153 #if defined SUBPLATFORM_SECURECRT
   154 void _ignore_invalid_parameter(
   155 						const wchar_t * expression,
   156 						const wchar_t * function, 
   157 						const wchar_t * file, 
   158 						unsigned int line,
   159 						uintptr_t pReserved
   160 						)
   161 {
   162 	/* Wow we don't care, thanks Microsoft. */
   163 }
   164 #endif
   165 
   166 static cell_t FormatTime(IPluginContext *pContext, const cell_t *params)
   167 {
   168 	char *format, *buffer;
   169 	pContext->LocalToString(params[1], &buffer);
   170 	pContext->LocalToStringNULL(params[3], &format);
   171 
   172 	if (format == NULL)
   173 	{
   174 		format = const_cast<char *>(sm_datetime_format.GetString());
   175 	}
   176 
   177 #if defined SUBPLATFORM_SECURECRT
   178 	_invalid_parameter_handler handler = _set_invalid_parameter_handler(_ignore_invalid_parameter);
   179 #endif
   180 
   181 	time_t t = (params[4] == -1) ? GetAdjustedTime() : (time_t)params[4];
   182 	size_t written = strftime(buffer, params[2], format, localtime(&t));
   183 
   184 #if defined SUBPLATFORM_SECURECRT
   185 	_set_invalid_parameter_handler(handler);
   186 #endif
   187 
   188 	if (params[2] && format[0] != '\0' && !written)
   189 	{
   190 		pContext->ThrowNativeError("Invalid time format or buffer too small");
   191 		return 0;
   192 	}
   193 
   194 	return 1;
   195 }
   196 
   197 static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params)
   198 {
   199 	IPluginIterator *iter = g_PluginSys.GetPluginIterator();
   200 
   201 	Handle_t hndl = g_HandleSys.CreateHandle(g_PlIter, iter, pContext->GetIdentity(), g_pCoreIdent, NULL);
   202 
   203 	if (hndl == BAD_HANDLE)
   204 	{
   205 		iter->Release();
   206 	}
   207 
   208 	return hndl;
   209 }
   210 
   211 static cell_t MorePlugins(IPluginContext *pContext, const cell_t *params)
   212 {
   213 	Handle_t hndl = (Handle_t)params[1];
   214 	HandleError err;
   215 	IPluginIterator *pIter;
   216 
   217 	HandleSecurity sec;
   218 	sec.pIdentity = g_pCoreIdent;
   219 	sec.pOwner = pContext->GetIdentity();
   220 
   221 	if ((err=g_HandleSys.ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None)
   222 	{
   223 		return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err);
   224 	}
   225 
   226 	return pIter->MorePlugins() ? 1 : 0;
   227 }
   228 
   229 static cell_t ReadPlugin(IPluginContext *pContext, const cell_t *params)
   230 {
   231 	Handle_t hndl = (Handle_t)params[1];
   232 	HandleError err;
   233 	IPluginIterator *pIter;
   234 
   235 	HandleSecurity sec;
   236 	sec.pIdentity = g_pCoreIdent;
   237 	sec.pOwner = pContext->GetIdentity();
   238 
   239 	if ((err=g_HandleSys.ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None)
   240 	{
   241 		return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err);
   242 	}
   243 
   244 	CPlugin *pPlugin = (CPlugin *)pIter->GetPlugin();
   245 	if (!pPlugin)
   246 	{
   247 		return BAD_HANDLE;
   248 	}
   249 
   250 	pIter->NextPlugin();
   251 
   252 	return pPlugin->GetMyHandle();
   253 }
   254 
   255 CPlugin *GetPluginFromHandle(IPluginContext *pContext, Handle_t hndl)
   256 {
   257 	if (hndl == BAD_HANDLE)
   258 	{
   259 		return g_PluginSys.GetPluginByCtx(pContext->GetContext());
   260 	} else {
   261 		HandleError err;
   262 		CPlugin *pPlugin = (CPlugin *)g_PluginSys.PluginFromHandle(hndl, &err);
   263 		if (!pPlugin)
   264 		{
   265 			pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err);
   266 		}
   267 		return pPlugin;
   268 	}
   269 }
   270 
   271 static cell_t GetPluginStatus(IPluginContext *pContext, const cell_t *params)
   272 {
   273 	CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   274 	if (!pPlugin)
   275 	{
   276 		return 0;
   277 	}
   278 
   279 	return pPlugin->GetStatus();
   280 }
   281 
   282 static cell_t GetPluginFilename(IPluginContext *pContext, const cell_t *params)
   283 {
   284 	CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   285 	if (!pPlugin)
   286 	{
   287 		return 0;
   288 	}
   289 
   290 	pContext->StringToLocalUTF8(params[2], params[3], pPlugin->GetFilename(), NULL);
   291 
   292 	return 1;
   293 }
   294 
   295 static cell_t IsPluginDebugging(IPluginContext *pContext, const cell_t *params)
   296 {
   297 	CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   298 	if (!pPlugin)
   299 	{
   300 		return 0;
   301 	}
   302 
   303 	return pPlugin->IsDebugging() ? 1 : 0;
   304 }
   305 
   306 /* Local to plugins only */
   307 enum PluginInfo
   308 {
   309 	PlInfo_Name,			/**< Plugin name */
   310 	PlInfo_Author,			/**< Plugin author */
   311 	PlInfo_Description,		/**< Plugin description */
   312 	PlInfo_Version,			/**< Plugin verison */
   313 	PlInfo_URL,				/**< Plugin URL */
   314 };
   315 
   316 static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params)
   317 {
   318 	CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   319 	if (!pPlugin)
   320 	{
   321 		return 0;
   322 	}
   323 
   324 	const sm_plugininfo_t *info = pPlugin->GetPublicInfo();
   325 
   326 	if (!info)
   327 	{
   328 		return 0;
   329 	}
   330 
   331 	const char *str = NULL;
   332 
   333 	switch ((PluginInfo)params[2])
   334 	{
   335 	case PlInfo_Name:
   336 		{
   337 			str = info->name;
   338 			break;
   339 		}
   340 	case PlInfo_Author:
   341 		{
   342 			str = info->author;
   343 			break;
   344 		}
   345 	case PlInfo_Description:
   346 		{
   347 			str = info->description;
   348 			break;
   349 		}
   350 	case PlInfo_Version:
   351 		{
   352 			str = info->version;
   353 			break;
   354 		}
   355 	case PlInfo_URL:
   356 		{
   357 			str = info->url;
   358 			break;
   359 		}
   360 	}
   361 
   362 	if (!str || str[0] == '\0')
   363 	{
   364 		return 0;
   365 	}
   366 
   367 	pContext->StringToLocalUTF8(params[3], params[4], str, NULL);
   368 
   369 	return 1;
   370 }
   371 
   372 static cell_t SetFailState(IPluginContext *pContext, const cell_t *params)
   373 {
   374 	char *str;
   375 	CPlugin *pPlugin;
   376 
   377 	pContext->LocalToString(params[1], &str);
   378 	pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   379 
   380 	if (params[0] == 1)
   381 	{
   382 		pPlugin->SetErrorState(Plugin_Error, "%s", str);
   383 
   384 		return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str);
   385 	}
   386 	else
   387 	{
   388 		char buffer[2048];
   389 
   390 		g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 1);
   391 		if (pContext->GetLastNativeError() != SP_ERROR_NONE)
   392 		{
   393 			pPlugin->SetErrorState(Plugin_Error, "%s", str);
   394 			return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "Formatting error (%s)", str);
   395 		}
   396 		else
   397 		{
   398 			pPlugin->SetErrorState(Plugin_Error, "%s", buffer);
   399 			return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", buffer);
   400 		}
   401 	}
   402 
   403 	return 0;
   404 }
   405 
   406 static cell_t GetSysTickCount(IPluginContext *pContext, const cell_t *params)
   407 {
   408 #if defined PLATFORM_WINDOWS
   409 	return (cell_t)GetTickCount();
   410 #elif defined PLATFORM_LINUX
   411 	tms tm;
   412 	clock_t ticks = times(&tm);
   413 	long ticks_per_sec = sysconf(_SC_CLK_TCK);
   414 	double fticks = (double)ticks / (double)ticks_per_sec;
   415 	fticks *= 1000.0f;
   416 	if (fticks > INT_MAX)
   417 	{
   418 		double r = (int)(fticks / INT_MAX) * (double)INT_MAX;
   419 		fticks -= r;
   420 	}
   421 	return (cell_t)fticks;
   422 #elif defined PLATFORM_APPLE
   423 	assert(false);
   424 	return 0;
   425 #endif
   426 }
   427 
   428 static cell_t AutoExecConfig(IPluginContext *pContext, const cell_t *params)
   429 {
   430 	CPlugin *plugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   431 
   432 	char *cfg, *folder;
   433 	pContext->LocalToString(params[2], &cfg);
   434 	pContext->LocalToString(params[3], &folder);
   435 
   436 	if (cfg[0] == '\0')
   437 	{
   438 		static char temp_str[255];
   439 		static char temp_file[PLATFORM_MAX_PATH];
   440 		char *ptr;
   441 
   442 		g_LibSys.GetFileFromPath(temp_str, sizeof(temp_str), plugin->GetFilename());
   443 		if ((ptr = strstr(temp_str, ".smx")) != NULL)
   444 		{
   445 			*ptr = '\0';
   446 		}
   447 
   448 		/* We have the raw filename! */
   449 		UTIL_Format(temp_file, sizeof(temp_file), "plugin.%s", temp_str);
   450 		cfg = temp_file;
   451 	}
   452 
   453 	plugin->AddConfig(params[1] ? true : false, cfg, folder);
   454 
   455 	return 1;
   456 }
   457 
   458 static cell_t MarkNativeAsOptional(IPluginContext *pContext, const cell_t *params)
   459 {
   460 	char *name;
   461 	uint32_t idx;
   462 	sp_native_t *native;
   463 
   464 	pContext->LocalToString(params[1], &name);
   465 	if (pContext->FindNativeByName(name, &idx) != SP_ERROR_NONE)
   466 	{
   467 		/* Oops! This HAS to silently fail! */
   468 		return 0;
   469 	}
   470 
   471 	pContext->GetNativeByIndex(idx, &native);
   472 
   473 	native->flags |= SP_NTVFLAG_OPTIONAL;
   474 
   475 	return 1;
   476 }
   477 
   478 static cell_t RegPluginLibrary(IPluginContext *pContext, const cell_t *params)
   479 {
   480 	char *name;
   481 	CPlugin *pl = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   482 
   483 	pContext->LocalToString(params[1], &name);
   484 
   485 	pl->AddLibrary(name);
   486 
   487 	return 1;
   488 }
   489 
   490 static cell_t LibraryExists(IPluginContext *pContext, const cell_t *params)
   491 {
   492 	char *str;
   493 	pContext->LocalToString(params[1], &str);
   494 
   495 	if (strcmp(str, "__CanTestFeatures__") == 0)
   496 	{
   497 		return 1;
   498 	}
   499 
   500 	if (g_PluginSys.LibraryExists(str))
   501 	{
   502 		return 1;
   503 	}
   504 
   505 	if (g_Extensions.LibraryExists(str))
   506 	{
   507 		return 1;
   508 	}
   509 
   510 	return 0;
   511 }
   512 
   513 static cell_t sm_LogAction(IPluginContext *pContext, const cell_t *params)
   514 {
   515 	char buffer[2048];
   516 	g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
   517 	g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 3);
   518 
   519 	if (pContext->GetLastNativeError() != SP_ERROR_NONE)
   520 	{
   521 		return 0;
   522 	}
   523 
   524 	CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   525 
   526 	LogAction(pPlugin->GetMyHandle(), 2, params[1], params[2], buffer);
   527 
   528 	return 1;
   529 }
   530 
   531 static cell_t LogToFile(IPluginContext *pContext, const cell_t *params)
   532 {
   533 	char *file;
   534 	pContext->LocalToString(params[1], &file);
   535 
   536 	char path[PLATFORM_MAX_PATH];
   537 	g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "%s", file);
   538 
   539 	FILE *fp = fopen(path, "at");
   540 	if (!fp)
   541 	{
   542 		return pContext->ThrowNativeError("Could not open file \"%s\"", path);
   543 	}
   544 
   545 	char buffer[2048];
   546 	g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
   547 	g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
   548 
   549 	if (pContext->GetLastNativeError() != SP_ERROR_NONE)
   550 	{
   551 		fclose(fp);
   552 		return 0;
   553 	}
   554 
   555 	CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   556 
   557 	g_Logger.LogToOpenFile(fp, "[%s] %s", pPlugin->GetFilename(), buffer);
   558 
   559 	fclose(fp);
   560 
   561 	return 1;
   562 }
   563 
   564 static cell_t LogToFileEx(IPluginContext *pContext, const cell_t *params)
   565 {
   566 	char *file;
   567 	pContext->LocalToString(params[1], &file);
   568 
   569 	char path[PLATFORM_MAX_PATH];
   570 	g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "%s", file);
   571 
   572 	FILE *fp = fopen(path, "at");
   573 	if (!fp)
   574 	{
   575 		return pContext->ThrowNativeError("Could not open file \"%s\"", path);
   576 	}
   577 
   578 	char buffer[2048];
   579 	g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
   580 	g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
   581 
   582 	if (pContext->GetLastNativeError() != SP_ERROR_NONE)
   583 	{
   584 		fclose(fp);
   585 		return 0;
   586 	}
   587 
   588 	g_Logger.LogToOpenFile(fp, "%s", buffer);
   589 
   590 	fclose(fp);
   591 
   592 	return 1;
   593 }
   594 
   595 static cell_t GetExtensionFileStatus(IPluginContext *pContext, const cell_t *params)
   596 {
   597 	char *str;
   598 	pContext->LocalToString(params[1], &str);
   599 
   600 	IExtension *pExtension = g_Extensions.FindExtensionByFile(str);
   601 	
   602 	if (!pExtension)
   603 	{
   604 		return -2;
   605 	}
   606 	
   607 	if (!pExtension->IsLoaded())
   608 	{
   609 		return -1;
   610 	}
   611 
   612 	char *error;
   613 	pContext->LocalToString(params[2], &error);
   614 	if (!pExtension->IsRunning(error, params[3]))
   615 	{
   616 		return 0;
   617 	}
   618 
   619 	return 1;
   620 }
   621 
   622 static cell_t FindPluginByNumber(IPluginContext *pContext, const cell_t *params)
   623 {
   624 	CPlugin *pPlugin = g_PluginSys.GetPluginByOrder(params[1]);
   625 	
   626 	if (pPlugin == NULL)
   627 	{
   628 		return BAD_HANDLE;
   629 	}
   630 
   631 	return pPlugin->GetMyHandle();
   632 }
   633 
   634 static cell_t VerifyCoreVersion(IPluginContext *pContext, const cell_t *params)
   635 {
   636 	return 4;
   637 }
   638 
   639 static cell_t GetFeatureStatus(IPluginContext *pContext, const cell_t *params)
   640 {
   641 	FeatureType type = (FeatureType)params[1];
   642 	char *name;
   643 
   644 	pContext->LocalToString(params[2], &name);
   645 
   646 	return g_ShareSys.TestFeature(pContext->GetRuntime(),type, name);
   647 }
   648 
   649 static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params)
   650 {
   651 	FeatureType type = (FeatureType)params[1];
   652 	char *name;
   653 
   654 	pContext->LocalToString(params[2], &name);
   655 
   656 	if (g_ShareSys.TestFeature(pContext->GetRuntime(),type, name) != FeatureStatus_Available)
   657 	{
   658 		char buffer[255];
   659 		char *msg = buffer;
   660 		char default_message[255];
   661 		CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   662 
   663 		g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 3);
   664 		if (pContext->GetLastNativeError() != SP_ERROR_NONE || buffer[0] == '\0')
   665 		{
   666 			UTIL_Format(default_message, sizeof(default_message), "Feature \"%s\" not available", name);
   667 			msg = default_message;
   668 		}
   669 		pPlugin->SetErrorState(Plugin_Error, "%s", msg);
   670 		return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", msg);
   671 	}
   672 
   673 	return 1;
   674 }
   675 
   676 REGISTER_NATIVES(coreNatives)
   677 {
   678 	{"AutoExecConfig",			AutoExecConfig},
   679 	{"GetPluginFilename",		GetPluginFilename},
   680 	{"GetPluginInfo",			GetPluginInfo},
   681 	{"GetPluginIterator",		GetPluginIterator},
   682 	{"GetPluginStatus",			GetPluginStatus},
   683 	{"GetSysTickCount",			GetSysTickCount},
   684 	{"GetTime",					GetTime},
   685 	{"IsPluginDebugging",		IsPluginDebugging},
   686 	{"MorePlugins",				MorePlugins},
   687 	{"ReadPlugin",				ReadPlugin},
   688 	{"ThrowError",				ThrowError},
   689 	{"SetFailState",			SetFailState},
   690 	{"FormatTime",				FormatTime},
   691 	{"MarkNativeAsOptional",	MarkNativeAsOptional},
   692 	{"RegPluginLibrary",		RegPluginLibrary},
   693 	{"LibraryExists",			LibraryExists},
   694 	{"LogAction",				sm_LogAction},
   695 	{"LogToFile",				LogToFile},
   696 	{"LogToFileEx",				LogToFileEx},
   697 	{"GetExtensionFileStatus",	GetExtensionFileStatus},
   698 	{"FindPluginByNumber",		FindPluginByNumber},
   699 	{"VerifyCoreVersion",		VerifyCoreVersion},
   700 	{"GetFeatureStatus",        GetFeatureStatus},
   701 	{"RequireFeature",          RequireFeature},
   702 	{NULL,						NULL},
   703 };
   704