| KLUA_MOD_REGISTER(9) | Kernel Developer's Manual | KLUA_MOD_REGISTER(9) | 
klua_mod_register,
  klua_mod_unregister —
#include <sys/lua.h>
void
  
  klua_mod_register(const
    char *name, lua_CFunction
    open);
void
  
  klua_mod_unregister(const
    char *name);
The lua_module structure is declared as follows:
struct lua_module {
        char                    mod_name[LUA_MAX_MODNAME];
        lua_CFunction           open;
        int                     refcount;
        LIST_ENTRY(lua_module)  mod_next;
};
The mod_name defines the unique name of a module. A C function must use the standard Lua protocol in order to communicate with Lua, this part is maintained with the open element in the standard Lua way. refcount protects the module from being unloaded whilst still in use. The last parameter, mod_next, is used for the standard container LIST(3).
The klua_mod_register() function registers
    a new function which is made available to the
    lua(9) device and Lua code using
    the require directive. The
    require directive can be called from
    luactl(8) and the kernel Lua
    version. The name parameter is a unique identifier of
    the kernel Lua module. open points to a function used
    in the C to Lua binding, defined with the appropriate standard Lua API.
Once registered, a C function can be unregistered with the
    klua_mod_unregister() function. This function takes
    as its parameter the unique literal identifier of the extending module.
| April 15, 2017 | NetBSD 10.0 |