+#define FREE(b) ({ free((b)); (b)=0; })
+
+struct load_ctx {
+ void (*verror)(struct load_ctx *l, struct cloc loc,
+ FILE *maybe_f,
+ const char *message, va_list args);
+ bool_t (*postreadcheck)(struct load_ctx *l, FILE *f);
+ const char *what;
+ struct cloc loc;
+ union {
+ struct {
+ struct log_if *log;
+ } tryload;
+ } u;
+};
+
+static void load_err(struct load_ctx *l,
+ const struct cloc *maybe_loc, FILE *maybe_f,
+ const char *fmt, ...)
+{
+ va_list al;
+ va_start(al,fmt);
+ l->verror(l, maybe_loc ? *maybe_loc : l->loc, maybe_f,fmt,al);
+ va_end(al);
+}
+
+FORMAT(printf,4,0)
+static void verror_tryload(struct load_ctx *l, struct cloc loc,
+ FILE *maybe_f,
+ const char *message, va_list args)
+{
+ int class=M_ERR;
+ slilog_part(l->u.tryload.log,class,"%s: ",l->what);
+ vslilog(l->u.tryload.log,class,message,args);
+}
+
+static void verror_cfgfatal(struct load_ctx *l, struct cloc loc,
+ FILE *maybe_f,
+ const char *message, va_list args)
+{
+ vcfgfatal_maybefile(maybe_f,l->loc,l->what,message,args,"");
+}
+