* more details.
*/
-#ifndef __LUA_H
-#define __LUA_H
+#ifndef __GLUA_H
+#define __GLUA_H
#ifdef HAVE_LUA
void lua_init(void);
+gchar *lua_callvalue(gchar *, gchar *);
+
#endif
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
#include "pixbuf_util.h"
#include "ui_fileops.h"
#include "image-load.h"
+#include "glua.h"
/*
*----------------------------------------------------------------------------
{
data = metadata_read_string(imd->image_fd, COMMENT_KEY, METADATA_PLAIN);
}
+#ifdef HAVE_LUA
+ else if (strncmp(name, "lua/", 4) == 0)
+ {
+ gchar *tmp;
+ tmp = strchr(name+4, '/');
+ if (!tmp)
+ break;
+ *tmp = '\0';
+ data = lua_callvalue(name+4, tmp+1);
+ }
+#endif
else
{
data = g_strdup(g_hash_table_lookup(vars, name));
#include <lua.h>
#include <lauxlib.h>
+#include <lualib.h>
+
+#include <stdio.h>
+#include <glib.h>
+
+#include "glua.h"
static lua_State *L; /** The LUA object needed for all operations (NOTE: That is
* a upper-case variable to match the documentation!) */
luaL_openlibs(L); /* Open all libraries for lua programms */
}
+/**
+ * \brief Call a lua function to get a single value.
+ */
+gchar *lua_callvalue(gchar *file, gchar *function)
+{
+ gint result;
+ gchar *data = NULL;
+
+ if (file[0] == '\0')
+ {
+ result = luaL_dostring(L, function);
+ }
+ else
+ {
+ result = luaL_dofile(L, file);
+ }
+
+ if (result)
+ {
+ data = g_strdup_printf("Error running lua script: %s", lua_tostring(L, -1));
+ return data;
+ }
+ data = g_strdup(lua_tostring(L, -1));
+ return data;
+}
+
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */