blob: 4019bdd54169663c0048419b0f8ffe17663f8402 [file] [log] [blame]
Ulf Möller388f2f52000-02-01 01:37:00 +00001=pod
2
3=head1 NAME
4
Bodo Möllera14e2d92002-01-24 16:16:43 +00005ERR_get_error, ERR_peek_error, ERR_peek_last_error,
6ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line,
Richard Levitteaf2f14a2020-11-20 22:13:11 +01007ERR_peek_error_func, ERR_peek_last_error_func,
8ERR_peek_error_data, ERR_peek_last_error_data,
Richard Levitteb13342e2019-09-04 22:04:08 +02009ERR_get_error_all, ERR_peek_error_all, ERR_peek_last_error_all,
10ERR_get_error_line_data, ERR_peek_error_line_data, ERR_peek_last_error_line_data
11- obtain error code and data
Ulf Möller388f2f52000-02-01 01:37:00 +000012
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öllera14e2d92002-01-24 16:16:43 +000019 unsigned long ERR_peek_last_error(void);
Ulf Möller388f2f52000-02-01 01:37:00 +000020
Ulf Möller388f2f52000-02-01 01:37:00 +000021 unsigned long ERR_peek_error_line(const char **file, int *line);
Bodo Möllera14e2d92002-01-24 16:16:43 +000022 unsigned long ERR_peek_last_error_line(const char **file, int *line);
Ulf Möller388f2f52000-02-01 01:37:00 +000023
Richard Levitteb13342e2019-09-04 22:04:08 +020024 unsigned long ERR_peek_error_func(const char **func);
25 unsigned long ERR_peek_last_error_func(const char **func);
26
Richard Levitteb13342e2019-09-04 22:04:08 +020027 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 Levitteaf2f14a2020-11-20 22:13:11 +010031 const char **func,
Richard Levitteb13342e2019-09-04 22:04:08 +020032 const char **data, int *flags);
33 unsigned long ERR_peek_error_all(const char **file, int *line,
Kevin Jonesf242ce92022-01-15 01:38:41 +000034 const char **func,
Richard Levitteb13342e2019-09-04 22:04:08 +020035 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 Caswell3dbf8242021-12-02 11:33:49 +000040The following functions have been deprecated since OpenSSL 3.0, and can be
41hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
42see L<openssl_user_macros(7)>:
Richard Levitteb13342e2019-09-04 22:04:08 +020043
Richard Levitteaf2f14a2020-11-20 22:13:11 +010044 unsigned long ERR_get_error_line(const char **file, int *line);
Ulf Möller388f2f52000-02-01 01:37:00 +000045 unsigned long ERR_get_error_line_data(const char **file, int *line,
Beat Bollie9b77242017-01-20 19:58:49 +010046 const char **data, int *flags);
Ulf Möller388f2f52000-02-01 01:37:00 +000047 unsigned long ERR_peek_error_line_data(const char **file, int *line,
Beat Bollie9b77242017-01-20 19:58:49 +010048 const char **data, int *flags);
Bodo Möllera14e2d92002-01-24 16:16:43 +000049 unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
Beat Bollie9b77242017-01-20 19:58:49 +010050 const char **data, int *flags);
Ulf Möller388f2f52000-02-01 01:37:00 +000051
52=head1 DESCRIPTION
53
Bodo Möllera14e2d92002-01-24 16:16:43 +000054ERR_get_error() returns the earliest error code from the thread's error
Richard Levitteaf2f14a2020-11-20 22:13:11 +010055queue and removes the entry. This function can be called repeatedly
Ulf Möller388f2f52000-02-01 01:37:00 +000056until there are no more error codes to return.
57
Bodo Möllera14e2d92002-01-24 16:16:43 +000058ERR_peek_error() returns the earliest error code from the thread's
59error queue without modifying it.
60
61ERR_peek_last_error() returns the latest error code from the thread's
Ulf Möller388f2f52000-02-01 01:37:00 +000062error queue without modifying it.
63
Dr. David von Oheimbdf082262019-09-19 15:02:50 +020064See L<ERR_GET_LIB(3)> for obtaining further specific information
65such as the reason of the error,
66and L<ERR_error_string(3)> for human-readable error messages.
Ulf Möller388f2f52000-02-01 01:37:00 +000067
Richard Levitteaf2f14a2020-11-20 22:13:11 +010068ERR_get_error_all() is the same as ERR_get_error(), but on success it
69additionally stores the filename, line number and function where the error
70occurred in *I<file>, *I<line> and *I<func>, and also extra text and flags
71in *I<data>, *I<flags>. If any of those parameters are NULL, it will not
72be changed.
73An unset filename is indicated as "", i.e. an empty string.
74An unset line number is indicated as 0.
75An unset function name is indicated as "", i.e. an empty string.
Dr. David von Oheimbdf082262019-09-19 15:02:50 +020076
77A pointer returned this way by these functions and the ones below
Richard Levitteaf2f14a2020-11-20 22:13:11 +010078is valid until the respective entry is overwritten in the error queue.
Ulf Möller388f2f52000-02-01 01:37:00 +000079
Richard Levitteaf2f14a2020-11-20 22:13:11 +010080ERR_peek_error_line() and ERR_peek_last_error_line() are the same as
81ERR_peek_error() and ERR_peek_last_error(), but on success they additionally
82store the filename and line number where the error occurred in *I<file> and
Pauli57cd10d2021-09-21 10:59:56 +100083*I<line>, as far as they are not NULL.
Richard Levitteaf2f14a2020-11-20 22:13:11 +010084An unset filename is indicated as "", i.e., an empty string.
85An unset line number is indicated as 0.
Richard Levitteb13342e2019-09-04 22:04:08 +020086
Richard Levitteaf2f14a2020-11-20 22:13:11 +010087ERR_peek_error_func() and ERR_peek_last_error_func() are the same as
88ERR_peek_error() and ERR_peek_last_error(), but on success they additionally
89store the name of the function where the error occurred in *I<func>, unless
Pauli57cd10d2021-09-21 10:59:56 +100090it is NULL.
Richard Levitteaf2f14a2020-11-20 22:13:11 +010091An unset function name is indicated as "".
Richard Levitteb13342e2019-09-04 22:04:08 +020092
Richard Levitteaf2f14a2020-11-20 22:13:11 +010093ERR_peek_error_data() and ERR_peek_last_error_data() are the same as
94ERR_peek_error() and ERR_peek_last_error(), but on success they additionally
95store additional data and flags associated with the error code in *I<data>
96and *I<flags>, as far as they are not NULL.
97Unset data is indicated as "".
98In 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 Levitteb13342e2019-09-04 22:04:08 +0200100
Richard Levitteaf2f14a2020-11-20 22:13:11 +0100101ERR_peek_error_all() and ERR_peek_last_error_all() are combinations of all
102of the above.
Dr. Stephen Henson30ea5702014-01-29 00:59:35 +0000103
Richard Levitteaf2f14a2020-11-20 22:13:11 +0100104ERR_get_error_line(), ERR_get_error_line_data(), ERR_peek_error_line_data()
105and ERR_peek_last_error_line_data() are older variants of ERR_get_error_all(),
106ERR_peek_error_all() and ERR_peek_last_error_all(), and may give confusing
107results. They should no longer be used and are therefore deprecated.
108
109An application B<MUST NOT> free the *I<data> pointer (or any other pointers
Dr. Stephen Henson30ea5702014-01-29 00:59:35 +0000110returned by these functions) with OPENSSL_free() as freeing is handled
111automatically by the error library.
Ulf Möller388f2f52000-02-01 01:37:00 +0000112
113=head1 RETURN VALUES
114
115The error code, or 0 if there is no error in the queue.
116
117=head1 SEE ALSO
118
Rich Salz73fb82b2017-03-02 10:07:21 -0500119L<ERR_error_string(3)>,
Rich Salz9b869742015-08-17 15:21:33 -0400120L<ERR_GET_LIB(3)>
Ulf Möller388f2f52000-02-01 01:37:00 +0000121
Richard Levitteb13342e2019-09-04 22:04:08 +0200122=head1 HISTORY
123
Richard Levitteaf2f14a2020-11-20 22:13:11 +0100124ERR_peek_error_func(), ERR_peek_last_error_func(),
125ERR_peek_error_data(), ERR_peek_last_error_data(),
126ERR_peek_error_all() and ERR_peek_last_error_all()
Richard Levitteb13342e2019-09-04 22:04:08 +0200127were added in OpenSSL 3.0.
128
Richard Levitteaf2f14a2020-11-20 22:13:11 +0100129ERR_get_error_line(), ERR_get_error_line_data(), ERR_peek_error_line_data()
130and ERR_peek_last_error_line_data() became deprecated in OpenSSL 3.0.
Richard Levitteb13342e2019-09-04 22:04:08 +0200131
132
Rich Salze2f92612016-05-18 11:44:05 -0400133=head1 COPYRIGHT
134
Richard Levitteaf2f14a2020-11-20 22:13:11 +0100135Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
Rich Salze2f92612016-05-18 11:44:05 -0400136
Richard Levitte4746f252018-12-06 14:04:44 +0100137Licensed under the Apache License 2.0 (the "License"). You may not use
Rich Salze2f92612016-05-18 11:44:05 -0400138this file except in compliance with the License. You can obtain a copy
139in the file LICENSE in the source distribution or at
140L<https://www.openssl.org/source/license.html>.
141
142=cut