server/src/settings.pkg.c

111 lines
2.6 KiB
C

/*
** Lua binding: settings
*/
#include "tolua.h"
#ifndef __cplusplus
#include <stdlib.h>
#endif
#ifdef __cplusplus
extern "C" int tolua_bnd_takeownership (lua_State* L); // from tolua_map.c
#else
int tolua_bnd_takeownership (lua_State* L); /* from tolua_map.c */
#endif
#include <string.h>
/* Exported function */
TOLUA_API int tolua_settings_open (lua_State* tolua_S);
LUALIB_API int luaopen_settings (lua_State* tolua_S);
#undef tolua_reg_types
#define tolua_reg_types tolua_reg_types_settings
#include "bind_settings.h"
/* function to register type */
static void tolua_reg_types (lua_State* tolua_S)
{
}
/* function: settings_set */
static int tolua_settings_eressea_settings_set00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isstring(tolua_S,1,0,&tolua_err) ||
!tolua_isstring(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const char* key = ((const char*) tolua_tostring(tolua_S,1,0));
const char* value = ((const char*) tolua_tostring(tolua_S,2,0));
{
settings_set(key,value);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
return 0;
#endif
}
/* function: settings_get */
static int tolua_settings_eressea_settings_get00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isstring(tolua_S,1,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const char* key = ((const char*) tolua_tostring(tolua_S,1,0));
{
const char* tolua_ret = (const char*) settings_get(key);
tolua_pushstring(tolua_S,(const char*)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'get'.",&tolua_err);
return 0;
#endif
}
/* Open lib function */
LUALIB_API int luaopen_settings (lua_State* tolua_S)
{
tolua_open(tolua_S);
tolua_reg_types(tolua_S);
tolua_module(tolua_S,NULL,0);
tolua_beginmodule(tolua_S,NULL);
tolua_module(tolua_S,"eressea",0);
tolua_beginmodule(tolua_S,"eressea");
tolua_module(tolua_S,"settings",0);
tolua_beginmodule(tolua_S,"settings");
tolua_function(tolua_S,"set",tolua_settings_eressea_settings_set00);
tolua_function(tolua_S,"get",tolua_settings_eressea_settings_get00);
tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
return 1;
}
/* Open tolua function */
TOLUA_API int tolua_settings_open (lua_State* tolua_S)
{
lua_pushcfunction(tolua_S, luaopen_settings);
lua_pushstring(tolua_S, "settings");
lua_call(tolua_S, 1, 0);
return 1;
}