void print_process_version(void) { char *app_name = shfs_app_name(process_path); printf ( "%s version %s\n" "\n" "Copyright 2014 Neo Natura\n" "Licensed under the GNU GENERAL PUBLIC LICENSE Version 3\n", app_name, VERSION); }
int main(int argc, char* argv[]) { lua_State* L; int i; process_path = argv[0]; strncpy(process_name, shfs_app_name(process_path), sizeof(process_name) - 1); run_flags |= RUNF_LOCAL; for (i = 1; i < argc; i++) { if (IS("-v") || IS("--version")) { print_process_version(); return (EXIT_SUCCESS); } if (IS("-h") || IS("--help")) { print_process_usage(); return (EXIT_SUCCESS); } if (IS("-V") || IS("--verbose")) { run_flags |= RUNF_VERBOSE; continue; } if (IS("-f") || IS("--fs")) { run_flags &= ~RUNF_LOCAL; if (i + 1 < argc && argv[i+1][0] != '-') { i++; strncpy(app_name, argv[i], sizeof(app_name) - 1); } continue; } if (argv[i][0] == '-') { printf("Warning: Invalid command-line option \"%s\".\n", argv[i]); continue; } /* source file specification. */ run_flags |= RUNF_INPUT; } if (!(run_flags & RUNF_INPUT)) { printf("Error: no input file(s) specified.\n"); exit(1); } L=luaL_newstate(); if (L==NULL) fatal("cannot create state: not enough memory"); lua_pushcfunction(L,&pmain); lua_pushinteger(L,argc); lua_pushlightuserdata(L,argv); if (lua_pcall(L,2,0,0)!=LUA_OK) fatal(lua_tostring(L,-1)); lua_close(L); return EXIT_SUCCESS; }