EXIT() may mean return(). That's confusing, so let's have it really mean
authorRichard Levitte <levitte@openssl.org>
Tue, 3 Dec 2002 16:33:03 +0000 (16:33 +0000)
committerRichard Levitte <levitte@openssl.org>
Tue, 3 Dec 2002 16:33:03 +0000 (16:33 +0000)
exit() in whatever way works for the intended platform, and define
OPENSSL_EXIT() to have the old meaning (the name is of course because
it's only used in the openssl program)

37 files changed:
apps/asn1pars.c
apps/ca.c
apps/ciphers.c
apps/crl.c
apps/crl2p7.c
apps/dgst.c
apps/dh.c
apps/dhparam.c
apps/dsa.c
apps/dsaparam.c
apps/ec.c
apps/ecparam.c
apps/enc.c
apps/engine.c
apps/errstr.c
apps/gendh.c
apps/gendsa.c
apps/genrsa.c
apps/nseq.c
apps/ocsp.c
apps/openssl.c
apps/passwd.c
apps/pkcs12.c
apps/pkcs7.c
apps/rand.c
apps/req.c
apps/rsa.c
apps/s_client.c
apps/s_server.c
apps/s_time.c
apps/sess_id.c
apps/speed.c
apps/spkac.c
apps/verify.c
apps/version.c
apps/x509.c
e_os.h

index dc41da3..5f8ba5e 100644 (file)
@@ -361,7 +361,7 @@ end:
        if (osk != NULL) sk_free(osk);
        OBJ_cleanup();
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
index cac83a1..8cb5342 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1652,7 +1652,7 @@ err:
        NCONF_free(conf);
        OBJ_cleanup();
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void lookup_fail(char *name, char *tag)
index fe26ae8..7c62fc5 100644 (file)
@@ -203,6 +203,6 @@ end:
        if (ssl != NULL) SSL_free(ssl);
        if (STDout != NULL) BIO_free_all(STDout);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
index 00946b4..c6089ac 100644 (file)
@@ -377,7 +377,7 @@ end:
                X509_STORE_free(store);
        }
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static X509_CRL *load_crl(char *infile, int format)
index 8729068..b2f2d12 100644 (file)
@@ -280,7 +280,7 @@ end:
        if (crl != NULL) X509_CRL_free(crl);
 
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 /*
index c4bb7a1..280f79b 100644 (file)
@@ -365,7 +365,7 @@ end:
        if(sigbuf) OPENSSL_free(sigbuf);
        if (bmd != NULL) BIO_free(bmd);
        apps_shutdown();
-       EXIT(err);
+       OPENSSL_EXIT(err);
        }
 
 int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
index 27c3dc8..c10ea96 100644 (file)
--- a/apps/dh.c
+++ b/apps/dh.c
@@ -333,6 +333,6 @@ end:
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 #endif
index ea15ef3..cbc65bc 100644 (file)
@@ -519,7 +519,7 @@ end:
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 /* dh_cb is identical to dsa_cb in apps/dsaparam.c */
index 9da1a41..6598871 100644 (file)
@@ -314,6 +314,6 @@ end:
        if(passin) OPENSSL_free(passin);
        if(passout) OPENSSL_free(passout);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 #endif
index 2f43680..320d76f 100644 (file)
@@ -372,7 +372,7 @@ end:
        if (out != NULL) BIO_free_all(out);
        if (dsa != NULL) DSA_free(dsa);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
index 71ffaec..7d57341 100644 (file)
--- a/apps/ec.c
+++ b/apps/ec.c
@@ -390,6 +390,6 @@ end:
        if (passout)
                OPENSSL_free(passout);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
 }
 #endif
