EXIT() may mean return(). That's confusing, so let's have it really mean
authorRichard Levitte <levitte@openssl.org>
Tue, 3 Dec 2002 16:51:51 +0000 (16:51 +0000)
committerRichard Levitte <levitte@openssl.org>
Tue, 3 Dec 2002 16:51:51 +0000 (16:51 +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)

33 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/enc.c
apps/errstr.c
apps/gendh.c
apps/gendsa.c
apps/genrsa.c
apps/nseq.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 5339166e088569ffdd9753eebe5a7cdb65444bda..8cc13ee2d1130a0fca9108932a574c06dfc7857b 100644 (file)
@@ -328,6 +328,6 @@ end:
        if (at != NULL) ASN1_TYPE_free(at);
        if (osk != NULL) sk_free(osk);
        OBJ_cleanup();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
index 8301f0f38f5552273967168199b14f3bd910cfcd..7e64a75e8d36e158b4270a2887a9d18a63260cdd 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1280,7 +1280,7 @@ err:
        X509_CRL_free(crl);
        CONF_free(conf);
        OBJ_cleanup();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void lookup_fail(char *name, char *tag)
index b6e2f966d86e78d7b01c097ea655fc4932920156..0dc30d65e4015b009b5970dbf7a90aecbed9a3d6 100644 (file)
@@ -202,6 +202,6 @@ end:
        if (ctx != NULL) SSL_CTX_free(ctx);
        if (ssl != NULL) SSL_free(ssl);
        if (STDout != NULL) BIO_free_all(STDout);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
index 3b5725f23f2c4335aed373140bd8ed991009e4f4..648a32ee4cf96a72d77a9a96ce17fd4d451e091f 100644 (file)
@@ -364,7 +364,7 @@ end:
                X509_STORE_CTX_cleanup(&ctx);
                X509_STORE_free(store);
        }
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static X509_CRL *load_crl(char *infile, int format)
index 7f853b65ab2b13bb2cba055bbce53503965970ef..3ef55dd2bb4ecaa6874912da40ef498e60f6736a 100644 (file)
@@ -166,7 +166,7 @@ bad:
                BIO_printf(bio_err," -certfile arg  certificates file of chain to a trusted CA\n");
                BIO_printf(bio_err,"                (can be used more than once)\n");
                BIO_printf(bio_err," -nocrl         no crl to load, just certs from '-certfile'\n");
-               EXIT(1);
+               OPENSSL_EXIT(1);
                }
 
        ERR_load_crypto_strings();
@@ -278,7 +278,7 @@ end:
        if (p7 != NULL) PKCS7_free(p7);
        if (crl != NULL) X509_CRL_free(crl);
 
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 /*
index 8da784771a5f8814cf069003d491d7a6b7d76e0b..e339811365c0d966d70bb5e71dc726cef755b504 100644 (file)
@@ -335,7 +335,7 @@ end:
        EVP_PKEY_free(sigkey);
        if(sigbuf) OPENSSL_free(sigbuf);
        if (bmd != NULL) BIO_free(bmd);
-       EXIT(err);
+       OPENSSL_EXIT(err);
        }
 
 void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
index 7465442e49f1c07f8d766029ca8bdfe599c0eb43..ee2514a07ea11ec1ff95be81f0438c23dcedca93 100644 (file)
--- a/apps/dh.c
+++ b/apps/dh.c
@@ -319,6 +319,6 @@ end:
        if (in != NULL) BIO_free(in);
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 #endif
index 5f9b60148d6fb60610a7abaf887b2be721d137e6..baf0d3302aace837ae9f149feedb77294f56c3c7 100644 (file)
@@ -506,7 +506,7 @@ end:
        if (in != NULL) BIO_free(in);
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 /* dh_cb is identical to dsa_cb in apps/dsaparam.c */
index 7c4a46f78eae21a7a9e22bcd6420697947bf941f..04efe16b58365208cba92a3a837f95824f7b5763 100644 (file)
@@ -293,6 +293,6 @@ end:
        if(dsa != NULL) DSA_free(dsa);
        if(passin) OPENSSL_free(passin);
        if(passout) OPENSSL_free(passout);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 #endif
index 0c2529e2859a0c8eec6c6350c759bdfd9f6682b1..ea29b0cf65af11944b97b4763a048fddfdebb4f2 100644 (file)
@@ -357,7 +357,7 @@ end:
        if (in != NULL) BIO_free(in);
        if (out != NULL) BIO_free_all(out);
        if (dsa != NULL) DSA_free(dsa);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
