static luaL_Reg luax_exts[] = {
{"cjson", luaopen_cjson},
{"pb",luaopen_pb},
{"protobuf.c",luaopen_protobuf_c},
{"lpeg",luaopen_lpeg},
{NULL, NULL}
};
void luaopen_lua_extensions(lua_State *L)
{
luaL_Reg* lib = luax_exts;
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");
for (; lib->func; lib++)
{
lua_pushcfunction(L, lib->func);
lua_setfield(L, -2, lib->name);
}
lua_pop(L, 2);
}