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

Function main

devtools/rune.c:12–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include <stdio.h>
11
12int main(int argc, char *argv[])
13{
14 struct rune *rune;
15 common_setup(argv[0]);
16
17 opt_register_noarg("--help|-h", opt_usage_and_exit,
18 "<rune>", "Show this message");
19 opt_register_version();
20
21 opt_early_parse(argc, argv, opt_log_stderr_exit);
22 opt_parse(&argc, argv, opt_log_stderr_exit);
23 if (argc != 2)
24 opt_usage_exit_fail("needs rune");
25
26 rune = rune_from_base64(NULL, argv[1]);
27 if (!rune)
28 opt_usage_exit_fail("invalid rune");
29
30 printf("string encoding: %s\n", rune_to_string(rune, rune));
31 for (size_t i = 0; i < tal_count(rune->restrs); i++) {
32 const struct rune_restr *restr = rune->restrs[i];
33 const char *sep = "- ";
34 for (size_t j = 0; j < tal_count(restr->alterns); j++) {
35 const struct rune_altern *alt = restr->alterns[j];
36 if (streq(alt->fieldname, "")) {
37 printf("Unique id is %s", alt->value);
38 } else {
39 printf("%s", sep);
40 switch (alt->condition) {
41 case RUNE_COND_IF_MISSING:
42 printf("%s is missing", alt->fieldname);
43 break;
44 case RUNE_COND_EQUAL:
45 printf("%s equal to %s", alt->fieldname, alt->value);
46 break;
47 case RUNE_COND_NOT_EQUAL:
48 printf("%s unequal to %s", alt->fieldname, alt->value);
49 break;
50 case RUNE_COND_BEGINS:
51 printf("%s starts with %s", alt->fieldname, alt->value);
52 break;
53 case RUNE_COND_ENDS:
54 printf("%s ends with %s", alt->fieldname, alt->value);
55 break;
56 case RUNE_COND_CONTAINS:
57 printf("%s contains %s", alt->fieldname, alt->value);
58 break;
59 case RUNE_COND_INT_LESS:
60 printf("%s < %s", alt->fieldname, alt->value);
61 break;
62 case RUNE_COND_INT_GREATER:
63 printf("%s > %s", alt->fieldname, alt->value);
64 break;
65 case RUNE_COND_LEXO_BEFORE:
66 printf("%s sorts before %s", alt->fieldname, alt->value);
67 break;
68 case RUNE_COND_LEXO_AFTER:
69 printf("%s sorts after %s", alt->fieldname, alt->value);

Callers

nothing calls this directly

Calls 7

common_setupFunction · 0.85
opt_early_parseFunction · 0.85
opt_parseFunction · 0.85
opt_usage_exit_failFunction · 0.85
rune_from_base64Function · 0.85
rune_to_stringFunction · 0.85
common_shutdownFunction · 0.85

Tested by

no test coverage detected