| 61 | #define CONFIG_SHOW_BUFSIZE 4096 |
| 62 | |
| 63 | static const char *get_opt_val(const struct opt_table *ot, |
| 64 | char buf[], |
| 65 | const struct configvar *cv) |
| 66 | { |
| 67 | if (ot->type & OPT_CONCEAL) |
| 68 | return "..."; |
| 69 | |
| 70 | if (ot->show == (void *)opt_show_charp) { |
| 71 | /* Don't truncate or quote! */ |
| 72 | return *(char **)ot->u.carg; |
| 73 | } |
| 74 | if (ot->show) { |
| 75 | /* Plugins options' show only shows defaults, so show val if |
| 76 | * we have it */ |
| 77 | if (is_plugin_opt(ot) && cv) |
| 78 | return cv->optarg; |
| 79 | strcpy(buf + CONFIG_SHOW_BUFSIZE, "..."); |
| 80 | if (ot->show(buf, CONFIG_SHOW_BUFSIZE, ot->u.carg)) |
| 81 | return buf; |
| 82 | return NULL; |
| 83 | } |
| 84 | |
| 85 | /* For everything else we only display if it's set, |
| 86 | * BUT we check here to make sure you've handled |
| 87 | * everything! */ |
| 88 | if (is_known_opt_cb_arg(ot->cb_arg) |
| 89 | || is_restricted_print_if_nonnull(ot->cb_arg)) { |
| 90 | /* Only if set! */ |
| 91 | if (cv) |
| 92 | return cv->optarg; |
| 93 | else |
| 94 | return NULL; |
| 95 | } |
| 96 | |
| 97 | /* Insert more decodes here! */ |
| 98 | errx(1, "Unknown decode for %s", ot->names); |
| 99 | } |
| 100 | |
| 101 | static void check_literal(const char *name, const char *val) |
| 102 | { |
no test coverage detected