add lua funcs names to Spell words && use tabs instead spaces

This commit is contained in:
2025-04-05 17:49:35 +05:00
parent 273e9edfc7
commit 5dc9f2ca31
11 changed files with 1586 additions and 1558 deletions

View File

@@ -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);
}