1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
.Dd $Mdocdate: November 2 2016 $
.Dt ERR_GET_ERROR 3
.Os
.Sh NAME
.Nm ERR_get_error ,
.Nm ERR_peek_error ,
.Nm ERR_peek_last_error ,
.Nm ERR_get_error_line ,
.Nm ERR_peek_error_line ,
.Nm ERR_peek_last_error_line ,
.Nm ERR_get_error_line_data ,
.Nm ERR_peek_error_line_data ,
.Nm ERR_peek_last_error_line_data
.Nd obtain OpenSSL error code and data
.Sh SYNOPSIS
.In openssl/err.h
.Ft unsigned long
.Fn ERR_get_error void
.Ft unsigned long
.Fn ERR_peek_error void
.Ft unsigned long
.Fn ERR_peek_last_error void
.Ft unsigned long
.Fo ERR_get_error_line
.Fa "const char **file"
.Fa "int *line"
.Fc
.Ft unsigned long
.Fo ERR_peek_error_line
.Fa "const char **file"
.Fa "int *line"
.Fc
.Ft unsigned long
.Fo ERR_peek_last_error_line
.Fa "const char **file"
.Fa "int *line"
.Fc
.Ft unsigned long
.Fo ERR_get_error_line_data
.Fa "const char **file"
.Fa "int *line"
.Fa "const char **data"
.Fa "int *flags"
.Fc
.Ft unsigned long
.Fo ERR_peek_error_line_data
.Fa "const char **file"
.Fa "int *line"
.Fa "const char **data"
.Fa "int *flags"
.Fc
.Ft unsigned long
.Fo ERR_peek_last_error_line_data
.Fa "const char **file"
.Fa "int *line"
.Fa "const char **data"
.Fa "int *flags"
.Fc
.Sh DESCRIPTION
.Fn ERR_get_error
returns the earliest error code from the thread's error queue and
removes the entry.
This function can be called repeatedly until there are no more error
codes to return.
.Pp
.Fn ERR_peek_error
returns the earliest error code from the thread's error queue without
modifying it.
.Pp
.Fn ERR_peek_last_error
returns the latest error code from the thread's error queue without
modifying it.
.Pp
See
.Xr ERR_GET_LIB 3
for obtaining information about location and reason of the error, and
.Xr ERR_error_string 3
for human-readable error messages.
.Pp
.Fn ERR_get_error_line ,
.Fn ERR_peek_error_line ,
and
.Fn ERR_peek_last_error_line
are the same as the above, but they additionally store the file name and
line number where the error occurred in
.Pf * Fa file
and
.Pf * Fa line ,
unless these are
.Dv NULL .
.Pp
.Fn ERR_get_error_line_data ,
.Fn ERR_peek_error_line_data ,
and
.Fn ERR_peek_last_error_line_data
store additional data and flags associated with the error code in
.Pf * Fa data
and
.Pf * Fa flags ,
unless these are
.Dv NULL .
.Pf * Fa data
contains a string if
.Pf * Fa flags Ns & Ns Dv ERR_TXT_STRING
is true.
.Pp
An application
.Sy MUST NOT
free the
.Pf * Fa data
pointer (or any other pointers returned by these functions) with
.Xr free 3
as freeing is handled automatically by the error library.
.Sh RETURN VALUES
The error code, or 0 if there is no error in the queue.
.Sh SEE ALSO
.Xr ERR 3 ,
.Xr ERR_error_string 3 ,
.Xr ERR_GET_LIB 3
.Sh HISTORY
.Fn ERR_get_error ,
.Fn ERR_peek_error ,
.Fn ERR_get_error_line ,
and
.Fn ERR_peek_error_line
are available in all versions of SSLeay and OpenSSL.
.Fn ERR_get_error_line_data
and
.Fn ERR_peek_error_line_data
were added in SSLeay 0.9.0.
.Fn ERR_peek_last_error ,
.Fn ERR_peek_last_error_line ,
and
.Fn ERR_peek_last_error_line_data
were added in OpenSSL 0.9.7.
|