New functions
authorBodo Möller <bodo@openssl.org>
Thu, 24 Jan 2002 16:16:43 +0000 (16:16 +0000)
committerBodo Möller <bodo@openssl.org>
Thu, 24 Jan 2002 16:16:43 +0000 (16:16 +0000)
    ERR_peek_last_error
    ERR_peek_last_error_line
    ERR_peek_last_error_line_data
(supersedes ERR_peek_top_error).

Rename OPENSSL_NO_OLD_DES_SUPPORT into OPENSSL_DISABLE_OLD_DES_SUPPORT
because OPENSSL_NO_... indicates disabled algorithms (according to
mkdef.pl).

CHANGES
crypto/bio/bss_file.c
crypto/conf/conf_def.c
crypto/conf/conf_mall.c
crypto/des/des.h
crypto/err/err.c
crypto/err/err.h
doc/crypto/ERR_get_error.pod
util/libeay.num

diff --git a/CHANGES b/CHANGES
index 1d27931d237d746585b83b7e777889b17fd23251..af0fc216d526403fca3c8f346b5bb57771bfe13a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
          *) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7
          +) applies to 0.9.7 only
 
+  +) Change BIO_new_file (crypto/bio/bss_file.c) to use new
+     BIO_R_NO_SUCH_FILE error code rather than the generic
+     ERR_R_SYS_LIB error code if fopen() fails with ENOENT.
+     [Ben Laurie]
+
+  +) Add new functions
+          ERR_peek_last_error
+          ERR_peek_last_error_line
+          ERR_peek_last_error_line_data.
+     These are similar to
+          ERR_peek_error
+          ERR_peek_error_line
+          ERR_peek_error_line_data,
+     but report on the latest error recorded rather than the first one
+     still in the error queue.
+     [Ben Laurie, Bodo Moeller]
+        
   +) default_algorithms option in ENGINE config module. This allows things
      like:
      default_algorithms = ALL
      and other DES libraries that are currently used by other projects.
      The old libdes interface (including crypt()) is provided if
      <openssl/des_old.h> is included.  For now, this automatically
-     happens in <openssl/des.h> unless OPENSSL_NO_OLD_DES_SUPPORT is
+     happens in <openssl/des.h> unless OPENSSL_DISABLE_OLD_DES_SUPPORT is
      defined.  Note that crypt() is no longer declared in <openssl/des.h>.
 
      NOTE: This is a major break of an old API into a new one.  Software
index e3af936374020385a2e50d991352feeb33ff1fcb..8b3ff278d901b2c3d021c0f32e82e40611446b6c 100644 (file)
@@ -103,7 +103,7 @@ BIO *BIO_new_file(const char *filename, const char *mode)
                {
                SYSerr(SYS_F_FOPEN,get_last_sys_error());
                ERR_add_error_data(5,"fopen('",filename,"','",mode,"')");
-               if(errno == ENOENT)
+               if (errno == ENOENT)
                        BIOerr(BIO_F_BIO_NEW_FILE,BIO_R_NO_SUCH_FILE);
                else
                        BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB);
index 20b0760fcd958f835b99a4640d74aa4db240f6b4..31f2766246a19f33a7539c69e95d2ae1a932a55f 100644 (file)
@@ -192,7 +192,7 @@ static int def_load(CONF *conf, const char *name, long *line)
 #endif
        if (in == NULL)
                {
-               if(ERR_GET_REASON(ERR_peek_top_error()) == BIO_R_NO_SUCH_FILE)
+               if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE)
                        CONFerr(CONF_F_CONF_LOAD,CONF_R_NO_SUCH_FILE);
                else
                        CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
index 59c7cfb966bace733a923059c0d2dacd2f0e5e15..01cff6946a44d8ddd347306c6d379a6446b75b63 100644 (file)
@@ -72,16 +72,18 @@ void OPENSSL_load_builtin_modules(void)
        ENGINE_add_conf_module();
        }
 
+#if 0 /* not yet */
 /* This is the automatic configuration loader: it is called automatically by
  * OpenSSL when any of a number of standard initialisation functions are called,
  * unless this is overridden by calling OPENSSL_no_config()
  */
+#endif
 
 static int openssl_configured = 0;
 
 void OPENSSL_config(void)
        {
-       int ret;
+       int err_exit = 0;
        char *file;
        if (openssl_configured)
                return;
@@ -92,10 +94,17 @@ void OPENSSL_config(void)
        if (!file)
                return;
 
-       ret=CONF_modules_load_file(file, "openssl_config", 0) <= 0
-         && ERR_GET_REASON(ERR_peek_top_error()) != CONF_R_NO_SUCH_FILE;
+       ERR_clear_error();
+       if (CONF_modules_load_file(file, "openssl_config", 0) <= 0)
+               {
+               if (ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE)
+                       ERR_clear_error();
+               else
+                       err_exit = 1;
+               }
+
        OPENSSL_free(file);
-       if (ret)
+       if (err_exit)
                {
                BIO *bio_err;
                ERR_load_crypto_strings();
@@ -109,7 +118,6 @@ void OPENSSL_config(void)
                }
 
        return;
-
        }
 
 void OPENSSL_no_config()
