void nft_ctx_output_set_echo(struct nft_ctx *ctx, bool val);
FILE *nft_ctx_set_output(struct nft_ctx *ctx, FILE *fp);
+FILE *nft_ctx_set_error(struct nft_ctx *ctx, FILE *fp);
+
int nft_ctx_add_include_path(struct nft_ctx *ctx, const char *path);
void nft_ctx_clear_include_paths(struct nft_ctx *ctx);
init_list_head(&ctx->cache.list);
ctx->flags = flags;
ctx->output.output_fp = stdout;
+ ctx->output.error_fp = stderr;
if (flags == NFT_CTX_DEFAULT)
nft_ctx_netlink_init(ctx);
return old;
}
+FILE *nft_ctx_set_error(struct nft_ctx *ctx, FILE *fp)
+{
+ FILE *old = ctx->output.error_fp;
+
+ if (!fp || ferror(fp))
+ return NULL;
+
+ ctx->output.error_fp = fp;
+
+ return old;
+}
+
bool nft_ctx_get_dry_run(struct nft_ctx *ctx)
{
return ctx->check;
LIST_HEAD(msgs);
size_t nlbuflen;
void *scanner;
- FILE *fp;
char *nlbuf;
nlbuflen = max(buflen + 1, strlen(buf) + 2);
if (nft_run(nft, nft->nf_sock, scanner, &state, &msgs) != 0)
rc = -1;
- fp = nft_ctx_set_output(nft, stderr);
erec_print_list(&nft->output, &msgs, nft->debug_mask);
- nft_ctx_set_output(nft, fp);
scanner_destroy(scanner);
iface_cache_release();
free(nlbuf);