Rename quvi.* functions
[libquvi.git] / src / lua / init.c
blobbf47973e88bf56b75d4261e11db3c9c721098ef9
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of libquvi <http://quvi.sourceforge.net/>.
6 * This library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #include "config.h"
23 #include <lauxlib.h>
24 #include <lualib.h>
25 #include <glib.h>
27 #include "quvi.h"
28 /* -- */
29 #include "_quvi_s.h"
31 /* 'quvi' object functions for scripts, e.g. 'quvi.http.fetch' */
33 extern gint l_quvi_http_metainfo(lua_State*);
34 extern gint l_quvi_http_resolve(lua_State*);
35 extern gint l_quvi_http_fetch(lua_State*);
37 static const luaL_Reg quvi_reg_meth[] =
39 {NULL, NULL}
42 static const luaL_Reg quvi_http_reg_meth[] =
44 {"metainfo", l_quvi_http_metainfo},
45 {"resolve", l_quvi_http_resolve},
46 {"fetch", l_quvi_http_fetch},
47 {NULL, NULL}
50 QuviError l_init(_quvi_t q)
52 q->handle.lua = (lua_State*) luaL_newstate();
53 if (q->handle.lua == NULL)
54 return (QUVI_ERROR_LUA_INIT);
56 luaL_openlibs(q->handle.lua);
57 luaL_openlib(q->handle.lua, "quvi", quvi_reg_meth, 1);
58 luaL_openlib(q->handle.lua, "quvi.http", quvi_http_reg_meth, 1);
60 return (QUVI_OK);
63 /* vim: set ts=2 sw=2 tw=72 expandtab: */