index 8ec7b90f852c0e5211fe232c885df6d914b94c7f..237113129d07048973921c73bf97b5619f433f3e 100644 (file)
@@ -66,7 +66,7 @@
 #include <openssl/opensslconf.h> /* DES_LONG */
 #include <openssl/e_os2.h>     /* OPENSSL_EXTERN */
 
-#ifndef OPENSSL_NO_OLD_DES_SUPPORT
+#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT
 # include <openssl/des_old.h>
 #endif
 
index 1b1e9bbcb0cdac4e5e354c52f67dfa34bdc047c2..c909c3f4dcf43144368e815a03bf23dbbaf74677 100644 (file)
@@ -318,7 +318,7 @@ static int err_cmp(const void *a_void, const void *b_void);
 static unsigned long pid_hash(const void *pid_void);
 /* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */
 static int pid_cmp(const void *a_void,const void *pid_void);
-static unsigned long get_error_values(int inc,const char **file,int *line,
+static unsigned long get_error_values(int inc,int top,const char **file,int *line,
                                      const char **data,int *flags);
 
 /* The internal functions used in the "err_defaults" implementation */
@@ -666,35 +666,37 @@ void ERR_clear_error(void)
 
 
 unsigned long ERR_get_error(void)
-       { return(get_error_values(1,NULL,NULL,NULL,NULL)); }
+       { return(get_error_values(1,0,NULL,NULL,NULL,NULL)); }
 
 unsigned long ERR_get_error_line(const char **file,
             int *line)
-       { return(get_error_values(1,file,line,NULL,NULL)); }
+       { return(get_error_values(1,0,file,line,NULL,NULL)); }
 
 unsigned long ERR_get_error_line_data(const char **file, int *line,
             const char **data, int *flags)
-       { return(get_error_values(1,file,line,data,flags)); }
+       { return(get_error_values(1,0,file,line,data,flags)); }
 
 unsigned long ERR_peek_error(void)
-       { return(get_error_values(0,NULL,NULL,NULL,NULL)); }
+       { return(get_error_values(0,0,NULL,NULL,NULL,NULL)); }
 
-unsigned long ERR_peek_top_error(void)
-       {
-       ERR_STATE *es=ERR_get_state();
+unsigned long ERR_peek_last_error(void)
+       { return(get_error_values(0,1,NULL,NULL,NULL,NULL)); }
 
-       return es->err_buffer[es->top];
-       }
+unsigned long ERR_peek_error_line(const char **file, int *line)
+       { return(get_error_values(0,0,file,line,NULL,NULL)); }
 
-unsigned long ERR_peek_error_line(const char **file,
-            int *line)
-       { return(get_error_values(0,file,line,NULL,NULL)); }
+unsigned long ERR_peek_last_error_line(const char **file, int *line)
+       { return(get_error_values(0,1,file,line,NULL,NULL)); }
 
 unsigned long ERR_peek_error_line_data(const char **file, int *line,
             const char **data, int *flags)
-       { return(get_error_values(0,file,line,data,flags)); }
+       { return(get_error_values(0,0,file,line,data,flags)); }
+
+unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
+            const char **data, int *flags)
+       { return(get_error_values(0,1,file,line,data,flags)); }
 