index 02bf6c1..3bd0a97 100644 (file)
@@ -679,7 +679,7 @@ end:
        if (group != NULL)
                EC_GROUP_free(group);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
 }
 
 int ecparam_print_var(BIO *out, BIGNUM *in, const char *var,
index bae7f21..42ddfd2 100644 (file)
@@ -586,7 +586,7 @@ end:
        if (b64 != NULL) BIO_free(b64);
        if(pass) OPENSSL_free(pass);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 int set_hex(char *in, unsigned char *out, int size)
index 734ecb3..b718ae1 100644 (file)
@@ -516,5 +516,5 @@ end:
        sk_pop_free(post_cmds, identity);
        if (bio_out != NULL) BIO_free_all(bio_out);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index fedb568..19489b0 100644 (file)
@@ -122,5 +122,5 @@ int MAIN(int argc, char **argv)
                        }
                }
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index f254296..98ee413 100644 (file)
@@ -198,7 +198,7 @@ end:
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void MS_CALLBACK dh_cb(int p, int n, void *arg)
index 1e1e9f3..4600711 100644 (file)
@@ -246,6 +246,6 @@ end:
        if (dsa != NULL) DSA_free(dsa);
        if(passout) OPENSSL_free(passout);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 #endif
index 515bd7c..dbc23e4 100644 (file)
@@ -258,7 +258,7 @@ err:
        if (ret != 0)
                ERR_print_errors(bio_err);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
index c26f62c..dc71d45 100644 (file)
@@ -102,7 +102,7 @@ int MAIN(int argc, char **argv)
                BIO_printf (bio_err, "-in file  input file\n");
                BIO_printf (bio_err, "-out file output file\n");
                BIO_printf (bio_err, "-toseq    output NS Sequence file\n");
-               EXIT(1);
+               OPENSSL_EXIT(1);
        }
 
        if (infile) {
@@ -162,6 +162,6 @@ end:
        BIO_free_all(out);
        NETSCAPE_CERT_SEQUENCE_free(seq);
 
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
 }
 
index d759b27..92922bc 100644 (file)
@@ -899,7 +899,7 @@ end:
                SSL_CTX_free(ctx);
                }
 
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
 }
 
 static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, X509 *issuer,
index 45f8d7f..4789647 100644 (file)
@@ -358,7 +358,7 @@ end:
                BIO_free(bio_err);
                bio_err=NULL;
                }
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 #define LIST_STANDARD_COMMANDS "list-standard-commands"
index 0c2cf62..3ad91d8 100644 (file)
@@ -292,7 +292,7 @@ err:
        if (out)
                BIO_free_all(out);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 
@@ -505,6 +505,6 @@ err:
 int MAIN(int argc, char **argv)
        {
        fputs("Program not available.\n", stderr)
-       EXIT(1);
+       OPENSSL_EXIT(1);
        }
 #endif
index 536cf57..e445c24 100644 (file)
@@ -651,7 +651,7 @@ int MAIN(int argc, char **argv)
     if(passin) OPENSSL_free(passin);
     if(passout) OPENSSL_free(passout);
     apps_shutdown();
-    EXIT(ret);
+    OPENSSL_EXIT(ret);
 }
 
 int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
index 0cced40..738dd85 100644 (file)
@@ -301,5 +301,5 @@ end:
        if (in != NULL) BIO_free(in);
        if (out != NULL) BIO_free_all(out);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index f51f5be..eaaa6e3 100644 (file)
@@ -213,5 +213,5 @@ err:
        if (out)
                BIO_free_all(out);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index 980138f..a582e69 100644 (file)
@@ -1150,7 +1150,7 @@ end:
        if (ec_params != NULL) EC_KEY_free(ec_params);
 #endif
        apps_shutdown();
-       EXIT(ex);
+       OPENSSL_EXIT(ex);
        }
 
 static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, char *subj, int attribs,
index 4e19bc1..aebec74 100644 (file)
@@ -369,7 +369,7 @@ end:
        if(passin) OPENSSL_free(passin);
        if(passout) OPENSSL_free(passout);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 #else /* !OPENSSL_NO_RSA */
 
