1.\" $OpenBSD: ERR_get_error.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 3.\" 4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 5.\" Copyright (c) 2000, 2002, 2014 The OpenSSL Project. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in 16.\" the documentation and/or other materials provided with the 17.\" distribution. 18.\" 19.\" 3. All advertising materials mentioning features or use of this 20.\" software must display the following acknowledgment: 21.\" "This product includes software developed by the OpenSSL Project 22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 23.\" 24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 25.\" endorse or promote products derived from this software without 26.\" prior written permission. For written permission, please contact 27.\" openssl-core@openssl.org. 28.\" 29.\" 5. Products derived from this software may not be called "OpenSSL" 30.\" nor may "OpenSSL" appear in their names without prior written 31.\" permission of the OpenSSL Project. 32.\" 33.\" 6. Redistributions of any form whatsoever must retain the following 34.\" acknowledgment: 35.\" "This product includes software developed by the OpenSSL Project 36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 37.\" 38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" 51.Dd $Mdocdate: March 27 2018 $ 52.Dt ERR_GET_ERROR 3 53.Os 54.Sh NAME 55.Nm ERR_get_error , 56.Nm ERR_peek_error , 57.Nm ERR_peek_last_error , 58.Nm ERR_get_error_line , 59.Nm ERR_peek_error_line , 60.Nm ERR_peek_last_error_line , 61.Nm ERR_get_error_line_data , 62.Nm ERR_peek_error_line_data , 63.Nm ERR_peek_last_error_line_data 64.Nd obtain OpenSSL error code and data 65.Sh SYNOPSIS 66.In openssl/err.h 67.Ft unsigned long 68.Fn ERR_get_error void 69.Ft unsigned long 70.Fn ERR_peek_error void 71.Ft unsigned long 72.Fn ERR_peek_last_error void 73.Ft unsigned long 74.Fo ERR_get_error_line 75.Fa "const char **file" 76.Fa "int *line" 77.Fc 78.Ft unsigned long 79.Fo ERR_peek_error_line 80.Fa "const char **file" 81.Fa "int *line" 82.Fc 83.Ft unsigned long 84.Fo ERR_peek_last_error_line 85.Fa "const char **file" 86.Fa "int *line" 87.Fc 88.Ft unsigned long 89.Fo ERR_get_error_line_data 90.Fa "const char **file" 91.Fa "int *line" 92.Fa "const char **data" 93.Fa "int *flags" 94.Fc 95.Ft unsigned long 96.Fo ERR_peek_error_line_data 97.Fa "const char **file" 98.Fa "int *line" 99.Fa "const char **data" 100.Fa "int *flags" 101.Fc 102.Ft unsigned long 103.Fo ERR_peek_last_error_line_data 104.Fa "const char **file" 105.Fa "int *line" 106.Fa "const char **data" 107.Fa "int *flags" 108.Fc 109.Sh DESCRIPTION 110.Fn ERR_get_error 111returns the earliest error code from the thread's error queue and 112removes the entry. 113This function can be called repeatedly until there are no more error 114codes to return. 115.Pp 116.Fn ERR_peek_error 117returns the earliest error code from the thread's error queue without 118modifying it. 119.Pp 120.Fn ERR_peek_last_error 121returns the latest error code from the thread's error queue without 122modifying it. 123.Pp 124See 125.Xr ERR_GET_LIB 3 126for obtaining information about the location and reason for the error, and 127.Xr ERR_error_string 3 128for human-readable error messages. 129.Pp 130.Fn ERR_get_error_line , 131.Fn ERR_peek_error_line , 132and 133.Fn ERR_peek_last_error_line 134are the same as the above, but they additionally store the file name and 135line number where the error occurred in 136.Pf * Fa file 137and 138.Pf * Fa line , 139unless these are 140.Dv NULL . 141.Pp 142.Fn ERR_get_error_line_data , 143.Fn ERR_peek_error_line_data , 144and 145.Fn ERR_peek_last_error_line_data 146store additional data and flags associated with the error code in 147.Pf * Fa data 148and 149.Pf * Fa flags , 150unless these are 151.Dv NULL . 152.Pf * Fa data 153contains a string if 154.Pf * Fa flags Ns & Ns Dv ERR_TXT_STRING 155is true. 156.Pp 157An application 158.Sy MUST NOT 159free the 160.Pf * Fa data 161pointer (or any other pointers returned by these functions) with 162.Xr free 3 163as freeing is handled automatically by the error library. 164.Sh RETURN VALUES 165The error code, or 0 if there is no error in the queue. 166.Sh SEE ALSO 167.Xr ERR 3 , 168.Xr ERR_error_string 3 , 169.Xr ERR_GET_LIB 3 170.Sh HISTORY 171.Fn ERR_get_error 172and 173.Fn ERR_peek_error 174first appeared in SSLeay 0.4.4. 175.Fn ERR_get_error_line 176and 177.Fn ERR_peek_error_line 178first appeared in SSLeay 0.6.0. 179.Fn ERR_get_error_line_data 180and 181.Fn ERR_peek_error_line_data 182first appeared in SSLeay 0.9.0. 183All these functions have been available since 184.Ox 2.4 . 185.Pp 186.Fn ERR_peek_last_error , 187.Fn ERR_peek_last_error_line , 188and 189.Fn ERR_peek_last_error_line_data 190first appeared in OpenSSL 0.9.7 and have been available since 191.Ox 3.2 . 192