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