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