Skip to content

Instantly share code, notes, and snippets.

@jballanc
Created December 26, 2013 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jballanc/8131872 to your computer and use it in GitHub Desktop.
Save jballanc/8131872 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <luajit-2.0/lua.h>
#include <luajit-2.0/lualib.h>
#include <luajit-2.0/lauxlib.h>
#include "main.h"
#define CHECK_LOADED(i) if(i) {\
fprintf(stderr, "Problem loading: %s\n",\
lua_tostring(L, -1));\
exit(i);\
}
extern int luaopen_lxp(lua_State *);
extern int luaopen_cURL(lua_State *);
int
main(int argc, char *argv[]) {
int status, result;
lua_State *L;
L = luaL_newstate();
luaL_openlibs(L);
luaopen_lxp(L);
luaopen_cURL(L);
CHECK_LOADED(luaL_loadbuffer(L, luaJIT_BC_main, luaJIT_BC_main_SIZE, "main"));
CHECK_LOADED(lua_pcall(L, 0, LUA_MULTRET, 0));
lua_getglobal(L, "main");
CHECK_LOADED(lua_pcall(L, 1, 0, 0));
return 0;
}
@jballanc
Copy link
Author

main.h can be generated from main.lua with luajit -b main.h main.lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment