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