]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lua: Add dluaL_error
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 16 Apr 2021 10:11:20 +0000 (13:11 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 12 May 2021 09:06:46 +0000 (09:06 +0000)
src/lib-lua/Makefile.am
src/lib-lua/dlua-error.c [new file with mode: 0644]
src/lib-lua/dlua-script-private.h

index c19ac8a13d9551b80e6cbdfd0cff9de47b35265f..4f8d25f84e89694f1c0fa2e06920ee095e1ecc73 100644 (file)
@@ -7,6 +7,7 @@ pkglib_LTLIBRARIES = libdovecot-lua.la
 libdovecot_lua_la_SOURCES = \
        dlua-script.c \
        dlua-pushstring.c \
+       dlua-error.c \
        dlua-dovecot.c \
        dlua-compat.c \
        dlua-resume.c \
diff --git a/src/lib-lua/dlua-error.c b/src/lib-lua/dlua-error.c
new file mode 100644 (file)
index 0000000..6ecb5d2
--- /dev/null
@@ -0,0 +1,13 @@
+/* Copyright (c) 2021 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "dlua-script-private.h"
+
+int dluaL_error(lua_State *L, const char *fmt, ...)
+{
+       va_list argp;
+       va_start(argp, fmt);
+       (void)dlua_pushvfstring(L, fmt, argp);
+       va_end(argp);
+       return lua_error(L);
+}
index 35035c0ee7eb327a397dc637d60d516a402174c7..8fde84e3765e2104f6d81e74165c147ea7bb112a 100644 (file)
@@ -105,6 +105,9 @@ struct event *dlua_check_event(lua_State *L, int arg);
 const char *dlua_pushvfstring(lua_State *L, const char *fmt, va_list argp) ATTR_FORMAT(2, 0);
 const char *dlua_pushfstring(lua_State *L, const char *fmt, ...) ATTR_FORMAT(2, 3);
 
+/* improved luaL_error, can handle full C format support */
+int dluaL_error(lua_State *L, const char *fmt, ...) ATTR_FORMAT(2, 3);
+
 /*
  * Returns field from a Lua table
  *