From 5dc9f2ca315eb91e343bfa199c535c9b9f4885fa Mon Sep 17 00:00:00 2001 From: Egor00f Date: Sat, 5 Apr 2025 17:49:35 +0500 Subject: [PATCH] add lua funcs names to Spell words && use tabs instead spaces --- .vscode/settings.json | 31 +- README.md | 4 +- src/ARP_entry.c | 170 +-- src/ARP_entry.h | 15 +- src/debug.h | 5 +- src/scancodes.h | 2 +- src/syscalls.c | 2628 +++++++++++++++++++-------------------- src/systemColors.c | 278 ++--- src/systemColors.h | 6 +- tests/SystemColors.lua | 2 +- tests/libraryStruct.lua | 3 +- 11 files changed, 1586 insertions(+), 1558 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9deab0a..2a17d46 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,34 @@ { + "editor.tabSize": 4, + "editor.insertSpaces": false, "files.associations": { "stdlib.h": "c" - } + }, + "cSpell.words": [ + "ksys", + "ksys_oskey_t", + "LUALIB_API", + "luaL_newlib", + "metatable", + "luaL_newmetatable", + "luaL_setmetatable", + "lua_createtable", + "luaL_setfuncs", + "luaL_checkinteger", + "luaL_checkstring", + "luaL_checkudata", + "lua_pushboolean", + "lua_pushinteger", + "lua_pushnumber", + "luaL_optinteger", + "lua_pushstring", + "lua_pushnil", + "lua_touserdata", + "lua_setfield", + "lua_getfield", + "lua_settop", + "lua_islightuserdata", + "luaL_checktype", + "LUA_TTABLE", + ] } \ No newline at end of file diff --git a/README.md b/README.md index fc3902d..c7f8587 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# syscalls +# Syscalls -syscalls for Lua \ No newline at end of file +Syscalls library for Lua diff --git a/src/ARP_entry.c b/src/ARP_entry.c index cc13acb..6a5dfe2 100644 --- a/src/ARP_entry.c +++ b/src/ARP_entry.c @@ -8,145 +8,145 @@ static int syscalls_gcARPEntry(lua_State* L) { - free(lua_touserdata(L, 1)); + free(lua_touserdata(L, 1)); - return 0; + return 0; } static bool syscalls_cmpAPREntry(const struct ARP_entry* entry1, const struct ARP_entry* entry2) { - return memcmp(entry1, entry2, sizeof(struct ARP_entry)); + return memcmp(entry1, entry2, sizeof(struct ARP_entry)); } int syscalls_indexARPEntry(lua_State* L) { - DEBUG_LINE("ARP entry index"); + DEBUG_LINE("ARP entry index"); - struct ARP_entry* entry = (struct ARP_entry*)luaL_checkudata(L, 1, syscalls_ARPEntry_metatable_name); + struct ARP_entry* entry = (struct ARP_entry*)luaL_checkudata(L, 1, syscalls_ARPEntry_metatable_name); - const char* index = luaL_checkstring(L, 2); + const char* index = luaL_checkstring(L, 2); - if (strcmp(index, "IP") == 0) - { - lua_pushinteger(L, entry->IP); - } - else if (strcmp(index, "MAC") == 0) - { - char str[7]; - memset(str, entry->MAC, 6); - str[6] = '\n'; - lua_pushstring(L, str); - } - else if (strcmp(index, "Status") == 0) - { - lua_pushinteger(L, entry->Status); - } - else if (strcmp(index, "TTL") == 0) - { - lua_pushinteger(L, entry->TTL); - } - else - { - _ksys_debug_puts("err\n"); - } + if (strcmp(index, "IP") == 0) + { + lua_pushinteger(L, entry->IP); + } + else if (strcmp(index, "MAC") == 0) + { + char str[7]; + memset(str, entry->MAC, 6); + str[6] = '\n'; + lua_pushstring(L, str); + } + else if (strcmp(index, "Status") == 0) + { + lua_pushinteger(L, entry->Status); + } + else if (strcmp(index, "TTL") == 0) + { + lua_pushinteger(L, entry->TTL); + } + else + { + _ksys_debug_puts("err\n"); + } - return 1; + return 1; } int syscalls_newindexARPEntry(lua_State* L) { - DEBUG_LINE("ARP entry newindex"); + DEBUG_LINE("ARP entry newindex"); - struct ARP_entry* entry = (struct ARP_entry*)luaL_checkudata(L, 1, syscalls_ARPEntry_metatable_name); + struct ARP_entry* entry = (struct ARP_entry*)luaL_checkudata(L, 1, syscalls_ARPEntry_metatable_name); - const char* index = luaL_checkstring(L, 2); + const char* index = luaL_checkstring(L, 2); - if (strcmp(index, "IP")) - { - entry->IP = luaL_checkinteger(L, 3); - } - else if (strcmp(index, "MAC")) - { - memset(entry->MAC, luaL_checkstring(L, 3), 6); - } - else if (strcmp(index, "Status")) - { - entry->Status = luaL_checkinteger(L, 3); - } - else if (strcmp(index, "TTL")) - { - entry->TTL = luaL_checkinteger(L, 3); - } - else - { - _ksys_debug_puts("err\n"); - } + if (strcmp(index, "IP")) + { + entry->IP = luaL_checkinteger(L, 3); + } + else if (strcmp(index, "MAC")) + { + memset(entry->MAC, luaL_checkstring(L, 3), 6); + } + else if (strcmp(index, "Status")) + { + entry->Status = luaL_checkinteger(L, 3); + } + else if (strcmp(index, "TTL")) + { + entry->TTL = luaL_checkinteger(L, 3); + } + else + { + _ksys_debug_puts("err\n"); + } - return 0; + return 0; } static int syscalls_eqAPREntry(lua_State* L) { - lua_pushboolean( - L, - syscalls_cmpAPREntry( - (struct ARP_entry*)lua_touserdata(L, 1), - (struct ARP_entry*)lua_touserdata(L, 2) - ) - ); + lua_pushboolean( + L, + syscalls_cmpAPREntry( + (struct ARP_entry*)lua_touserdata(L, 1), + (struct ARP_entry*)lua_touserdata(L, 2) + ) + ); - return 1; + return 1; } int syscalls_newARPEntry(lua_State* L) { - struct ARP_entry* entry = syscalls_pushARPEntry(L);; + struct ARP_entry* entry = syscalls_pushARPEntry(L);; - entry->IP = luaL_checkinteger(L, 1); - memcpy(entry->MAC, luaL_checkstring(L, 2), 6); - entry->Status = luaL_checkinteger(L, 3); - entry->TTL = luaL_checkinteger(L, 4); + entry->IP = luaL_checkinteger(L, 1); + memcpy(entry->MAC, luaL_checkstring(L, 2), 6); + entry->Status = luaL_checkinteger(L, 3); + entry->TTL = luaL_checkinteger(L, 4); - return 1; + return 1; } static const luaL_Reg syscalls_ARPEntry_m[] = { - {"__index", syscalls_indexARPEntry}, - {"__newindex", syscalls_newindexARPEntry}, - {"__eq", syscalls_eqAPREntry}, - {"__gc", syscalls_gcARPEntry}, - {NULL, NULL} + {"__index", syscalls_indexARPEntry}, + {"__newindex", syscalls_newindexARPEntry}, + {"__eq", syscalls_eqAPREntry}, + {"__gc", syscalls_gcARPEntry}, + {NULL, NULL} }; struct ARP_entry* syscalls_pushARPEntry(lua_State* L) { - DEBUG_LINE("push ARP entry"); + DEBUG_LINE("push ARP entry"); - struct ARP_entry* entry = lua_newuserdata(L, sizeof(struct ARP_entry)); + struct ARP_entry* entry = lua_newuserdata(L, sizeof(struct ARP_entry)); - luaL_setmetatable(L, syscalls_ARPEntry_metatable_name); + luaL_setmetatable(L, syscalls_ARPEntry_metatable_name); - return entry; + return entry; } static const luaL_Reg syscalls_ARPEntry_lib[] = { - {"new", syscalls_newARPEntry}, - {NULL, NULL} + {"new", syscalls_newARPEntry}, + {NULL, NULL} }; void syscalls_register_ARPEntry(lua_State* L) { - DEBUG_LINE("register ARP entry"); + DEBUG_LINE("register ARP entry"); - luaL_newlib(L, syscalls_ARPEntry_lib); + luaL_newlib(L, syscalls_ARPEntry_lib); - lua_setfield(L, -2, syscalls_ARPEntry_name); + lua_setfield(L, -2, syscalls_ARPEntry_name); - luaL_newmetatable(L, syscalls_ARPEntry_metatable_name); - luaL_setfuncs(L, syscalls_ARPEntry_m, 0); + luaL_newmetatable(L, syscalls_ARPEntry_metatable_name); + luaL_setfuncs(L, syscalls_ARPEntry_m, 0); - lua_pop(L, 1); + lua_pop(L, 1); } diff --git a/src/ARP_entry.h b/src/ARP_entry.h index 31b8fd6..090ccd9 100644 --- a/src/ARP_entry.h +++ b/src/ARP_entry.h @@ -1,19 +1,18 @@ -#ifndef _SYSCALLS_ARP_ENTRY_ -#define _SYSCALLS_ARP_ENTRY +#ifndef __SYSCALLS_ARP_ENTRY__ +#define __SYSCALLS_ARP_ENTRY__ #include #include #include - #include struct ARP_entry { - uint32_t IP; - char MAC[6]; - uint16_t Status; - uint16_t TTL; + uint32_t IP; + char MAC[6]; + uint16_t Status; + uint16_t TTL; }; #define syscalls_ARPEntry_name "ARPEntry" @@ -33,4 +32,4 @@ int syscalls_newindexARPEntry(lua_State* L); void syscalls_register_ARPEntry(lua_State* L); -#endif +#endif // __SYSCALLS_ARP_ENTRY__ diff --git a/src/debug.h b/src/debug.h index c6342f9..2d4ce14 100644 --- a/src/debug.h +++ b/src/debug.h @@ -4,10 +4,11 @@ #ifdef NDEBUG #include + /** * Debug out, enabled */ -#define DEBUG_PRINT(msg) _ksys_debug_puts(msg) +#define DEBUG_PRINT(msg) _ksys_debug_puts(msg) #else @@ -18,6 +19,6 @@ #endif -#define DEBUG_LINE(msg) DEBUG_PRINT(msg); DEBUG_PRINT("\n") +#define DEBUG_LINE(msg) DEBUG_PRINT(msg); DEBUG_PRINT("\n") #endif // __DEBUG_H__ diff --git a/src/scancodes.h b/src/scancodes.h index a6ad03c..a582ab4 100644 --- a/src/scancodes.h +++ b/src/scancodes.h @@ -6,7 +6,7 @@ #include #include -static inline void syscalls_register_scancodes(lua_State *L) +static inline void syscalls_register_scancodes(lua_State* L) { lua_newtable(L); diff --git a/src/syscalls.c b/src/syscalls.c index c923422..e548e98 100644 --- a/src/syscalls.c +++ b/src/syscalls.c @@ -1,5 +1,5 @@ /* - syscalls + syscalls */ #include @@ -19,75 +19,75 @@ /* - Режим ввода с клавиатуры + Режим ввода с клавиатуры - функции для получения текущего режима нет, поэтому выкручиваемся таким образом + функции для получения текущего режима нет, поэтому выкручиваемся таким образом */ static ksys_key_input_mode_t syscalls_KeyInputState = KSYS_KEY_INPUT_MODE_ASCII; /* - Кеш размера экрана. + Кеш размера экрана. - Нужно для того чтобы не вызывать систменое прерывание лишний раз (другие функции тоже используют это значение) + Нужно для того чтобы не вызывать систменое прерывание лишний раз (другие функции тоже используют это значение) - Сомневаюсь что в размер экрана в колибри вообще может меняться без перезагрузки + Сомневаюсь что в размер экрана в колибри вообще может меняться без перезагрузки - обновляется функцией syscalls_updateScreenSize + обновляется функцией syscalls_updateScreenSize */ static ksys_pos_t syscalls_screenSizeCache = { 0 }; /* - функции для того чтобы возвращаемые значения функций были болле-мение едиообразны + функции для того чтобы возвращаемые значения функций были болле-мение едиообразны */ inline void syscalls_ReturnIntegerOrNil(LUA_INTEGER value, lua_State* L) { - if (value == -1) - { - lua_pushnil(L); - } - else - { - lua_pushinteger(L, value); - } + if (value == -1) + { + lua_pushnil(L); + } + else + { + lua_pushinteger(L, value); + } } inline void syscalls_ReturnIntegerValueOrNil(LUA_INTEGER cond, LUA_INTEGER value, lua_State* L) { - if (cond == -1) - { - lua_pushnil(L); - } - else - { - lua_pushinteger(L, value); - } + if (cond == -1) + { + lua_pushnil(L); + } + else + { + lua_pushinteger(L, value); + } } inline void syscalls_ReturnTrueOrNil(LUA_INTEGER value, lua_State* L) { - if (value == -1) - { - lua_pushnil(L); - } - else - { - lua_pushboolean(L, true); - } + if (value == -1) + { + lua_pushnil(L); + } + else + { + lua_pushboolean(L, true); + } } inline void syscalls_ReturnStringOrNil(LUA_INTEGER cond, const char* value, lua_State* L) { - if (cond == -1) - { - lua_pushnil(L); - } - else - { - lua_pushstring(L, value); - } + if (cond == -1) + { + lua_pushnil(L); + } + else + { + lua_pushstring(L, value); + } } @@ -95,1828 +95,1828 @@ inline void syscalls_ReturnStringOrNil(LUA_INTEGER cond, const char* value, lua_ static int syscalls_createWindow(lua_State* L) { - uint32_t x = luaL_checkinteger(L, 1); - uint32_t y = luaL_checkinteger(L, 2); - uint32_t w = luaL_checkinteger(L, 3); - uint32_t h = luaL_checkinteger(L, 4); - ksys_color_t workcolor = luaL_checkinteger(L, 6); - uint32_t style = luaL_checkinteger(L, 7); + uint32_t x = luaL_checkinteger(L, 1); + uint32_t y = luaL_checkinteger(L, 2); + uint32_t w = luaL_checkinteger(L, 3); + uint32_t h = luaL_checkinteger(L, 4); + ksys_color_t workcolor = luaL_checkinteger(L, 6); + uint32_t style = luaL_checkinteger(L, 7); - if (style == 0 || style == 2) - { - uint32_t borderColor = luaL_checkinteger(L, 5); - uint32_t titleColor = luaL_checkinteger(L, 8); - asm_inline( - "int $0x40" ::"a"(0), - "b"((x << 16) | ((w - 1) & 0xFFFF)), - "c"((y << 16) | ((h - 1) & 0xFFFF)), - "d"((style << 24) | (workcolor & 0xFFFFFF)), - "D"(borderColor), - "S"(titleColor) - : "memory"); - } - else - { - _ksys_create_window( - x, y, w, h, - luaL_checkstring(L, 5), - workcolor, - style); - } + if (style == 0 || style == 2) + { + uint32_t borderColor = luaL_checkinteger(L, 5); + uint32_t titleColor = luaL_checkinteger(L, 8); + asm_inline( + "int $0x40" ::"a"(0), + "b"((x << 16) | ((w - 1) & 0xFFFF)), + "c"((y << 16) | ((h - 1) & 0xFFFF)), + "d"((style << 24) | (workcolor & 0xFFFFFF)), + "D"(borderColor), + "S"(titleColor) + : "memory"); + } + else + { + _ksys_create_window( + x, y, w, h, + luaL_checkstring(L, 5), + workcolor, + style); + } - return 0; + return 0; } static int syscalls_changeWindow(lua_State* L) { - _ksys_change_window( - luaL_checkinteger(L, 1), - luaL_checkinteger(L, 2), - luaL_checkinteger(L, 3), - luaL_checkinteger(L, 4)); + _ksys_change_window( + luaL_checkinteger(L, 1), + luaL_checkinteger(L, 2), + luaL_checkinteger(L, 3), + luaL_checkinteger(L, 4)); - return 0; + return 0; } static int syscalls_setWindowTitle(lua_State* L) { - _ksys_set_window_title(luaL_checkstring(L, 1)); + _ksys_set_window_title(luaL_checkstring(L, 1)); - return 0; + return 0; } static int syscalls_startRedraw(lua_State* L) { - _ksys_start_draw(); + _ksys_start_draw(); - return 0; + return 0; } static int syscalls_endRedraw(lua_State* L) { - _ksys_end_draw(); + _ksys_end_draw(); - return 0; + return 0; } static int syscalls_SetSkin(lua_State* L) { - unsigned ret; - asm_inline( - "int $0x40" - : "=a"(ret) - : "a"(48), "b"(8), "c"(luaL_checkstring(L, 1))); + unsigned ret; + asm_inline( + "int $0x40" + : "=a"(ret) + : "a"(48), "b"(8), "c"(luaL_checkstring(L, 1))); - lua_pushinteger(L, ret); + lua_pushinteger(L, ret); - return 1; + return 1; } static int syscalls_GetSkinTilteArea(lua_State* L) { - ksys_pos_t leftRight, topBottom; + ksys_pos_t leftRight, topBottom; - asm_inline( - "int $0x40" - : "=a"(leftRight), "=b"(topBottom) - : "a"(48), "b"(7)); + asm_inline( + "int $0x40" + : "=a"(leftRight), "=b"(topBottom) + : "a"(48), "b"(7)); - lua_createtable(L, 0, 4); + lua_createtable(L, 0, 4); - lua_pushinteger(L, leftRight.x); - lua_setfield(L, -2, "Left"); + lua_pushinteger(L, leftRight.x); + lua_setfield(L, -2, "Left"); - lua_pushinteger(L, leftRight.y); - lua_setfield(L, -2, "Right"); + lua_pushinteger(L, leftRight.y); + lua_setfield(L, -2, "Right"); - lua_pushinteger(L, topBottom.x); - lua_setfield(L, -2, "Top"); + lua_pushinteger(L, topBottom.x); + lua_setfield(L, -2, "Top"); - lua_pushinteger(L, topBottom.y); - lua_setfield(L, -2, "Bottom"); + lua_pushinteger(L, topBottom.y); + lua_setfield(L, -2, "Bottom"); - return 1; + return 1; } static int syscalls_SetWorkArea(lua_State* L) { - uint32_t left = luaL_checkinteger(L, 1); - uint32_t top = luaL_checkinteger(L, 2); - uint32_t right = luaL_checkinteger(L, 3); - uint32_t bottom = luaL_checkinteger(L, 4); + uint32_t left = luaL_checkinteger(L, 1); + uint32_t top = luaL_checkinteger(L, 2); + uint32_t right = luaL_checkinteger(L, 3); + uint32_t bottom = luaL_checkinteger(L, 4); - asm_inline( - "int $0x40" ::"a"(48), "b"(6), "c"(left * 65536 + right), "d"(top * 65536 + bottom)); + asm_inline( + "int $0x40" ::"a"(48), "b"(6), "c"(left * 65536 + right), "d"(top * 65536 + bottom)); - return 0; + return 0; } static int syscalls_GetWorkArea(lua_State* L) { - ksys_pos_t leftlright; - ksys_pos_t toplbottom; + ksys_pos_t leftlright; + ksys_pos_t toplbottom; - asm_inline( - "int $0x40" - :"=a"(leftlright), "=b"(toplbottom) - : "a"(48), "b"(5) - ); + asm_inline( + "int $0x40" + :"=a"(leftlright), "=b"(toplbottom) + : "a"(48), "b"(5) + ); - lua_createtable(L, 0, 4); + lua_createtable(L, 0, 4); - lua_pushinteger(L, leftlright.x); - lua_setfield(L, -2, "Left"); + lua_pushinteger(L, leftlright.x); + lua_setfield(L, -2, "Left"); - lua_pushinteger(L, leftlright.y); - lua_setfield(L, -2, "Right"); + lua_pushinteger(L, leftlright.y); + lua_setfield(L, -2, "Right"); - lua_pushinteger(L, toplbottom.x); - lua_setfield(L, -2, "Top"); + lua_pushinteger(L, toplbottom.x); + lua_setfield(L, -2, "Top"); - lua_pushinteger(L, toplbottom.y); - lua_setfield(L, -2, "Bottom"); + lua_pushinteger(L, toplbottom.y); + lua_setfield(L, -2, "Bottom"); - return 1; + return 1; } static int syscalls_defineButton(lua_State* L) { - _ksys_define_button( - luaL_checkinteger(L, 1), - luaL_checkinteger(L, 2), - luaL_checkinteger(L, 3), - luaL_checkinteger(L, 4), - luaL_checkinteger(L, 5), - luaL_checkinteger(L, 6)); + _ksys_define_button( + luaL_checkinteger(L, 1), + luaL_checkinteger(L, 2), + luaL_checkinteger(L, 3), + luaL_checkinteger(L, 4), + luaL_checkinteger(L, 5), + luaL_checkinteger(L, 6)); - return 0; + return 0; } static int syscalls_deleteButton(lua_State* L) { - _ksys_delete_button(luaL_checkinteger(L, 1)); + _ksys_delete_button(luaL_checkinteger(L, 1)); - return 0; + return 0; } static int syscalls_SetButtonsStyle(lua_State* L) { - uint32_t style = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" ::"a"(48), "b"(1), "c"(style)); + uint32_t style = luaL_checkinteger(L, 1); + asm_inline( + "int $0x40" ::"a"(48), "b"(1), "c"(style)); - asm_inline( - "int $0x40" ::"a"(48), "b"(0), "c"(0)); + asm_inline( + "int $0x40" ::"a"(48), "b"(0), "c"(0)); - return 0; + return 0; } /* static void syscalls_DrawBitmap(lua_State *L) { - _ksys_draw_bitmap(,); + _ksys_draw_bitmap(,); } */ static int syscalls_drawPixel(lua_State* L) { - _ksys_draw_pixel( - luaL_checkinteger(L, 1), - luaL_checkinteger(L, 2), - luaL_checkinteger(L, 3)); + _ksys_draw_pixel( + luaL_checkinteger(L, 1), + luaL_checkinteger(L, 2), + luaL_checkinteger(L, 3)); - return 0; + return 0; } static int syscalls_threadInfo(lua_State* L) { - ksys_thread_t t; + ksys_thread_t t; - _ksys_thread_info(&t, luaL_checkinteger(L, 1)); + _ksys_thread_info(&t, luaL_checkinteger(L, 1)); - lua_createtable(L, 0, 13); + lua_createtable(L, 0, 13); - lua_pushstring(L, t.name); - lua_setfield(L, -2, "name"); + lua_pushstring(L, t.name); + lua_setfield(L, -2, "name"); - lua_pushinteger(L, t.cpu_usage); - lua_setfield(L, -2, "cpu_usage"); + lua_pushinteger(L, t.cpu_usage); + lua_setfield(L, -2, "cpu_usage"); - lua_pushinteger(L, t.memused); - lua_setfield(L, -2, "memused"); + lua_pushinteger(L, t.memused); + lua_setfield(L, -2, "memused"); - lua_pushinteger(L, t.pid); - lua_setfield(L, -2, "pid"); + lua_pushinteger(L, t.pid); + lua_setfield(L, -2, "pid"); - lua_pushinteger(L, t.key_input_mode); - lua_setfield(L, -2, "keyInputMode"); + lua_pushinteger(L, t.key_input_mode); + lua_setfield(L, -2, "keyInputMode"); - lua_pushinteger(L, t.pos_in_window_stack); - lua_setfield(L, -2, "posInWindowStack"); + lua_pushinteger(L, t.pos_in_window_stack); + lua_setfield(L, -2, "posInWindowStack"); - lua_pushinteger(L, t.slot_num_window_stack); - lua_setfield(L, -2, "slotNumWindowStack"); + lua_pushinteger(L, t.slot_num_window_stack); + lua_setfield(L, -2, "slotNumWindowStack"); - lua_pushinteger(L, t.slot_state); - lua_setfield(L, -2, "slotState"); + lua_pushinteger(L, t.slot_state); + lua_setfield(L, -2, "slotState"); - lua_pushinteger(L, t.window_state); - lua_setfield(L, -2, "windowState"); + lua_pushinteger(L, t.window_state); + lua_setfield(L, -2, "windowState"); - lua_pushinteger(L, t.winx_size); - lua_setfield(L, -2, "winXSize"); + lua_pushinteger(L, t.winx_size); + lua_setfield(L, -2, "winXSize"); - lua_pushinteger(L, t.winy_size); - lua_setfield(L, -2, "winYSize"); + lua_pushinteger(L, t.winy_size); + lua_setfield(L, -2, "winYSize"); - lua_pushinteger(L, t.winx_start); - lua_setfield(L, -2, "winXPos"); + lua_pushinteger(L, t.winx_start); + lua_setfield(L, -2, "winXPos"); - lua_pushinteger(L, t.winy_start); - lua_setfield(L, -2, "winYPos"); + lua_pushinteger(L, t.winy_start); + lua_setfield(L, -2, "winYPos"); - return 1; + return 1; } static int syscalls_KillBySlot(lua_State* L) { - _ksys_kill_by_slot( - luaL_checkinteger(L, 1)); + _ksys_kill_by_slot( + luaL_checkinteger(L, 1)); - return 0; + return 0; } static int syscalls_setEventMask(lua_State* L) { - _ksys_set_event_mask(luaL_checkinteger(L, 1)); + _ksys_set_event_mask(luaL_checkinteger(L, 1)); - return 0; + return 0; } static int syscalls_waitEvent(lua_State* L) { - lua_pushinteger(L, _ksys_wait_event()); + lua_pushinteger(L, _ksys_wait_event()); - return 1; + return 1; } static int syscalls_checkEvent(lua_State* L) { - lua_pushinteger(L, _ksys_check_event()); + lua_pushinteger(L, _ksys_check_event()); - return 1; + return 1; } static int syscalls_waitEventTimeout(lua_State* L) { - lua_pushinteger(L, _ksys_wait_event_timeout(luaL_checkinteger(L, 1))); + lua_pushinteger(L, _ksys_wait_event_timeout(luaL_checkinteger(L, 1))); - return 1; + return 1; } static int syscalls_getFreeRam(lua_State* L) { - lua_pushinteger(L, _ksys_get_ram_size()); + lua_pushinteger(L, _ksys_get_ram_size()); - return 1; + return 1; } static int syscalls_getRamSize(lua_State* L) { - lua_pushinteger(L, _ksys_get_full_ram()); + lua_pushinteger(L, _ksys_get_full_ram()); - return 1; + return 1; } static int syscalls_shutdownPowerOff(lua_State* L) { - _ksys_shutdown(KSYS_SHD_POWEROFF); + _ksys_shutdown(KSYS_SHD_POWEROFF); - return 0; + return 0; } static int syscalls_shutdownReboot(lua_State* L) { - _ksys_shutdown(KSYS_SHD_REBOOT); + _ksys_shutdown(KSYS_SHD_REBOOT); - return 0; + return 0; } static int syscalls_shutdownRestartKRN(lua_State* L) { - _ksys_shutdown(KSYS_SHD_RESTART_KRN); + _ksys_shutdown(KSYS_SHD_RESTART_KRN); - return 0; + return 0; } static int syscalls_focusWindow(lua_State* L) { - _ksys_focus_window(luaL_checkinteger(L, 1)); + _ksys_focus_window(luaL_checkinteger(L, 1)); - return 0; + return 0; } static int syscalls_unfocusWindow(lua_State* L) { - _ksys_unfocus_window(luaL_checkinteger(L, 1)); + _ksys_unfocus_window(luaL_checkinteger(L, 1)); - return 0; + return 0; } static int syscalls_getButton(lua_State* L) { - uint32_t val; + uint32_t val; - asm_inline( - "int $0x40" - : "=a"(val) - : "a"(17)); + asm_inline( + "int $0x40" + : "=a"(val) + : "a"(17)); - if (val != 0) - { - lua_pushinteger(L, val >> 8); + if (val != 0) + { + lua_pushinteger(L, val >> 8); - lua_pushinteger(L, val & 0xFF); - } - else - { - lua_pushnil(L); - lua_pushnil(L); - } + lua_pushinteger(L, val & 0xFF); + } + else + { + lua_pushnil(L); + lua_pushnil(L); + } - return 2; + return 2; } static void syscalls_updateScreenSize() { - syscalls_screenSizeCache = _ksys_screen_size(); + syscalls_screenSizeCache = _ksys_screen_size(); } static int syscalls_screenSize(lua_State* L) { - syscalls_updateScreenSize(); + syscalls_updateScreenSize(); - lua_createtable(L, 0, 2); + lua_createtable(L, 0, 2); - lua_pushinteger(L, syscalls_screenSizeCache.x); - lua_setfield(L, -2, "x"); + lua_pushinteger(L, syscalls_screenSizeCache.x); + lua_setfield(L, -2, "x"); - lua_pushinteger(L, syscalls_screenSizeCache.y); - lua_setfield(L, -2, "y"); + lua_pushinteger(L, syscalls_screenSizeCache.y); + lua_setfield(L, -2, "y"); - return 1; + return 1; } /* - Backgound + Backgound */ static int syscalls_backgroundSetSize(lua_State* L) { - _ksys_bg_set_size( - luaL_checkinteger(L, 1), - luaL_checkinteger(L, 2)); + _ksys_bg_set_size( + luaL_checkinteger(L, 1), + luaL_checkinteger(L, 2)); - return 0; + return 0; } static int syscalls_backgroundPutPixel(lua_State* L) { - _ksys_bg_put_pixel( - luaL_checkinteger(L, 1), - luaL_checkinteger(L, 2), - luaL_checkinteger(L, 3), - luaL_checkinteger(L, 4)); + _ksys_bg_put_pixel( + luaL_checkinteger(L, 1), + luaL_checkinteger(L, 2), + luaL_checkinteger(L, 3), + luaL_checkinteger(L, 4)); - return 0; + return 0; } static int syscalls_backgroundRedraw(lua_State* L) { - _ksys_bg_redraw(); + _ksys_bg_redraw(); - return 0; + return 0; } static int syscalls_getCPUClock(lua_State* L) { - lua_pushinteger(L, _ksys_get_cpu_clock()); + lua_pushinteger(L, _ksys_get_cpu_clock()); - return 1; + return 1; } static int syscalls_drawLine(lua_State* L) { - _ksys_draw_line( - luaL_checkinteger(L, 1), - luaL_checkinteger(L, 2), - luaL_checkinteger(L, 3), - luaL_checkinteger(L, 4), - luaL_checkinteger(L, 5)); + _ksys_draw_line( + luaL_checkinteger(L, 1), + luaL_checkinteger(L, 2), + luaL_checkinteger(L, 3), + luaL_checkinteger(L, 4), + luaL_checkinteger(L, 5)); - return 0; + return 0; } enum TextScale { - TextScale_SIZE_6x9, // 1x 6x9 - TextScale_SIZE_8x16, // 1x 8x16 - TextScale_SIZE_12x18, // 2x 6x9 - TextScale_SIZE_16x32, // 2x 8x16 - TextScale_SIZE_18x27, // 3x 6x9 - TextScale_SIZE_24x36, // 4x 6x9 - TextScale_SIZE_24x48, // 3x 8x16 - TextScale_SIZE_30x45, // 5x 6x9 - TextScale_SIZE_32x64, // 4x 8x16 - TextScale_SIZE_36x54, // 6x 6x9 - TextScale_SIZE_40x80, // 5x 8x16 - TextScale_SIZE_42x63, // 7x 6x9 - TextScale_SIZE_48x72, // 8x 6x9 - TextScale_SIZE_48x96, // 6x 8x16 - TextScale_SIZE_56x112, // 7x 8x16 - TextScale_SIZE_64x128 // 8x 8x16 + TextScale_SIZE_6x9, // 1x 6x9 + TextScale_SIZE_8x16, // 1x 8x16 + TextScale_SIZE_12x18, // 2x 6x9 + TextScale_SIZE_16x32, // 2x 8x16 + TextScale_SIZE_18x27, // 3x 6x9 + TextScale_SIZE_24x36, // 4x 6x9 + TextScale_SIZE_24x48, // 3x 8x16 + TextScale_SIZE_30x45, // 5x 6x9 + TextScale_SIZE_32x64, // 4x 8x16 + TextScale_SIZE_36x54, // 6x 6x9 + TextScale_SIZE_40x80, // 5x 8x16 + TextScale_SIZE_42x63, // 7x 6x9 + TextScale_SIZE_48x72, // 8x 6x9 + TextScale_SIZE_48x96, // 6x 8x16 + TextScale_SIZE_56x112, // 7x 8x16 + TextScale_SIZE_64x128 // 8x 8x16 }; static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_color_t color, enum TextScale size, uint32_t len, bool fillBackground, ksys_color_t backgroundColor) { - enum DrawTextEncoding - { - cp866_6x9 = 0, - cp866_8x16 = 1, - utf8 = 3, - utf16 = 4 - }; + enum DrawTextEncoding + { + cp866_6x9 = 0, + cp866_8x16 = 1, + utf8 = 3, + utf16 = 4 + }; - enum scale - { - scale_x1 = 0, - scale_x2 = 1, - scale_x3 = 2, - scale_x4 = 3, - scale_x5 = 4, - scale_x6 = 5, - scale_x7 = 6, - scale_x8 = 7 - }; + enum scale + { + scale_x1 = 0, + scale_x2 = 1, + scale_x3 = 2, + scale_x4 = 3, + scale_x5 = 4, + scale_x6 = 5, + scale_x7 = 6, + scale_x8 = 7 + }; - color &= 0x00FFFFFF; + color &= 0x00FFFFFF; - color |= (fillBackground << 30); + color |= (fillBackground << 30); - switch (size) - { - case TextScale_SIZE_6x9: - color |= (cp866_8x16 << 28) | (scale_x1 << 24); - break; - case TextScale_SIZE_8x16: - color |= (cp866_8x16 << 28); - break; - case TextScale_SIZE_12x18: - color |= (cp866_6x9 << 28) | (scale_x2 << 24); - break; - case TextScale_SIZE_16x32: - color |= (cp866_8x16 << 28) | (scale_x2 << 24); - break; - case TextScale_SIZE_18x27: - color |= (cp866_6x9 << 28) | (scale_x3 << 24); - break; - case TextScale_SIZE_24x36: - color |= (cp866_6x9 << 28) | (scale_x4 << 24); - break; - case TextScale_SIZE_24x48: - color |= (cp866_8x16 << 28) | (scale_x3 << 24); - break; - case TextScale_SIZE_30x45: - color |= (cp866_6x9 << 28) | (scale_x5 << 24); - break; - case TextScale_SIZE_36x54: - color |= (cp866_6x9 << 28) | (scale_x6 << 24); - break; - case TextScale_SIZE_40x80: - color |= (cp866_8x16 << 28) | (scale_x5 << 24); - break; - case TextScale_SIZE_42x63: - color |= (cp866_6x9 << 28) | (scale_x7 << 24); - break; - case TextScale_SIZE_48x72: - color |= (cp866_6x9 << 28) | (scale_x8 << 24); - break; - case TextScale_SIZE_48x96: - color |= (cp866_8x16 << 28) | (scale_x6 << 24); - break; - case TextScale_SIZE_56x112: - color |= (cp866_8x16 << 28) | (scale_x7 << 24); - break; - case TextScale_SIZE_64x128: - color |= (cp866_8x16 << 28) | (scale_x8 << 24); - break; - default: - break; - }; + switch (size) + { + case TextScale_SIZE_6x9: + color |= (cp866_8x16 << 28) | (scale_x1 << 24); + break; + case TextScale_SIZE_8x16: + color |= (cp866_8x16 << 28); + break; + case TextScale_SIZE_12x18: + color |= (cp866_6x9 << 28) | (scale_x2 << 24); + break; + case TextScale_SIZE_16x32: + color |= (cp866_8x16 << 28) | (scale_x2 << 24); + break; + case TextScale_SIZE_18x27: + color |= (cp866_6x9 << 28) | (scale_x3 << 24); + break; + case TextScale_SIZE_24x36: + color |= (cp866_6x9 << 28) | (scale_x4 << 24); + break; + case TextScale_SIZE_24x48: + color |= (cp866_8x16 << 28) | (scale_x3 << 24); + break; + case TextScale_SIZE_30x45: + color |= (cp866_6x9 << 28) | (scale_x5 << 24); + break; + case TextScale_SIZE_36x54: + color |= (cp866_6x9 << 28) | (scale_x6 << 24); + break; + case TextScale_SIZE_40x80: + color |= (cp866_8x16 << 28) | (scale_x5 << 24); + break; + case TextScale_SIZE_42x63: + color |= (cp866_6x9 << 28) | (scale_x7 << 24); + break; + case TextScale_SIZE_48x72: + color |= (cp866_6x9 << 28) | (scale_x8 << 24); + break; + case TextScale_SIZE_48x96: + color |= (cp866_8x16 << 28) | (scale_x6 << 24); + break; + case TextScale_SIZE_56x112: + color |= (cp866_8x16 << 28) | (scale_x7 << 24); + break; + case TextScale_SIZE_64x128: + color |= (cp866_8x16 << 28) | (scale_x8 << 24); + break; + default: + break; + }; - if (len <= 0) - color |= (1 << 31); + if (len <= 0) + color |= (1 << 31); - asm_inline( - "int $0x40" ::"a"(4), - "b"((x << 16) | y), - "c"(color), - "d"(text), - "S"(len), - "D"(backgroundColor)); + asm_inline( + "int $0x40" ::"a"(4), + "b"((x << 16) | y), + "c"(color), + "d"(text), + "S"(len), + "D"(backgroundColor)); } static int syscalls_drawText(lua_State* L) { - syscall_drawText( - luaL_checkstring(L, 1), - luaL_checkinteger(L, 2), - luaL_checkinteger(L, 3), - luaL_checkinteger(L, 4), - luaL_optinteger(L, 5, TextScale_SIZE_8x16), - luaL_optinteger(L, 6, 0), - luaL_optinteger(L, 7, 0), - luaL_optinteger(L, 8, 0)); + syscall_drawText( + luaL_checkstring(L, 1), + luaL_checkinteger(L, 2), + luaL_checkinteger(L, 3), + luaL_checkinteger(L, 4), + luaL_optinteger(L, 5, TextScale_SIZE_8x16), + luaL_optinteger(L, 6, 0), + luaL_optinteger(L, 7, 0), + luaL_optinteger(L, 8, 0)); - return 0; + return 0; } static int syscalls_drawRectangle(lua_State* L) { - _ksys_draw_bar( - luaL_checkinteger(L, 1), - luaL_checkinteger(L, 2), - luaL_checkinteger(L, 3), - luaL_checkinteger(L, 4), - luaL_checkinteger(L, 5)); + _ksys_draw_bar( + luaL_checkinteger(L, 1), + luaL_checkinteger(L, 2), + luaL_checkinteger(L, 3), + luaL_checkinteger(L, 4), + luaL_checkinteger(L, 5)); - return 0; + return 0; } static int syscalls_ReadPoint(lua_State* L) { - ksys_color_t color; + ksys_color_t color; - if (syscalls_screenSizeCache.val == 0) - syscalls_updateScreenSize(); + if (syscalls_screenSizeCache.val == 0) + syscalls_updateScreenSize(); - uint32_t x = luaL_checkinteger(L, 1); - uint32_t y = luaL_checkinteger(L, 2); + uint32_t x = luaL_checkinteger(L, 1); + uint32_t y = luaL_checkinteger(L, 2); - asm_inline( - "int $ 0x40" - : "=a"(color) - : "a"(35), "b"(x * syscalls_screenSizeCache.x + y)); + asm_inline( + "int $ 0x40" + : "=a"(color) + : "a"(35), "b"(x * syscalls_screenSizeCache.x + y)); - lua_pushnumber(L, color); + lua_pushnumber(L, color); - return 1; + return 1; } static int syscalls_getSystemColors(lua_State* L) { - ksys_colors_table_t* t = syscalls_pushSystemColors(L); + ksys_colors_table_t* t = syscalls_pushSystemColors(L); - _ksys_get_system_colors(t); + _ksys_get_system_colors(t); - return 1; + return 1; } static int syscalls_SetSystemColors(lua_State* L) { - ksys_colors_table_t* t = (ksys_colors_table_t*)lua_touserdata(L, 1); + ksys_colors_table_t* t = (ksys_colors_table_t*)lua_touserdata(L, 1); - asm_inline( - "int $0x40" ::"a"(48), "b"(2), "c"(t), "d"(40)); + asm_inline( + "int $0x40" ::"a"(48), "b"(2), "c"(t), "d"(40)); - asm_inline( - "int $0x40" ::"a"(48), "b"(0), "c"(0)); + asm_inline( + "int $0x40" ::"a"(48), "b"(0), "c"(0)); - return 0; + return 0; } static int syscalls_getSkinHeight(lua_State* L) { - lua_pushinteger(L, _ksys_get_skin_height()); + lua_pushinteger(L, _ksys_get_skin_height()); - return 1; + return 1; } static int syscalls_setKeyInputMode(lua_State* L) { - syscalls_KeyInputState = luaL_checkinteger(L, 1); - _ksys_set_key_input_mode(syscalls_KeyInputState); + syscalls_KeyInputState = luaL_checkinteger(L, 1); + _ksys_set_key_input_mode(syscalls_KeyInputState); - return 0; + return 0; } static int syscalls_getKeyInputMode(lua_State* L) { - lua_pushinteger(L, syscalls_KeyInputState); + lua_pushinteger(L, syscalls_KeyInputState); - return 1; + return 1; } static int syscalls_getKey(lua_State* L) { - ksys_oskey_t a = _ksys_get_key(); + ksys_oskey_t a = _ksys_get_key(); - if (a.val == 1) - { - lua_pushnil(L); - } - else if (a.state == 0) - { - if (syscalls_KeyInputState == KSYS_KEY_INPUT_MODE_ASCII) - { - char s[2]; - s[0] = a.code; - s[1] = '\n'; - lua_pushstring(L, s); - } - else - { - lua_pushinteger(L, a.code); - } - } + if (a.val == 1) + { + lua_pushnil(L); + } + else if (a.state == 0) + { + if (syscalls_KeyInputState == KSYS_KEY_INPUT_MODE_ASCII) + { + char s[2]; + s[0] = a.code; + s[1] = '\n'; + lua_pushstring(L, s); + } + else + { + lua_pushinteger(L, a.code); + } + } - if (a.state == 2) - { - lua_pushinteger(L, a.code); - } - else - { - lua_pushnil(L); - } + if (a.state == 2) + { + lua_pushinteger(L, a.code); + } + else + { + lua_pushnil(L); + } - return 2; + return 2; } static int syscalls_getControlKeyState(lua_State* L) { - uint32_t state = _ksys_get_control_key_state(); + uint32_t state = _ksys_get_control_key_state(); - lua_createtable(L, 0, 9); + lua_createtable(L, 0, 9); - lua_pushboolean(L, state & KSYS_CONTROL_LSHIFT); - lua_setfield(L, -2, "LeftShift"); + lua_pushboolean(L, state & KSYS_CONTROL_LSHIFT); + lua_setfield(L, -2, "LeftShift"); - lua_pushboolean(L, state & KSYS_CONTROL_RSHIFT); - lua_setfield(L, -2, "RightShift"); + lua_pushboolean(L, state & KSYS_CONTROL_RSHIFT); + lua_setfield(L, -2, "RightShift"); - lua_pushboolean(L, state & KSYS_CONTROL_LCTRL); - lua_setfield(L, -2, "LeftCtrl"); + lua_pushboolean(L, state & KSYS_CONTROL_LCTRL); + lua_setfield(L, -2, "LeftCtrl"); - lua_pushboolean(L, state & KSYS_CONTROL_RCTRL); - lua_setfield(L, -2, "RightCtrl"); + lua_pushboolean(L, state & KSYS_CONTROL_RCTRL); + lua_setfield(L, -2, "RightCtrl"); - lua_pushboolean(L, state & KSYS_CONTROL_LALT); - lua_setfield(L, -2, "LeftAlt"); + lua_pushboolean(L, state & KSYS_CONTROL_LALT); + lua_setfield(L, -2, "LeftAlt"); - lua_pushboolean(L, state & KSYS_CONTROL_RALT); - lua_setfield(L, -2, "RightAlt"); + lua_pushboolean(L, state & KSYS_CONTROL_RALT); + lua_setfield(L, -2, "RightAlt"); - lua_pushboolean(L, state & KSYS_CONTROL_CAPS); - lua_setfield(L, -2, "Caps"); + lua_pushboolean(L, state & KSYS_CONTROL_CAPS); + lua_setfield(L, -2, "Caps"); - lua_pushboolean(L, state & KSYS_CONTROL_NUM_LOCK); - lua_setfield(L, -2, "NumLock"); + lua_pushboolean(L, state & KSYS_CONTROL_NUM_LOCK); + lua_setfield(L, -2, "NumLock"); - lua_pushboolean(L, state & KSYS_CONTROL_SCROLL_LOCK); - lua_setfield(L, -2, "ScrollLock"); + lua_pushboolean(L, state & KSYS_CONTROL_SCROLL_LOCK); + lua_setfield(L, -2, "ScrollLock"); - return 1; + return 1; } static int syscalls_SetHotkey(lua_State* L) { - lua_settop(L, 1); - luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); + luaL_checktype(L, 1, LUA_TTABLE); - if (_ksys_set_sys_hotkey( - lua_getfield(L, -2, "Scancode"), - (lua_getfield(L, -2, "Shift")) | - (lua_getfield(L, -2, "Ctrl") << 4) | - (lua_getfield(L, -2, "Alt") << 8))) - { - luaL_pushfail(L); - } + if (_ksys_set_sys_hotkey( + lua_getfield(L, -2, "Scancode"), + (lua_getfield(L, -2, "Shift")) | + (lua_getfield(L, -2, "Ctrl") << 4) | + (lua_getfield(L, -2, "Alt") << 8))) + { + luaL_pushfail(L); + } - return 1; + return 1; } static int syscalls_DeleteHotkey(lua_State* L) { - lua_settop(L, 1); - luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); + luaL_checktype(L, 1, LUA_TTABLE); - if (_ksys_del_sys_hotkey( - lua_getfield(L, -2, "Scancode"), - lua_getfield(L, -2, "Shift") | - (lua_getfield(L, -2, "Ctrl") << 4) | - (lua_getfield(L, -2, "Alt") << 8))) - { - luaL_pushfail(L); - } + if (_ksys_del_sys_hotkey( + lua_getfield(L, -2, "Scancode"), + lua_getfield(L, -2, "Shift") | + (lua_getfield(L, -2, "Ctrl") << 4) | + (lua_getfield(L, -2, "Alt") << 8))) + { + luaL_pushfail(L); + } - return 1; + return 1; } static int syscalls_LockNormalInput(lua_State* L) { - asm_inline( - "int $0x40" ::"a"(66), "b"(6)); + asm_inline( + "int $0x40" ::"a"(66), "b"(6)); - return 0; + return 0; } static int syscalls_UnlockNormalInput(lua_State* L) { - asm_inline( - "int $0x40" ::"a"(66), "b"(7)); + asm_inline( + "int $0x40" ::"a"(66), "b"(7)); - return 0; + return 0; } /* - Mouse Funcs + Mouse Funcs */ static int syscalls_getMousePositionScreen(lua_State* L) { - ksys_pos_t pos = _ksys_get_mouse_pos(KSYS_MOUSE_SCREEN_POS); + ksys_pos_t pos = _ksys_get_mouse_pos(KSYS_MOUSE_SCREEN_POS); - lua_createtable(L, 0, 2); + lua_createtable(L, 0, 2); - lua_pushinteger(L, pos.x); - lua_setfield(L, -2, "x"); + lua_pushinteger(L, pos.x); + lua_setfield(L, -2, "x"); - lua_pushinteger(L, pos.y); - lua_setfield(L, -2, "y"); + lua_pushinteger(L, pos.y); + lua_setfield(L, -2, "y"); - return 1; + return 1; } static int syscalls_getMousePositionWindow(lua_State* L) { - ksys_pos_t pos = _ksys_get_mouse_pos(KSYS_MOUSE_WINDOW_POS); + ksys_pos_t pos = _ksys_get_mouse_pos(KSYS_MOUSE_WINDOW_POS); - lua_createtable(L, 0, 2); + lua_createtable(L, 0, 2); - lua_pushinteger(L, pos.x); - lua_setfield(L, -2, "x"); + lua_pushinteger(L, pos.x); + lua_setfield(L, -2, "x"); - lua_pushinteger(L, pos.y); - lua_setfield(L, -2, "y"); + lua_pushinteger(L, pos.y); + lua_setfield(L, -2, "y"); - return 1; + return 1; } static int syscalls_getMouseWheels(lua_State* L) { - uint32_t state = _ksys_get_mouse_wheels(); + uint32_t state = _ksys_get_mouse_wheels(); - lua_createtable(L, 0, 2); + lua_createtable(L, 0, 2); - lua_pushinteger(L, state & 0xFFFF); - lua_setfield(L, -2, "y"); + lua_pushinteger(L, state & 0xFFFF); + lua_setfield(L, -2, "y"); - lua_pushinteger(L, state << 16); - lua_setfield(L, -2, "x"); + lua_pushinteger(L, state << 16); + lua_setfield(L, -2, "x"); - return 1; + return 1; } void createMouseState(uint32_t state, lua_State* L) { - lua_pushboolean(L, state & KSYS_MOUSE_LBUTTON_PRESSED); - lua_setfield(L, -2, "LeftButton"); + lua_pushboolean(L, state & KSYS_MOUSE_LBUTTON_PRESSED); + lua_setfield(L, -2, "LeftButton"); - lua_pushboolean(L, state & KSYS_MOUSE_RBUTTON_PRESSED); - lua_setfield(L, -2, "RightButton"); + lua_pushboolean(L, state & KSYS_MOUSE_RBUTTON_PRESSED); + lua_setfield(L, -2, "RightButton"); - lua_pushboolean(L, state & KSYS_MOUSE_MBUTTON_PRESSED); - lua_setfield(L, -2, "MiddleButton"); + lua_pushboolean(L, state & KSYS_MOUSE_MBUTTON_PRESSED); + lua_setfield(L, -2, "MiddleButton"); - lua_pushboolean(L, state & KSYS_MOUSE_4BUTTON_PRESSED); - lua_setfield(L, -2, "Button4"); + lua_pushboolean(L, state & KSYS_MOUSE_4BUTTON_PRESSED); + lua_setfield(L, -2, "Button4"); - lua_pushboolean(L, state & KSYS_MOUSE_5BUTTON_PRESSED); - lua_setfield(L, -2, "Button5"); + lua_pushboolean(L, state & KSYS_MOUSE_5BUTTON_PRESSED); + lua_setfield(L, -2, "Button5"); } static int syscalls_getMouseButtons(lua_State* L) { - lua_createtable(L, 0, 5); + lua_createtable(L, 0, 5); - createMouseState(_ksys_get_mouse_buttons(), L); + createMouseState(_ksys_get_mouse_buttons(), L); - return 1; + return 1; } static int syscalls_getMouseEvents(lua_State* L) { - uint32_t state = _ksys_get_mouse_eventstate(); + uint32_t state = _ksys_get_mouse_eventstate(); - lua_createtable(L, 0, 5 + 9); + lua_createtable(L, 0, 5 + 9); - createMouseState(state, L); + createMouseState(state, L); - lua_pushboolean(L, state & (1 << 8)); - lua_setfield(L, -2, "getMouseEvents"); + lua_pushboolean(L, state & (1 << 8)); + lua_setfield(L, -2, "getMouseEvents"); - lua_pushboolean(L, state & (1 << 9)); - lua_setfield(L, -2, "RightButtonPressed"); + lua_pushboolean(L, state & (1 << 9)); + lua_setfield(L, -2, "RightButtonPressed"); - lua_pushboolean(L, state & (1 << 10)); - lua_setfield(L, -2, "MiddleButtonPressed"); + lua_pushboolean(L, state & (1 << 10)); + lua_setfield(L, -2, "MiddleButtonPressed"); - lua_pushboolean(L, state & (1 << 15)); - lua_setfield(L, -2, "VerticalScroll"); + lua_pushboolean(L, state & (1 << 15)); + lua_setfield(L, -2, "VerticalScroll"); - lua_pushboolean(L, state & (1 << 16)); - lua_setfield(L, -2, "LeftButtonReleased"); + lua_pushboolean(L, state & (1 << 16)); + lua_setfield(L, -2, "LeftButtonReleased"); - lua_pushboolean(L, state & (1 << 17)); - lua_setfield(L, -2, "RightButtonReleased"); + lua_pushboolean(L, state & (1 << 17)); + lua_setfield(L, -2, "RightButtonReleased"); - lua_pushboolean(L, state & (1 << 18)); - lua_setfield(L, -2, "MiddleButtonReleased"); + lua_pushboolean(L, state & (1 << 18)); + lua_setfield(L, -2, "MiddleButtonReleased"); - lua_pushboolean(L, state & (1 << 23)); - lua_setfield(L, -2, "HorizontalScroll"); + lua_pushboolean(L, state & (1 << 23)); + lua_setfield(L, -2, "HorizontalScroll"); - lua_pushboolean(L, state & (1 << 24)); - lua_setfield(L, -2, "DoubleClick"); + lua_pushboolean(L, state & (1 << 24)); + lua_setfield(L, -2, "DoubleClick"); - return 1; + return 1; } inline uint32_t getMouseSettings(ksys_mouse_settings_t settings) { - uint32_t result; + uint32_t result; - asm_inline( - "int $0x40" - : "=a"(result) - : "a"(18), "b"(19), "c"(settings) - : "memory"); + asm_inline( + "int $0x40" + : "=a"(result) + : "a"(18), "b"(19), "c"(settings) + : "memory"); - return result; + return result; } static int syscalls_GetMouseSpeed(lua_State* L) { - lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_SPEED)); + lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_SPEED)); - return 1; + return 1; } static int syscalls_GetMouseSens(lua_State* L) { - lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_SENS)); + lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_SENS)); - return 1; + return 1; } static int syscalls_GetMouseDoubleClickDelay(lua_State* L) { - lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_DOUBLE_CLICK_DELAY)); + lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_DOUBLE_CLICK_DELAY)); - return 1; + return 1; } static int syscalls_GetMouseSettings(lua_State* L) { - lua_createtable(L, 0, 3); + lua_createtable(L, 0, 3); - lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_SPEED)); - lua_setfield(L, -2, "speed"); + lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_SPEED)); + lua_setfield(L, -2, "speed"); - lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_SENS)); - lua_setfield(L, -2, "sensitivity"); + lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_SENS)); + lua_setfield(L, -2, "sensitivity"); - lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_DOUBLE_CLICK_DELAY)); - lua_setfield(L, -2, "doubleClickDelay"); + lua_pushinteger(L, getMouseSettings(KSYS_MOUSE_GET_DOUBLE_CLICK_DELAY)); + lua_setfield(L, -2, "doubleClickDelay"); - return 1; + return 1; } static int syscalls_MouseSimulateState(lua_State* L) { - lua_settop(L, 1); - luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); + luaL_checktype(L, 1, LUA_TTABLE); - lua_getfield(L, 1, "LeftButton"); - lua_getfield(L, 1, "RightButton"); - lua_getfield(L, 1, "MiddleButton"); - lua_getfield(L, 1, "Button4"); - lua_getfield(L, 1, "Button5"); + lua_getfield(L, 1, "LeftButton"); + lua_getfield(L, 1, "RightButton"); + lua_getfield(L, 1, "MiddleButton"); + lua_getfield(L, 1, "Button4"); + lua_getfield(L, 1, "Button5"); - _ksys_set_mouse_settings( - KSYS_MOUSE_SIM_STATE, - (luaL_checkinteger(L, -1) << 4) | - (luaL_checkinteger(L, -2) << 3) | - (luaL_checkinteger(L, -3) << 2) | - (luaL_checkinteger(L, -4) << 1) | - (luaL_checkinteger(L, -5))); + _ksys_set_mouse_settings( + KSYS_MOUSE_SIM_STATE, + (luaL_checkinteger(L, -1) << 4) | + (luaL_checkinteger(L, -2) << 3) | + (luaL_checkinteger(L, -3) << 2) | + (luaL_checkinteger(L, -4) << 1) | + (luaL_checkinteger(L, -5))); - lua_pop(L, 2); + lua_pop(L, 2); - return 1; + return 1; } static int syscalls_SetMouseSpeed(lua_State* L) { - _ksys_set_mouse_settings(KSYS_MOUSE_SET_SPEED, luaL_checkinteger(L, 1)); + _ksys_set_mouse_settings(KSYS_MOUSE_SET_SPEED, luaL_checkinteger(L, 1)); - return 0; + return 0; } static int syscalls_SetMouseSens(lua_State* L) { - _ksys_set_mouse_settings(KSYS_MOUSE_SET_SENS, luaL_checkinteger(L, 1)); + _ksys_set_mouse_settings(KSYS_MOUSE_SET_SENS, luaL_checkinteger(L, 1)); - return 0; + return 0; } static int syscalls_SetMousePos(lua_State* L) { - _ksys_set_mouse_pos(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)); + _ksys_set_mouse_pos(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)); - return 0; + return 0; } static int syscalls_SetMouseDoubleClickDelay(lua_State* L) { - _ksys_set_mouse_settings(KSYS_MOUSE_SET_DOUBLE_CLICK_DELAY, luaL_checkinteger(L, 1)); + _ksys_set_mouse_settings(KSYS_MOUSE_SET_DOUBLE_CLICK_DELAY, luaL_checkinteger(L, 1)); - return 0; + return 0; } static int syscalls_SetMouseSettings(lua_State* L) { - lua_settop(L, 1); - luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); + luaL_checktype(L, 1, LUA_TTABLE); - lua_getfield(L, 1, "Speed"); - lua_getfield(L, 1, "Sens"); - lua_getfield(L, 1, "DoubleClickDelay"); + lua_getfield(L, 1, "Speed"); + lua_getfield(L, 1, "Sens"); + lua_getfield(L, 1, "DoubleClickDelay"); - _ksys_set_mouse_settings(KSYS_MOUSE_GET_SPEED, luaL_checkinteger(L, -3)); - _ksys_set_mouse_settings(KSYS_MOUSE_SET_SENS, luaL_checkinteger(L, -2)); - _ksys_set_mouse_settings(KSYS_MOUSE_SET_DOUBLE_CLICK_DELAY, luaL_checkinteger(L, -1)); + _ksys_set_mouse_settings(KSYS_MOUSE_GET_SPEED, luaL_checkinteger(L, -3)); + _ksys_set_mouse_settings(KSYS_MOUSE_SET_SENS, luaL_checkinteger(L, -2)); + _ksys_set_mouse_settings(KSYS_MOUSE_SET_DOUBLE_CLICK_DELAY, luaL_checkinteger(L, -1)); - return 0; + return 0; } static int syscalls_LoadCursor(lua_State* L) { - lua_pushlightuserdata( - L, - _ksys_load_cursor( - (void*)luaL_checkstring(L, 1), - KSYS_CURSOR_FROM_FILE | - (luaL_checkinteger(L, 2) << 24) | - (luaL_checkinteger(L, 3) << 16))); - return 1; + lua_pushlightuserdata( + L, + _ksys_load_cursor( + (void*)luaL_checkstring(L, 1), + KSYS_CURSOR_FROM_FILE | + (luaL_checkinteger(L, 2) << 24) | + (luaL_checkinteger(L, 3) << 16))); + return 1; } static int syscalls_SetCursor(lua_State* L) { - lua_islightuserdata(L, 1); - lua_pushlightuserdata( - L, - lua_touserdata(L, 1)); + lua_islightuserdata(L, 1); + lua_pushlightuserdata( + L, + lua_touserdata(L, 1)); - return 1; + return 1; } static int syscalls_DeleteCursor(lua_State* L) { - _ksys_delete_cursor(lua_touserdata(L, 1)); + _ksys_delete_cursor(lua_touserdata(L, 1)); - return 0; + return 0; } /* - network funcs + network funcs */ static int syscalls_GetDevicesNum(lua_State* L) { - uint32_t num; + uint32_t num; - asm_inline( - "int $0x40" - :"=a"(num) - : "a"(74), "b"(-1) - ); + asm_inline( + "int $0x40" + :"=a"(num) + : "a"(74), "b"(-1) + ); - lua_pushinteger(L, num); + lua_pushinteger(L, num); - return 1; + return 1; } static int syscalls_GetDeviceType(lua_State* L) { - uint32_t type; + uint32_t type; - uint32_t device = luaL_checkinteger(L, 1); + uint32_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(type) - : "a"(74), "b"(0 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(type) + : "a"(74), "b"(0 | device << 8)); - lua_pushinteger(L, type); + lua_pushinteger(L, type); - return 1; + return 1; } static int syscalls_GetDeviceName(lua_State* L) { - char name[64]; - uint32_t ret; - uint32_t device = luaL_checkinteger(L, 1); + char name[64]; + uint32_t ret; + uint32_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(ret) - : "a"(74), "b"(1 | device << 8), "c"(name)); + asm_inline( + "int $0x40" + : "=a"(ret) + : "a"(74), "b"(1 | device << 8), "c"(name)); - syscalls_ReturnStringOrNil(ret, name, L); + syscalls_ReturnStringOrNil(ret, name, L); - return 1; + return 1; } static int syscalls_ResetDevice(lua_State* L) { - uint32_t ret = 0; + uint32_t ret = 0; - asm_inline( - "int $0x40" - : "=a"(ret) - : "a"(74), "b"(2)); + asm_inline( + "int $0x40" + : "=a"(ret) + : "a"(74), "b"(2)); - syscalls_ReturnTrueOrNil(ret, L); + syscalls_ReturnTrueOrNil(ret, L); - return 1; + return 1; } static int syscalls_StopDevice(lua_State* L) { - uint32_t ret = 0; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t ret = 0; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(ret) - : "a"(74), "b"(3 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(ret) + : "a"(74), "b"(3 | device << 8)); - syscalls_ReturnTrueOrNil(ret, L); + syscalls_ReturnTrueOrNil(ret, L); - return 1; + return 1; } static int syscalls_GetTXPacketCount(lua_State* L) { - uint32_t num; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t num; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num) - : "a"(74), "b"(6 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num) + : "a"(74), "b"(6 | device << 8)); - syscalls_ReturnIntegerOrNil(num, L); + syscalls_ReturnIntegerOrNil(num, L); - return 1; + return 1; } static int syscalls_GetRXPacketCount(lua_State* L) { - uint32_t num; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t num; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num) - : "a"(74), "b"(7 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num) + : "a"(74), "b"(7 | device << 8)); - syscalls_ReturnIntegerOrNil(num, L); + syscalls_ReturnIntegerOrNil(num, L); - return 1; + return 1; } static int syscalls_GetTXByteCount(lua_State* L) { - int num; - uint32_t NUM; - uint8_t device = luaL_checkinteger(L, 1); + int num; + uint32_t NUM; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num), "=b"(NUM) - : "a"(74), "b"(8 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num), "=b"(NUM) + : "a"(74), "b"(8 | device << 8)); - if (num == -1) - lua_pushnil(L); - else - lua_pushinteger(L, (uint64_t)(num | NUM << 31)); + if (num == -1) + lua_pushnil(L); + else + lua_pushinteger(L, (uint64_t)(num | NUM << 31)); - return 1; + return 1; } static int syscalls_GetRXByteCount(lua_State* L) { - int num; - uint32_t NUM; - uint8_t device = luaL_checkinteger(L, 1); + int num; + uint32_t NUM; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num), "=b"(NUM) - : "a"(74), "b"(9 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num), "=b"(NUM) + : "a"(74), "b"(9 | device << 8)); - if (num == -1) - lua_pushnil(L); - else - lua_pushinteger(L, (uint64_t)(num | NUM << 31)); + if (num == -1) + lua_pushnil(L); + else + lua_pushinteger(L, (uint64_t)(num | NUM << 31)); - return 1; + return 1; } static int syscalls_GetTXErrorPacketCount(lua_State* L) { - int num; - uint32_t NUM; - uint8_t device = luaL_checkinteger(L, 1); + int num; + uint32_t NUM; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num), "=b"(NUM) - : "a"(74), "b"(11 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num), "=b"(NUM) + : "a"(74), "b"(11 | device << 8)); - if (num == -1) - lua_pushnil(L); - else - lua_pushinteger(L, (uint64_t)(num | NUM << 31)); + if (num == -1) + lua_pushnil(L); + else + lua_pushinteger(L, (uint64_t)(num | NUM << 31)); - return 1; + return 1; } static int syscalls_GetTXDropPacketCount(lua_State* L) { - int num; - uint32_t NUM; - uint8_t device = luaL_checkinteger(L, 1); + int num; + uint32_t NUM; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num), "=b"(NUM) - : "a"(74), "b"(12 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num), "=b"(NUM) + : "a"(74), "b"(12 | device << 8)); - if (num == -1) - lua_pushnil(L); - else - lua_pushinteger(L, (uint64_t)(num | NUM << 31)); + if (num == -1) + lua_pushnil(L); + else + lua_pushinteger(L, (uint64_t)(num | NUM << 31)); - return 1; + return 1; } static int syscalls_GetTXMissPacketCount(lua_State* L) { - int num; - uint32_t NUM; - uint8_t device = luaL_checkinteger(L, 1); + int num; + uint32_t NUM; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num), "=b"(NUM) - : "a"(74), "b"(13 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num), "=b"(NUM) + : "a"(74), "b"(13 | device << 8)); - if (num == -1) - lua_pushnil(L); - else - lua_pushinteger(L, (uint64_t)(num | NUM << 31)); + if (num == -1) + lua_pushnil(L); + else + lua_pushinteger(L, (uint64_t)(num | NUM << 31)); - return 1; + return 1; } static int syscalls_GetRXErrorPacketCount(lua_State* L) { - int num; - uint32_t NUM; - uint8_t device = luaL_checkinteger(L, 1); + int num; + uint32_t NUM; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num), "=b"(NUM) - : "a"(74), "b"(14 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num), "=b"(NUM) + : "a"(74), "b"(14 | device << 8)); - if (num == -1) - lua_pushnil(L); - else - lua_pushinteger(L, (uint64_t)(num | NUM << 31)); + if (num == -1) + lua_pushnil(L); + else + lua_pushinteger(L, (uint64_t)(num | NUM << 31)); - return 1; + return 1; } static int syscalls_GetRXDropPacketCount(lua_State* L) { - int num; - uint32_t NUM; - uint8_t device = luaL_checkinteger(L, 1); + int num; + uint32_t NUM; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num), "=b"(NUM) - : "a"(74), "b"(15 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num), "=b"(NUM) + : "a"(74), "b"(15 | device << 8)); - syscalls_ReturnIntegerValueOrNil(num, (uint64_t)(num | NUM << 31), L); + syscalls_ReturnIntegerValueOrNil(num, (uint64_t)(num | NUM << 31), L); - return 1; + return 1; } static int syscalls_GetRXMissPacketCount(lua_State* L) { - int num; - uint32_t NUM; - uint8_t device = luaL_checkinteger(L, 1); + int num; + uint32_t NUM; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num), "=b"(NUM) - : "a"(74), "b"(16 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num), "=b"(NUM) + : "a"(74), "b"(16 | device << 8)); - syscalls_ReturnIntegerValueOrNil(num, (uint64_t)(num | NUM << 31), L); + syscalls_ReturnIntegerValueOrNil(num, (uint64_t)(num | NUM << 31), L); - return 1; + return 1; } enum ConnectionStatus { - NoConnect = 0, - Unknown = 1, - Mb10 = 4, // 10Mb - Mb100 = 5, // 100Mb - Gb = 6, // 1Gb - FullDuplex = 0b10 // + NoConnect = 0, + Unknown = 1, + Mb10 = 4, // 10Mb + Mb100 = 5, // 100Mb + Gb = 6, // 1Gb + FullDuplex = 0b10 // }; static int syscalls_GetConnectionStatus(lua_State* L) { - int num; - uint8_t device = luaL_checkinteger(L, 1); + int num; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(num) - : "a"(74), "b"(10 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(num) + : "a"(74), "b"(10 | device << 8)); - if (num == -1) - lua_pushnil(L); - else - lua_pushinteger(L, num & 0x101); - lua_pushinteger(L, (num & FullDuplex) != 0); + if (num == -1) + lua_pushnil(L); + else + lua_pushinteger(L, num & 0x101); + lua_pushinteger(L, (num & FullDuplex) != 0); - return 2; + return 2; } static int syscalls_ReadMAC(lua_State* L) { - uint32_t eax, ebx; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax, ebx; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax), "=b"(ebx) - : "a"(76), "b"(0 | device << 8)); + asm_inline( + "int $0x40" + : "=a"(eax), "=b"(ebx) + : "a"(76), "b"(0 | device << 8)); - syscalls_ReturnIntegerValueOrNil(eax, eax | (ebx << 31), L); + syscalls_ReturnIntegerValueOrNil(eax, eax | (ebx << 31), L); - return 1; + return 1; } typedef enum SYSCALLS_PROTOCOLS { - IPv4 = 1, - ICMP = 2, - UDP = 3, - TCP = 4, - ARP = 5 + IPv4 = 1, + ICMP = 2, + UDP = 3, + TCP = 4, + ARP = 5 } SYSCALLS_PROTOCOLS; inline int syscalls_ReadPacketSend(lua_State* L, SYSCALLS_PROTOCOLS protocol) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((protocol << 24) | (device << 8) | 0)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((protocol << 24) | (device << 8) | 0)); - syscalls_ReturnIntegerOrNil(eax, L); + syscalls_ReturnIntegerOrNil(eax, L); - return 1; + return 1; } inline int syscalls_ReadPacketReceive(lua_State* L, SYSCALLS_PROTOCOLS protocol) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((protocol << 24) | (device << 8) | 1)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((protocol << 24) | (device << 8) | 1)); - syscalls_ReturnIntegerOrNil(eax, L); + syscalls_ReturnIntegerOrNil(eax, L); - return 1; + return 1; } // IPv4 static int syscalls_IPv4ReadPacketSend(lua_State* L) { - return syscalls_ReadPacketSend(L, IPv4); + return syscalls_ReadPacketSend(L, IPv4); } static int syscalls_IPv4ReadPacketReceive(lua_State* L) { - return syscalls_ReadPacketReceive(L, IPv4); + return syscalls_ReadPacketReceive(L, IPv4); } static int syscalls_ReadIPv4Address(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((IPv4 << 24) | (device << 8) | 2)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((IPv4 << 24) | (device << 8) | 2)); - syscalls_ReturnIntegerOrNil(eax, L); + syscalls_ReturnIntegerOrNil(eax, L); - return 1; + return 1; } static int syscalls_SetIPv4Address(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); - uint32_t IP = luaL_checkinteger(L, 2); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); + uint32_t IP = luaL_checkinteger(L, 2); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((IPv4 << 24) | (device << 8) | 3), "c"(IP)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((IPv4 << 24) | (device << 8) | 3), "c"(IP)); - syscalls_ReturnTrueOrNil(eax, L); + syscalls_ReturnTrueOrNil(eax, L); - return 1; + return 1; } static int syscalls_ReadIPv4DNSAddress(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((IPv4 << 24) | (device << 8) | 4)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((IPv4 << 24) | (device << 8) | 4)); - syscalls_ReturnIntegerOrNil(eax, L); + syscalls_ReturnIntegerOrNil(eax, L); - return 1; + return 1; } static int syscalls_SetIPv4DNSAddress(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); - uint32_t IP = luaL_checkinteger(L, 2); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); + uint32_t IP = luaL_checkinteger(L, 2); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((IPv4 << 24) | (device << 8) | 5), "c"(IP)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((IPv4 << 24) | (device << 8) | 5), "c"(IP)); - syscalls_ReturnTrueOrNil(eax, L); + syscalls_ReturnTrueOrNil(eax, L); - return 1; + return 1; } static int syscalls_ReadIPv4SubnetMask(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((IPv4 << 24) | (device << 8) | 6)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((IPv4 << 24) | (device << 8) | 6)); - syscalls_ReturnIntegerOrNil(eax, L); + syscalls_ReturnIntegerOrNil(eax, L); - return 1; + return 1; } static int syscalls_SetIPv4SubnetMask(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); - uint32_t IP = luaL_checkinteger(L, 2); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); + uint32_t IP = luaL_checkinteger(L, 2); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((IPv4 << 24) | (device << 8) | 7), "c"(IP)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((IPv4 << 24) | (device << 8) | 7), "c"(IP)); - syscalls_ReturnTrueOrNil(eax, L); + syscalls_ReturnTrueOrNil(eax, L); - return 1; + return 1; } static int syscalls_ReadIPv4Gateway(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((IPv4 << 24) | (device << 8) | 8)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((IPv4 << 24) | (device << 8) | 8)); - syscalls_ReturnIntegerOrNil(eax, L); + syscalls_ReturnIntegerOrNil(eax, L); - return 1; + return 1; } static int syscalls_SetIPv4Gateway(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); - uint32_t IP = luaL_checkinteger(L, 2); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); + uint32_t IP = luaL_checkinteger(L, 2); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((IPv4 << 24) | (device << 8) | 7), "c"(IP)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((IPv4 << 24) | (device << 8) | 7), "c"(IP)); - syscalls_ReturnTrueOrNil(eax, L); + syscalls_ReturnTrueOrNil(eax, L); - return 1; + return 1; } // ICMP static int syscalls_ICMPReadPacketSend(lua_State* L) { - return syscalls_ReadPacketSend(L, ICMP); + return syscalls_ReadPacketSend(L, ICMP); } static int syscalls_ICMPReadPacketReceive(lua_State* L) { - return syscalls_ReadPacketReceive(L, ICMP); + return syscalls_ReadPacketReceive(L, ICMP); } // UDP static int syscalls_UDPReadPacketSend(lua_State* L) { - return syscalls_ReadPacketSend(L, UDP); + return syscalls_ReadPacketSend(L, UDP); } static int syscalls_UDPReadPacketReceive(lua_State* L) { - return syscalls_ReadPacketReceive(L, UDP); + return syscalls_ReadPacketReceive(L, UDP); } // TCP static int syscalls_TCPReadPacketSend(lua_State* L) { - return syscalls_ReadPacketSend(L, TCP); + return syscalls_ReadPacketSend(L, TCP); } static int syscalls_TCPReadPacketReceive(lua_State* L) { - return syscalls_ReadPacketReceive(L, TCP); + return syscalls_ReadPacketReceive(L, TCP); } // ARP static int syscalls_ARPReadPacketSend(lua_State* L) { - return syscalls_ReadPacketSend(L, ARP); + return syscalls_ReadPacketSend(L, ARP); } static int syscalls_ARPReadPacketReceive(lua_State* L) { - return syscalls_ReadPacketReceive(L, ARP); + return syscalls_ReadPacketReceive(L, ARP); } static int syscalls_ReadARPEntries(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((ARP << 24) | (device << 8) | 2)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((ARP << 24) | (device << 8) | 2)); - syscalls_ReturnIntegerOrNil(eax, L); + syscalls_ReturnIntegerOrNil(eax, L); - return 1; + return 1; } static int syscalls_ReadARPEntry(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); - uint32_t entryNum = luaL_checkinteger(L, 2); - struct ARP_entry* buffer = syscalls_pushARPEntry(L); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); + uint32_t entryNum = luaL_checkinteger(L, 2); + struct ARP_entry* buffer = syscalls_pushARPEntry(L); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((ARP << 24) | (device << 8) | 3), "c"(entryNum), "D"(buffer)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((ARP << 24) | (device << 8) | 3), "c"(entryNum), "D"(buffer)); - return 1; + return 1; } static int syscalls_AddARPEntry(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); - uint32_t entryNum = luaL_checkinteger(L, 2); - struct ARP_entry* buffer = (struct ARP_entry*)lua_touserdata(L, 3); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); + uint32_t entryNum = luaL_checkinteger(L, 2); + struct ARP_entry* buffer = (struct ARP_entry*)lua_touserdata(L, 3); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((ARP << 24) | (device << 8) | 4), "c"(entryNum), "S"(buffer)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((ARP << 24) | (device << 8) | 4), "c"(entryNum), "S"(buffer)); - syscalls_ReturnTrueOrNil(eax, L); + syscalls_ReturnTrueOrNil(eax, L); - return 1; + return 1; } static int syscalls_RemoveARPEntry(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); - uint32_t entryNum = luaL_checkinteger(L, 2); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); + uint32_t entryNum = luaL_checkinteger(L, 2); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((ARP << 24) | (device << 8) | 5), "c"(entryNum)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((ARP << 24) | (device << 8) | 5), "c"(entryNum)); - syscalls_ReturnTrueOrNil(eax, L); + syscalls_ReturnTrueOrNil(eax, L); - return 1; + return 1; } static int syscalls_SendARPAnnounce(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((ARP << 24) | (device << 8) | 6)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((ARP << 24) | (device << 8) | 6)); - syscalls_ReturnTrueOrNil(eax, L); + syscalls_ReturnTrueOrNil(eax, L); - return 1; + return 1; } static int syscalls_ReadARPConflicts(lua_State* L) { - uint32_t eax; - uint8_t device = luaL_checkinteger(L, 1); + uint32_t eax; + uint8_t device = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax) - : "a"(76), "b"((ARP << 24) | (device << 8) | 7)); + asm_inline( + "int $0x40" + : "=a"(eax) + : "a"(76), "b"((ARP << 24) | (device << 8) | 7)); - syscalls_ReturnTrueOrNil(eax, L); + syscalls_ReturnTrueOrNil(eax, L); - return 1; + return 1; } /* Сокеты */ static int syscalls_OpenSocket(lua_State* L) { - int32_t socketNum; - uint32_t errorCode; + int32_t socketNum; + uint32_t errorCode; - uint32_t family = luaL_checkinteger(L, 1); - uint32_t type = luaL_checkinteger(L, 2); - uint32_t protocol = luaL_checkinteger(L, 3); + uint32_t family = luaL_checkinteger(L, 1); + uint32_t type = luaL_checkinteger(L, 2); + uint32_t protocol = luaL_checkinteger(L, 3); - asm_inline( - "int $0x40" - :"=a"(socketNum), "=b"(errorCode) - : "a"(77), "b"(0), "c"(family), "d"(type), "S"(protocol) - ); + asm_inline( + "int $0x40" + :"=a"(socketNum), "=b"(errorCode) + : "a"(77), "b"(0), "c"(family), "d"(type), "S"(protocol) + ); - if (socketNum == -1) - { - lua_pushnil(L); // Push socketNum - lua_pushnumber(L, socketNum); // Push error Code - } - else - { - lua_pushnumber(L, socketNum); // Push socketNum - lua_pushnil(L); // Push error code - } + if (socketNum == -1) + { + lua_pushnil(L); // Push socketNum + lua_pushnumber(L, socketNum); // Push error Code + } + else + { + lua_pushnumber(L, socketNum); // Push socketNum + lua_pushnil(L); // Push error code + } - return 2; + return 2; } static int syscalls_CloseSocket(lua_State* L) { - uint32_t eax; - uint32_t errorCode; - uint32_t socketNum = luaL_checkinteger(L, 1); + uint32_t eax; + uint32_t errorCode; + uint32_t socketNum = luaL_checkinteger(L, 1); - asm_inline( - "int $0x40" - : "=a"(eax), "=b"(errorCode) - : "a"(77), "b"(1), "c"(socketNum)); + asm_inline( + "int $0x40" + : "=a"(eax), "=b"(errorCode) + : "a"(77), "b"(1), "c"(socketNum)); - syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); + syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); - return 1; + return 1; } static int syscalls_Bind(lua_State* L) { - uint32_t eax; - uint32_t errorCode; + uint32_t eax; + uint32_t errorCode; - uint32_t socketNum = luaL_checkinteger(L, 1); - uint32_t sockaddr = luaL_checkinteger(L, 2); - uint32_t sockaddrLen = luaL_checkinteger(L, 3); + uint32_t socketNum = luaL_checkinteger(L, 1); + uint32_t sockaddr = luaL_checkinteger(L, 2); + uint32_t sockaddrLen = luaL_checkinteger(L, 3); - asm_inline( - "int $0x40" - : "=a"(eax), "=b"(errorCode) - : "a"(77), "b"(2), "c"(socketNum), "d"(sockaddr), "S"(sockaddrLen)); + asm_inline( + "int $0x40" + : "=a"(eax), "=b"(errorCode) + : "a"(77), "b"(2), "c"(socketNum), "d"(sockaddr), "S"(sockaddrLen)); - syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); + syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); - return 1; + return 1; } static int syscalls_Listen(lua_State* L) { - uint32_t eax; - uint32_t errorCode; + uint32_t eax; + uint32_t errorCode; - uint32_t socketNum = luaL_checkinteger(L, 1); - uint32_t backlog = luaL_checkinteger(L, 2); + uint32_t socketNum = luaL_checkinteger(L, 1); + uint32_t backlog = luaL_checkinteger(L, 2); - asm_inline( - "int $0x40" - : "=a"(eax), "=b"(errorCode) - : "a"(77), "b"(3), "c"(socketNum), "d"(backlog)); + asm_inline( + "int $0x40" + : "=a"(eax), "=b"(errorCode) + : "a"(77), "b"(3), "c"(socketNum), "d"(backlog)); - syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); + syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); - return 1; + return 1; } static int syscalls_Connect(lua_State* L) { - uint32_t eax; - uint32_t errorCode; + uint32_t eax; + uint32_t errorCode; - uint32_t socketNum = luaL_checkinteger(L, 1); - uint32_t sockaddr = luaL_checkinteger(L, 2); - uint32_t sockaddrLen = luaL_checkinteger(L, 3); + uint32_t socketNum = luaL_checkinteger(L, 1); + uint32_t sockaddr = luaL_checkinteger(L, 2); + uint32_t sockaddrLen = luaL_checkinteger(L, 3); - asm_inline( - "int $0x40" - : "=a"(eax), "=b"(errorCode) - : "a"(77), "b"(4), "c"(socketNum), "d"(sockaddr), "S"(sockaddrLen)); + asm_inline( + "int $0x40" + : "=a"(eax), "=b"(errorCode) + : "a"(77), "b"(4), "c"(socketNum), "d"(sockaddr), "S"(sockaddrLen)); - syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); + syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); - return 1; + return 1; } static int syscalls_Accept(lua_State* L) { - uint32_t eax; - uint32_t errorCode; + uint32_t eax; + uint32_t errorCode; - uint32_t socketNum = luaL_checkinteger(L, 1); - uint32_t sockaddr = luaL_checkinteger(L, 2); - uint32_t sockaddrLen = luaL_checkinteger(L, 3); + uint32_t socketNum = luaL_checkinteger(L, 1); + uint32_t sockaddr = luaL_checkinteger(L, 2); + uint32_t sockaddrLen = luaL_checkinteger(L, 3); - asm_inline( - "int $0x40" - : "=a"(eax), "=b"(errorCode) - : "a"(77), "b"(5), "c"(socketNum), "d"(sockaddr), "S"(sockaddrLen)); + asm_inline( + "int $0x40" + : "=a"(eax), "=b"(errorCode) + : "a"(77), "b"(5), "c"(socketNum), "d"(sockaddr), "S"(sockaddrLen)); - syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); + syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); - return 1; + return 1; } static int syscalls_Send(lua_State* L) { - uint32_t eax; - uint32_t errorCode; + uint32_t eax; + uint32_t errorCode; - uint32_t socketNum = luaL_checkinteger(L, 1); - uint32_t buffer = luaL_checkinteger(L, 2); - uint32_t bufferLen = luaL_checkinteger(L, 3); - uint32_t flags = luaL_checkinteger(L, 4); + uint32_t socketNum = luaL_checkinteger(L, 1); + uint32_t buffer = luaL_checkinteger(L, 2); + uint32_t bufferLen = luaL_checkinteger(L, 3); + uint32_t flags = luaL_checkinteger(L, 4); - asm_inline( - "int $0x40" - : "=a"(eax), "=b"(errorCode) - : "a"(77), "b"(6), "c"(socketNum), "d"(buffer), "S"(bufferLen), "D"(flags)); + asm_inline( + "int $0x40" + : "=a"(eax), "=b"(errorCode) + : "a"(77), "b"(6), "c"(socketNum), "d"(buffer), "S"(bufferLen), "D"(flags)); - syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); + syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); - return 1; + return 1; } static int syscalls_Receive(lua_State* L) { - uint32_t eax; - uint32_t errorCode; + uint32_t eax; + uint32_t errorCode; - uint32_t socketNum = luaL_checkinteger(L, 1); - uint32_t buffer = luaL_checkinteger(L, 2); - uint32_t bufferLen = luaL_checkinteger(L, 3); - uint32_t flags = luaL_checkinteger(L, 4); + uint32_t socketNum = luaL_checkinteger(L, 1); + uint32_t buffer = luaL_checkinteger(L, 2); + uint32_t bufferLen = luaL_checkinteger(L, 3); + uint32_t flags = luaL_checkinteger(L, 4); - asm_inline( - "int $0x40" - : "=a"(eax), "=b"(errorCode) - : "a"(77), "b"(7), "c"(socketNum), "d"(buffer), "S"(bufferLen), "D"(flags)); + asm_inline( + "int $0x40" + : "=a"(eax), "=b"(errorCode) + : "a"(77), "b"(7), "c"(socketNum), "d"(buffer), "S"(bufferLen), "D"(flags)); - syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); + syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); - return 1; + return 1; } static int syscalls_GetSocketOptions(lua_State* L) { - uint32_t eax; - uint32_t errorCode; + uint32_t eax; + uint32_t errorCode; - uint32_t socketNum = luaL_checkinteger(L, 1); - uint32_t optstruct = luaL_checkinteger(L, 2); + uint32_t socketNum = luaL_checkinteger(L, 1); + uint32_t optstruct = luaL_checkinteger(L, 2); - asm_inline( - "int $0x40" - : "=a"(eax), "=b"(errorCode) - : "a"(77), "b"(8), "c"(socketNum), "d"(optstruct)); + asm_inline( + "int $0x40" + : "=a"(eax), "=b"(errorCode) + : "a"(77), "b"(8), "c"(socketNum), "d"(optstruct)); - syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); + syscalls_ReturnIntegerValueOrNil(eax, errorCode, L); - return 1; + return 1; } static int syscalls_GetPairSocket(lua_State* L) { - int32_t firstSocketNum; - uint32_t secondSocketNum; + int32_t firstSocketNum; + uint32_t secondSocketNum; - asm_inline( - "int $0x40" - : "=a"(firstSocketNum), "=b"(secondSocketNum) - : "a"(77), "b"(9)); + asm_inline( + "int $0x40" + : "=a"(firstSocketNum), "=b"(secondSocketNum) + : "a"(77), "b"(9)); - if (firstSocketNum == -1) - { - lua_pushnil(L); - lua_pushinteger(L, secondSocketNum); - } - else - { - lua_pushinteger(L, firstSocketNum); - lua_pushinteger(L, secondSocketNum); - } + if (firstSocketNum == -1) + { + lua_pushnil(L); + lua_pushinteger(L, secondSocketNum); + } + else + { + lua_pushinteger(L, firstSocketNum); + lua_pushinteger(L, secondSocketNum); + } - return 2; + return 2; } @@ -1924,390 +1924,390 @@ static int syscalls_GetPairSocket(lua_State* L) ** functions for 'syscalls' library */ static const luaL_Reg syscallsLib[] = { - /* Window funcs */ - {"CreateWindow", syscalls_createWindow}, - {"StartRedraw", syscalls_startRedraw}, - {"EndRedraw", syscalls_endRedraw}, - {"ChangeWindow", syscalls_changeWindow}, - {"FocusWindow", syscalls_focusWindow}, - {"UnfocusWindow", syscalls_unfocusWindow}, - {"SetWindowTitle", syscalls_setWindowTitle}, - {"GetSkinHeight", syscalls_getSkinHeight}, - {"SetSkin", syscalls_SetSkin}, - {"GetSkinTitleArea", syscalls_GetSkinTilteArea}, - /* Buttons funcs*/ - {"DefineButton", syscalls_defineButton}, - {"DeleteButton", syscalls_deleteButton}, - {"GetButton", syscalls_getButton}, - {"SetButtonStyle", syscalls_SetButtonsStyle}, - /* Events funcs */ - {"SetEventMask", syscalls_setEventMask}, - {"WaitEvent", syscalls_waitEvent}, - {"CheckEvent", syscalls_checkEvent}, - {"WaitEventTimeout", syscalls_waitEventTimeout}, - /* Background funcs */ - {"BackgroundSetSize", syscalls_backgroundSetSize}, - {"BackgroundPutPixel", syscalls_backgroundPutPixel}, - {"BackgroundRedraw", syscalls_backgroundRedraw}, - /* system funcs */ - {"GetRamSize", syscalls_getRamSize}, - {"GetFreeRam", syscalls_getFreeRam}, - {"GetCPUClock", syscalls_getCPUClock}, - {"ShutdownPowerOff", syscalls_shutdownPowerOff}, - {"ShutdownReboot", syscalls_shutdownReboot}, - {"ShutdownRestartKernel", syscalls_shutdownRestartKRN}, - {"GetSystemColors", syscalls_getSystemColors}, - {"SetSystemColors", syscalls_SetSystemColors}, - {"ScreenSize", syscalls_screenSize}, - {"GetWorkArea", syscalls_GetWorkArea}, - {"SetWorkArea", syscalls_SetWorkArea}, - /* Draw funcs*/ - {"DrawLine", syscalls_drawLine}, - {"DrawPixel", syscalls_drawPixel}, - {"DrawText", syscalls_drawText}, - {"DrawRectangle", syscalls_drawRectangle}, - {"ReadPoint", syscalls_ReadPoint}, - /* keyboard funcs */ - {"SetKeyInputMode", syscalls_setKeyInputMode}, - {"GetKeyInputMouse", syscalls_getKeyInputMode}, - {"getKey", syscalls_getKey}, - {"getControlKeyState", syscalls_getControlKeyState}, - {"SetHotkey", syscalls_SetHotkey}, - {"DeleteHotkey", syscalls_DeleteHotkey}, - {"LockNormalInput", syscalls_LockNormalInput}, - {"UnlockNormalInput", syscalls_UnlockNormalInput}, - /* Threads funcs */ - {"ThreadInfo", syscalls_threadInfo}, - {"KillBySlot", syscalls_KillBySlot}, - /* Mouse funcs */ - {"GetMouseButtons", syscalls_getMouseButtons}, - {"GetMouseEvents", syscalls_getMouseEvents}, - {"GetMousePositionScreen", syscalls_getMousePositionScreen}, - {"GetMousePositionWindow", syscalls_getMousePositionWindow}, - {"GetMouseWheels", syscalls_getMouseWheels}, - {"GetMouseSpeed", syscalls_GetMouseSpeed}, - {"GetMouseSens", syscalls_GetMouseSens}, - {"GetMouseDoubleClickDelay", syscalls_GetMouseDoubleClickDelay}, - {"GetMouseSettings", syscalls_GetMouseSettings}, - {"MouseSimulateState", syscalls_MouseSimulateState}, - {"SetMouseSpeed", syscalls_SetMouseSpeed}, - {"SetMouseSens", syscalls_SetMouseSens}, - {"SetMousePos", syscalls_SetMousePos}, - {"SetMouseDoubleClickDelay", syscalls_SetMouseDoubleClickDelay}, - {"SetMouseSettings", syscalls_SetMouseSettings}, - {"LoadCursor", syscalls_LoadCursor}, - {"SetCursor", syscalls_SetCursor}, - {"DeleteCursor", syscalls_DeleteCursor}, - /* network funcs */ - {"GetDevicesNum", syscalls_GetDevicesNum}, - {"GetDeviceType", syscalls_GetDeviceType}, - {"GetDeviceName", syscalls_GetDeviceName}, - {"ResetDevice", syscalls_ResetDevice}, - {"StopDevice", syscalls_StopDevice}, - {"GetConnectionStatus", syscalls_GetConnectionStatus}, - {"ReadMAC", syscalls_ReadMAC}, - /* statistic funcs */ - {"GetTXPacketCount", syscalls_GetTXPacketCount}, - {"GetRXPacketCount", syscalls_GetRXPacketCount}, - {"GetTXByteCount", syscalls_GetTXByteCount}, - {"GetRXByteCount", syscalls_GetRXByteCount}, - {"GetTXErrorPacketCount", syscalls_GetTXErrorPacketCount}, - {"GetTXDropPacketCount", syscalls_GetTXDropPacketCount}, - {"GetTXMissPacketCount", syscalls_GetTXMissPacketCount}, - {"GetRXErrorPacketCount", syscalls_GetRXErrorPacketCount}, - {"GetRXDropPacketCount", syscalls_GetRXDropPacketCount}, - {"GetRXMissPacketCount", syscalls_GetRXMissPacketCount}, - {"IPv4ReadPacketSend", syscalls_IPv4ReadPacketSend}, - {"IPv4ReadPacketReceive", syscalls_IPv4ReadPacketReceive}, - {"ICMPReadPacketSend", syscalls_ICMPReadPacketSend}, - {"ICMPReadPacketReceive", syscalls_ICMPReadPacketReceive}, - {"UDPReadPacketSend", syscalls_UDPReadPacketSend}, - {"UDPReadPacketReceive", syscalls_UDPReadPacketReceive}, - {"TCPReadPacketSend", syscalls_TCPReadPacketSend}, - {"TCPReadPacketReceive", syscalls_TCPReadPacketReceive}, - {"ARPReadPacketSend", syscalls_ARPReadPacketSend}, - {"ARPReadPacketReceive", syscalls_ARPReadPacketReceive}, - {"ReadIPv4Address", syscalls_ReadIPv4Address}, - {"SetIPv4Address", syscalls_SetIPv4Address}, - {"ReadIPv4DNSAddress", syscalls_ReadIPv4DNSAddress}, - {"SetIPv4DNSAddress", syscalls_SetIPv4DNSAddress}, - {"ReadIPv4SubnetMask", syscalls_ReadIPv4SubnetMask}, - {"SetIPv4SubnetMask", syscalls_SetIPv4SubnetMask}, - {"ReadIPv4Gateway", syscalls_ReadIPv4Gateway}, - {"SetIPv4Gateway", syscalls_SetIPv4Gateway}, - {"ReadARPEntries", syscalls_ReadARPEntries}, - {"ReadARPEntry", syscalls_ReadARPEntry}, - {"RemoveARPEntry", syscalls_RemoveARPEntry}, - {"AddARPEntry", syscalls_AddARPEntry}, - {"SendARPAnnounce", syscalls_SendARPAnnounce}, - {"ReadARPConflicts", syscalls_ReadARPConflicts}, - /* Socket funcs */ - {"OpenSocket", syscalls_OpenSocket}, - {"CloseSocket", syscalls_CloseSocket}, - {"Bind", syscalls_Bind}, - {"Listen", syscalls_Listen}, - {"Connect", syscalls_Connect}, - {"Accept", syscalls_Accept}, - {"Send", syscalls_Send}, - {"Receive", syscalls_Receive}, - {"GetSocketOptions", syscalls_GetSocketOptions}, - {"GetPairSocket", syscalls_GetPairSocket}, - {NULL, NULL} }; + /* Window funcs */ + {"CreateWindow", syscalls_createWindow}, + {"StartRedraw", syscalls_startRedraw}, + {"EndRedraw", syscalls_endRedraw}, + {"ChangeWindow", syscalls_changeWindow}, + {"FocusWindow", syscalls_focusWindow}, + {"UnfocusWindow", syscalls_unfocusWindow}, + {"SetWindowTitle", syscalls_setWindowTitle}, + {"GetSkinHeight", syscalls_getSkinHeight}, + {"SetSkin", syscalls_SetSkin}, + {"GetSkinTitleArea", syscalls_GetSkinTilteArea}, + /* Buttons funcs*/ + {"DefineButton", syscalls_defineButton}, + {"DeleteButton", syscalls_deleteButton}, + {"GetButton", syscalls_getButton}, + {"SetButtonStyle", syscalls_SetButtonsStyle}, + /* Events funcs */ + {"SetEventMask", syscalls_setEventMask}, + {"WaitEvent", syscalls_waitEvent}, + {"CheckEvent", syscalls_checkEvent}, + {"WaitEventTimeout", syscalls_waitEventTimeout}, + /* Background funcs */ + {"BackgroundSetSize", syscalls_backgroundSetSize}, + {"BackgroundPutPixel", syscalls_backgroundPutPixel}, + {"BackgroundRedraw", syscalls_backgroundRedraw}, + /* system funcs */ + {"GetRamSize", syscalls_getRamSize}, + {"GetFreeRam", syscalls_getFreeRam}, + {"GetCPUClock", syscalls_getCPUClock}, + {"ShutdownPowerOff", syscalls_shutdownPowerOff}, + {"ShutdownReboot", syscalls_shutdownReboot}, + {"ShutdownRestartKernel", syscalls_shutdownRestartKRN}, + {"GetSystemColors", syscalls_getSystemColors}, + {"SetSystemColors", syscalls_SetSystemColors}, + {"ScreenSize", syscalls_screenSize}, + {"GetWorkArea", syscalls_GetWorkArea}, + {"SetWorkArea", syscalls_SetWorkArea}, + /* Draw funcs*/ + {"DrawLine", syscalls_drawLine}, + {"DrawPixel", syscalls_drawPixel}, + {"DrawText", syscalls_drawText}, + {"DrawRectangle", syscalls_drawRectangle}, + {"ReadPoint", syscalls_ReadPoint}, + /* keyboard funcs */ + {"SetKeyInputMode", syscalls_setKeyInputMode}, + {"GetKeyInputMouse", syscalls_getKeyInputMode}, + {"getKey", syscalls_getKey}, + {"getControlKeyState", syscalls_getControlKeyState}, + {"SetHotkey", syscalls_SetHotkey}, + {"DeleteHotkey", syscalls_DeleteHotkey}, + {"LockNormalInput", syscalls_LockNormalInput}, + {"UnlockNormalInput", syscalls_UnlockNormalInput}, + /* Threads funcs */ + {"ThreadInfo", syscalls_threadInfo}, + {"KillBySlot", syscalls_KillBySlot}, + /* Mouse funcs */ + {"GetMouseButtons", syscalls_getMouseButtons}, + {"GetMouseEvents", syscalls_getMouseEvents}, + {"GetMousePositionScreen", syscalls_getMousePositionScreen}, + {"GetMousePositionWindow", syscalls_getMousePositionWindow}, + {"GetMouseWheels", syscalls_getMouseWheels}, + {"GetMouseSpeed", syscalls_GetMouseSpeed}, + {"GetMouseSens", syscalls_GetMouseSens}, + {"GetMouseDoubleClickDelay", syscalls_GetMouseDoubleClickDelay}, + {"GetMouseSettings", syscalls_GetMouseSettings}, + {"MouseSimulateState", syscalls_MouseSimulateState}, + {"SetMouseSpeed", syscalls_SetMouseSpeed}, + {"SetMouseSens", syscalls_SetMouseSens}, + {"SetMousePos", syscalls_SetMousePos}, + {"SetMouseDoubleClickDelay", syscalls_SetMouseDoubleClickDelay}, + {"SetMouseSettings", syscalls_SetMouseSettings}, + {"LoadCursor", syscalls_LoadCursor}, + {"SetCursor", syscalls_SetCursor}, + {"DeleteCursor", syscalls_DeleteCursor}, + /* network funcs */ + {"GetDevicesNum", syscalls_GetDevicesNum}, + {"GetDeviceType", syscalls_GetDeviceType}, + {"GetDeviceName", syscalls_GetDeviceName}, + {"ResetDevice", syscalls_ResetDevice}, + {"StopDevice", syscalls_StopDevice}, + {"GetConnectionStatus", syscalls_GetConnectionStatus}, + {"ReadMAC", syscalls_ReadMAC}, + /* statistic funcs */ + {"GetTXPacketCount", syscalls_GetTXPacketCount}, + {"GetRXPacketCount", syscalls_GetRXPacketCount}, + {"GetTXByteCount", syscalls_GetTXByteCount}, + {"GetRXByteCount", syscalls_GetRXByteCount}, + {"GetTXErrorPacketCount", syscalls_GetTXErrorPacketCount}, + {"GetTXDropPacketCount", syscalls_GetTXDropPacketCount}, + {"GetTXMissPacketCount", syscalls_GetTXMissPacketCount}, + {"GetRXErrorPacketCount", syscalls_GetRXErrorPacketCount}, + {"GetRXDropPacketCount", syscalls_GetRXDropPacketCount}, + {"GetRXMissPacketCount", syscalls_GetRXMissPacketCount}, + {"IPv4ReadPacketSend", syscalls_IPv4ReadPacketSend}, + {"IPv4ReadPacketReceive", syscalls_IPv4ReadPacketReceive}, + {"ICMPReadPacketSend", syscalls_ICMPReadPacketSend}, + {"ICMPReadPacketReceive", syscalls_ICMPReadPacketReceive}, + {"UDPReadPacketSend", syscalls_UDPReadPacketSend}, + {"UDPReadPacketReceive", syscalls_UDPReadPacketReceive}, + {"TCPReadPacketSend", syscalls_TCPReadPacketSend}, + {"TCPReadPacketReceive", syscalls_TCPReadPacketReceive}, + {"ARPReadPacketSend", syscalls_ARPReadPacketSend}, + {"ARPReadPacketReceive", syscalls_ARPReadPacketReceive}, + {"ReadIPv4Address", syscalls_ReadIPv4Address}, + {"SetIPv4Address", syscalls_SetIPv4Address}, + {"ReadIPv4DNSAddress", syscalls_ReadIPv4DNSAddress}, + {"SetIPv4DNSAddress", syscalls_SetIPv4DNSAddress}, + {"ReadIPv4SubnetMask", syscalls_ReadIPv4SubnetMask}, + {"SetIPv4SubnetMask", syscalls_SetIPv4SubnetMask}, + {"ReadIPv4Gateway", syscalls_ReadIPv4Gateway}, + {"SetIPv4Gateway", syscalls_SetIPv4Gateway}, + {"ReadARPEntries", syscalls_ReadARPEntries}, + {"ReadARPEntry", syscalls_ReadARPEntry}, + {"RemoveARPEntry", syscalls_RemoveARPEntry}, + {"AddARPEntry", syscalls_AddARPEntry}, + {"SendARPAnnounce", syscalls_SendARPAnnounce}, + {"ReadARPConflicts", syscalls_ReadARPConflicts}, + /* Socket funcs */ + {"OpenSocket", syscalls_OpenSocket}, + {"CloseSocket", syscalls_CloseSocket}, + {"Bind", syscalls_Bind}, + {"Listen", syscalls_Listen}, + {"Connect", syscalls_Connect}, + {"Accept", syscalls_Accept}, + {"Send", syscalls_Send}, + {"Receive", syscalls_Receive}, + {"GetSocketOptions", syscalls_GetSocketOptions}, + {"GetPairSocket", syscalls_GetPairSocket}, + {NULL, NULL} }; static inline void syscalls_push_events(lua_State* L) { - lua_newtable(L); + lua_newtable(L); - lua_pushinteger(L, KSYS_EVENT_NONE); - lua_setfield(L, -2, "None"); + lua_pushinteger(L, KSYS_EVENT_NONE); + lua_setfield(L, -2, "None"); - lua_pushinteger(L, KSYS_EVENT_REDRAW); - lua_setfield(L, -2, "Redraw"); + lua_pushinteger(L, KSYS_EVENT_REDRAW); + lua_setfield(L, -2, "Redraw"); - lua_pushinteger(L, KSYS_EVENT_KEY); - lua_setfield(L, -2, "Key"); + lua_pushinteger(L, KSYS_EVENT_KEY); + lua_setfield(L, -2, "Key"); - lua_pushinteger(L, KSYS_EVENT_BUTTON); - lua_setfield(L, -2, "Button"); + lua_pushinteger(L, KSYS_EVENT_BUTTON); + lua_setfield(L, -2, "Button"); - lua_pushinteger(L, KSYS_EVENT_DESKTOP); - lua_setfield(L, -2, "Desktop"); + lua_pushinteger(L, KSYS_EVENT_DESKTOP); + lua_setfield(L, -2, "Desktop"); - lua_pushinteger(L, KSYS_EVENT_MOUSE); - lua_setfield(L, -2, "Mouse"); + lua_pushinteger(L, KSYS_EVENT_MOUSE); + lua_setfield(L, -2, "Mouse"); - lua_pushinteger(L, KSYS_EVENT_IPC); - lua_setfield(L, -2, "IPC"); + lua_pushinteger(L, KSYS_EVENT_IPC); + lua_setfield(L, -2, "IPC"); - lua_pushinteger(L, KSYS_EVENT_NETWORK); - lua_setfield(L, -2, "Network"); + lua_pushinteger(L, KSYS_EVENT_NETWORK); + lua_setfield(L, -2, "Network"); - lua_pushinteger(L, KSYS_EVENT_DEBUG); - lua_setfield(L, -2, "Debug"); + lua_pushinteger(L, KSYS_EVENT_DEBUG); + lua_setfield(L, -2, "Debug"); - lua_pushinteger(L, KSYS_EVENT_IRQBEGIN); - lua_setfield(L, -2, "IRQBegin"); + lua_pushinteger(L, KSYS_EVENT_IRQBEGIN); + lua_setfield(L, -2, "IRQBegin"); - lua_setfield(L, -2, "Event"); + lua_setfield(L, -2, "Event"); } static inline void syscalls_push_buttonCodes(lua_State* L) { - lua_newtable(L); + lua_newtable(L); - lua_pushinteger(L, KSYS_MOUSE_LBUTTON_PRESSED); - lua_setfield(L, -2, "LeftButton"); + lua_pushinteger(L, KSYS_MOUSE_LBUTTON_PRESSED); + lua_setfield(L, -2, "LeftButton"); - lua_pushinteger(L, KSYS_MOUSE_RBUTTON_PRESSED); - lua_setfield(L, -2, "RightButton"); + lua_pushinteger(L, KSYS_MOUSE_RBUTTON_PRESSED); + lua_setfield(L, -2, "RightButton"); - lua_pushinteger(L, KSYS_MOUSE_MBUTTON_PRESSED); - lua_setfield(L, -2, "MiddleButton"); + lua_pushinteger(L, KSYS_MOUSE_MBUTTON_PRESSED); + lua_setfield(L, -2, "MiddleButton"); - lua_pushinteger(L, KSYS_MOUSE_4BUTTON_PRESSED); - lua_setfield(L, -2, "Button4"); + lua_pushinteger(L, KSYS_MOUSE_4BUTTON_PRESSED); + lua_setfield(L, -2, "Button4"); - lua_pushinteger(L, KSYS_MOUSE_5BUTTON_PRESSED); - lua_setfield(L, -2, "Button5"); + lua_pushinteger(L, KSYS_MOUSE_5BUTTON_PRESSED); + lua_setfield(L, -2, "Button5"); - lua_setfield(L, -2, "mouseButtons"); + lua_setfield(L, -2, "mouseButtons"); } static inline void syscalls_push_slotStates(lua_State* L) { - lua_newtable(L); + lua_newtable(L); - lua_pushinteger(L, KSYS_SLOT_STATE_RUNNING); - lua_setfield(L, -2, "Running"); + lua_pushinteger(L, KSYS_SLOT_STATE_RUNNING); + lua_setfield(L, -2, "Running"); - lua_pushinteger(L, KSYS_SLOT_STATE_SUSPENDED); - lua_setfield(L, -2, "Suspended"); + lua_pushinteger(L, KSYS_SLOT_STATE_SUSPENDED); + lua_setfield(L, -2, "Suspended"); - lua_pushinteger(L, KSYS_SLOT_STATE_SUSPENDED_WAIT_EVENT); - lua_setfield(L, -2, "SuspendedWaitEvent"); + lua_pushinteger(L, KSYS_SLOT_STATE_SUSPENDED_WAIT_EVENT); + lua_setfield(L, -2, "SuspendedWaitEvent"); - lua_pushinteger(L, KSYS_SLOT_STATE_NORMAL_TERM); - lua_setfield(L, -2, "NormalTerm"); + lua_pushinteger(L, KSYS_SLOT_STATE_NORMAL_TERM); + lua_setfield(L, -2, "NormalTerm"); - lua_pushinteger(L, KSYS_SLOT_STATE_EXCEPT_TERM); - lua_setfield(L, -2, "ExceptTerm"); + lua_pushinteger(L, KSYS_SLOT_STATE_EXCEPT_TERM); + lua_setfield(L, -2, "ExceptTerm"); - lua_pushinteger(L, KSYS_SLOT_STATE_EXCEPT_TERM); - lua_setfield(L, -2, "WaitEvent"); + lua_pushinteger(L, KSYS_SLOT_STATE_EXCEPT_TERM); + lua_setfield(L, -2, "WaitEvent"); - lua_pushinteger(L, KSYS_SLOT_STATE_WAIT_EVENT); - lua_setfield(L, -2, "Free"); + lua_pushinteger(L, KSYS_SLOT_STATE_WAIT_EVENT); + lua_setfield(L, -2, "Free"); - lua_setfield(L, -2, "slotState"); + lua_setfield(L, -2, "slotState"); } static inline void syscalls_push_hotkey_states(lua_State* L) { - lua_newtable(L); + lua_newtable(L); - lua_pushinteger(L, 0); - lua_setfield(L, -2, "hotkeyNoOne"); + lua_pushinteger(L, 0); + lua_setfield(L, -2, "hotkeyNoOne"); - lua_pushinteger(L, 1); - lua_setfield(L, -2, "hotkeyOnlyOne"); + lua_pushinteger(L, 1); + lua_setfield(L, -2, "hotkeyOnlyOne"); - lua_pushinteger(L, 2); - lua_setfield(L, -2, "hotkeyBoth"); + lua_pushinteger(L, 2); + lua_setfield(L, -2, "hotkeyBoth"); - lua_pushinteger(L, 4); - lua_setfield(L, -2, "hotkeyLeftOnly"); + lua_pushinteger(L, 4); + lua_setfield(L, -2, "hotkeyLeftOnly"); - lua_pushinteger(L, 5); - lua_setfield(L, -2, "hotkeyRightOnly"); + lua_pushinteger(L, 5); + lua_setfield(L, -2, "hotkeyRightOnly"); - lua_setfield(L, -2, "hotkeyStates"); + lua_setfield(L, -2, "hotkeyStates"); } static inline void syscalls_push_buttonsStyle(lua_State* L) { - lua_newtable(L); + lua_newtable(L); - lua_pushinteger(L, 0); - lua_setfield(L, -2, "ButtonStyleFlat"); + lua_pushinteger(L, 0); + lua_setfield(L, -2, "ButtonStyleFlat"); - lua_pushinteger(L, 1); - lua_setfield(L, -2, "ButtonStyleVolume"); + lua_pushinteger(L, 1); + lua_setfield(L, -2, "ButtonStyleVolume"); - lua_setfield(L, -2, "buttonStyle"); + lua_setfield(L, -2, "buttonStyle"); } static inline void syscalls_push_windowStyles(lua_State* L) { - lua_newtable(L); + lua_newtable(L); - lua_pushinteger(L, 0); - lua_setfield(L, -2, "FixSizes"); + lua_pushinteger(L, 0); + lua_setfield(L, -2, "FixSizes"); - lua_pushinteger(L, 1); - lua_setfield(L, -2, "NoDraw"); + lua_pushinteger(L, 1); + lua_setfield(L, -2, "NoDraw"); - lua_pushinteger(L, 2); - lua_setfield(L, -2, "CanChangeSizes"); + lua_pushinteger(L, 2); + lua_setfield(L, -2, "CanChangeSizes"); - lua_pushinteger(L, 3); - lua_setfield(L, -2, "WithSkin"); + lua_pushinteger(L, 3); + lua_setfield(L, -2, "WithSkin"); - lua_pushinteger(L, 4); - lua_setfield(L, -2, "WithSkinFixSizes"); + lua_pushinteger(L, 4); + lua_setfield(L, -2, "WithSkinFixSizes"); - lua_setfield(L, -2, "windowStyle"); + lua_setfield(L, -2, "windowStyle"); } static inline void syscalls_push_buttons(lua_State* L) { - lua_newtable(L); + lua_newtable(L); - lua_pushinteger(L, 0xffff); - lua_setfield(L, -2, "minimization"); + lua_pushinteger(L, 0xffff); + lua_setfield(L, -2, "minimization"); - lua_pushinteger(L, 1); - lua_setfield(L, -2, "close"); + lua_pushinteger(L, 1); + lua_setfield(L, -2, "close"); - lua_setfield(L, -2, "buttons"); + lua_setfield(L, -2, "buttons"); } static inline void syscalls_push_connectionStatus(lua_State* L) { - lua_newtable(L); + lua_newtable(L); - lua_pushinteger(L, NoConnect); - lua_setfield(L, -2, "no"); + lua_pushinteger(L, NoConnect); + lua_setfield(L, -2, "no"); - lua_pushinteger(L, Unknown); - lua_setfield(L, -2, "unknown"); + lua_pushinteger(L, Unknown); + lua_setfield(L, -2, "unknown"); - lua_pushinteger(L, Mb10); - lua_setfield(L, -2, "10Mb"); + lua_pushinteger(L, Mb10); + lua_setfield(L, -2, "10Mb"); - lua_pushinteger(L, Mb100); - lua_setfield(L, -2, "100Mb"); + lua_pushinteger(L, Mb100); + lua_setfield(L, -2, "100Mb"); - lua_pushinteger(L, Gb); - lua_setfield(L, -2, "1Gb"); + lua_pushinteger(L, Gb); + lua_setfield(L, -2, "1Gb"); - lua_setfield(L, -2, "connectionStatus"); + lua_setfield(L, -2, "connectionStatus"); } inline void syscalls_push_textSizes(lua_State* L) { - lua_newtable(L); + lua_newtable(L); - lua_pushinteger(L, TextScale_SIZE_6x9); - lua_setfield(L, -2, "6x9"); + lua_pushinteger(L, TextScale_SIZE_6x9); + lua_setfield(L, -2, "6x9"); - lua_pushinteger(L, TextScale_SIZE_8x16); - lua_setfield(L, -2, "8x16"); + lua_pushinteger(L, TextScale_SIZE_8x16); + lua_setfield(L, -2, "8x16"); - lua_pushinteger(L, TextScale_SIZE_12x18); - lua_setfield(L, -2, "12x18"); + lua_pushinteger(L, TextScale_SIZE_12x18); + lua_setfield(L, -2, "12x18"); - lua_pushinteger(L, TextScale_SIZE_16x32); - lua_setfield(L, -2, "16x32"); + lua_pushinteger(L, TextScale_SIZE_16x32); + lua_setfield(L, -2, "16x32"); - lua_pushinteger(L, TextScale_SIZE_18x27); - lua_setfield(L, -2, "18x27"); + lua_pushinteger(L, TextScale_SIZE_18x27); + lua_setfield(L, -2, "18x27"); - lua_pushinteger(L, TextScale_SIZE_24x36); - lua_setfield(L, -2, "24x36"); + lua_pushinteger(L, TextScale_SIZE_24x36); + lua_setfield(L, -2, "24x36"); - lua_pushinteger(L, TextScale_SIZE_24x48); - lua_setfield(L, -2, "24x48"); + lua_pushinteger(L, TextScale_SIZE_24x48); + lua_setfield(L, -2, "24x48"); - lua_pushinteger(L, TextScale_SIZE_30x45); - lua_setfield(L, -2, "30x45"); + lua_pushinteger(L, TextScale_SIZE_30x45); + lua_setfield(L, -2, "30x45"); - lua_pushinteger(L, TextScale_SIZE_32x64); - lua_setfield(L, -2, "32x64"); + lua_pushinteger(L, TextScale_SIZE_32x64); + lua_setfield(L, -2, "32x64"); - lua_pushinteger(L, TextScale_SIZE_36x54); - lua_setfield(L, -2, "36x54"); + lua_pushinteger(L, TextScale_SIZE_36x54); + lua_setfield(L, -2, "36x54"); - lua_pushinteger(L, TextScale_SIZE_40x80); - lua_setfield(L, -2, "40x80"); + lua_pushinteger(L, TextScale_SIZE_40x80); + lua_setfield(L, -2, "40x80"); - lua_pushinteger(L, TextScale_SIZE_42x63); - lua_setfield(L, -2, "42x63"); + lua_pushinteger(L, TextScale_SIZE_42x63); + lua_setfield(L, -2, "42x63"); - lua_pushinteger(L, TextScale_SIZE_48x72); - lua_setfield(L, -2, "48x72"); + lua_pushinteger(L, TextScale_SIZE_48x72); + lua_setfield(L, -2, "48x72"); - lua_pushinteger(L, TextScale_SIZE_48x96); - lua_setfield(L, -2, "48x96"); + lua_pushinteger(L, TextScale_SIZE_48x96); + lua_setfield(L, -2, "48x96"); - lua_pushinteger(L, TextScale_SIZE_56x112); - lua_setfield(L, -2, "56x112"); + lua_pushinteger(L, TextScale_SIZE_56x112); + lua_setfield(L, -2, "56x112"); - lua_pushinteger(L, TextScale_SIZE_64x128); - lua_setfield(L, -2, "64x128"); + lua_pushinteger(L, TextScale_SIZE_64x128); + lua_setfield(L, -2, "64x128"); - lua_setfield(L, -2, "textSize"); + lua_setfield(L, -2, "textSize"); } LUALIB_API int luaopen_syscalls(lua_State* L) { - luaL_newlib(L, syscallsLib); + luaL_newlib(L, syscallsLib); - syscalls_push_events(L); - syscalls_push_slotStates(L); - syscalls_register_scancodes(L); - syscalls_push_hotkey_states(L); - syscalls_push_buttonsStyle(L); - syscalls_push_windowStyles(L); - syscalls_push_buttons(L); - syscalls_push_connectionStatus(L); - syscalls_push_textSizes(L); + syscalls_push_events(L); + syscalls_push_slotStates(L); + syscalls_register_scancodes(L); + syscalls_push_hotkey_states(L); + syscalls_push_buttonsStyle(L); + syscalls_push_windowStyles(L); + syscalls_push_buttons(L); + syscalls_push_connectionStatus(L); + syscalls_push_textSizes(L); - syscalls_register_ARPEntry(L); - syscalls_register_SystemColors(L); + syscalls_register_ARPEntry(L); + syscalls_register_SystemColors(L); - _ksys_set_event_mask(7); // set default event mask + _ksys_set_event_mask(7); // set default event mask - return 1; + return 1; } diff --git a/src/systemColors.c b/src/systemColors.c index f7332fc..e9ef6ee 100644 --- a/src/systemColors.c +++ b/src/systemColors.c @@ -8,187 +8,187 @@ static int syscalls_SystemColors_m_index; int syscalls_newSystemColors(lua_State* L) { - ksys_colors_table_t* colorsTable = syscalls_pushSystemColors(L); + ksys_colors_table_t* colorsTable = syscalls_pushSystemColors(L); - colorsTable->frame_area = luaL_optinteger(L, 1, 0); - colorsTable->grab_bar = luaL_optinteger(L, 2, 0); - colorsTable->grab_bar_button = luaL_optinteger(L, 3, 0); - colorsTable->grab_button_text = luaL_optinteger(L, 4, 0); - colorsTable->grab_text = luaL_optinteger(L, 5, 0); - colorsTable->work_area = luaL_optinteger(L, 6, 0); - colorsTable->work_button = luaL_optinteger(L, 7, 0); - colorsTable->work_button_text = luaL_optinteger(L, 8, 0); - colorsTable->work_graph = luaL_optinteger(L, 9, 0); - colorsTable->work_text = luaL_optinteger(L, 10, 0); + colorsTable->frame_area = luaL_optinteger(L, 1, 0); + colorsTable->grab_bar = luaL_optinteger(L, 2, 0); + colorsTable->grab_bar_button = luaL_optinteger(L, 3, 0); + colorsTable->grab_button_text = luaL_optinteger(L, 4, 0); + colorsTable->grab_text = luaL_optinteger(L, 5, 0); + colorsTable->work_area = luaL_optinteger(L, 6, 0); + colorsTable->work_button = luaL_optinteger(L, 7, 0); + colorsTable->work_button_text = luaL_optinteger(L, 8, 0); + colorsTable->work_graph = luaL_optinteger(L, 9, 0); + colorsTable->work_text = luaL_optinteger(L, 10, 0); - return 1; + return 1; } static int syscalls_indexSystemColors(lua_State* L) { - DEBUG_LINE("system colors index"); + DEBUG_LINE("system colors index"); - const ksys_colors_table_t* t = (const ksys_colors_table_t*)luaL_checkudata(L, 1, syscalls_SystemColors_metatable_name); + const ksys_colors_table_t* t = (const ksys_colors_table_t*)luaL_checkudata(L, 1, syscalls_SystemColors_metatable_name); - const char* index = luaL_checkstring(L, 2); + const char* index = luaL_checkstring(L, 2); - if (strcmp("frameArea", index) == 0) - { - lua_pushinteger(L, t->frame_area); - } - else if (strcmp("grabBar", index) == 0) - { - lua_pushinteger(L, t->grab_bar); - } - else if (strcmp("grabBarButton", index) == 0) - { - lua_pushinteger(L, t->grab_bar_button); - } - else if (strcmp("grab_button_text", index) == 0) - { - lua_pushinteger(L, t->grab_button_text); - } - else if (strcmp("grabText", index) == 0) - { - lua_pushinteger(L, t->grab_text); - } - else if (strcmp("workArea", index) == 0) - { - lua_pushinteger(L, t->work_area); - } - else if (strcmp("workButton", index) == 0) - { - lua_pushinteger(L, t->work_button); - } - else if (strcmp("workButtonText", index) == 0) - { - lua_pushinteger(L, t->work_button_text); - } - else if (strcmp("workGraph", index) == 0) - { - lua_pushinteger(L, t->work_graph); - } - else if (strcmp("workText", index) == 0) - { - lua_pushinteger(L, t->work_text); - } - else - { - luaL_error(L, "wrong index: %s", index); - } + if (strcmp("frameArea", index) == 0) + { + lua_pushinteger(L, t->frame_area); + } + else if (strcmp("grabBar", index) == 0) + { + lua_pushinteger(L, t->grab_bar); + } + else if (strcmp("grabBarButton", index) == 0) + { + lua_pushinteger(L, t->grab_bar_button); + } + else if (strcmp("grab_button_text", index) == 0) + { + lua_pushinteger(L, t->grab_button_text); + } + else if (strcmp("grabText", index) == 0) + { + lua_pushinteger(L, t->grab_text); + } + else if (strcmp("workArea", index) == 0) + { + lua_pushinteger(L, t->work_area); + } + else if (strcmp("workButton", index) == 0) + { + lua_pushinteger(L, t->work_button); + } + else if (strcmp("workButtonText", index) == 0) + { + lua_pushinteger(L, t->work_button_text); + } + else if (strcmp("workGraph", index) == 0) + { + lua_pushinteger(L, t->work_graph); + } + else if (strcmp("workText", index) == 0) + { + lua_pushinteger(L, t->work_text); + } + else + { + luaL_error(L, "wrong index: %s", index); + } - return 1; + return 1; } static int syscalls_newindexSystemColors(lua_State* L) { - ksys_colors_table_t* t = luaL_checkudata(L, 1, syscalls_SystemColors_metatable_name); + ksys_colors_table_t* t = luaL_checkudata(L, 1, syscalls_SystemColors_metatable_name); - const char* index = luaL_checkstring(L, 2); + const char* index = luaL_checkstring(L, 2); - LUA_INTEGER val = luaL_checkinteger(L, 3); + ksys_color_t val = luaL_checkinteger(L, 3); - if (strcmp("frameArea", index) == 0) - { - t->frame_area = val; - } - else if (strcmp("grabBar", index) == 0) - { - t->grab_bar = val; - } - else if (strcmp("grabBarButton", index) == 0) - { - t->grab_bar_button = val; - } - else if (strcmp("grab_button_text", index) == 0) - { - t->grab_button_text = val; - } - else if (strcmp("grabText", index) == 0) - { - t->grab_text = val; - } - else if (strcmp("workArea", index) == 0) - { - t->work_area = val; - } - else if (strcmp("workButton", index) == 0) - { - t->work_button = val; - } - else if (strcmp("workButtonText", index) == 0) - { - t->work_button_text = val; - } - else if (strcmp("workGraph", index) == 0) - { - t->work_graph = val; - } - else if (strcmp("workText", index) == 0) - { - t->work_text = val; - } - else - { - luaL_error(L, "wrong index: %s", index); - } + if (strcmp("frameArea", index) == 0) + { + t->frame_area = val; + } + else if (strcmp("grabBar", index) == 0) + { + t->grab_bar = val; + } + else if (strcmp("grabBarButton", index) == 0) + { + t->grab_bar_button = val; + } + else if (strcmp("grab_button_text", index) == 0) + { + t->grab_button_text = val; + } + else if (strcmp("grabText", index) == 0) + { + t->grab_text = val; + } + else if (strcmp("workArea", index) == 0) + { + t->work_area = val; + } + else if (strcmp("workButton", index) == 0) + { + t->work_button = val; + } + else if (strcmp("workButtonText", index) == 0) + { + t->work_button_text = val; + } + else if (strcmp("workGraph", index) == 0) + { + t->work_graph = val; + } + else if (strcmp("workText", index) == 0) + { + t->work_text = val; + } + else + { + luaL_error(L, "wrong index: %s", index); + } - return 0; + return 0; } -static int sycalls_eqSystemColors(lua_State* L) +static int syscalls_eqSystemColors(lua_State* L) { - lua_pushboolean( - L, - memcmp( - luaL_checkudata(L, 1, syscalls_SystemColors_metatable_name), - luaL_checkudata(L, 2, syscalls_SystemColors_metatable_name), - sizeof(ksys_colors_table_t) - ) - ); + lua_pushboolean( + L, + memcmp( + luaL_checkudata(L, 1, syscalls_SystemColors_metatable_name), + luaL_checkudata(L, 2, syscalls_SystemColors_metatable_name), + sizeof(ksys_colors_table_t) + ) + ); - return 1; + return 1; } -static int sycalls_gcSystemColors(lua_State* L) +static int syscalls_gcSystemColors(lua_State* L) { - ksys_colors_table_t* t = luaL_checkudata(L, 1, syscalls_SystemColors_metatable_name); - free(t); + ksys_colors_table_t* t = luaL_checkudata(L, 1, syscalls_SystemColors_metatable_name); + free(t); - return 1; + return 1; } ksys_colors_table_t* syscalls_pushSystemColors(lua_State* L) { - DEBUG_LINE("push system colors table"); - - ksys_colors_table_t* colorsTable = lua_newuserdata(L, sizeof(ksys_colors_table_t)); - luaL_setmetatable(L, syscalls_SystemColors_metatable_name); + DEBUG_LINE("push system colors table"); - return colorsTable; + ksys_colors_table_t* colorsTable = lua_newuserdata(L, sizeof(ksys_colors_table_t)); + luaL_setmetatable(L, syscalls_SystemColors_metatable_name); + + return colorsTable; } static const luaL_Reg syscalls_SystemColors_m[] = { - {"__index", syscalls_indexSystemColors}, - {"__newindex", syscalls_newindexSystemColors}, - {"__eq", sycalls_eqSystemColors}, - {"__gc", sycalls_gcSystemColors}, - {NULL, NULL} + {"__index", syscalls_indexSystemColors}, + {"__newindex", syscalls_newindexSystemColors}, + {"__eq", syscalls_eqSystemColors}, + {"__gc", syscalls_gcSystemColors}, + {NULL, NULL} }; static const luaL_Reg syscalls_SystemColors_lib[] = { - {"new", syscalls_newSystemColors}, - {NULL, NULL} + {"new", syscalls_newSystemColors}, + {NULL, NULL} }; void syscalls_register_SystemColors(lua_State* L) { - luaL_newlib(L, syscalls_SystemColors_lib); - lua_setfield(L, -2, "SystemColors"); + luaL_newlib(L, syscalls_SystemColors_lib); + lua_setfield(L, -2, "SystemColors"); - luaL_newmetatable(L, syscalls_SystemColors_metatable_name); - luaL_setfuncs(L, syscalls_SystemColors_m, 0); + luaL_newmetatable(L, syscalls_SystemColors_metatable_name); + luaL_setfuncs(L, syscalls_SystemColors_m, 0); - lua_pop(L, 1); + lua_pop(L, 1); } diff --git a/src/systemColors.h b/src/systemColors.h index 5deea74..a7ea281 100644 --- a/src/systemColors.h +++ b/src/systemColors.h @@ -1,5 +1,5 @@ -#ifndef _SYSCALLS_SYSTEMCOLORS_H_ -#define _SYSCALLS_SYSTEMCOLORS_H_ +#ifndef _SYSCALLS_SYSTEM_COLORS_H_ +#define _SYSCALLS_SYSTEM_COLORS_H_ #include #include @@ -17,4 +17,4 @@ ksys_colors_table_t* syscalls_pushSystemColors(lua_State* L); */ void syscalls_register_SystemColors(lua_State* L); -#endif // _SYSCALLS_SYSTEMCOLORS_H_ +#endif // _SYSCALLS_SYSTEM_COLORS_H_ diff --git a/tests/SystemColors.lua b/tests/SystemColors.lua index 89166e2..0e98b08 100644 --- a/tests/SystemColors.lua +++ b/tests/SystemColors.lua @@ -5,5 +5,5 @@ local SystemColors = syscalls.GetSystemColors() print(SystemColors) for i, v in pairs(SystemColors) do - print(i, v) + print(i, v) end diff --git a/tests/libraryStruct.lua b/tests/libraryStruct.lua index e8dcfdb..f279934 100644 --- a/tests/libraryStruct.lua +++ b/tests/libraryStruct.lua @@ -1,4 +1,3 @@ - for i, v in pairs(require("syscalls")) do - print(i, v) + print(i, v) end