From 0bf3e14cec222907d845e7bc968f7f31129c4186 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Mon, 25 Oct 2010 21:41:45 +0000 Subject: [PATCH] --- lsyncd-conf.lua | 2 -- lsyncd.c | 15 ++++++++------- lsyncd.lua | 4 +++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lsyncd-conf.lua b/lsyncd-conf.lua index 669981d..a4a34ad 100644 --- a/lsyncd-conf.lua +++ b/lsyncd-conf.lua @@ -9,8 +9,6 @@ settings = { loglevel = DEBUG, } -print(bla) - ------ -- for testing purposes -- diff --git a/lsyncd.c b/lsyncd.c index 6a66914..587871e 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -1099,15 +1099,16 @@ main(int argc, char *argv[]) /* initialize */ /* lua code will set configuration and add watches */ { - ind idx = 0; + int idx = 1; /* creates a table with all option arguments */ - lua_newtable(L); - lua_pushnumber(L, idx++); - lua_pushstring(L, argv[argp++]); - lua_settable(L, -3); - lua_getglobal(L, "lsyncd_initialize"); - lua_call(L, 0, 0); + lua_newtable(L); + while(argp < argc) { + lua_pushnumber(L, idx++); + lua_pushstring(L, argv[argp++]); + lua_settable(L, -3); + } + lua_call(L, 1, 0); } masterloop(L); diff --git a/lsyncd.lua b/lsyncd.lua index 3d4cd08..f0f1224 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -426,10 +426,12 @@ end ---- -- Called from core on init or restart after user configuration. -- -function lsyncd_initialize() +function lsyncd_initialize(args) -- From this point on, no globals may be created anymore GLOBAL_lock(_G) + print(table.concat(args)) + -- makes sure the user gave lsyncd anything to do if #origins == 0 then log(ERROR, "nothing to watch. Use directory(SOURCEDIR, TARGET) in your config file.");