static int nftnl_gen_cmd_snprintf(char *buf, size_t size, const struct nftnl_gen *gen, uint32_t cmd, uint32_t type, uint32_t flags) { int ret, len = size, offset = 0; ret = nftnl_cmd_header_snprintf(buf + offset, len, cmd, type, flags); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); switch(type) { case NFTNL_OUTPUT_DEFAULT: ret = nftnl_gen_snprintf_default(buf + offset, len, gen); break; default: return -1; } SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = nftnl_cmd_footer_snprintf(buf + offset, len, cmd, type, flags); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); return offset; }
static int nftnl_cmd_header_fprintf_cb(char *buf, size_t size, void *obj, uint32_t cmd, uint32_t type, uint32_t flags) { return nftnl_cmd_header_snprintf(buf, size, cmd, type, flags); }