axmol/lua/exts/lualoadexts.c

49 lines
1.1 KiB
C
Raw Normal View History

2011-11-18 21:31:01 +08:00
//
// lualoadexts.c
// Mystic-Fish-Puzzle
//
// Created by on 11-10-3.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#include "lualoadexts.h"
2011-12-05 19:09:24 +08:00
2011-11-18 21:31:01 +08:00
// luasocket
#include "luasocket.h"
#include "mime.h"
#include "luasocketscripts.h"
2011-12-05 13:56:51 +08:00
// cjson
2011-12-05 19:09:24 +08:00
#include "lua_cjson.h"
// llthread
#include "llthreads.h"
2011-12-05 13:56:51 +08:00
static luaL_Reg luax_exts[] = {
2011-11-18 21:31:01 +08:00
{"socket.core", luaopen_socket_core},
{"mime.core", luaopen_mime_core},
{"socket", luaopen_socket},
{"socket.smtp", luaopen_socket_smtp},
{"socket.http", luaopen_socket_http},
{"socket.ftp", luaopen_socket_ftp},
{"socket.tp", luaopen_socket_tp},
{"socket.url", luaopen_socket_url},
{"mime", luaopen_socket_mime},
{"ltn12", luaopen_socket_ltn12},
2011-12-05 19:09:24 +08:00
{"cjson", luaopen_cjson},
{"llthreads", luaopen_llthreads},
2011-11-18 21:31:01 +08:00
{NULL, NULL}
};
void luax_loadexts(lua_State *L)
2011-11-18 21:31:01 +08:00
{
luaL_Reg* lib = luax_exts;
luaL_findtable(L, LUA_GLOBALSINDEX, "package.preload", sizeof(luax_exts)/sizeof(luax_exts[0])-1);
2011-11-18 21:31:01 +08:00
for (; lib->func; lib++) {
lua_pushstring(L, lib->name);
lua_pushcfunction(L, lib->func);
lua_rawset(L, -3);
}
lua_pop(L, 1);
}