Пример #1
0
/**
 * Convenience routine: dump tree with prologue to specified file, skipping
 * pure white space nodes.
 *
 * @param root		tree to dump
 * @param f			file where we should dump the tree
 *
 * @return TRUE on success.
 */
bool
xfmt_tree_prologue_dump(const xnode_t *root, FILE *f)
{
    ostream_t *os;

    if (!log_file_printable(f))
        return FALSE;

    os = ostream_open_file(f);
    xfmt_tree(root, os, XFMT_O_SKIP_BLANKS | XFMT_O_PROLOGUE);
    return 0 == ostream_close(os);
}
Пример #2
0
/**
 * Dump whole header on specified file, followed by trailer string
 * (if not NULL) and a final "\n".
 */
void
header_dump(FILE *out, const header_t *o, const char *trailer)
{
	header_check(o);

	if (!log_file_printable(out))
		return;

	if (o->fields) {
		slist_foreach(o->fields, header_dump_item, out);
	}
	if (trailer)
		fprintf(out, "%s\n", trailer);
}
Пример #3
0
/**
 * Convenience routine: dump tree specified file.
 *
 * See xfmt_tree_extended() for a description of the available options.
 *
 * @param root			tree to dump
 * @param f				file where we should dump the tree
 * @param options		formatting options, as documented above
 * @param pvec			a vector of prefixes to be used for namespaces
 * @param pvcnt			amount of entries in vector
 * @param default_ns	default namespace to install at root element
 *
 * @return TRUE on success.
 */
bool
xfmt_tree_dump_extended(const xnode_t *root, FILE *f,
                        uint32 options, const struct xfmt_prefix *pvec, size_t pvcnt,
                        const char *default_ns)
{
    ostream_t *os;

    if (!log_file_printable(f))
        return FALSE;

    os = ostream_open_file(f);
    xfmt_tree_extended(root, os, options, pvec, pvcnt, default_ns);
    return 0 == ostream_close(os);
}