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 dc41da38a01437d8fee6450d402d189ef662273f..5f8ba5e730337468e78466548928e585b536040d 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 cac83a114f17f97e83a995a7ad90cc19d0e5f0d7..8cb5342ce0c5dc0d15b1c53baf1fcc334177b5ae 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 fe26ae8cd62504b13a891dbab4ee9a2e7ec57015..7c62fc5dc3394e3dea48a8db9d700db93bdc4806 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 00946b4d20fc2370cb9636ac9e41594a45e6af2f..c6089ace526189ee55cdb00df04e9a6cf09defb5 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 8729068462baa840f934e5c13bac4d38c784767c..b2f2d121d56cb8739f32d6b9a6173051fdd98d55 100644 (file)
@@ -280,7 +280,7 @@ end:
        if (crl != NULL) X509_CRL_free(crl);
 
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 /*
index c4bb7a106153bd31bcac32f0d044b721c490c4cd..280f79b4a23abaf5f1c3029642763bdc5dd7536f 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 27c3dc8df22cdc8e86d5d8a80ccaaace72bff20d..c10ea96b90ac9a4cd7c92b00cf7fdfac44a532b1 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 ea15ef32368f66abcf45b6575727f47d9d9c83c5..cbc65bcc5f5e94c4686efb979e741e07a48861b6 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 9da1a41645b78f493d78d24bb5c23410c9959617..65988717bbd176270c0652f84a427220919922fa 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 2f436803e36ce598d417f16303626b361fc021a5..320d76f632d43dea28207672f0dc28b333e9dd3b 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 71ffaecb15cdb85c0cfbbf36eea790811e0433f8..7d57341cb47d1046008b0638fe7eb2b5fa5a1de0 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 02bf6c1a9dd5e0bfebb48caaf713e7aa0a4ed3dd..3bd0a974873b32cc7b101ccc76ba7ce16586c1f6 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 bae7f21d79047530792c9ded85f31c9e845f2d30..42ddfd244bc5588c5983edefa2881a1b78e0fd50 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 734ecb3e5db0a4581bc5e495d7057f8785536041..b718ae124c05f6523178fc29cbd62e84b7e8993f 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 fedb568d686988ce9da114c63495227f2b927bfe..19489b0df3b7b9d7a83c924e77fc2107bce84e1e 100644 (file)
@@ -122,5 +122,5 @@ int MAIN(int argc, char **argv)
                        }
                }
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index f2542960bf28be2bb311a750fba474bd2490eb7d..98ee413c74b716c82bf2f0f0ad2ea404cd2bb031 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 1e1e9f3e4c4e672b439873ebc91db05613d12cef..4600711c369a138586dc50f1ff4bcf43bf9f2dab 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 515bd7c9017135667781a2c8cc4ba3ae2ba84d16..dbc23e40aa85f46afd009cc5d8a262c8b8b5aaa7 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 c26f62cb6137d07c2a26d8b7dd56c3f559d6caeb..dc71d45012f8002e01e533410515aacf40cb5046 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 d759b2709ca2b0549e08059801f6d31a862d05bd..92922bc8ad6f0568bac17dd4eb969cef316407b7 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 45f8d7f4ef2b1faca9294d7ad51afc24f4768b2b..47896472e8fd19bb751c9400c84e2a51b01a8689 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 0c2cf62e8bec2e93f767fa4f99c3a1c848978fd3..3ad91d89d6a51f3647d3212e294fdc2b809e35b4 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 536cf57c154533e92198f8181eac060055783096..e445c24b9bd667cc9c140f74374e312612912648 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 0cced40f0f10a8ea8bb1b527a57bd18ca6c46c8a..738dd853ceed006ba3e28fe4eaea8599a2b704a7 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 f51f5bec3560d487c38d6e6fc45b2d51b56accda..eaaa6e35a62008572fb2da51ac294506595e6868 100644 (file)
@@ -213,5 +213,5 @@ err:
        if (out)
                BIO_free_all(out);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index 980138f04137cdc5bc26c05be5d9f362cfd690ac..a582e69775036986c7d8b15b404398bfc7e82391 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 4e19bc16fb877d019abe2aa65e38be1ed2c90cbb..aebec744a2929ffabc36de6dbdd2144e634157cb 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 7b1fa7b22be01569f6636766b3f699a70ab5706b..738588c6aab65163d3c7bd7f909213e73280853e 100644 (file)
@@ -917,7 +917,7 @@ end:
                bio_c_out=NULL;
                }
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 
index 7380fcc85f756abedf75442087dce0973158ba58..aa7ff66b704a8b51f69ecf005b01de97a4b728bb 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 181a7c82f66e80555824575e19084b3177b77536..1ad16cd607d4f95979b40a4e8f4aecc040d1a18a 100644 (file)
@@ -642,7 +642,7 @@ end:
                tm_ctx=NULL;
                }
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
 
 /***********************************************************************
index 41c3b3f4a3ab649ba05ae3580b8ecbdc7bc292d3..d91d84d2206b08b570908d694bc082a90f58dc3c 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 27f2e675cdb9c96da9562b8ec86d22080970ee40..800ecd35d606fc93d137c783b2cbef15f6fd193a 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 4ce53e36c9022820432338aa525719efafe22bd0..ed370c5ca9c688168efad85956a11108cb9ccdca 100644 (file)
@@ -295,5 +295,5 @@ end:
        EVP_PKEY_free(pkey);
        if(passin) OPENSSL_free(passin);
        apps_shutdown();
-       EXIT(ret);
+       OPENSSL_EXIT(ret);
        }
index e4cbceaf8e8785cfa3d40921055b2e760816b372..9a18213ece454c45b93f03ee649424d4342eb63e 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 435e0b4bb3870b2d09dffd0dc6f1aa62b43bff69..041da37e99afb4f3300849434297a13eecf0ba11 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 0f6e9ad907c7bff0d3908962e20d26b49d385c06..9709628df35ac0c85f588ce5255bb0d0a157f8cd 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 5d761781b8577ef4e4ed4bb23ac7a849ba8ba034..db9ba97ec8451d985a9b5267bc26ca745fedea12 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.