2016-01-04 04:08:43 +11:00
|
|
|
#include "luares.h"
|
|
|
|
#include "lupi.h"
|
|
|
|
#include <lua.h>
|
|
|
|
#include <lualib.h>
|
|
|
|
#include <lauxlib.h>
|
2016-01-05 04:20:40 +11:00
|
|
|
#include <stdlib.h>
|
2016-01-04 04:08:43 +11:00
|
|
|
|
2016-01-10 05:39:48 +11:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2016-01-15 08:44:49 +11:00
|
|
|
static lua_State* L = NULL;
|
|
|
|
|
|
|
|
lua_State* getL() {
|
|
|
|
return L;
|
|
|
|
}
|
|
|
|
|
2016-02-29 00:31:55 +11:00
|
|
|
void run_init(int argc, char **argv) {
|
2016-01-04 04:08:43 +11:00
|
|
|
L = luaL_newstate();
|
2016-01-07 03:16:09 +11:00
|
|
|
|
2016-01-07 02:58:05 +11:00
|
|
|
luaL_openlibs (L);
|
|
|
|
setup_modules (L);
|
2016-01-07 03:16:09 +11:00
|
|
|
luanative_start (L);
|
2016-01-21 03:54:04 +11:00
|
|
|
internet_start (L);
|
2016-03-03 04:48:12 +11:00
|
|
|
#ifdef _WIN32
|
|
|
|
winapigpu_init (L);
|
|
|
|
#endif
|
2016-01-20 04:04:12 +11:00
|
|
|
fb_start (L);
|
2016-01-07 02:58:05 +11:00
|
|
|
termutils_start (L);
|
2016-02-27 06:09:38 +11:00
|
|
|
event_prepare();
|
2016-01-07 02:58:05 +11:00
|
|
|
|
2016-01-10 05:39:48 +11:00
|
|
|
int status = luaL_loadbuffer(L, lua_init, strlen(lua_init), "=INIT");
|
2016-01-04 04:08:43 +11:00
|
|
|
if (status) {
|
|
|
|
fprintf(stderr, "Couldn't load init: %s\n", lua_tostring(L, -1));
|
|
|
|
exit(1);
|
|
|
|
}
|
2016-02-29 00:31:55 +11:00
|
|
|
for(int i = 0; i < argc; i++) {
|
|
|
|
lua_pushstring(L, argv[i]);
|
|
|
|
}
|
|
|
|
lua_call(L, argc, 0);
|
2016-01-04 04:08:43 +11:00
|
|
|
lua_close(L);
|
|
|
|
}
|