MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

ccan/ccan/cdump/tools/cdump-enumstr.c:22–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22int main(int argc, char *argv[])
23{
24 char *code, *problems;
25 struct cdump_definitions *defs;
26
27 if (argc < 2)
28 errx(1, "Usage: cdump-enumstr <filename> [<enums>...]");
29
30 code = grab_file(NULL, streq(argv[1], "-") ? NULL : argv[1]);
31 if (!code)
32 err(1, "Reading %s", argv[1]);
33
34 defs = cdump_extract(code, code, &problems);
35 if (!defs)
36 errx(1, "Parsing %s:\n%s", argv[1], problems);
37
38 if (argc == 2)
39 strmap_iterate(&defs->enums, dump_map, NULL);
40 else {
41 unsigned int i;
42 struct cdump_type *t;
43
44 for (i = 2; i < argc; i++) {
45 t = strmap_get(&defs->enums, argv[i]);
46 if (!t)
47 errx(1, "Enum %s not found", argv[i]);
48 dump_map(argv[i], t, NULL);
49 }
50 }
51 return 0;
52}

Callers

nothing calls this directly

Calls 5

errxFunction · 0.85
grab_fileFunction · 0.85
errFunction · 0.85
cdump_extractFunction · 0.85
dump_mapFunction · 0.85

Tested by

no test coverage detected