Home | History | Annotate | Line # | Download | only in man3
      1 =pod
      2 
      3 =head1 NAME
      4 
      5 ERR_get_error, ERR_peek_error, ERR_peek_last_error,
      6 ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line,
      7 ERR_peek_error_func, ERR_peek_last_error_func,
      8 ERR_peek_error_data, ERR_peek_last_error_data,
      9 ERR_get_error_all, ERR_peek_error_all, ERR_peek_last_error_all,
     10 ERR_get_error_line_data, ERR_peek_error_line_data, ERR_peek_last_error_line_data
     11 - obtain error code and data
     12 
     13 =head1 SYNOPSIS
     14 
     15  #include <openssl/err.h>
     16 
     17  unsigned long ERR_get_error(void);
     18  unsigned long ERR_peek_error(void);
     19  unsigned long ERR_peek_last_error(void);
     20 
     21  unsigned long ERR_peek_error_line(const char **file, int *line);
     22  unsigned long ERR_peek_last_error_line(const char **file, int *line);
     23 
     24  unsigned long ERR_peek_error_func(const char **func);
     25  unsigned long ERR_peek_last_error_func(const char **func);
     26 
     27  unsigned long ERR_peek_error_data(const char **data, int *flags);
     28  unsigned long ERR_peek_last_error_data(const char **data, int *flags);
     29 
     30  unsigned long ERR_get_error_all(const char **file, int *line,
     31                                  const char **func,
     32                                  const char **data, int *flags);
     33  unsigned long ERR_peek_error_all(const char **file, int *line,
     34                                   const char **func,
     35                                   const char **data, int *flags);
     36  unsigned long ERR_peek_last_error_all(const char **file, int *line,
     37                                        const char *func,
     38                                        const char **data, int *flags);
     39 
     40 The following functions have been deprecated since OpenSSL 3.0, and can be
     41 hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
     42 see L<openssl_user_macros(7)>:
     43 
     44  unsigned long ERR_get_error_line(const char **file, int *line);
     45  unsigned long ERR_get_error_line_data(const char **file, int *line,
     46                                        const char **data, int *flags);
     47  unsigned long ERR_peek_error_line_data(const char **file, int *line,
     48                                         const char **data, int *flags);
     49  unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
     50                                              const char **data, int *flags);
     51 
     52 =head1 DESCRIPTION
     53 
     54 ERR_get_error() returns the earliest error code from the thread's error
     55 queue and removes the entry.  This function can be called repeatedly
     56 until there are no more error codes to return.
     57 
     58 ERR_peek_error() returns the earliest error code from the thread's
     59 error queue without modifying it.
     60 
     61 ERR_peek_last_error() returns the latest error code from the thread's
     62 error queue without modifying it.
     63 
     64 See L<ERR_GET_LIB(3)> for obtaining further specific information
     65 such as the reason of the error,
     66 and L<ERR_error_string(3)> for human-readable error messages.
     67 
     68 ERR_get_error_all() is the same as ERR_get_error(), but on success it
     69 additionally stores the filename, line number and function where the error
     70 occurred in *I<file>, *I<line> and *I<func>, and also extra text and flags
     71 in *I<data>, *I<flags>.  If any of those parameters are NULL, it will not
     72 be changed.
     73 An unset filename is indicated as "", i.e. an empty string.
     74 An unset line number is indicated as 0.
     75 An unset function name is indicated as "", i.e. an empty string.
     76 
     77 A pointer returned this way by these functions and the ones below
     78 is valid until the respective entry is overwritten in the error queue.
     79 
     80 ERR_peek_error_line() and ERR_peek_last_error_line() are the same as
     81 ERR_peek_error() and ERR_peek_last_error(), but on success they additionally
     82 store the filename and line number where the error occurred in *I<file> and
     83 *I<line>, as far as they are not NULL.
     84 An unset filename is indicated as "", i.e., an empty string.
     85 An unset line number is indicated as 0.
     86 
     87 ERR_peek_error_func() and ERR_peek_last_error_func() are the same as
     88 ERR_peek_error() and ERR_peek_last_error(), but on success they additionally
     89 store the name of the function where the error occurred in *I<func>, unless
     90 it is NULL.
     91 An unset function name is indicated as "".
     92 
     93 ERR_peek_error_data() and ERR_peek_last_error_data() are the same as
     94 ERR_peek_error() and ERR_peek_last_error(), but on success they additionally
     95 store additional data and flags associated with the error code in *I<data>
     96 and *I<flags>, as far as they are not NULL.
     97 Unset data is indicated as "".
     98 In this case the value given for the flag is irrelevant (and equals 0).
     99 *I<data> contains a string if *I<flags>&B<ERR_TXT_STRING> is true.
    100 
    101 ERR_peek_error_all() and ERR_peek_last_error_all() are combinations of all
    102 of the above.
    103 
    104 ERR_get_error_line(), ERR_get_error_line_data(), ERR_peek_error_line_data()
    105 and ERR_peek_last_error_line_data() are older variants of ERR_get_error_all(),
    106 ERR_peek_error_all() and ERR_peek_last_error_all(), and may give confusing
    107 results.  They should no longer be used and are therefore deprecated.
    108 
    109 An application B<MUST NOT> free the *I<data> pointer (or any other pointers
    110 returned by these functions) with OPENSSL_free() as freeing is handled
    111 automatically by the error library.
    112 
    113 =head1 RETURN VALUES
    114 
    115 The error code, or 0 if there is no error in the queue.
    116 
    117 =head1 SEE ALSO
    118 
    119 L<ERR_error_string(3)>,
    120 L<ERR_GET_LIB(3)>
    121 
    122 =head1 HISTORY
    123 
    124 ERR_peek_error_func(), ERR_peek_last_error_func(),
    125 ERR_peek_error_data(), ERR_peek_last_error_data(),
    126 ERR_peek_error_all() and ERR_peek_last_error_all()
    127 were added in OpenSSL 3.0.
    128 
    129 ERR_get_error_line(), ERR_get_error_line_data(), ERR_peek_error_line_data()
    130 and ERR_peek_last_error_line_data() became deprecated in OpenSSL 3.0.
    131 
    132 
    133 =head1 COPYRIGHT
    134 
    135 Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
    136 
    137 Licensed under the Apache License 2.0 (the "License").  You may not use
    138 this file except in compliance with the License.  You can obtain a copy
    139 in the file LICENSE in the source distribution or at
    140 L<https://www.openssl.org/source/license.html>.
    141 
    142 =cut
    143