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

Function main

tools/libxo/tests/core/test_10.c:21–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include "xo_encoder.h"
20
21int
22main (int argc, char **argv)
23{
24 static char base_grocery[] = "GRO";
25 static char base_hardware[] = "HRD";
26 struct item {
27 const char *i_title;
28 int i_sold;
29 int i_instock;
30 int i_onorder;
31 const char *i_sku_base;
32 int i_sku_num;
33 };
34 struct item list[] = {
35 { "gum", 1412, 54, 10, base_grocery, 415 },
36 { "rope", 85, 4, 2, base_hardware, 212 },
37 { "ladder", 0, 2, 1, base_hardware, 517 },
38 { "bolt", 4123, 144, 42, base_hardware, 632 },
39 { "water", 17, 14, 2, base_grocery, 2331 },
40 { NULL, 0, 0, 0, NULL, 0 }
41 };
42 struct item list2[] = {
43 { "fish", 1321, 45, 1, base_grocery, 533 },
44 { NULL, 0, 0, 0, NULL, 0 }
45 };
46 struct item *ip;
47 xo_info_t info[] = {
48 { "in-stock", "number", "Number of items in stock" },
49 { "name", "string", "Name of the item" },
50 { "on-order", "number", "Number of items on order" },
51 { "sku", "string", "Stock Keeping Unit" },
52 { "sold", "number", "Number of items sold" },
53 { NULL, NULL, NULL },
54 };
55 int info_count = (sizeof(info) / sizeof(info[0])) - 1;
56
57 argc = xo_parse_args(argc, argv);
58 if (argc < 0)
59 return 1;
60
61 for (argc = 1; argv[argc]; argc++) {
62 if (xo_streq(argv[argc], "xml"))
63 xo_set_style(NULL, XO_STYLE_XML);
64 else if (xo_streq(argv[argc], "json"))
65 xo_set_style(NULL, XO_STYLE_JSON);
66 else if (xo_streq(argv[argc], "text"))
67 xo_set_style(NULL, XO_STYLE_TEXT);
68 else if (xo_streq(argv[argc], "html"))
69 xo_set_style(NULL, XO_STYLE_HTML);
70 else if (xo_streq(argv[argc], "pretty"))
71 xo_set_flags(NULL, XOF_PRETTY);
72 else if (xo_streq(argv[argc], "xpath"))
73 xo_set_flags(NULL, XOF_XPATH);
74 else if (xo_streq(argv[argc], "info"))
75 xo_set_flags(NULL, XOF_INFO);
76 else if (xo_streq(argv[argc], "error")) {
77 close(-1);
78 xo_err(1, "error detected");

Callers

nothing calls this directly

Calls 15

xo_parse_argsFunction · 0.85
xo_streqFunction · 0.85
xo_set_styleFunction · 0.85
xo_set_flagsFunction · 0.85
xo_errFunction · 0.85
xo_set_infoFunction · 0.85
xo_set_versionFunction · 0.85
xo_open_container_hFunction · 0.85
xo_attrFunction · 0.85
xo_open_containerFunction · 0.85
xo_open_listFunction · 0.85
xo_emitFunction · 0.85

Tested by

no test coverage detected