2
* @file script.c LUA scripting plugin implementation
4
* Copyright (C) 2006-2008 Lars Lindner <lars.lindner@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program 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 General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include "liferea_wrap.h"
28
static lua_State *luaVM = NULL;
37
luaL_openlibs (luaVM); /* LUA 5.1 allows loading all default modules */
39
luaL_reg lualibs[] = {
40
/* This loads swig generated Liferea module... */
41
{SWIG_name, SWIG_init},
45
for (i=0; lualibs[i].func != 0 ; i++) {
46
lua_pushcfunction (luaVM, lualibs[i].func);
47
lua_pushstring (luaVM, lualibs[i].name);
48
lua_call (luaVM, 1, 0);
53
lua_run_cmd (const gchar *cmd)
57
lua_getglobal(luaVM, "liferea");
59
lua_setfield(luaVM, -2, "calling_hook");
62
result = luaL_dostring (luaVM, cmd);
65
g_warning ("Error code %d when running LUA command \"%s\"!", result, cmd);
69
lua_run_script (const gchar *filename, const gchar *for_hook)
73
lua_getglobal(luaVM, "liferea");
76
lua_pushstring(luaVM, for_hook);
82
lua_setfield(luaVM, -2, "calling_hook");
85
result = luaL_dofile (luaVM, filename);
88
g_warning ("Error code %d when running LUA script \"%s\"!", result, filename);
97
static struct scriptSupportImpl ssi = {
98
SCRIPT_SUPPORT_API_VERSION,
106
static struct plugin pi = {
108
"LUA Scripting Support Plugin",
109
PLUGIN_TYPE_SCRIPT_SUPPORT,
114
DECLARE_SCRIPT_SUPPORT_IMPL(ssi);