Add rpmluaGetGlobalState() to internal lua api
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 14 Jan 2009 12:39:55 +0000 (14:39 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 14 Jan 2009 13:08:59 +0000 (15:08 +0200)
- retrieve global state, init if needed
- inspired by rpm5.org, details differ
- use it for initialisation in rpmrc instead of abusing rpmluaGetPrintBuffer

lib/rpmrc.c
rpmio/rpmlua.c
rpmio/rpmlua.h

index 03d5dd1..c2bf118 100644 (file)
@@ -1694,7 +1694,7 @@ int rpmReadConfigFiles(const char * file, const char * target)
 
     /* Force Lua state initialization */
 #ifdef WITH_LUA
-    (void)rpmluaGetPrintBuffer(NULL);
+    (void) rpmluaGetGlobalState();
 #endif
 
     return 0;
index 1a40b27..4afa8d5 100644 (file)
@@ -35,6 +35,12 @@ static rpmlua globalLuaState = NULL;
 static int luaopen_rpm(lua_State *L);
 static int rpm_print(lua_State *L);
 
+rpmlua rpmluaGetGlobalState(void)
+{
+    INITSTATE(NULL, lua);
+    return lua;
+}
+
 rpmlua rpmluaNew()
 {
     rpmlua lua = (rpmlua) xcalloc(1, sizeof(*lua));
index 145cdbb..12b0fa1 100644 (file)
@@ -44,6 +44,7 @@ typedef struct rpmluav_s * rpmluav;
 
 rpmlua rpmluaNew(void);
 void *rpmluaFree(rpmlua lua);
+rpmlua rpmluaGetGlobalState(void);
 
 int rpmluaCheckScript(rpmlua lua, const char *script,
                      const char *name);