MCPcopy Create free account
hub / github.com/F-Stack/f-stack / main

Function main

tools/libxo/tests/core/test_03.c:26–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24int info_count = (sizeof(info) / sizeof(info[0]));
25
26int
27main (int argc, char **argv)
28{
29 unsigned opt_count = 1;
30 unsigned opt_extra = 0;
31
32 struct employee {
33 const char *e_first;
34 const char *e_last;
35 unsigned e_dept;
36 } employees[] = {
37 { "Terry", "Jones", 660 },
38 { "Leslie", "Patterson", 341 },
39 { "Ashley", "Smith", 1440 },
40 { NULL, NULL }
41 }, *ep;
42
43 argc = xo_parse_args(argc, argv);
44 if (argc < 0)
45 return 1;
46
47 for (argc = 1; argv[argc]; argc++) {
48 if (xo_streq(argv[argc], "count")) {
49 if (argv[argc + 1])
50 opt_count = atoi(argv[++argc]);
51 } else if (xo_streq(argv[argc], "extra")) {
52 if (argv[argc + 1])
53 opt_extra = atoi(argv[++argc]);
54 }
55 }
56
57 xo_set_info(NULL, info, info_count);
58
59 xo_open_container("employees");
60 xo_open_list("employee");
61
62 xo_emit("[{:extra/%*s}]\n", opt_extra, "");
63
64 xo_emit("{T:/%13s} {T:/%5s} {T:/%6s} {T:/%7s} {T:/%8s} {T:Size(s)}\n",
65 "Type", "InUse", "MemUse", "HighUse", "Requests");
66 xo_open_list("memory");
67 xo_open_instance("memory");
68
69#define PRIu64 "llu"
70#define TO_ULL(_x) ((unsigned long long) _x)
71 xo_emit("{k:type/%13s} {:in-use/%5" PRIu64 "} "
72 "{:memory-use/%5" PRIu64 "}{U:K} {:high-use/%7s} "
73 "{:requests/%8" PRIu64 "} ",
74 "name", TO_ULL(12345), TO_ULL(54321), "-", TO_ULL(32145));
75
76 int first = 1, i;
77#if 0
78 xo_open_list("size");
79 for (i = 0; i < 32; i++) {
80 if (!first)
81 xo_emit(",");
82 xo_emit("{l:size/%d}", 1 << (i + 4));
83 first = 0;

Callers

nothing calls this directly

Calls 11

xo_parse_argsFunction · 0.85
xo_streqFunction · 0.85
xo_set_infoFunction · 0.85
xo_open_containerFunction · 0.85
xo_open_listFunction · 0.85
xo_emitFunction · 0.85
xo_open_instanceFunction · 0.85
xo_close_listFunction · 0.85
xo_close_instanceFunction · 0.85
xo_close_containerFunction · 0.85
xo_finishFunction · 0.85

Tested by

no test coverage detected