Further synchronisation with Unix build. I hadn't noticed pq_compat.h
[openssl.git] / apps / engine.c
index 953b4d97a21405470d746ae0304344fbaf53ed06..a93ea4de3c6bf3053e14034abf9edd646c7f842e 100644 (file)
@@ -72,7 +72,7 @@
 #undef PROG
 #define PROG   engine_main
 
-static char *engine_usage[]={
+static const char *engine_usage[]={
 "usage: engine opts [engine ...]\n",
 " -v[v[v[v]]] - verbose mode, for each engine, list its 'control commands'\n",
 "               -vv will additionally display each command's description\n",
@@ -123,8 +123,8 @@ static int append_buf(char **buf, const char *s, int *size, int step)
                return 0;
 
        if (**buf != '\0')
-               strcat(*buf, ", ");
-       strcat(*buf, s);
+               BUF_strlcat(*buf, ", ", *size);
+       BUF_strlcat(*buf, s, *size);
 
        return 1;
        }
@@ -148,11 +148,6 @@ static int util_flags(BIO *bio_out, unsigned int flags, const char *indent)
 
        if(flags & ENGINE_CMD_FLAG_NUMERIC)
                {
-               if(started)
-                       {
-                       BIO_printf(bio_out, "|");
-                       err = 1;
-                       }
                BIO_printf(bio_out, "NUMERIC");
                started = 1;
                }
@@ -344,7 +339,7 @@ int MAIN(int, char **);
 int MAIN(int argc, char **argv)
        {
        int ret=1,i;
-       char **pp;
+       const char **pp;
        int verbose=0, list_cap=0, test_avail=0, test_avail_noise = 0;
        ENGINE *e;
        STACK *engines = sk_new_null();
@@ -394,11 +389,15 @@ int MAIN(int argc, char **argv)
                else if (strcmp(*argv,"-pre") == 0)
                        {
                        argc--; argv++;
+                       if (argc == 0)
+                               goto skip_arg_loop;
                        sk_push(pre_cmds,*argv);
                        }
                else if (strcmp(*argv,"-post") == 0)
                        {
                        argc--; argv++;
+                       if (argc == 0)
+                               goto skip_arg_loop;
                        sk_push(post_cmds,*argv);
                        }
                else if ((strncmp(*argv,"-h",2) == 0) ||
@@ -450,6 +449,7 @@ skip_arg_loop:
                                const int *nids;
                                ENGINE_CIPHERS_PTR fn_c;
                                ENGINE_DIGESTS_PTR fn_d;
+                               ENGINE_PKEY_METHS_PTR fn_pk;
 
                                if (ENGINE_get_RSA(e) != NULL
                                        && !append_buf(&cap_buf, "RSA",
@@ -488,6 +488,15 @@ skip_ciphers:
                                                goto end;
 
 skip_digests:
+                               fn_pk = ENGINE_get_pkey_meths(e);
+                               if(!fn_pk) goto skip_pmeths;
+                               n = fn_pk(e, NULL, &nids, 0);
+                               for(k=0 ; k < n ; ++k)
+                                       if(!append_buf(&cap_buf,
+                                                      OBJ_nid2sn(nids[k]),
+                                                      &cap_size, 256))
+                                               goto end;
+skip_pmeths:
                                if (cap_buf && (*cap_buf != '\0'))
                                        BIO_printf(bio_out, " [%s]\n", cap_buf);
 
@@ -520,13 +529,6 @@ skip_digests:
 
        ret=0;
 end:
-#else
-
-# if PEDANTIC
-
-void *dummy=&dummy;
-
-# endif
 
        ERR_print_errors(bio_err);
        sk_pop_free(engines, identity);
@@ -536,4 +538,10 @@ void *dummy=&dummy;
        apps_shutdown();
        OPENSSL_EXIT(ret);
        }
+#else
+
+# if PEDANTIC
+static void *dummy=&dummy;
+# endif
+
 #endif