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

Function main

tools/libxo/tests/core/test_01.c:19–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "xo_encoder.h"
18
19int
20main (int argc, char **argv)
21{
22 static char base_grocery[] = "GRO";
23 static char base_hardware[] = "HRD";
24 struct item {
25 const char *i_title;
26 int i_sold;
27 int i_instock;
28 int i_onorder;
29 const char *i_sku_base;
30 int i_sku_num;
31 };
32 struct item list[] = {
33 { "gum", 1412, 54, 10, base_grocery, 415 },
34 { "rope", 85, 4, 2, base_hardware, 212 },
35 { "ladder", 0, 2, 1, base_hardware, 517 },
36 { "bolt", 4123, 144, 42, base_hardware, 632 },
37 { "water", 17, 14, 2, base_grocery, 2331 },
38 { NULL, 0, 0, 0, NULL, 0 }
39 };
40 struct item list2[] = {
41 { "fish", 1321, 45, 1, base_grocery, 533 },
42 { NULL, 0, 0, 0, NULL, 0 }
43 };
44 struct item *ip;
45 xo_info_t info[] = {
46 { "in-stock", "number", "Number of items in stock" },
47 { "name", "string", "Name of the item" },
48 { "on-order", "number", "Number of items on order" },
49 { "sku", "string", "Stock Keeping Unit" },
50 { "sold", "number", "Number of items sold" },
51 { XO_INFO_NULL },
52 };
53
54 char name[] = "test_01.test"; /* test trimming of xo_program */
55 argv[0] = name;
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")) {

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_open_container_hFunction · 0.85
xo_emitFunction · 0.85
xo_emit_fieldFunction · 0.85
xo_attrFunction · 0.85
xo_open_containerFunction · 0.85
xo_open_listFunction · 0.85

Tested by

no test coverage detected