index 1e554053ea35f5d7157d2926956d22a751d54db9..397b0e9c12eace100cc80c257629f00eb4899b72 100644 (file)
@@ -604,7 +604,7 @@ end:
        if (benc != NULL) BIO_free(benc);
        if (b64 != NULL) BIO_free(b64);
        if(pass) OPENSSL_free(pass);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 int set_hex(char *in, unsigned char *out, int size)
index e392328f93d2656f84653e53c68de5f37495538f..de7d5fd6501ad7e5e5fd47178115d707ce9b146d 100644 (file)
@@ -121,5 +121,5 @@ int MAIN(int argc, char **argv)
                        ret++;
                        }
                }
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index e0c7889a31e119a680f16cc112cdb071245bbf6c..f02f87d17b3db51591395098185b7aeab689380d 100644 (file)
@@ -184,7 +184,7 @@ end:
                ERR_print_errors(bio_err);
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void MS_CALLBACK dh_cb(int p, int n, void *arg)
index 6022d8f1427a6c29f8d4d73f9e4f680f378b9930..4abd7786b1b82aac658f3eeeeebe74a57235e035 100644 (file)
@@ -220,6 +220,6 @@ end:
        if (out != NULL) BIO_free_all(out);
        if (dsa != NULL) DSA_free(dsa);
        if(passout) OPENSSL_free(passout);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 #endif
index ac0b709e7af97725a8661c0a7bd511c53e9534b5..1f0f2d780942317c3c7ee9940ba0e8345da9201d 100644 (file)
@@ -224,7 +224,7 @@ err:
        if(passout) OPENSSL_free(passout);
        if (ret != 0)
                ERR_print_errors(bio_err);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
index 1d73d1ad5231e2e6cdfa5e0a991e0bd019c4276c..da5277d4c4411a37ddbf8ba3025af7b010a59f78 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 55af53f3e2b52e0e6b759d7309e0b1f933a4b72d..95e1e00a8d04aa63f0781b9f1a4f48da16e031f8 100644 (file)
@@ -215,7 +215,7 @@ end:
                BIO_free(bio_err);
                bio_err=NULL;
                }
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 #define LIST_STANDARD_COMMANDS "list-standard-commands"
index ea2b089e24a73762fd027f997f5a34b5ef9e9487..eaa90312fc83446a7a8256d46236eecf475576a6 100644 (file)
@@ -284,7 +284,7 @@ err:
                BIO_free(in);
        if (out)
                BIO_free_all(out);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 
@@ -498,6 +498,6 @@ err:
 int MAIN(int argc, char **argv)
        {
        fputs("Program not available.\n", stderr)
-       EXIT(1);
+       OPENSSL_EXIT(1);
        }
 #endif
index f53b44721eb9d7c3dae4c839f8df237bec17e59c..4e20c0cc369f6675cbdf7b802e1dee01c0900e77 100644 (file)
@@ -666,7 +666,7 @@ int MAIN(int argc, char **argv)
     if (canames) sk_free(canames);
     if(passin) OPENSSL_free(passin);
     if(passout) OPENSSL_free(passout);
-    EXIT(ret);
+    OPENSSL_EXIT(ret);
 }
 
 int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
index a9fff11e5cf930099cc36bb9d9327869b54d2736..f100c8d053776cac07444e681833c6d1e4120cca 100644 (file)
@@ -154,7 +154,7 @@ bad:
                BIO_printf(bio_err," -print_certs  print any certs or crl in the input\n");
                BIO_printf(bio_err," -text         print full details of certificates\n");
                BIO_printf(bio_err," -noout        don't output encoded data\n");
-               EXIT(1);
+               OPENSSL_EXIT(1);
                }
 
        ERR_load_crypto_strings();
@@ -289,5 +289,5 @@ end:
        if (p7 != NULL) PKCS7_free(p7);
        if (in != NULL) BIO_free(in);
        if (out != NULL) BIO_free_all(out);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index 04764d7ffb6c961742dac375d97b8244e5ce8716..498a802650e31acea9efde4b2cf636568b3d5155 100644 (file)
@@ -144,5 +144,5 @@ err:
        ERR_print_errors(bio_err);
        if (out)
                BIO_free_all(out);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index f9253452a7738deb1f47e8d4d07dc05fdc0cdc3c..0fb426d9023e1d5dbd2916642e4666f0fc7f71c9 100644 (file)
@@ -909,7 +909,7 @@ end:
 #ifndef NO_DSA
        if (dsa_params != NULL) DSA_free(dsa_params);
 #endif
