[rt-commit] r201 - in /redwax-tool/trunk: ChangeLog redwax-tool.c
rt-commit at redwax.eu
rt-commit at redwax.eu
Tue Feb 18 13:15:59 CET 2025
Author: minfrin at redwax.eu
Date: Tue Feb 18 13:15:58 2025
New Revision: 201
Log:
Simplify completion code for non quoted options.
Modified:
redwax-tool/trunk/ChangeLog
redwax-tool/trunk/redwax-tool.c
Modified: redwax-tool/trunk/ChangeLog
==============================================================================
--- redwax-tool/trunk/ChangeLog (original)
+++ redwax-tool/trunk/ChangeLog Tue Feb 18 13:15:58 2025
@@ -1,5 +1,8 @@
Changes with v0.9.8
+
+ *) Simplify completion code for non quoted options.
+ [Graham Leggett]
*) Add a dedicated exit code for options that are not
implemented on a specific platform.
Modified: redwax-tool/trunk/redwax-tool.c
==============================================================================
--- redwax-tool/trunk/redwax-tool.c (original)
+++ redwax-tool/trunk/redwax-tool.c Tue Feb 18 13:15:58 2025
@@ -1546,31 +1546,6 @@
return APR_SUCCESS;
}
-apr_status_t redwax_complete_filter(redwax_tool_t *r, const char *arg,
- redwax_token_quoted_e quoted)
-{
- apr_hash_t *filters = apr_hash_make(r->pool);
-
- apr_hash_index_t *hi;
- void *val;
- int arglen = strlen(arg);
-
- rt_run_complete_filter(r, filters);
-
- for (hi = apr_hash_first(r->pool, filters); hi; hi = apr_hash_next(hi)) {
- apr_hash_this(hi, NULL, NULL, &val);
-
- if (!strncmp(arg, (const char *)val, arglen)) {
-
- apr_file_printf(r->out, "%s \n",
- redwax_pescape_echo_quoted(r->pool,
- (const char *)val, quoted, 1));
- }
- }
-
- return APR_SUCCESS;
-}
-
apr_status_t redwax_complete_directory(redwax_tool_t *r, const char *arg,
redwax_token_quoted_e quoted)
{
@@ -1825,18 +1800,18 @@
return APR_SUCCESS;
}
-static apr_status_t redwax_complete_verify_param(redwax_tool_t *r, const char *arg,
+static apr_status_t redwax_complete_nss_token_out(redwax_tool_t *r, const char *arg,
redwax_token_quoted_e quoted)
{
- apr_hash_t *params = apr_hash_make(r->pool);
+ apr_hash_t *tokens = apr_hash_make(r->pool);
apr_hash_index_t *hi;
void *val;
int arglen = strlen(arg);
- rt_run_complete_verify_param(r, params);
-
- for (hi = apr_hash_first(r->pool, params); hi; hi = apr_hash_next(hi)) {
+ rt_run_complete_nss_token_out(r, tokens);
+
+ for (hi = apr_hash_first(r->pool, tokens); hi; hi = apr_hash_next(hi)) {
apr_hash_this(hi, NULL, NULL, &val);
if (!strncmp(arg, (const char *)val, arglen)) {
@@ -1850,106 +1825,6 @@
return APR_SUCCESS;
}
-static apr_status_t redwax_complete_verify_expiry(redwax_tool_t *r, const char *arg,
- redwax_token_quoted_e quoted)
-{
- apr_hash_t *expiries = apr_hash_make(r->pool);
-
- apr_hash_index_t *hi;
- void *val;
- int arglen = strlen(arg);
-
- rt_run_complete_verify_expiry(r, expiries);
-
- for (hi = apr_hash_first(r->pool, expiries); hi; hi = apr_hash_next(hi)) {
- apr_hash_this(hi, NULL, NULL, &val);
-
- if (!strncmp(arg, (const char *)val, arglen)) {
-
- apr_file_printf(r->out, "%s \n",
- redwax_pescape_echo_quoted(r->pool,
- (const char *)val, quoted, 1));
- }
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t redwax_complete_verify_dane(redwax_tool_t *r, const char *arg,
- redwax_token_quoted_e quoted)
-{
- apr_hash_t *danes = apr_hash_make(r->pool);
-
- apr_hash_index_t *hi;
- void *val;
- int arglen = strlen(arg);
-
- rt_run_complete_verify_dane(r, danes);
-
- for (hi = apr_hash_first(r->pool, danes); hi; hi = apr_hash_next(hi)) {
- apr_hash_this(hi, NULL, NULL, &val);
-
- if (!strncmp(arg, (const char *)val, arglen)) {
-
- apr_file_printf(r->out, "%s \n",
- redwax_pescape_echo_quoted(r->pool,
- (const char *)val, quoted, 1));
- }
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t redwax_complete_purpose(redwax_tool_t *r, const char *arg,
- redwax_token_quoted_e quoted)
-{
- apr_hash_t *purposes = apr_hash_make(r->pool);
-
- apr_hash_index_t *hi;
- void *val;
- int arglen = strlen(arg);
-
- rt_run_complete_purpose(r, purposes);
-
- for (hi = apr_hash_first(r->pool, purposes); hi; hi = apr_hash_next(hi)) {
- apr_hash_this(hi, NULL, NULL, &val);
-
- if (!strncmp(arg, (const char *)val, arglen)) {
-
- apr_file_printf(r->out, "%s \n",
- redwax_pescape_echo_quoted(r->pool,
- (const char *)val, quoted, 1));
- }
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t redwax_complete_nss_token_out(redwax_tool_t *r, const char *arg,
- redwax_token_quoted_e quoted)
-{
- apr_hash_t *tokens = apr_hash_make(r->pool);
-
- apr_hash_index_t *hi;
- void *val;
- int arglen = strlen(arg);
-
- rt_run_complete_nss_token_out(r, tokens);
-
- for (hi = apr_hash_first(r->pool, tokens); hi; hi = apr_hash_next(hi)) {
- apr_hash_this(hi, NULL, NULL, &val);
-
- if (!strncmp(arg, (const char *)val, arglen)) {
-
- apr_file_printf(r->out, "%s \n",
- redwax_pescape_echo_quoted(r->pool,
- (const char *)val, quoted, 1));
- }
- }
-
- return APR_SUCCESS;
-}
-
static apr_status_t redwax_complete_pkcs11_in(redwax_tool_t *r, const char *arg,
redwax_token_quoted_e quoted)
{
@@ -2017,56 +1892,6 @@
apr_file_printf(r->out, "%s\n",
redwax_pescape_echo_quoted(r->pool,
redwax_stroff((const char *)val, skiplen), quoted, 0));
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t redwax_complete_format_out(redwax_tool_t *r, const char *arg,
- redwax_token_quoted_e quoted)
-{
- apr_hash_t *formats = apr_hash_make(r->pool);
-
- apr_hash_index_t *hi;
- void *val;
- int arglen = strlen(arg);
-
- rt_run_complete_format_out(r, formats);
-
- for (hi = apr_hash_first(r->pool, formats); hi; hi = apr_hash_next(hi)) {
- apr_hash_this(hi, NULL, NULL, &val);
-
- if (!strncmp(arg, (const char *)val, arglen)) {
-
- apr_file_printf(r->out, "%s \n",
- redwax_pescape_echo_quoted(r->pool,
- (const char *)val, quoted, 1));
- }
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t redwax_complete_order_out(redwax_tool_t *r, const char *arg,
- redwax_token_quoted_e quoted)
-{
- apr_hash_t *orders = apr_hash_make(r->pool);
-
- apr_hash_index_t *hi;
- void *val;
- int arglen = strlen(arg);
-
- rt_run_complete_order_out(r, orders);
-
- for (hi = apr_hash_first(r->pool, orders); hi; hi = apr_hash_next(hi)) {
- apr_hash_this(hi, NULL, NULL, &val);
-
- if (!strncmp(arg, (const char *)val, arglen)) {
-
- apr_file_printf(r->out, "%s \n",
- redwax_pescape_echo_quoted(r->pool,
- (const char *)val, quoted, 1));
- }
}
return APR_SUCCESS;
@@ -3210,19 +3035,19 @@
break;
}
case REDWAX_TOOL_FILTER_VERIFY_PARAM: {
- redwax_complete_verify_param(r, optarg, state.isquoted);
+ redwax_complete_hash(r, optarg, &rt_run_complete_verify_param, state.isquoted);
break;
}
case REDWAX_TOOL_FILTER_EXPIRY: {
- redwax_complete_verify_expiry(r, optarg, state.isquoted);
+ redwax_complete_hash(r, optarg, &rt_run_complete_verify_expiry, state.isquoted);
break;
}
case REDWAX_TOOL_FILTER_DANE: {
- redwax_complete_verify_dane(r, optarg, state.isquoted);
+ redwax_complete_hash(r, optarg, &rt_run_complete_verify_dane, state.isquoted);
break;
}
case REDWAX_TOOL_FILTER_PURPOSE: {
- redwax_complete_purpose(r, optarg, state.isquoted);
+ redwax_complete_hash(r, optarg, &rt_run_complete_purpose, state.isquoted);
break;
}
case REDWAX_TOOL_NSS_OUT: {
@@ -3262,7 +3087,7 @@
break;
}
case REDWAX_TOOL_FORMAT_OUT: {
- redwax_complete_format_out(r, optarg, state.isquoted);
+ redwax_complete_hash(r, optarg, &rt_run_complete_format_out, state.isquoted);
break;
}
case REDWAX_TOOL_JWKS_OUT: {
@@ -3278,7 +3103,7 @@
break;
}
case REDWAX_TOOL_ORDER_OUT: {
- redwax_complete_order_out(r, optarg, state.isquoted);
+ redwax_complete_hash(r, optarg, &rt_run_complete_order_out, state.isquoted);
break;
}
case REDWAX_TOOL_DNS_TRUST_ANCHOR: {
@@ -3434,19 +3259,19 @@
break;
}
case REDWAX_TOOL_FILTER_VERIFY_PARAM: {
- redwax_complete_verify_param(r, "", state.isquoted);
+ redwax_complete_hash(r, "", &rt_run_complete_verify_param, state.isquoted);
break;
}
case REDWAX_TOOL_FILTER_EXPIRY: {
- redwax_complete_verify_expiry(r, "", state.isquoted);
+ redwax_complete_hash(r, "", &rt_run_complete_verify_expiry, state.isquoted);
break;
}
case REDWAX_TOOL_FILTER_DANE: {
- redwax_complete_verify_dane(r, "", state.isquoted);
+ redwax_complete_hash(r, "", &rt_run_complete_verify_dane, state.isquoted);
break;
}
case REDWAX_TOOL_FILTER_PURPOSE: {
- redwax_complete_purpose(r, "", state.isquoted);
+ redwax_complete_hash(r, "", &rt_run_complete_purpose, state.isquoted);
break;
}
case REDWAX_TOOL_NSS_OUT: {
@@ -3486,7 +3311,7 @@
break;
}
case REDWAX_TOOL_FORMAT_OUT: {
- redwax_complete_format_out(r, "", state.isquoted);
+ redwax_complete_hash(r, "", &rt_run_complete_format_out, state.isquoted);
break;
}
case REDWAX_TOOL_JWKS_OUT: {
@@ -3502,7 +3327,7 @@
break;
}
case REDWAX_TOOL_ORDER_OUT: {
- redwax_complete_order_out(r, "", state.isquoted);
+ redwax_complete_hash(r, "", &rt_run_complete_order_out, state.isquoted);
break;
}
case REDWAX_TOOL_DNS_TRUST_ANCHOR: {
More information about the rt-commit
mailing list