diff --git a/lsyncd.c b/lsyncd.c index 53cc128..e0c0301 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -2142,11 +2142,12 @@ l_jiffies_index(lua_State *L) clock_t a1 = ( *( clock_t * ) luaL_checkudata( L, 1, "Lsyncd.jiffies" ) ); const char *a2 = luaL_checkstring(L, 2); - printf("in index %s %d\n", a2, a1); - if (!strcmp(a2, "seconds")) { lua_pushinteger( L, a1 / clocks_per_sec); return 1; + } else if (!strcmp(a2, "string")) { + lua_pushfstring (L, "%d", a1 / clocks_per_sec); + return 1; } return 0; } diff --git a/lsyncd.lua b/lsyncd.lua index 019cea9..8572413 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -151,6 +151,13 @@ inheritKV = end end +function alarm2string(a) + if type(a) == 'userdata' then + return a.string + end + return tostring( a ) +end + -- -- Coping globals to ensure userscripts cannot change this. -- @@ -849,6 +856,20 @@ local Delay = ( function self[ k_nt ].alarm = alarm end + -- + -- Returns a debug string of the delay + -- + local function debug(self, deep) + local rv = "" + return rv + end + -- -- Creates a new delay. -- @@ -868,6 +889,7 @@ local Delay = ( function blockedBy = blockedBy, setActive = setActive, wait = wait, + debug = debug, [ k_nt ] = { etype = etype, @@ -3174,6 +3196,16 @@ local Sync = ( function f:write( '\n' ) end + -- + -- Returns a debug string describing the Sync + -- + local function debug + ( + self + ) + local rv = " " + return rv + end -- -- Returns substitude data for event -- @@ -3214,6 +3246,7 @@ local Sync = ( function collect = collect, concerns = concerns, delay = delay, + debug = debug, getAlarm = getAlarm, getDelays = getDelays, getNextDelay = getNextDelay,