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
18 { "employee", "object", "Employee data" },
19 { "first-name", "string", "First name of employee" },
20 { "last-name", "string", "Last name of employee" },
21 { "department", "number", "Department number" },
23 int info_count = (sizeof(info) / sizeof(info[0]));
26 main (int argc, char **argv)
28 unsigned opt_count = 1;
29 unsigned opt_extra = 0;
36 { "Terry", "Jones", 660 },
37 { "Leslie", "Patterson", 341 },
38 { "Ashley", "Smith", 1440 },
42 argc = xo_parse_args(argc, argv);
46 for (argc = 1; argv[argc]; argc++) {
47 if (strcmp(argv[argc], "count") == 0) {
49 opt_count = atoi(argv[++argc]);
50 } else if (strcmp(argv[argc], "extra") == 0) {
52 opt_extra = atoi(argv[++argc]);
56 xo_set_info(NULL, info, info_count);
58 xo_open_container("employees");
59 xo_open_list("employee");
61 xo_emit("[{:extra/%*s}]\n", opt_extra, "");
63 xo_emit("{T:/%13s} {T:/%5s} {T:/%6s} {T:/%7s} {T:/%8s} {T:Size(s)}\n",
64 "Type", "InUse", "MemUse", "HighUse", "Requests");
65 xo_open_list("memory");
66 xo_open_instance("memory");
69 #define TO_ULL(_x) ((unsigned long long) _x)
70 xo_emit("{k:type/%13s} {:in-use/%5" PRIu64 "} "
71 "{:memory-use/%5" PRIu64 "}{U:K} {:high-use/%7s} "
72 "{:requests/%8" PRIu64 "} ",
73 "name", TO_ULL(12345), TO_ULL(54321), "-", TO_ULL(32145));
78 for (i = 0; i < 32; i++) {
81 xo_emit("{l:size/%d}", 1 << (i + 4));
84 xo_close_list("size");
86 xo_close_instance("memory");
88 xo_close_list("memory");
90 while (opt_count-- != 0) {
91 for (ep = employees; ep->e_first; ep++) {
92 xo_open_instance("employee");
93 xo_emit("{:first-name} {:last-name} works in "
94 "dept #{:department/%u}\n",
95 ep->e_first, ep->e_last, ep->e_dept);
96 xo_close_instance("employee");
102 xo_close_list("employee");
103 xo_close_container("employees");