{"action":"created","comment":{"url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/comments/40813519","id":40813519,"diff_hunk":"@@ -0,0 +1,272 @@\n+/**\n+ * \\file\n+ *\n+ * \\brief Plugin which acts as proxy and calls other plugins written in lua\n+ *\n+ * \\copyright BSD License (see doc/COPYING or http://www.libelektra.org)\n+ *\n+ */\n+\n+#ifndef SWIG_TYPE_TABLE\n+# error Build system error, SWIG_TYPE_TABLE is not defined\n+#endif\n+\n+#include \"lua.hpp\"\n+#ifndef HAVE_KDBCONFIG\n+# include <kdbconfig.h>\n+#endif\n+#include <kdbhelper.h>\n+\n+#include <key.hpp>\n+#include <keyset.hpp>\n+#include <libgen.h>\n+\n+#include <lua.hpp>\n+extern \"C\" {\n+#include <lualib.h>\n+}\n+#include \"runtime.h\"\n+\n+using namespace ckdb;\n+#include <kdberrors.h>\n+\n+static void Lua_fromSWIG(lua_State *L, ckdb::Key *key)\n+{\n+\tswig_type_info *ti = SWIG_TypeQuery(L, \"kdb::Key *\");\n+\tif (key == NULL || ti == NULL)\n+\t\tlua_pushnil(L);\n+\telse\n+\t\tSWIG_NewPointerObj(L, new kdb::Key(key), ti, 0);\n+}\n+\n+static void Lua_fromSWIG(lua_State *L, ckdb::KeySet *keyset)\n+{\n+\tswig_type_info *ti = SWIG_TypeQuery(L, \"kdb::KeySet *\");\n+\tif (keyset == NULL || ti == NULL)\n+\t\tlua_pushnil(L);\n+\telse\n+\t\tSWIG_NewPointerObj(L, new kdb::KeySet(keyset), ti, 0);\n+}\n+\n+extern \"C\"\n+{\n+\n+typedef struct\n+{\n+\tlua_State *L;\n+\tint printError;\n+\tint shutdown;\n+} moduleData;\n+\n+static void *Lua_alloc(void *ud ELEKTRA_UNUSED, void *ptr,\n+\t\tsize_t osize ELEKTRA_UNUSED, size_t nsize)\n+{\n+\tif (nsize == 0) {\n+\t\telektraFree(ptr);\n+\t\treturn NULL;\n+\t}\n+\treturn (elektraRealloc(&ptr, nsize) < 0) ? NULL : ptr;\n+}\n+\n+static void Lua_Shutdown(lua_State *L)\n+{\n+\tif (L)\n+\t\tlua_close(L);\n+}\n+\n+static int Lua_Require(lua_State *L, const char *name)\n+{\n+\tlua_getglobal(L, \"require\");\n+\tlua_pushstring(L, name);\n+\tint status = lua_pcall(L, 1, 1, 0);\n+\tif (status == LUA_OK)\n+\t\tlua_setglobal(L, name);\n+\treturn status;\n+}\n+\n+static int Lua_CallFunction_Int(lua_State *L, int nargs, ckdb::Key *errorKey)\n+{\n+\tint ret = -1;\n+\tif (lua_pcall(L, nargs, 1, 0) != LUA_OK)\n+\t\tELEKTRA_SET_ERROR(125, errorKey, lua_tostring(L, -1));\n+\telse\n+\t{\n+\t\tif (!lua_isnumber(L, -1))\n+\t\t\tELEKTRA_SET_ERROR(125, errorKey,\n+\t\t\t\t\t\"Return value is no integer\");\n+\t\telse\n+\t\t\tret = lua_tonumber(L, -1);\n+\t}\n+\treturn ret;\n+}\n+\n+static int Lua_CallFunction_Helper1(lua_State *L, const char *funcName,\n+\tckdb::Key *errorKey)\n+{\n+\tint ret = 0;\n+\tint top = lua_gettop(L);\n+\tlua_getglobal(L, funcName);\n+\tif (lua_isfunction(L, -1))\n+\t{\n+\t\tLua_fromSWIG(L, errorKey);\n+\t\tret = Lua_CallFunction_Int(L, 1, errorKey);\n+\t}\n+\tlua_settop(L, top);\n+\treturn ret;\n+}\n+\n+static int Lua_CallFunction_Helper2(lua_State *L, const char *funcName,\n+\tckdb::KeySet *returned, ckdb::Key *parentKey)\n+{\n+\tint ret = 0;\n+\tint top = lua_gettop(L);\n+\tlua_getglobal(L, funcName);\n+\tif (lua_isfunction(L, -1))\n+\t{\n+\t\tLua_fromSWIG(L, returned);\n+\t\tLua_fromSWIG(L, parentKey);\n+\t\tret = Lua_CallFunction_Int(L, 2, parentKey);\n+\t}\n+\tlua_settop(L, top);\n+\treturn ret;\n+}\n+\n+int elektraLuaOpen(ckdb::Plugin *handle, ckdb::Key *errorKey)\n+{\n+\tKeySet *config = elektraPluginGetConfig(handle);\n+\tKey *script = ksLookupByName(config, \"/script\", 0);\n+\tif (script == NULL)\n+\t\treturn 0; // success if no script to execute\n+\n+\tif (keyString(script) == NULL)","path":"src/plugins/lua/lua.cpp","position":141,"original_position":141,"commit_id":"333be01f6f4291524c96fe20538cff6b495ad4b8","original_commit_id":"333be01f6f4291524c96fe20538cff6b495ad4b8","user":{"login":"manuelm","id":357694,"avatar_url":"https://avatars.githubusercontent.com/u/357694?v=3","gravatar_id":"","url":"https://api.github.com/users/manuelm","html_url":"https://github.com/manuelm","followers_url":"https://api.github.com/users/manuelm/followers","following_url":"https://api.github.com/users/manuelm/following{/other_user}","gists_url":"https://api.github.com/users/manuelm/gists{/gist_id}","starred_url":"https://api.github.com/users/manuelm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manuelm/subscriptions","organizations_url":"https://api.github.com/users/manuelm/orgs","repos_url":"https://api.github.com/users/manuelm/repos","events_url":"https://api.github.com/users/manuelm/events{/privacy}","received_events_url":"https://api.github.com/users/manuelm/received_events","type":"User","site_admin":false},"body":"so `/module` exists during loading in order to check if the library is actually usable?","created_at":"2015-09-30T16:03:26Z","updated_at":"2015-09-30T16:03:26Z","html_url":"https://github.com/ElektraInitiative/libelektra/pull/312#discussion_r40813519","pull_request_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/312","_links":{"self":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/comments/40813519"},"html":{"href":"https://github.com/ElektraInitiative/libelektra/pull/312#discussion_r40813519"},"pull_request":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/312"}}},"pull_request":{"url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/312","id":46260698,"html_url":"https://github.com/ElektraInitiative/libelektra/pull/312","diff_url":"https://github.com/ElektraInitiative/libelektra/pull/312.diff","patch_url":"https://github.com/ElektraInitiative/libelektra/pull/312.patch","issue_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/312","number":312,"state":"open","locked":false,"title":"lua: add lua plugin","user":{"login":"manuelm","id":357694,"avatar_url":"https://avatars.githubusercontent.com/u/357694?v=3","gravatar_id":"","url":"https://api.github.com/users/manuelm","html_url":"https://github.com/manuelm","followers_url":"https://api.github.com/users/manuelm/followers","following_url":"https://api.github.com/users/manuelm/following{/other_user}","gists_url":"https://api.github.com/users/manuelm/gists{/gist_id}","starred_url":"https://api.github.com/users/manuelm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manuelm/subscriptions","organizations_url":"https://api.github.com/users/manuelm/orgs","repos_url":"https://api.github.com/users/manuelm/repos","events_url":"https://api.github.com/users/manuelm/events{/privacy}","received_events_url":"https://api.github.com/users/manuelm/received_events","type":"User","site_admin":false},"body":"things before merging:\r\n- [ ] review work\r\n- [ ] because of shared error numbers, either crypto or lua plugin needs a rebase","created_at":"2015-09-29T10:35:46Z","updated_at":"2015-09-30T16:03:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"23dad97923662dfc90882bcf4b1109bf0be1626b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/312/commits","review_comments_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/312/comments","review_comment_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/312/comments","statuses_url":"https://api.github.com/repos/ElektraInitiative/libelektra/statuses/333be01f6f4291524c96fe20538cff6b495ad4b8","head":{"label":"manuelm:lua","ref":"lua","sha":"333be01f6f4291524c96fe20538cff6b495ad4b8","user":{"login":"manuelm","id":357694,"avatar_url":"https://avatars.githubusercontent.com/u/357694?v=3","gravatar_id":"","url":"https://api.github.com/users/manuelm","html_url":"https://github.com/manuelm","followers_url":"https://api.github.com/users/manuelm/followers","following_url":"https://api.github.com/users/manuelm/following{/other_user}","gists_url":"https://api.github.com/users/manuelm/gists{/gist_id}","starred_url":"https://api.github.com/users/manuelm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manuelm/subscriptions","organizations_url":"https://api.github.com/users/manuelm/orgs","repos_url":"https://api.github.com/users/manuelm/repos","events_url":"https://api.github.com/users/manuelm/events{/privacy}","received_events_url":"https://api.github.com/users/manuelm/received_events","type":"User","site_admin":false},"repo":{"id":21131285,"name":"libelektra","full_name":"manuelm/libelektra","owner":{"login":"manuelm","id":357694,"avatar_url":"https://avatars.githubusercontent.com/u/357694?v=3","gravatar_id":"","url":"https://api.github.com/users/manuelm","html_url":"https://github.com/manuelm","followers_url":"https://api.github.com/users/manuelm/followers","following_url":"https://api.github.com/users/manuelm/following{/other_user}","gists_url":"https://api.github.com/users/manuelm/gists{/gist_id}","starred_url":"https://api.github.com/users/manuelm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manuelm/subscriptions","organizations_url":"https://api.github.com/users/manuelm/orgs","repos_url":"https://api.github.com/users/manuelm/repos","events_url":"https://api.github.com/users/manuelm/events{/privacy}","received_events_url":"https://api.github.com/users/manuelm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/manuelm/libelektra","description":"Elektra provides a universal and secure framework to store configuration parameters in a global, hierarchical key database.","fork":true,"url":"https://api.github.com/repos/manuelm/libelektra","forks_url":"https://api.github.com/repos/manuelm/libelektra/forks","keys_url":"https://api.github.com/repos/manuelm/libelektra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/manuelm/libelektra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/manuelm/libelektra/teams","hooks_url":"https://api.github.com/repos/manuelm/libelektra/hooks","issue_events_url":"https://api.github.com/repos/manuelm/libelektra/issues/events{/number}","events_url":"https://api.github.com/repos/manuelm/libelektra/events","assignees_url":"https://api.github.com/repos/manuelm/libelektra/assignees{/user}","branches_url":"https://api.github.com/repos/manuelm/libelektra/branches{/branch}","tags_url":"https://api.github.com/repos/manuelm/libelektra/tags","blobs_url":"https://api.github.com/repos/manuelm/libelektra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/manuelm/libelektra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/manuelm/libelektra/git/refs{/sha}","trees_url":"https://api.github.com/repos/manuelm/libelektra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/manuelm/libelektra/statuses/{sha}","languages_url":"https://api.github.com/repos/manuelm/libelektra/languages","stargazers_url":"https://api.github.com/repos/manuelm/libelektra/stargazers","contributors_url":"https://api.github.com/repos/manuelm/libelektra/contributors","subscribers_url":"https://api.github.com/repos/manuelm/libelektra/subscribers","subscription_url":"https://api.github.com/repos/manuelm/libelektra/subscription","commits_url":"https://api.github.com/repos/manuelm/libelektra/commits{/sha}","git_commits_url":"https://api.github.com/repos/manuelm/libelektra/git/commits{/sha}","comments_url":"https://api.github.com/repos/manuelm/libelektra/comments{/number}","issue_comment_url":"https://api.github.com/repos/manuelm/libelektra/issues/comments{/number}","contents_url":"https://api.github.com/repos/manuelm/libelektra/contents/{+path}","compare_url":"https://api.github.com/repos/manuelm/libelektra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/manuelm/libelektra/merges","archive_url":"https://api.github.com/repos/manuelm/libelektra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/manuelm/libelektra/downloads","issues_url":"https://api.github.com/repos/manuelm/libelektra/issues{/number}","pulls_url":"https://api.github.com/repos/manuelm/libelektra/pulls{/number}","milestones_url":"https://api.github.com/repos/manuelm/libelektra/milestones{/number}","notifications_url":"https://api.github.com/repos/manuelm/libelektra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/manuelm/libelektra/labels{/name}","releases_url":"https://api.github.com/repos/manuelm/libelektra/releases{/id}","created_at":"2014-06-23T15:25:38Z","updated_at":"2015-09-07T12:24:38Z","pushed_at":"2015-09-29T18:29:22Z","git_url":"git://github.com/manuelm/libelektra.git","ssh_url":"git@github.com:manuelm/libelektra.git","clone_url":"https://github.com/manuelm/libelektra.git","svn_url":"https://github.com/manuelm/libelektra","homepage":"","size":29174,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ElektraInitiative:master","ref":"master","sha":"f42d2d5970967ac27869cc9a664cc9719adb6a5e","user":{"login":"ElektraInitiative","id":7949092,"avatar_url":"https://avatars.githubusercontent.com/u/7949092?v=3","gravatar_id":"","url":"https://api.github.com/users/ElektraInitiative","html_url":"https://github.com/ElektraInitiative","followers_url":"https://api.github.com/users/ElektraInitiative/followers","following_url":"https://api.github.com/users/ElektraInitiative/following{/other_user}","gists_url":"https://api.github.com/users/ElektraInitiative/gists{/gist_id}","starred_url":"https://api.github.com/users/ElektraInitiative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElektraInitiative/subscriptions","organizations_url":"https://api.github.com/users/ElektraInitiative/orgs","repos_url":"https://api.github.com/users/ElektraInitiative/repos","events_url":"https://api.github.com/users/ElektraInitiative/events{/privacy}","received_events_url":"https://api.github.com/users/ElektraInitiative/received_events","type":"Organization","site_admin":false},"repo":{"id":21063580,"name":"libelektra","full_name":"ElektraInitiative/libelektra","owner":{"login":"ElektraInitiative","id":7949092,"avatar_url":"https://avatars.githubusercontent.com/u/7949092?v=3","gravatar_id":"","url":"https://api.github.com/users/ElektraInitiative","html_url":"https://github.com/ElektraInitiative","followers_url":"https://api.github.com/users/ElektraInitiative/followers","following_url":"https://api.github.com/users/ElektraInitiative/following{/other_user}","gists_url":"https://api.github.com/users/ElektraInitiative/gists{/gist_id}","starred_url":"https://api.github.com/users/ElektraInitiative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElektraInitiative/subscriptions","organizations_url":"https://api.github.com/users/ElektraInitiative/orgs","repos_url":"https://api.github.com/users/ElektraInitiative/repos","events_url":"https://api.github.com/users/ElektraInitiative/events{/privacy}","received_events_url":"https://api.github.com/users/ElektraInitiative/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ElektraInitiative/libelektra","description":"Elektra provides a universal and secure framework to store configuration parameters in a global, hierarchical key database.","fork":false,"url":"https://api.github.com/repos/ElektraInitiative/libelektra","forks_url":"https://api.github.com/repos/ElektraInitiative/libelektra/forks","keys_url":"https://api.github.com/repos/ElektraInitiative/libelektra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ElektraInitiative/libelektra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ElektraInitiative/libelektra/teams","hooks_url":"https://api.github.com/repos/ElektraInitiative/libelektra/hooks","issue_events_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/events{/number}","events_url":"https://api.github.com/repos/ElektraInitiative/libelektra/events","assignees_url":"https://api.github.com/repos/ElektraInitiative/libelektra/assignees{/user}","branches_url":"https://api.github.com/repos/ElektraInitiative/libelektra/branches{/branch}","tags_url":"https://api.github.com/repos/ElektraInitiative/libelektra/tags","blobs_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/refs{/sha}","trees_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ElektraInitiative/libelektra/statuses/{sha}","languages_url":"https://api.github.com/repos/ElektraInitiative/libelektra/languages","stargazers_url":"https://api.github.com/repos/ElektraInitiative/libelektra/stargazers","contributors_url":"https://api.github.com/repos/ElektraInitiative/libelektra/contributors","subscribers_url":"https://api.github.com/repos/ElektraInitiative/libelektra/subscribers","subscription_url":"https://api.github.com/repos/ElektraInitiative/libelektra/subscription","commits_url":"https://api.github.com/repos/ElektraInitiative/libelektra/commits{/sha}","git_commits_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/commits{/sha}","comments_url":"https://api.github.com/repos/ElektraInitiative/libelektra/comments{/number}","issue_comment_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/comments{/number}","contents_url":"https://api.github.com/repos/ElektraInitiative/libelektra/contents/{+path}","compare_url":"https://api.github.com/repos/ElektraInitiative/libelektra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ElektraInitiative/libelektra/merges","archive_url":"https://api.github.com/repos/ElektraInitiative/libelektra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ElektraInitiative/libelektra/downloads","issues_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues{/number}","pulls_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls{/number}","milestones_url":"https://api.github.com/repos/ElektraInitiative/libelektra/milestones{/number}","notifications_url":"https://api.github.com/repos/ElektraInitiative/libelektra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ElektraInitiative/libelektra/labels{/name}","releases_url":"https://api.github.com/repos/ElektraInitiative/libelektra/releases{/id}","created_at":"2014-06-21T08:01:04Z","updated_at":"2015-09-19T08:40:44Z","pushed_at":"2015-09-29T21:35:18Z","git_url":"git://github.com/ElektraInitiative/libelektra.git","ssh_url":"git@github.com:ElektraInitiative/libelektra.git","clone_url":"https://github.com/ElektraInitiative/libelektra.git","svn_url":"https://github.com/ElektraInitiative/libelektra","homepage":"","size":31885,"stargazers_count":18,"watchers_count":18,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":45,"forks":15,"open_issues":45,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/312"},"html":{"href":"https://github.com/ElektraInitiative/libelektra/pull/312"},"issue":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/312"},"comments":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/312/comments"},"review_comments":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/312/comments"},"review_comment":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/312/commits"},"statuses":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/statuses/333be01f6f4291524c96fe20538cff6b495ad4b8"}}}}