-       EXIT(ex);
+       OPENSSL_EXIT(ex);
        }
 
 static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, int attribs)
index b4b0651a94bde577728f0697a5bb331a8bbdb26f..f35b6d166e97a6092e3ccd9b89402bca37218da1 100644 (file)
@@ -389,7 +389,7 @@ end:
        if(rsa != NULL) RSA_free(rsa);
        if(passin) OPENSSL_free(passin);
        if(passout) OPENSSL_free(passout);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 #else /* !NO_RSA */
 
index a637fec0a6b0c1b2a4f8d8b8496f5775db4bcd1b..3e2a2953d77bd0f6470e8106a0cb398cc3c8769f 100644 (file)
@@ -775,7 +775,7 @@ end:
                BIO_free(bio_c_out);
                bio_c_out=NULL;
                }
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 
index 0cff7f8adebbe240b86b2f5e6eb88d813a3ac5bc..0839ac07daf25dc8c3c3b0f3d4ab5a5f3a91a5b7 100644 (file)
@@ -741,7 +741,7 @@ end:
                BIO_free(bio_s_out);
                bio_s_out=NULL;
                }
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static void print_stats(BIO *bio, SSL_CTX *ssl_ctx)
index 2d8e2b24d228187517541b2658d86e6d432258c8..c8719a6a2200fcbce411cac6dc0d9781d2e143f5 100644 (file)
@@ -461,7 +461,7 @@ int MAIN(int argc, char **argv)
 
        if (tm_cipher == NULL ) {
                fprintf( stderr, "No CIPHER specified\n" );
-/*             EXIT(1); */
+/*             OPENSSL_EXIT(1); */
        }
 
        if (!(perform & 1)) goto next;
@@ -628,7 +628,7 @@ end:
                SSL_CTX_free(tm_ctx);
                tm_ctx=NULL;
                }
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 /***********************************************************************
index 60cc3f1e496a3d524e9c408f7c9aa99251e76473..cf15006ca72a846fd4281b17e3f4599757d860be 100644 (file)
@@ -272,7 +272,7 @@ bad:
 end:
        if (out != NULL) BIO_free_all(out);
        if (x != NULL) SSL_SESSION_free(x);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static SSL_SESSION *load_sess_id(char *infile, int format)
index 9fb0aa19912c9ed744cf3d07c61ef0c6617c1a15..6ae0c8d6ebf77953c57a2714fdda9b4d81a4fffe 100644 (file)
@@ -1412,7 +1412,7 @@ end:
                if (dsa_key[i] != NULL)
                        DSA_free(dsa_key[i]);
 #endif
-       EXIT(mret);
+       OPENSSL_EXIT(mret);
        }
 
 static void print_message(char *s, long num, int length)
index 459d730a704a30372fd6dec030b99ba8f332b4d2..94723a79c359fd6d9c93d48fcd4e2768a62f83ab 100644 (file)
@@ -288,5 +288,5 @@ end:
        BIO_free(key);
        EVP_PKEY_free(pkey);
        if(passin) OPENSSL_free(passin);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index 47e602d4a3c6d9099933f1b5910db2c35f019b95..3ff1c0f9e7d40b3a853024030fb35e2ff264c414 100644 (file)
@@ -213,7 +213,7 @@ end:
        if (cert_ctx != NULL) X509_STORE_free(cert_ctx);
        sk_X509_pop_free(untrusted, X509_free);
        sk_X509_pop_free(trusted, X509_free);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose)
index f5c9adc25471c17e8f05ae54822c28ad15fb70e4..b67f2d18126cd22db004cf3139d3f2cf7054b0f9 100644 (file)
@@ -128,5 +128,5 @@ int MAIN(int argc, char **argv)
                }
        if (cflags)  printf("%s\n",SSLeay_version(SSLEAY_CFLAGS));
 end:
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index 7dfbfbfee90b9fff18a051a0b0046b66576df5d3..d20cf15267fa3e7eabdbbbcab2ab1acec05dd7ed 100644 (file)
@@ -961,7 +961,7 @@ end:
        sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free);
        sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free);
        if (passin) OPENSSL_free(passin);
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
diff --git a/e_os.h b/e_os.h
index 30008fa781ad63d21fe1b50c3a8da68d5b335bb9..58df717722c466763e5382f8667269abb8f076b6 100644 (file)
--- a/e_os.h
+++ b/e_os.h
@@ -219,10 +219,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
@@ -275,18 +276,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 */
@@ -317,11 +313,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()
@@ -441,6 +433,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.