Guest User

Untitled

a guest
Feb 22nd, 2012
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. int Import_lua(lua_State *l)
  2. {
  3.     int argc = lua_gettop(l);
  4.     if(argc==0) return 0;
  5.    
  6.     int retNum = 0;
  7.     size_t i;
  8.     char buf[256];
  9.    
  10.     for(i=1; i<=argc; ++i)
  11.     {
  12.         if(lua_type(l, i) == LUA_TSTRING)
  13.         {
  14.             char *str = lua_tostring(l, i);
  15.             lua_createtable(l,0,1);
  16.             int sz = snprintf(buf, sizeof(buf)-1,
  17.                 "function %s(%s)\n\ti_syscall(\"%s\",%s);\nend\n",
  18.                 str, "str", str, "str");
  19.            
  20.             /*Add to table*/
  21.             lua_pushstring(l, str);
  22.             luaL_loadbuffer(l, buf,sz,buf);
  23.             lua_settable(l, -3);
  24.            
  25.             ++retNum;
  26.         }
  27.     }
  28.    
  29.     return retNum;
  30. }
  31. int i_syscall_lua(lua_State *l)
  32. {
  33.     if(lua_type(l, 1) !=LUA_TSTRING) return 0;
  34.     printf("i_syscall: %s\n", lua_tostring(l, 1));
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment