lua_lsup.c 531 B

123456789101112131415161718192021222324252627282930313233
  1. #include <lua.h>
  2. //#include <lualib.h>
  3. #include <lauxlib.h>
  4. #include <lsup_rdf.h>
  5. lua_State *L;
  6. static int l_env_init (lua_State *L)
  7. {
  8. LSUP_rc rc;
  9. if ((rc = LSUP_init ()) != LSUP_OK) {
  10. lua_pushnil (L);
  11. lua_pushstring (L, LSUP_strerror (rc));
  12. return 2;
  13. }
  14. return 0;
  15. }
  16. static const struct luaL_Reg lsup [] = {
  17. {"env_init", l_env_init},
  18. {NULL, NULL}
  19. };
  20. int init (lua_State *L) {
  21. lua_newtable (L);
  22. luaL_setfuncs(L, lsup, 0);
  23. lua_setglobal (L, "LSUP");
  24. return 1;
  25. }