- if(!cmds)
- goto err;
- if(!ENGINE_ctrl(e, ENGINE_CTRL_HAS_CTRL_FUNCTION, 0, NULL, NULL) ||
- ((num = ENGINE_ctrl(e, ENGINE_CTRL_GET_FIRST_CMD_TYPE,
- 0, NULL, NULL)) <= 0))
- {
-#if 0
- BIO_printf(bio_out, "%s<no control commands>\n", indent);
-#endif
- return 1;
- }
- do {
- int len;
- /* Get the command name */
- if((len = ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_LEN_FROM_CMD, num,
- NULL, NULL)) <= 0)
- goto err;
- if((name = OPENSSL_malloc(len + 1)) == NULL)
- goto err;
- if(ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_FROM_CMD, num, name,
- NULL) <= 0)
- goto err;
- /* Get the command description */
- if((len = ENGINE_ctrl(e, ENGINE_CTRL_GET_DESC_LEN_FROM_CMD, num,
- NULL, NULL)) < 0)
- goto err;
- if(len > 0)
- {
- if((desc = OPENSSL_malloc(len + 1)) == NULL)
- goto err;
- if(ENGINE_ctrl(e, ENGINE_CTRL_GET_DESC_FROM_CMD, num, desc,
- NULL) <= 0)
- goto err;
- }
- /* Get the command input flags */
- if((flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, num,
- NULL, NULL)) < 0)
- goto err;
- /* Now decide on the output */
- if(xpos == 0)
- /* Do an indent */
- xpos = BIO_printf(bio_out, indent);
- else
- /* Otherwise prepend a ", " */
- xpos += BIO_printf(bio_out, ", ");
- if(verbose == 1)
- {
- /* We're just listing names, comma-delimited */
- if((xpos > (int)strlen(indent)) &&
- (xpos + (int)strlen(name) > line_wrap))
- {
- BIO_printf(bio_out, "\n");
- xpos = BIO_printf(bio_out, indent);
- }
- xpos += BIO_printf(bio_out, "%s", name);
- }
- else
- {
- /* We're listing names plus descriptions */
- BIO_printf(bio_out, "%s: %s\n", name,
- (desc == NULL) ? "<no description>" : desc);
- /* ... and sometimes input flags */
- if((verbose == 3) && !util_flags(bio_out, flags,
- indent))
- goto err;
- xpos = 0;
- }
- OPENSSL_free(name); name = NULL;
- if(desc) { OPENSSL_free(desc); desc = NULL; }
- /* Move to the next command */
- num = ENGINE_ctrl(e, ENGINE_CTRL_GET_NEXT_CMD_TYPE,
- num, NULL, NULL);
- } while(num > 0);
- if(xpos > 0)
- BIO_printf(bio_out, "\n");
- return 1;
-err:
- if(cmds) sk_pop_free(cmds, identity);
- if(name) OPENSSL_free(name);
- if(desc) OPENSSL_free(desc);
- return 0;
- }
+static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent)
+{
+ static const int line_wrap = 78;
+ int num;
+ int ret = 0;
+ char *name = NULL;
+ char *desc = NULL;
+ int flags;
+ int xpos = 0;
+ STACK_OF(OPENSSL_STRING) *cmds = NULL;
+ if (!ENGINE_ctrl(e, ENGINE_CTRL_HAS_CTRL_FUNCTION, 0, NULL, NULL) ||
+ ((num = ENGINE_ctrl(e, ENGINE_CTRL_GET_FIRST_CMD_TYPE,
+ 0, NULL, NULL)) <= 0)) {
+ return 1;
+ }