]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lua: Add dlua_push_timeval()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 25 Aug 2025 09:47:44 +0000 (12:47 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 25 Aug 2025 09:47:44 +0000 (12:47 +0300)
src/lib-lua/dlua-dovecot.c
src/lib-lua/dlua-script-private.h

index d3bc2457d664e7a7961705990379ad5992211fdd..4d0ea911da208a2cc41717e673ead9d26869c194 100644 (file)
@@ -286,6 +286,12 @@ void dlua_push_event(lua_State *L, struct event *event)
        lua_setfield(L, -2, "item");
 }
 
+void dlua_push_timeval(lua_State *L, const struct timeval *tv)
+{
+       lua_pushinteger(L, tv == NULL ? 0 :
+                       tv->tv_sec * 1000000LL + tv->tv_usec);
+}
+
 static int dlua_event_append_log_prefix(lua_State *L)
 {
        DLUA_REQUIRE_ARGS(L, 2);
index af5bc6c8fb6c67a28ae7a14c14187fe07b5aae76..daccbb5aa0ff7805aee92ee53292cc3d122a2c47 100644 (file)
@@ -116,6 +116,9 @@ struct event *dlua_check_event(lua_State *L, int arg);
 const char *dlua_push_vfstring(lua_State *L, const char *fmt, va_list argp) ATTR_FORMAT(2, 0);
 const char *dlua_push_fstring(lua_State *L, const char *fmt, ...) ATTR_FORMAT(2, 3);
 
+/* push timeval as a microseconds integer to top of the stack */
+void dlua_push_timeval(lua_State *L, const struct timeval *tv);
+
 /* improved luaL_error, can handle full C format support */
 int dluaL_error(lua_State *L, const char *fmt, ...) ATTR_FORMAT(2, 3);
 #define luaL_error(...) dluaL_error(__VA_ARGS__)