Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / tests / utils / xml-utils / pretty_xml.cpp
CommitLineData
bb901ead 1/*
4b2b86f2 2 * Copyright (C) 2021 EfficiOS Inc.
bb901ead
JR
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8/*
9 * Prettyfi a xml input from stdin to stddout.
10 * This allows a more human friendly format for xml testing when problems occur.
11 */
12
051356a8
SM
13#include "common.hpp"
14
f59edc7c
JG
15#include <common/scope-exit.hpp>
16
17#include <iostream>
bb901ead 18#include <libxml/parser.h>
051356a8 19#include <unistd.h>
bb901ead 20
f59edc7c
JG
21namespace ll = lttng::libxml;
22
051356a8 23int main()
bb901ead 24{
f59edc7c
JG
25 const ll::global_parser_context global_parser_context;
26 const ll::parser_ctx_uptr parserCtx{ xmlNewParserCtxt() };
27
28 /* Parse the XML document from stdin. */
29 const ll::doc_uptr doc{ xmlCtxtReadFd(
30 parserCtx.get(), STDIN_FILENO, nullptr, nullptr, XML_PARSE_NOBLANKS) };
31 if (!doc) {
32 std::cerr << "Error: invalid XML input on stdin\n";
33 return -1;
051356a8 34 }
bb901ead 35
f59edc7c 36 xmlDocFormatDump(stdout, doc.get(), 1);
bb901ead
JR
37
38 return 0;
39}
This page took 0.041399 seconds and 4 git commands to generate.