tests/supports.c: Use a different URL
[libquvi.git] / src / lua / chk_accepts.c
blob334ca7f4e030d7d4122be71c599e432929237f69
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
20 #include "config.h"
22 #include <lauxlib.h>
23 #include <glib.h>
25 #include "quvi.h"
26 /* -- */
27 #include "_quvi_s.h"
28 #include "_quvi_script_s.h"
29 /* -- */
30 #include "lua/chk_accepts.h"
31 #include "lua/getfield.h"
33 gboolean l_chk_accepts(lua_State *l, _quvi_script_t qs,
34 const gchar *k_accepts, const gchar *k_domains,
35 const gchar *script_func)
37 gboolean r = FALSE;
39 lua_pushstring(l, k_accepts);
40 lua_gettable(l, -2);
42 if (lua_istable(l, -1))
44 const gchar *s = l_getfield_s(l, k_domains,
45 qs->fpath->str, script_func);
47 g_string_assign(qs->domains, s);
49 r = l_getfield_b(l, k_accepts, qs->fpath->str, script_func);
51 else
53 luaL_error(l, "%s: %s: expected to return a table containing table `%s'",
54 qs->fpath->str, script_func, k_accepts);
56 lua_pop(l, 1);
58 return (r);
61 /* vim: set ts=2 sw=2 tw=72 expandtab: */