提交 1dcb8ca2 编写于 作者: M Matt Caswell

Use a STACK_OF(OPENSSL_CSTRING) for const char * stacks

Better than losing the const qualifier.

RT4378
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 6b44f259
...@@ -45,10 +45,6 @@ OPTIONS engine_options[] = { ...@@ -45,10 +45,6 @@ OPTIONS engine_options[] = {
{NULL} {NULL}
}; };
static void identity(char *ptr)
{
}
static int append_buf(char **buf, int *size, const char *s) static int append_buf(char **buf, int *size, const char *s)
{ {
if (*buf == NULL) { if (*buf == NULL) {
...@@ -217,7 +213,7 @@ static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent) ...@@ -217,7 +213,7 @@ static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent)
BIO_printf(out, "\n"); BIO_printf(out, "\n");
ret = 1; ret = 1;
err: err:
sk_OPENSSL_STRING_pop_free(cmds, identity); sk_OPENSSL_STRING_free(cmds);
OPENSSL_free(name); OPENSSL_free(name);
OPENSSL_free(desc); OPENSSL_free(desc);
return ret; return ret;
...@@ -267,7 +263,7 @@ int engine_main(int argc, char **argv) ...@@ -267,7 +263,7 @@ int engine_main(int argc, char **argv)
int ret = 1, i; int ret = 1, i;
int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0; int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
ENGINE *e; ENGINE *e;
STACK_OF(OPENSSL_STRING) *engines = sk_OPENSSL_STRING_new_null(); STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null(); STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null(); STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();
BIO *out; BIO *out;
...@@ -284,7 +280,7 @@ int engine_main(int argc, char **argv) ...@@ -284,7 +280,7 @@ int engine_main(int argc, char **argv)
* names, and then setup to parse the rest of the line as flags. */ * names, and then setup to parse the rest of the line as flags. */
prog = argv[0]; prog = argv[0];
while ((argv1 = argv[1]) != NULL && *argv1 != '-') { while ((argv1 = argv[1]) != NULL && *argv1 != '-') {
sk_OPENSSL_STRING_push(engines, argv1); sk_OPENSSL_CSTRING_push(engines, argv1);
argc--; argc--;
argv++; argv++;
} }
...@@ -337,17 +333,17 @@ int engine_main(int argc, char **argv) ...@@ -337,17 +333,17 @@ int engine_main(int argc, char **argv)
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
goto end; goto end;
} }
sk_OPENSSL_STRING_push(engines, *argv); sk_OPENSSL_CSTRING_push(engines, *argv);
} }
if (sk_OPENSSL_STRING_num(engines) == 0) { if (sk_OPENSSL_CSTRING_num(engines) == 0) {
for (e = ENGINE_get_first(); e != NULL; e = ENGINE_get_next(e)) { for (e = ENGINE_get_first(); e != NULL; e = ENGINE_get_next(e)) {
sk_OPENSSL_STRING_push(engines, (char *)ENGINE_get_id(e)); sk_OPENSSL_CSTRING_push(engines, ENGINE_get_id(e));
} }
} }
for (i = 0; i < sk_OPENSSL_STRING_num(engines); i++) { for (i = 0; i < sk_OPENSSL_CSTRING_num(engines); i++) {
const char *id = sk_OPENSSL_STRING_value(engines, i); const char *id = sk_OPENSSL_CSTRING_value(engines, i);
if ((e = ENGINE_by_id(id)) != NULL) { if ((e = ENGINE_by_id(id)) != NULL) {
const char *name = ENGINE_get_name(e); const char *name = ENGINE_get_name(e);
/* /*
...@@ -436,9 +432,9 @@ int engine_main(int argc, char **argv) ...@@ -436,9 +432,9 @@ int engine_main(int argc, char **argv)
end: end:
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
sk_OPENSSL_STRING_pop_free(engines, identity); sk_OPENSSL_CSTRING_free(engines);
sk_OPENSSL_STRING_pop_free(pre_cmds, identity); sk_OPENSSL_STRING_free(pre_cmds);
sk_OPENSSL_STRING_pop_free(post_cmds, identity); sk_OPENSSL_STRING_free(post_cmds);
BIO_free_all(out); BIO_free_all(out);
return (ret); return (ret);
} }
......
...@@ -120,6 +120,8 @@ extern "C" { ...@@ -120,6 +120,8 @@ extern "C" {
# define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2) # define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2)
# define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t) # define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t)
# define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) \
SKM_DEFINE_STACK_OF(t1, const t2, t2)
# define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t) # define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t)
/*- /*-
...@@ -147,6 +149,7 @@ typedef const char *OPENSSL_CSTRING; ...@@ -147,6 +149,7 @@ typedef const char *OPENSSL_CSTRING;
* dealt with in the autogenerated macros below. * dealt with in the autogenerated macros below.
*/ */
DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char) DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)
/* /*
* Similarly, we sometimes use a block of characters, NOT nul-terminated. * Similarly, we sometimes use a block of characters, NOT nul-terminated.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册