const char *err = engine_hint_root_file(ctx, file);
if (err) {
- lua_pushstring(L, err);
+ if (!file) {
+ file = ROOTHINTS;
+ }
+ lua_push_printf(L, "error when opening '%s': %s", file, err);
lua_error(L);
} else {
lua_pushboolean(L, true);
#include <libknot/packet/pkt.h>
#include <libknot/rrset.h>
#include <libknot/rrtype/rrsig.h>
+#include <lua.h>
#include "lib/generic/map.h"
#include "lib/generic/array.h"
#include "lib/defines.h"
type = knot_rrsig_type_covered(&rr->rrs, 0);
return type;
}
+
+/** Printf onto the lua stack, avoiding additional copy (thin wrapper). */
+static inline const char *lua_push_printf(lua_State *L, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ const char *ret = lua_pushvfstring(L, fmt, args);
+ va_end(args);
+ return ret;
+}
+
{
struct engine *engine = env;
struct kr_context *ctx = &engine->resolver;
- return (char *)/*const-cast*/engine_hint_root_file(ctx, args);
+ return strdup(engine_hint_root_file(ctx, args));
}
/*