index 7b1fa7b..738588c 100644 (file)
@@ -917,7 +917,7 @@ end:
                bio_c_out=NULL;
                }
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 
index 7380fcc..aa7ff66 100644 (file)
@@ -946,7 +946,7 @@ end:
                bio_s_out=NULL;
                }
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void print_stats(BIO *bio, SSL_CTX *ssl_ctx)
index 181a7c8..1ad16cd 100644 (file)
@@ -642,7 +642,7 @@ end:
                tm_ctx=NULL;
                }
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 /***********************************************************************
index 41c3b3f..d91d84d 100644 (file)
@@ -273,7 +273,7 @@ end:
        if (out != NULL) BIO_free_all(out);
        if (x != NULL) SSL_SESSION_free(x);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static SSL_SESSION *load_sess_id(char *infile, int format)
index 27f2e67..800ecd3 100644 (file)
@@ -2316,7 +2316,7 @@ end:
 #endif
 
        apps_shutdown();
-       EXIT(mret);
+       OPENSSL_EXIT(mret);
        }
 
 static void print_message(const char *s, long num, int length)
index 4ce53e3..ed370c5 100644 (file)
@@ -295,5 +295,5 @@ end:
        EVP_PKEY_free(pkey);
        if(passin) OPENSSL_free(passin);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index e4cbcea..9a18213 100644 (file)
@@ -232,7 +232,7 @@ end:
        sk_X509_pop_free(untrusted, X509_free);
        sk_X509_pop_free(trusted, X509_free);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e)
index 435e0b4..041da37 100644 (file)
@@ -212,5 +212,5 @@ int MAIN(int argc, char **argv)
        if (dir)  printf("%s\n",SSLeay_version(SSLEAY_DIR));
 end:
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index 0f6e9ad..9709628 100644 (file)
@@ -1029,7 +1029,7 @@ end:
        sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free);
        if (passin) OPENSSL_free(passin);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create)
diff --git a/e_os.h b/e_os.h
index 5d76178..db9ba97 100644 (file)
--- a/e_os.h
+++ b/e_os.h
@@ -243,10 +243,11 @@ extern "C" {
 #    define _kbhit kbhit
 #  endif
 
-#  if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
-#    define EXIT(n) do { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); } while(0)
+#  if defined(WIN16) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
+#    define EXIT(n) _wsetexit(_WINEXITNOPERSIST)
+#    define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0)
 #  else
-#    define EXIT(n)            return(n)
+#    define EXIT(n) return(n)
 #  endif
 #  define LIST_SEPARATOR_CHAR ';'
 #  ifndef X_OK
@@ -302,18 +303,13 @@ extern "C" {
      the status is tagged as an error, which I believe is what is wanted here.
      -- Richard Levitte
   */
-#    if !defined(MONOLITH) || defined(OPENSSL_C)
-#      define EXIT(n)          do { int __VMS_EXIT = n; \
+#    define EXIT(n)            do { int __VMS_EXIT = n; \
                                      if (__VMS_EXIT == 0) \
                                       __VMS_EXIT = 1; \
                                     else \
                                       __VMS_EXIT = (n << 3) | 2; \
                                      __VMS_EXIT |= 0x10000000; \
-                                    exit(__VMS_EXIT); \
-                                    return(__VMS_EXIT); } while(0)
-#    else
-#      define EXIT(n)          return(n)
-#    endif
+                                    exit(__VMS_EXIT); } while(0)
 #    define NO_SYS_PARAM_H
 #  else
      /* !defined VMS */
@@ -344,11 +340,7 @@ extern "C" {
 #    define RFILE              ".rnd"
 #    define LIST_SEPARATOR_CHAR ':'
 #    define NUL_DEV            "/dev/null"
-#    ifndef MONOLITH
-#      define EXIT(n)          do { exit(n); return(n); } while(0)
-#    else
-#      define EXIT(n)          return(n)
-#    endif
+#    define EXIT(n)            exit(n)
 #  endif
 
 #  define SSLeay_getpid()      getpid()
@@ -475,6 +467,14 @@ extern char *sys_errlist[]; extern int sys_nerr;
        (((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
 #endif
 
+#ifndef OPENSSL_EXIT
+# if defined(MONOLITH) && !defined(OPENSSL_C)
+#  define OPENSSL_EXIT(n) return(n)
+# else
+#  define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
+# endif
+#endif
+
 /***********************************************/
 
 /* do we need to do this for getenv.