aboutsummaryrefslogtreecommitdiff
path: root/src/sysbin/lx/lxlib.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2017-04-21 16:57:00 +0200
committerAlex Auvolat <alex@adnab.me>2017-04-21 16:57:00 +0200
commitf8334e283c5eb0efeb4bb8a134041e18388d5f01 (patch)
tree508bc475133262afee1d4a1d9fe7af3f576e2ee9 /src/sysbin/lx/lxlib.c
parentec08d0410730a16836eb40f5e46082b3bbaf45f6 (diff)
downloadkogata-f8334e283c5eb0efeb4bb8a134041e18388d5f01.tar.gz
kogata-f8334e283c5eb0efeb4bb8a134041e18388d5f01.zip
Lua init
Diffstat (limited to 'src/sysbin/lx/lxlib.c')
-rw-r--r--src/sysbin/lx/lxlib.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/sysbin/lx/lxlib.c b/src/sysbin/lx/lxlib.c
new file mode 100644
index 0000000..9f6843b
--- /dev/null
+++ b/src/sysbin/lx/lxlib.c
@@ -0,0 +1,41 @@
+/*
+** Lua eXtended library helpers
+*/
+
+#define lxsyslib_c
+#define LUA_LIB
+
+#include <lua/lprefix.h>
+
+
+#include <errno.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <lua/lua.h>
+
+#include <lua/lauxlib.h>
+#include <lua/lualib.h>
+
+#include "lxlib.h"
+
+
+bool lx_checkboolean(lua_State *L, int arg) {
+ if (!lua_isboolean(L, arg)) {
+ luaL_argerror(L, arg, "expected boolean");
+ }
+ return lua_toboolean(L, arg);
+}
+
+
+void setintfield (lua_State *L, const char *key, int value) {
+ lua_pushinteger(L, value);
+ lua_setfield(L, -2, key);
+}
+
+void setstrfield (lua_State *L, const char *key, const char* value) {
+ lua_pushstring(L, value);
+ lua_setfield(L, -2, key);
+}