42ff34c310
0.5.0: document "trim" modifier add xo_emit_field functions Add xo_set_file{,_h} functions Fix LIBXO_* variables; add -L and -I as needed add --disable-silent-rules and an explicit make; s/PACKAGE-NAME/PACKAGE_NAME/; add /download/ to 'url' fix silliness where xo_flush_h emitted closing tag (html); make the caller (xo_message) do it flush after transitions; fix flush call in xo_do_emit mkdir the version-specific packaging dir use "XO_" instead of LIBXO_ 0.6.0: Add --with-retain-size to set the size (in bits) of the retain hash buckets Add The Argument Modifier ({a:}) Add retain and no-retain to --libxo autoconf: Add test for monitor.h Document quote heuristic go deep with nroff backslashes Use "ULL" for 32 bit check add xo_retain_clear and xo_retain_clear_all docs: combine two 'handles' section; move command line argument section handle GETTEXT when msgfmt isn't where it's supposed to be (FreeBSD) make 'retain' a flag (XOEF_RETAIN) instead of a role; it's simpler, and doesn't feel as tacky. "{R:}" was painful to document, which means it's painful to use. new xo_emit_f functions nuke some unused UNUSEDs test code: path must be static update test cases 0.6.1: fix version number (missed a commit during new-release) Reviewed by: sjg Approved by: sjg (mentor)
77 lines
2.0 KiB
C
77 lines
2.0 KiB
C
/*
|
|
* Copyright (c) 2014, Juniper Networks, Inc.
|
|
* All rights reserved.
|
|
* This SOFTWARE is licensed under the LICENSE provided in the
|
|
* ../Copyright file. By downloading, installing, copying, or otherwise
|
|
* using the SOFTWARE, you agree to be bound by the terms of that
|
|
* LICENSE.
|
|
* Phil Shafer, July 2014
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
#include "xo_config.h"
|
|
#include "xo.h"
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
int i, count = 10;
|
|
int mon = 0;
|
|
xo_emit_flags_t flags = XOEF_RETAIN;
|
|
|
|
argc = xo_parse_args(argc, argv);
|
|
if (argc < 0)
|
|
return 1;
|
|
|
|
for (argc = 1; argv[argc]; argc++) {
|
|
if (strcmp(argv[argc], "xml") == 0)
|
|
xo_set_style(NULL, XO_STYLE_XML);
|
|
else if (strcmp(argv[argc], "json") == 0)
|
|
xo_set_style(NULL, XO_STYLE_JSON);
|
|
else if (strcmp(argv[argc], "text") == 0)
|
|
xo_set_style(NULL, XO_STYLE_TEXT);
|
|
else if (strcmp(argv[argc], "html") == 0)
|
|
xo_set_style(NULL, XO_STYLE_HTML);
|
|
else if (strcmp(argv[argc], "pretty") == 0)
|
|
xo_set_flags(NULL, XOF_PRETTY);
|
|
else if (strcmp(argv[argc], "xpath") == 0)
|
|
xo_set_flags(NULL, XOF_XPATH);
|
|
else if (strcmp(argv[argc], "info") == 0)
|
|
xo_set_flags(NULL, XOF_INFO);
|
|
else if (strcmp(argv[argc], "no-retain") == 0)
|
|
flags &= ~XOEF_RETAIN;
|
|
else if (strcmp(argv[argc], "big") == 0) {
|
|
if (argv[argc + 1])
|
|
count = atoi(argv[++argc]);
|
|
}
|
|
}
|
|
|
|
xo_set_flags(NULL, XOF_UNITS); /* Always test w/ this */
|
|
xo_set_file(stdout);
|
|
|
|
xo_open_container("top");
|
|
xo_open_container("data");
|
|
|
|
const char *fmt1 = "The {C:fg-red}{k:name}{C:reset} is "
|
|
"{C:/fg-%s}{:color}{C:reset} til {:time/%02d:%02d}\n";
|
|
const char *fmt2 = "My {C:fg-red}{:hand}{C:reset} hand is "
|
|
"{C:/fg-%s}{:color}{C:reset} til {:time/%02d:%02d}\n";
|
|
|
|
for (i = 0; i < count; i++) {
|
|
xo_open_instance("thing");
|
|
xo_emit_f(flags, fmt1, "thing", "green", "green", 2, 15);
|
|
xo_emit_f(flags, fmt2, "left", "blue", "blue", 3, 45);
|
|
}
|
|
|
|
xo_close_container("data");
|
|
xo_close_container_h(NULL, "top");
|
|
|
|
xo_finish();
|
|
|
|
return 0;
|
|
}
|