adding inlprog.c with changes referenced in last commit.
This commit is contained in:
parent
2cc77e5fba
commit
8efdc95748
|
|
@ -23,9 +23,60 @@
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "shared_enums.h"
|
#include "shared_enums.h"
|
||||||
|
|
||||||
|
//lua libraries
|
||||||
|
#include "lua\lua.h"
|
||||||
|
#include "lua\lauxlib.h"
|
||||||
|
#include "lua\lualib.h"
|
||||||
|
|
||||||
|
void error (lua_State *L, const char *fmt, ...) {
|
||||||
|
va_list argp;
|
||||||
|
va_start(argp, fmt);
|
||||||
|
vfprintf(stderr, fmt, argp);
|
||||||
|
va_end(argp);
|
||||||
|
lua_close(L);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int getglobint (lua_State *L, const char *var) {
|
||||||
|
int isnum, result;
|
||||||
|
lua_getglobal(L, var);
|
||||||
|
result = (int)lua_tointegerx(L, -1, &isnum);
|
||||||
|
if (!isnum)
|
||||||
|
error(L, "'%s' should be a number\n", var);
|
||||||
|
//printf("'%s' should be a number\n", var);
|
||||||
|
lua_pop(L, 1); /* remove result from the stack */
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void load (lua_State *L, const char *fname, int *w, int *h) {
|
||||||
|
if (luaL_loadfile(L, fname) || lua_pcall(L, 0, 0, 0))
|
||||||
|
error(L, "cannot run config. file: %s", lua_tostring(L, -1));
|
||||||
|
//printf("cannot run config. file: %s", lua_tostring(L, -1));
|
||||||
|
*w = getglobint(L, "width");
|
||||||
|
*h = getglobint(L, "height");
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
// char buff[256];
|
||||||
|
// int error;
|
||||||
|
lua_State *L = luaL_newstate(); /* opens Lua */
|
||||||
|
luaL_openlibs(L); /* opens the standard libraries */
|
||||||
|
|
||||||
|
int high, wide;
|
||||||
|
load(L, "scripts/test.lua", &high, &wide );
|
||||||
|
printf("high= %d, wide=%d\n", high, wide);
|
||||||
|
// while (fgets(buff, sizeof(buff), stdin) != NULL) {
|
||||||
|
// error = luaL_loadstring(L, buff) || lua_pcall(L, 0, 0, 0);
|
||||||
|
// if (error) {
|
||||||
|
// fprintf(stderr, "%s\n", lua_tostring(L, -1));
|
||||||
|
// lua_pop(L, 1); /* pop error message from the stack */
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
lua_close(L);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*luacut
|
||||||
|
|
||||||
//lower case flags suggested for average user
|
//lower case flags suggested for average user
|
||||||
int e_flag = 0; //FORCE ERASE
|
int e_flag = 0; //FORCE ERASE
|
||||||
|
|
@ -359,6 +410,8 @@ error:
|
||||||
// fclose(rom->fileptr);
|
// fclose(rom->fileptr);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
luacut */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue