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/>.
30 #include "_quvi_http_metainfo_s.h"
31 #include "_quvi_net_s.h"
33 #include "lua/load_util_script.h"
35 static const gchar script_fname
[]= "to_file_ext.lua";
36 static const gchar script_func
[] = "to_file_ext";
38 QuviError
l_exec_util_to_file_ext(_quvi_http_metainfo_t qmi
, _quvi_net_t n
)
45 rc
= l_load_util_script(q
, script_fname
, script_func
);
51 lua_pushstring(l
, n
->http_metainfo
.content_type
->str
);
54 * 2=qargs,content-type [qargs: set in l_load_util_script]
57 if (lua_pcall(l
, 2, 1, 0))
59 g_string_assign(q
->status
.errmsg
, lua_tostring(l
, -1));
60 return (QUVI_ERROR_SCRIPT
);
63 if (!lua_isstring(l
, -1))
64 luaL_error(l
, "%s: did not return a string", script_func
);
66 g_string_assign(qmi
->file_ext
, lua_tostring(l
,-1));
72 /* vim: set ts=2 sw=2 tw=72 expandtab: */