-static unsigned long get_error_values(int inc, const char **file, int *line,
+static unsigned long get_error_values(int inc, int top, const char **file, int *line,
             const char **data, int *flags)
        {       
        int i=0;
@@ -703,8 +705,21 @@ static unsigned long get_error_values(int inc, const char **file, int *line,
 
        es=ERR_get_state();
 
+       if (inc && top)
+               {
+               if (file) *file = "";
+               if (line) *line = 0;
+               if (data) *data = "";
+               if (flags) *flags = 0;
+                       
+               return ERR_R_INTERNAL_ERROR;
+               }
+
        if (es->bottom == es->top) return 0;
-       i=(es->bottom+1)%ERR_NUM_ERRORS;
+       if (top)
+               i=(es->bottom+1)%ERR_NUM_ERRORS; /* last error */
+       else
+               i=(es->bottom+1)%ERR_NUM_ERRORS; /* first error */
 
        ret=es->err_buffer[i];
        if (inc)
index 4456e0e97176a3a8058bc86ef3d66662ed679934..adf52e21b772c2082342b55ba4fb55c341f5bf8c 100644 (file)
@@ -238,15 +238,18 @@ typedef struct ERR_string_data_st
 void ERR_put_error(int lib, int func,int reason,const char *file,int line);
 void ERR_set_error_data(char *data,int flags);
 
-unsigned long ERR_get_error(void );
+unsigned long ERR_get_error(void);
 unsigned long ERR_get_error_line(const char **file,int *line);
 unsigned long ERR_get_error_line_data(const char **file,int *line,
                                      const char **data, int *flags);
-unsigned long ERR_peek_error(void );
-unsigned long ERR_peek_top_error(void);
+unsigned long ERR_peek_last_error(void);
+unsigned long ERR_peek_error(void);
 unsigned long ERR_peek_error_line(const char **file,int *line);
+unsigned long ERR_peek_last_error_line(const char **file,int *line);
 unsigned long ERR_peek_error_line_data(const char **file,int *line,
                                       const char **data,int *flags);
+unsigned long ERR_peek_last_error_line_data(const char **file,int *line,
+                                      const char **data,int *flags);
 void ERR_clear_error(void );
 char *ERR_error_string(unsigned long e,char *buf);
 void ERR_error_string_n(unsigned long e, char *buf, size_t len);
index 3551bacb8dea27201ef7383c8a9c13c7ca9ab479..9fdedbcb9178ba41c72ca8afa47334c12177f3ec 100644 (file)
@@ -2,8 +2,10 @@
 
 =head1 NAME
 
-ERR_get_error, ERR_peek_error, ERR_get_error_line, ERR_peek_error_line,
-ERR_get_error_line_data, ERR_peek_error_line_data - obtain error code and data
+ERR_get_error, ERR_peek_error, ERR_peek_last_error,
+ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line,
+ERR_get_error_line_data, ERR_peek_error_line_data,
+ERR_peek_error_line_data - obtain error code and data
 
 =head1 SYNOPSIS
 
@@ -11,22 +13,29 @@ ERR_get_error_line_data, ERR_peek_error_line_data - obtain error code and data
 
  unsigned long ERR_get_error(void);
  unsigned long ERR_peek_error(void);
+ unsigned long ERR_peek_last_error(void);
 
  unsigned long ERR_get_error_line(const char **file, int *line);
  unsigned long ERR_peek_error_line(const char **file, int *line);
+ unsigned long ERR_peek_last_error_line(const char **file, int *line);
 
  unsigned long ERR_get_error_line_data(const char **file, int *line,
          const char **data, int *flags);
  unsigned long ERR_peek_error_line_data(const char **file, int *line,
          const char **data, int *flags);
+ unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
+         const char **data, int *flags);
 
 =head1 DESCRIPTION
 
-ERR_get_error() returns the last error code from the thread's error
+ERR_get_error() returns the earliest error code from the thread's error
 queue and removes the entry. This function can be called repeatedly
 until there are no more error codes to return.
 
-ERR_peek_error() returns the last error code from the thread's
+ERR_peek_error() returns the earliest error code from the thread's
+error queue without modifying it.
+
+ERR_peek_last_error() returns the latest error code from the thread's
 error queue without modifying it.
 
 See L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> for obtaining information about
@@ -34,12 +43,14 @@ location and reason of the error, and
 L<ERR_error_string(3)|ERR_error_string(3)> for human-readable error
 messages.
 
-ERR_get_error_line() and ERR_peek_error_line() are the same as the
-above, but they additionally store the file name and line number where
+ERR_get_error_line(), ERR_peek_error_line() and
+ERR_peek_last_error_line() are the same as the above, but they
+additionally store the file name and line number where
 the error occurred in *B<file> and *B<line>, unless these are B<NULL>.
 
-ERR_get_error_line_data() and ERR_peek_error_line_data() store
-additional data and flags associated with the error code in *B<data>
+ERR_get_error_line_data(), ERR_peek_error_line_data() and
+ERR_get_last_error_line_data() store additional data and flags
+associated with the error code in *B<data>
 and *B<flags>, unless these are B<NULL>. *B<data> contains a string
 if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by OPENSSL_malloc(),
 *B<flags>&B<ERR_TXT_MALLOCED> is true.
@@ -59,5 +70,7 @@ ERR_get_error(), ERR_peek_error(), ERR_get_error_line() and
 ERR_peek_error_line() are available in all versions of SSLeay and
 OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data()
 were added in SSLeay 0.9.0.
+ERR_peek_last_error(), ERR_peek_last_error_line() and
+ERR_peek_last_error_line_data() were added in OpenSSL 0.9.7.
 
 =cut
index 106806bebd77cca32992e68f59de67f687442327..6823d03bb485f57eaf5329e7569d6f81a2ead53f 100755 (executable)
@@ -2749,7 +2749,10 @@ CONF_imodule_get_flags                  3195     EXIST::FUNCTION:
 CONF_imodule_get_module                 3196   EXIST::FUNCTION:
 CONF_modules_load                       3197   EXIST::FUNCTION:
 CONF_imodule_get_name                   3198   EXIST::FUNCTION:
-ERR_peek_top_error                      3199   EXIST::FUNCTION:
+ERR_peek_top_error                      3199   NOEXIST::FUNCTION:
 CONF_imodule_get_usr_data               3200   EXIST::FUNCTION:
 CONF_imodule_set_flags                  3201   EXIST::FUNCTION:
 ENGINE_add_conf_module                  3202   EXIST::FUNCTION:
+ERR_peek_last_error_line                3203   EXIST::FUNCTION:
+ERR_peek_last_error_line_data           3204   EXIST::FUNCTION:
+ERR_peek_last_error                     3205   EXIST::FUNCTION: