Beispiel #1
0
Datei: luq.c Projekt: ld-test/luq
LLUQ_EXPORT int luaopen_luq(lua_State *L){
  if(!LUQ_INIT){
    luq_library_lock();
    if(!LUQ_INIT){
      if(0 == luq_map_init(&luq_global_queue)){
        if(0 == luq_map_init(&luq_global_shared)){
          LUQ_INIT = 1;
          luq_library_on_unload(lluq_cleanup, NULL);
        }
        else{
          luq_map_destroy(&luq_global_queue);
        }
      }
    }
    luq_library_unlock();
  }
  if(!LUQ_INIT){
    lua_pushstring(L, "Can not init LUQ library");
    return lua_error(L);
  }

  lutil_createmetap(L, LLUQ_QVOID_TYPE, lluq_qvoid_meth, 0);

  lua_newtable(L);
  luaL_setfuncs(L, lluq_lib, 0);
  return 1;
}
Beispiel #2
0
void lcurl_mime_initlib(lua_State *L, int nup){
#if LCURL_CURL_VER_GE(7,56,0)
  lcurl_pushvalues(L, nup);

  if(!lutil_createmetap(L, LCURL_MIME, lcurl_mime_methods, nup))
    lua_pop(L, nup);
  lua_pop(L, 1);

  if(!lutil_createmetap(L, LCURL_MIME_PART, lcurl_mime_part_methods, nup))
    lua_pop(L, nup);
  lua_pop(L, 1);

#else
  lua_pop(L, nup);
#endif
}
Beispiel #3
0
void lcurl_share_initlib(lua_State *L, int nup){
  if(!lutil_createmetap(L, LCURL_SHARE, lcurl_share_methods, nup))
    lua_pop(L, nup);
  lua_pop(L, 1);

  lcurl_util_set_const(L, lcurl_share_opt);
}
Beispiel #4
0
void lcurl_error_initlib(lua_State *L, int nup){
  if(!lutil_createmetap(L, LCURL_ERROR, lcurl_err_methods, nup))
    lua_pop(L, nup);
  lua_pop(L, 1);

  lcurl_util_set_const(L, lcurl_error_codes);
  lcurl_util_set_const(L, lcurl_error_category);
}
Beispiel #5
0
LLUV_INTERNAL void lluv_tcp_initlib(lua_State *L, int nup, int safe){
  lutil_pushnvalues(L, nup);
  if(!lutil_createmetap(L, LLUV_TCP, lluv_tcp_methods, nup))
    lua_pop(L, nup);
  lua_pop(L, 1);

  luaL_setfuncs(L, lluv_functions[safe], nup);
  lluv_register_constants(L, lluv_tcp_constants);
}
Beispiel #6
0
void lcurl_url_initlib(lua_State *L, int nup){
#if LCURL_CURL_VER_GE(7,62,0)
  if(!lutil_createmetap(L, LCURL_URL, lcurl_url_methods, nup))
    lua_pop(L, nup);
  lua_pop(L, 1);

  lcurl_util_set_const(L, lcurl_url_opt);
#else
  lua_pop(L, nup);
#endif
}
Beispiel #7
0
LLUV_INTERNAL void lluv_poll_initlib(lua_State *L, int nup, int safe){
  assert((safe == 0) || (safe == 1));

  lutil_pushnvalues(L, nup);
  if(!lutil_createmetap(L, LLUV_POLL, lluv_poll_methods, nup))
    lua_pop(L, nup);
  lua_pop(L, 1);

  luaL_setfuncs(L, lluv_poll_functions[safe], nup);
  lluv_register_constants(L, lluv_poll_constants);
}
Beispiel #8
0
LLUV_INTERNAL void lluv_fs_initlib(lua_State *L, int nup, int safe){
  assert((safe == 0) || (safe == 1));

  lutil_pushnvalues(L, nup);

  if(!lutil_createmetap(L, LLUV_FILE, lluv_file_methods, nup))
    lua_pop(L, nup);
  lua_pop(L, 1);

  luaL_setfuncs(L, lluv_fs_functions[safe], nup);
}
Beispiel #9
0
LLUV_INTERNAL void lluv_signal_initlib(lua_State *L, int nup, int safe){
  lutil_pushnvalues(L, nup);
  if(!lutil_createmetap(L, LLUV_SIGNAL, lluv_signal_methods, nup))
    lua_pop(L, nup);
  lua_pop(L, 1);

  luaL_setfuncs(L, lluv_functions[safe], nup);
  lluv_register_constants(L, lluv_signal_constants);

#ifndef _WIN32
  signal(SIGPIPE, SIG_IGN);
#endif
}
Beispiel #10
0
void lodbc_env_initlib (lua_State *L, int nup) {
    lutil_createmetap(L, LODBC_ENV, lodbc_env_methods, nup);
    lua_pushstring(L,LODBC_ENV);
    lua_setfield(L,-2,"__metatable");
    lua_pop(L, 1);
}