aboutsummaryrefslogtreecommitdiff
path: root/src/sysbin/lx/lxioctllib.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/lxioctllib.c
parentec08d0410730a16836eb40f5e46082b3bbaf45f6 (diff)
downloadkogata-f8334e283c5eb0efeb4bb8a134041e18388d5f01.tar.gz
kogata-f8334e283c5eb0efeb4bb8a134041e18388d5f01.zip
Lua init
Diffstat (limited to 'src/sysbin/lx/lxioctllib.c')
-rw-r--r--src/sysbin/lx/lxioctllib.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/sysbin/lx/lxioctllib.c b/src/sysbin/lx/lxioctllib.c
new file mode 100644
index 0000000..4b9be91
--- /dev/null
+++ b/src/sysbin/lx/lxioctllib.c
@@ -0,0 +1,62 @@
+/*
+** Lua eXtended ioctl library
+*/
+
+#define lxioctllib_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 <kogata/syscall.h>
+#include <kogata/gip.h>
+
+#include "lxlib.h"
+
+
+static int ioctl_fb_get_info(lua_State *L) {
+ int fd = luaL_checkinteger(L, 1);
+
+ fb_info_t mode;
+ int r = sc_ioctl(fd, IOCTL_FB_GET_INFO, &mode);
+ if (r == 1) {
+ lua_createtable(L, 0, 5);
+ setintfield(L, "width", mode.width);
+ setintfield(L, "height", mode.height);
+ setintfield(L, "pitch", mode.pitch);
+ setintfield(L, "bpp", mode.bpp);
+ setintfield(L, "memory_model", mode.memory_model);
+ } else {
+ lua_pushnil(L);
+ }
+
+ return 1;
+}
+
+
+/* }====================================================== */
+
+static const luaL_Reg ioctllib[] = {
+ {"fb_get_info", ioctl_fb_get_info},
+ {NULL, NULL}
+};
+
+
+LUAMOD_API int lx_open_ioctl (lua_State *L) {
+ luaL_newlib(L, ioctllib);
+ return 1;
+}
+
+
+/* vim: set sts=2 ts=2 sw=2 tw=0 et :*/