blob: 1395e944dd23df67b7126d7c1939e2e2e84f693c (
plain)
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
|
/*
* Copyright 2003-2022 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#define OSSL_FORCE_ERR_STATE
#include <openssl/err.h>
#include "err_local.h"
int ERR_set_mark(void)
{
ERR_STATE *es;
es = ossl_err_get_state_int();
if (es == NULL)
return 0;
if (es->bottom == es->top)
return 0;
es->err_marks[es->top]++;
return 1;
}
int ERR_pop_to_mark(void)
{
ERR_STATE *es;
es = ossl_err_get_state_int();
if (es == NULL)
return 0;
while (es->bottom != es->top
&& es->err_marks[es->top] == 0) {
err_clear(es, es->top, 0);
es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
}
if (es->bottom == es->top)
return 0;
es->err_marks[es->top]--;
return 1;
}
int ERR_count_to_mark(void)
{
ERR_STATE *es;
int count = 0, top;
es = ossl_err_get_state_int();
if (es == NULL)
return 0;
top = es->top;
while (es->bottom != top
&& es->err_marks[top] == 0) {
++count;
top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
}
return count;
}
int ERR_clear_last_mark(void)
{
ERR_STATE *es;
int top;
es = ossl_err_get_state_int();
if (es == NULL)
return 0;
top = es->top;
while (es->bottom != top
&& es->err_marks[top] == 0) {
top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
}
if (es->bottom == top)
return 0;
es->err_marks[top]--;
return 1;
}
|