Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 1 | =pod |
| 2 | |
| 3 | =head1 NAME |
| 4 | |
Bodo Möller | a14e2d9 | 2002-01-24 16:16:43 +0000 | [diff] [blame] | 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, |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 7 | ERR_peek_error_func, ERR_peek_last_error_func, |
| 8 | ERR_peek_error_data, ERR_peek_last_error_data, |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 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 |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 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); |
Bodo Möller | a14e2d9 | 2002-01-24 16:16:43 +0000 | [diff] [blame] | 19 | unsigned long ERR_peek_last_error(void); |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 20 | |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 21 | unsigned long ERR_peek_error_line(const char **file, int *line); |
Bodo Möller | a14e2d9 | 2002-01-24 16:16:43 +0000 | [diff] [blame] | 22 | unsigned long ERR_peek_last_error_line(const char **file, int *line); |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 23 | |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 24 | unsigned long ERR_peek_error_func(const char **func); |
| 25 | unsigned long ERR_peek_last_error_func(const char **func); |
| 26 | |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 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, |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 31 | const char **func, |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 32 | const char **data, int *flags); |
| 33 | unsigned long ERR_peek_error_all(const char **file, int *line, |
Kevin Jones | f242ce9 | 2022-01-15 01:38:41 +0000 | [diff] [blame] | 34 | const char **func, |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 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 | |
Matt Caswell | 3dbf824 | 2021-12-02 11:33:49 +0000 | [diff] [blame] | 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)>: |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 43 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 44 | unsigned long ERR_get_error_line(const char **file, int *line); |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 45 | unsigned long ERR_get_error_line_data(const char **file, int *line, |
Beat Bolli | e9b7724 | 2017-01-20 19:58:49 +0100 | [diff] [blame] | 46 | const char **data, int *flags); |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 47 | unsigned long ERR_peek_error_line_data(const char **file, int *line, |
Beat Bolli | e9b7724 | 2017-01-20 19:58:49 +0100 | [diff] [blame] | 48 | const char **data, int *flags); |
Bodo Möller | a14e2d9 | 2002-01-24 16:16:43 +0000 | [diff] [blame] | 49 | unsigned long ERR_peek_last_error_line_data(const char **file, int *line, |
Beat Bolli | e9b7724 | 2017-01-20 19:58:49 +0100 | [diff] [blame] | 50 | const char **data, int *flags); |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 51 | |
| 52 | =head1 DESCRIPTION |
| 53 | |
Bodo Möller | a14e2d9 | 2002-01-24 16:16:43 +0000 | [diff] [blame] | 54 | ERR_get_error() returns the earliest error code from the thread's error |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 55 | queue and removes the entry. This function can be called repeatedly |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 56 | until there are no more error codes to return. |
| 57 | |
Bodo Möller | a14e2d9 | 2002-01-24 16:16:43 +0000 | [diff] [blame] | 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 |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 62 | error queue without modifying it. |
| 63 | |
Dr. David von Oheimb | df08226 | 2019-09-19 15:02:50 +0200 | [diff] [blame] | 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. |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 67 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 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. |
Dr. David von Oheimb | df08226 | 2019-09-19 15:02:50 +0200 | [diff] [blame] | 76 | |
| 77 | A pointer returned this way by these functions and the ones below |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 78 | is valid until the respective entry is overwritten in the error queue. |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 79 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 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 |
Pauli | 57cd10d | 2021-09-21 10:59:56 +1000 | [diff] [blame] | 83 | *I<line>, as far as they are not NULL. |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 84 | An unset filename is indicated as "", i.e., an empty string. |
| 85 | An unset line number is indicated as 0. |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 86 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 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 |
Pauli | 57cd10d | 2021-09-21 10:59:56 +1000 | [diff] [blame] | 90 | it is NULL. |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 91 | An unset function name is indicated as "". |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 92 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 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. |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 100 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 101 | ERR_peek_error_all() and ERR_peek_last_error_all() are combinations of all |
| 102 | of the above. |
Dr. Stephen Henson | 30ea570 | 2014-01-29 00:59:35 +0000 | [diff] [blame] | 103 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 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 |
Dr. Stephen Henson | 30ea570 | 2014-01-29 00:59:35 +0000 | [diff] [blame] | 110 | returned by these functions) with OPENSSL_free() as freeing is handled |
| 111 | automatically by the error library. |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 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 | |
Rich Salz | 73fb82b | 2017-03-02 10:07:21 -0500 | [diff] [blame] | 119 | L<ERR_error_string(3)>, |
Rich Salz | 9b86974 | 2015-08-17 15:21:33 -0400 | [diff] [blame] | 120 | L<ERR_GET_LIB(3)> |
Ulf Möller | 388f2f5 | 2000-02-01 01:37:00 +0000 | [diff] [blame] | 121 | |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 122 | =head1 HISTORY |
| 123 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 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() |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 127 | were added in OpenSSL 3.0. |
| 128 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 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. |
Richard Levitte | b13342e | 2019-09-04 22:04:08 +0200 | [diff] [blame] | 131 | |
| 132 | |
Rich Salz | e2f9261 | 2016-05-18 11:44:05 -0400 | [diff] [blame] | 133 | =head1 COPYRIGHT |
| 134 | |
Richard Levitte | af2f14a | 2020-11-20 22:13:11 +0100 | [diff] [blame] | 135 | Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. |
Rich Salz | e2f9261 | 2016-05-18 11:44:05 -0400 | [diff] [blame] | 136 | |
Richard Levitte | 4746f25 | 2018-12-06 14:04:44 +0100 | [diff] [blame] | 137 | Licensed under the Apache License 2.0 (the "License"). You may not use |
Rich Salz | e2f9261 | 2016-05-18 11:44:05 -0400 | [diff] [blame] | 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 |