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"
|
|
|
|
|
|
|
|
// luasocket
|
|
|
|
#include "luasocket.h"
|
|
|
|
#include "mime.h"
|
|
|
|
#include "luasocketscripts.h"
|
|
|
|
|
2011-11-23 13:55:07 +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},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2011-11-23 13:55:07 +08:00
|
|
|
void luax_loadexts(lua_State *L)
|
2011-11-18 21:31:01 +08:00
|
|
|
{
|
2011-11-23 13:55:07 +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);
|
|
|
|
}
|