livewp/mess/lua-api.c

26 lines
427 B
C

// x-run: ~/scripts/runc.sh % -lm -llua
#include <stdlib.h>
#include <lua5.2/lua.h>
#include <lua5.2/lualib.h>
#include <lua5.2/lauxlib.h>
int meow(lua_State *state) {
printf("meow!\n");
return 0;
}
int main(void) {
lua_State *lua = luaL_newstate();
luaL_openlibs(lua);
lua_pushcfunction(lua, meow);
lua_setglobal(lua, "meow");
luaL_dofile(lua, "./lua-api.lua");
lua_close(lua);
return EXIT_SUCCESS;
}