diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-05-23 16:05:12 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-05-23 16:08:22 +0200 |
commit | 9caccc5ad5e6d4c6b6caa01bc13364fa62ec3779 (patch) | |
tree | ebb34b6ce4496f6d8b9fb36446b42cf7e140b7c4 /src | |
parent | ebdf5197a585d39efe6e0d42d1b4ebe56e3e694b (diff) | |
download | gnutls-9caccc5ad5e6d4c6b6caa01bc13364fa62ec3779.tar.gz |
Allow wildcard comparison of options.
Diffstat (limited to 'src')
-rw-r--r-- | src/certtool-cfg.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/certtool-cfg.c b/src/certtool-cfg.c index 907dbb9b08..83ac32f13e 100644 --- a/src/certtool-cfg.c +++ b/src/certtool-cfg.c @@ -97,7 +97,7 @@ static struct cfg_options available_options[] = { { .name = "country", .type = OPTION_STRING }, { .name = "expiration_date", .type = OPTION_STRING }, { .name = "activation_date", .type = OPTION_STRING }, - { .name = "policy*", .type = OPTION_STRING }, + { .name = "policy*", .type = OPTION_MULTI_LINE }, /* not a multi-line but there are multi as it is a wildcard */ { .name = "pkcs12_key_name", .type = OPTION_STRING }, { .name = "proxy_policy_language", .type = OPTION_STRING }, { .name = "serial", .type = OPTION_NUMERIC }, @@ -256,9 +256,16 @@ void cfg_init(void) static int handle_option(const tOptionValue* val) { unsigned j; +unsigned len, cmp; for (j=0;j<sizeof(available_options)/sizeof(available_options[0]);j++) { - if (strcasecmp(val->pzName, available_options[j].name) == 0) { + len = strlen(available_options[j].name); + if (len > 2 && available_options[j].name[len-1] == '*') + cmp = strncasecmp(val->pzName, available_options[j].name, len-1); + else + cmp = strcasecmp(val->pzName, available_options[j].name); + + if (cmp == 0) { if (available_options[j].type != OPTION_MULTI_LINE && available_options[j].found != 0) { fprintf(stderr, "Warning: multiple options found for '%s'; only the first will be taken into account.\n", available_options[j].name); |