1=pod
2
3=head1 NAME
4
5ERR_get_error, ERR_peek_error, ERR_peek_last_error,
6ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line,
7ERR_peek_error_func, ERR_peek_last_error_func,
8ERR_peek_error_data, ERR_peek_last_error_data,
9ERR_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
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
40The 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)>:
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
54ERR_get_error() returns the earliest error code from the thread's error
55queue and removes the entry.  This function can be called repeatedly
56until there are no more error codes to return.
57
58ERR_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
62error queue without modifying it.
63
64See 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.
67
68ERR_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.
76
77A pointer returned this way by these functions and the ones below
78is valid until the respective entry is overwritten in the error queue.
79
80ERR_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
83*I<line>, as far as they are not NULL.
84An unset filename is indicated as "", i.e., an empty string.
85An unset line number is indicated as 0.
86
87ERR_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
90it is NULL.
91An unset function name is indicated as "".
92
93ERR_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.
100
101ERR_peek_error_all() and ERR_peek_last_error_all() are combinations of all
102of the above.
103
104ERR_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
110returned by these functions) with OPENSSL_free() as freeing is handled
111automatically by the error library.
112
113=head1 RETURN VALUES
114
115The error code, or 0 if there is no error in the queue.
116
117=head1 SEE ALSO
118
119L<ERR_error_string(3)>,
120L<ERR_GET_LIB(3)>
121
122=head1 HISTORY
123
124ERR_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()
127were added in OpenSSL 3.0.
128
129ERR_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.
131
132
133=head1 COPYRIGHT
134
135Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
136
137Licensed under the Apache License 2.0 (the "License").  You may not use
138this 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
143