Replace "SSLeay" in API with OpenSSL
[openssl.git] / apps / openssl.c
index 90f2223c70c40ecf5acc26d761e7cc71b2a696b0..1fd3e73a483a550cbdba474017b28ec5afe2cc5d 100644 (file)
@@ -166,7 +166,7 @@ BIO *bio_in = NULL;
 BIO *bio_out = NULL;
 BIO *bio_err = NULL;
 
-static void apps_startup()
+static int apps_startup()
 {
 #ifdef SIGPIPE
     signal(SIGPIPE, SIG_IGN);
@@ -174,14 +174,22 @@ static void apps_startup()
     CRYPTO_malloc_init();
     ERR_load_crypto_strings();
     ERR_load_SSL_strings();
-    OpenSSL_add_all_algorithms();
-    OpenSSL_add_ssl_algorithms();
+
     OPENSSL_load_builtin_modules();
-    setup_ui_method();
-    /*SSL_library_init();*/
 #ifndef OPENSSL_NO_ENGINE
     ENGINE_load_builtin_engines();
 #endif
+    if (!app_load_modules(NULL)) {
+        ERR_print_errors(bio_err);
+        BIO_printf(bio_err, "Error loading default configuration\n");
+        return 0;
+    }
+
+    OpenSSL_add_all_algorithms();
+    OpenSSL_add_ssl_algorithms();
+    setup_ui_method();
+    /*SSL_library_init();*/
+    return 1;
 }
 
 static void apps_shutdown()
@@ -209,8 +217,7 @@ static char *make_config_name()
     size_t len;
     char *p;
 
-    if ((t = getenv("OPENSSL_CONF")) != NULL
-        || (t = getenv("SSLEAY_CONF")) != NULL)
+    if ((t = getenv("OPENSSL_CONF")) != NULL)
         return BUF_strdup(t);
 
     t = X509_get_default_cert_area();
@@ -328,18 +335,9 @@ int main(int argc, char *argv[])
 #endif
     }
 
-    apps_startup();
+    if (!apps_startup())
+        goto end;
 
-    /*
-     * If first argument is a colon, skip it.  Because in "interactive"
-     * mode our prompt is a colon and we can cut/paste whole lines
-     * by doing this hack.
-     */
-    if (argv[1] && strcmp(argv[1], ":") == 0) {
-        argv[1] = argv[0];
-        argc--;
-        argv++;
-    }
     prog = prog_init();
     pname = opt_progname(argv[0]);
 
@@ -367,7 +365,7 @@ int main(int argc, char *argv[])
         ret = 0;
         /* Read a line, continue reading if line ends with \ */
         for (p = buf, n = sizeof buf, i = 0, first = 1; n > 0; first = 0) {
-            prompt = first ? "openssl : " : "> ";
+            prompt = first ? "OpenSSL> " : "> ";
             p[0] = '\0';
 #ifndef READLINE
             fputs(prompt, stdout);
@@ -504,11 +502,12 @@ int list_main(int argc, char **argv)
 {
     char *prog;
     HELPLIST_CHOICE o;
+    int done = 0;
 
     prog = opt_init(argc, argv, list_options);
     while ((o = opt_next()) != OPT_EOF) {
         switch (o) {
-        case OPT_EOF:
+        case OPT_EOF:  /* Never hit, but suppresses warning */
         case OPT_ERR:
             BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
             return 1;
@@ -537,6 +536,12 @@ int list_main(int argc, char **argv)
             list_disabled();
             break;
         }
+        done = 1;
+    }
+
+    if (!done) {
+        BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
+        return 1;
     }
 
     return 0;
@@ -735,6 +740,9 @@ static void list_disabled(void)
 #ifdef OPENSSL_NO_CAST
     BIO_puts(bio_out, "CAST\n");
 #endif
+#ifdef OPENSSL_NO_CMAC
+    BIO_puts(bio_out, "CMAC\n");
+#endif
 #ifdef OPENSSL_NO_CMS
     BIO_puts(bio_out, "CMS\n");
 #endif
@@ -768,6 +776,9 @@ static void list_disabled(void)
 #ifdef OPENSSL_NO_GOST
     BIO_puts(bio_out, "GOST\n");
 #endif
+#ifdef OPENSSL_NO_HMAC
+    BIO_puts(bio_out, "HMAC\n");
+#endif
 #ifdef OPENSSL_NO_IDEA
     BIO_puts(bio_out, "IDEA\n");
 #endif
@@ -786,9 +797,6 @@ static void list_disabled(void)
 #ifdef OPENSSL_NO_MDC2
     BIO_puts(bio_out, "MDC2\n");
 #endif
-#ifdef OPENSSL_NO_MD_GHOST94
-    BIO_puts(bio_out, "MD_GHOST94\n");
-#endif
 #ifdef OPENSSL_NO_OCB
     BIO_puts(bio_out, "OCB\n");
 #endif