Add main.version ()
authorMyhailo Danylenko <isbear@ukrpost.net>
Wed, 07 Apr 2010 21:40:52 +0300
changeset 107 1ed8491ae1b4
parent 106 c60fe499f075
child 108 dedb85093c02
Add main.version ()
lua.c
--- a/lua.c	Sun Apr 04 20:55:04 2010 +0300
+++ b/lua.c	Wed Apr 07 21:40:52 2010 +0300
@@ -38,6 +38,8 @@
 #include <mcabber/compl.h>       // compl_new_category, compl_add_category_word, compl_del_category_word
 #include <mcabber/events.h>      // evs_*
 #include <mcabber/modules.h>     // module_info_t
+#include <mcabber/api.h>         // mcabber_branch, mcabber_api_version
+#include <mcabber/main.h>        // mcabber_version
 
 #include "config.h"
 #include "util.h"
@@ -60,7 +62,7 @@
 
 static module_info_t info_lua_experimental = {
 	.branch      = "experimental",
-	.api         = 15,
+	.api         = 20,
 	.version     = PROJECT_VERSION,
 	.description = DESCRIPTION,
 	.requires    = NULL,
@@ -200,6 +202,31 @@
 	return 1;
 }
 
+/// main.version
+/// Returns information about mcabber version
+/// R: table
+static int lua_main_version (lua_State *L)
+{
+	lua_createtable (L, 0, 3);
+	lua_pushstring (L, mcabber_branch);
+	lua_setfield (L, -2, "branch");
+	lua_pushinteger (L, mcabber_api_version);
+	lua_setfield (L, -2, "api");
+	{
+		gchar *version = mcabber_version ();
+		lua_pushstring (L, version);
+		g_free (version);
+	}
+	lua_setfield (L, -2, "version");
+	lua_pushliteral (L, MCABBER_BRANCH);
+	lua_setfield (L, -2, "build_branch");
+	lua_pushinteger (L, MCABBER_API_VERSION);
+	lua_setfield (L, -2, "build_api");
+	lua_pushinteger (L, MCABBER_API_MIN);
+	lua_setfield (L, -2, "build_api_min");
+	return 1;
+}
+
 /// log print type
 /// G:
 static const string2enum_t lua_lprint[] = {
@@ -1564,6 +1591,7 @@
 #ifdef LLM_CONNECTION_ENABLE
 	reg ( connection     ) 
 #endif
+	reg ( version        )
 	reg ( log            ) 
 	reg ( option         ) 
 	reg ( alias          )