2 * Copyright (c) 2014, Juniper Networks, Inc.
4 * This SOFTWARE is licensed under the LICENSE provided in the
5 * ../Copyright file. By downloading, installing, copying, or otherwise
6 * using the SOFTWARE, you agree to be bound by the terms of that
8 * Phil Shafer, July 2014
19 main (int argc, char **argv)
21 argc = xo_parse_args(argc, argv);
25 for (argc = 1; argv[argc]; argc++) {
26 if (strcmp(argv[argc], "xml") == 0)
27 xo_set_style(NULL, XO_STYLE_XML);
28 else if (strcmp(argv[argc], "json") == 0)
29 xo_set_style(NULL, XO_STYLE_JSON);
30 else if (strcmp(argv[argc], "text") == 0)
31 xo_set_style(NULL, XO_STYLE_TEXT);
32 else if (strcmp(argv[argc], "html") == 0)
33 xo_set_style(NULL, XO_STYLE_HTML);
34 else if (strcmp(argv[argc], "pretty") == 0)
35 xo_set_flags(NULL, XOF_PRETTY);
36 else if (strcmp(argv[argc], "xpath") == 0)
37 xo_set_flags(NULL, XOF_XPATH);
38 else if (strcmp(argv[argc], "info") == 0)
39 xo_set_flags(NULL, XOF_INFO);
42 xo_set_flags(NULL, XOF_UNITS); /* Always test w/ this */
44 xo_open_container_h(NULL, "top");
46 xo_open_container("data");
48 xo_emit("{:mbuf-current/%u}/{:mbuf-cache/%u}/{:mbuf-total/%u} "
49 "{N:mbufs <&> in use (current\\/cache\\/total)}\n",
52 xo_emit("{:distance/%u}{Uw:miles} from {:location}\n", 50, "Boston");
53 xo_emit("{:memory/%u}{U:k} left out of {:total/%u}{U:kb}\n", 64, 640);
54 xo_emit("{:memory/%u}{U:/%s} left out of {:total/%u}{U:/%s}\n",
55 64, "k", 640, "kilobytes");
57 xo_emit("{T:/before%safter:}\n", "working");
59 xo_emit("{d:some/%s}{:ten/%ju}{:eleven/%ju}\n",
60 "string", (uintmax_t) 10, (uintmax_t) 11);
62 xo_emit("{:unknown/%u} "
63 "{N:/packet%s here\\/there\\/everywhere}\n",
66 xo_emit("({[:/%d}{n:min/15}/{n:cur/20}/{:max/%d}{]:})\n", 30, 125);
67 xo_emit("({[:30}{:min/%u}/{:cur/%u}/{:max/%u}{]:})\n", 15, 20, 125);
68 xo_emit("({[:-30}{n:min/15}/{n:cur/20}/{n:max/125}{]:})\n");
69 xo_emit("({[:}{:min/%u}/{:cur/%u}/{:max/%u}{]:/%d})\n", 15, 20, 125, -30);
72 xo_emit("{lq:flag/one} {lq:flag/two} {lq:flag/three}\n");
73 xo_close_list("flag");
75 xo_emit("{e:empty-tag/}");
76 xo_emit("1:{qt:t1/%*d} 2:{qt:t2/test%-*u} 3:{qt:t3/%10sx} 4:{qt:t4/x%-*.*s}\n",
77 6, 1000, 8, 5000, "ten-long", 10, 10, "test");
78 xo_emit("{E:this is an error}\n");
79 xo_emit("{E:/%s more error%s}\n", "two", "s" );
80 xo_emit("{W:this is an warning}\n");
81 xo_emit("{W:/%s more warning%s}\n", "two", "s" );
82 xo_emit("{L:/V1\\/V2 packet%s}: {:count/%u}\n", "s", 10);
85 xo_emit("{:test/%04d} {L:/tr%s}\n", test, (test == 1) ? "y" : "ies");
87 xo_message("improper use of profanity; %s; %s",
88 "ten yard penalty", "first down");
90 xo_error("Shut 'er down, Clancey! She's a-pumpin' mud! <>!,\"!<>\n");
92 xo_close_container("data");
94 xo_close_container_h(NULL, "top");