28#include "../../shared/cxx.h"
29#include "../../shared/defines.h"
30#include "../../shared/shared.h"
31#include "../../common/hashtable.h"
32#include "../../common/filesys.h"
51 const char*
name = lua_tostring(L, -1);
55 memset(module, 0,
sizeof(module));
57 memset(errmsg, 0,
sizeof(errmsg));
65 if (luaL_loadbuffer(L, (
const char*) buffer,
len, module) == 0) {
69 sprintf(errmsg,
"Lua custom-loader error: cannot load module named [%s]:\n\t%s\n", module, lua_tostring(L, -1));
71 lua_pushstring(L, errmsg);
75 sprintf(errmsg,
"Lua custom-loader error: cannot find module named [%s]\n", module);
77 lua_pushstring(L, errmsg);
90 int pos = lua_gettop(L);
92 lua_getglobal(L,
"package");
94 luaL_error(L,
"Can't register searcher: package table does not exist.");
95 lua_getfield(L, -1,
"searchers");
97 luaL_error(L,
"Can't register searcher: package.searchers table does not exist.");
110 while (lua_next(L, -2) != 0) {
118 lua_pushinteger(L, nloaders + 1);
176 int regvalue = (
int) fnc;
183 Com_Printf(
"CL_RegisterCallback: lua callback registration error: script name has zero length!\n");
198 int regvalue = * ((
int*)value);
199 lua_rawgeti(L, LUA_REGISTRYINDEX, regvalue);
200 if (lua_pcall(L, 0, 0, 0) != 0) {
lua_State * CL_GetLuaState(void)
Returns the lua state for the client side.
void CL_InitLua(void)
Initializes the ui-lua interfacing environment.
int luaopen_ufo(lua_State *L)
void CL_RegisterCallback(const char *key, LUA_FUNCTION fnc)
Registers a lua callback function with a key.
static int CL_UfoModuleLoader(lua_State *L)
Loader that enables the lua files to access .ufo files through the ufo filesystem.
void CL_ShutdownLua(void)
Shutdown the ui-lua interfacing environment.
static void CL_InsertModuleLoader(lua_State *L)
This function adds loader to the lua table of module loaders that enables lua to access the ufo files...
void CL_ExecuteCallback(lua_State *L, const char *key)
Calls the registered lua onload callback function.
hashTable_s * cl_callback
void Com_Printf(const char *const fmt,...)
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
void * HASH_Get(hashTable_s *t, const void *key, int nkey)
Returns the value for a given key.
hashTable_s * HASH_NewTable(bool ownsKeys, bool ownsValues, bool duplicateOverwrite)
Creates a new hash table and sets it initial capacity.
bool HASH_Insert(hashTable_s *t, const void *key, int nkey, const void *value, int nvalue)
Inserts a new value with given key into the hash table.
void HASH_DeleteTable(hashTable_s **t)
Deletes a hash table and sets the pointer to NULL.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
QGL_EXTERN GLuint GLchar GLuint * len
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
int LUA_FUNCTION
callback signatures for functions defined in Lua
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
The hash table structure, contains an array of buckets being indexed by the hash function.