OSSL_ERR_STATE_save.3ossl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "OSSL_ERR_STATE_SAVE 3ossl"
  58. .TH OSSL_ERR_STATE_SAVE 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. OSSL_ERR_STATE_new, OSSL_ERR_STATE_save, OSSL_ERR_STATE_save_to_mark,
  65. OSSL_ERR_STATE_restore, OSSL_ERR_STATE_free \- saving and restoring error state
  66. .SH SYNOPSIS
  67. .IX Header "SYNOPSIS"
  68. .Vb 1
  69. \& #include <openssl/err.h>
  70. \&
  71. \& ERR_STATE *OSSL_ERR_STATE_new(void);
  72. \& void OSSL_ERR_STATE_save(ERR_STATE *es);
  73. \& void OSSL_ERR_STATE_save_to_mark(ERR_STATE *es);
  74. \& void OSSL_ERR_STATE_restore(const ERR_STATE *es);
  75. \& void OSSL_ERR_STATE_free(ERR_STATE *es);
  76. .Ve
  77. .SH DESCRIPTION
  78. .IX Header "DESCRIPTION"
  79. These functions save and restore the error state from the thread
  80. local error state to a preallocated error state structure.
  81. .PP
  82. \&\fBOSSL_ERR_STATE_new()\fR allocates an empty error state structure to
  83. be used when saving and restoring thread error state.
  84. .PP
  85. \&\fBOSSL_ERR_STATE_save()\fR saves the thread error state to \fIes\fR. It
  86. subsequently clears the thread error state. Any previously saved
  87. state in \fIes\fR is cleared prior to saving the new state.
  88. .PP
  89. \&\fBOSSL_ERR_STATE_save_to_mark()\fR is similar to \fBOSSL_ERR_STATE_save()\fR but only saves
  90. ERR entries up to the most recent mark on the ERR stack. These entries are moved
  91. to \fIes\fR and removed from the thread error state. However, the most recent
  92. marked ERR and any ERR state before it remains part of the thread error state
  93. and is not moved to the ERR_STATE. The mark is not cleared and must be cleared
  94. explicitly after a call to this function using \fBERR_pop_to_mark\fR\|(3) or
  95. \&\fBERR_clear_last_mark\fR\|(3). (Since a call to \fBOSSL_ERR_STATE_save_to_mark()\fR leaves
  96. the marked ERR as the top error, either of these functions will have the same
  97. effect.) If there is no marked ERR in the thread local error state, all ERR
  98. entries are copied and the effect is the same as for a call to
  99. \&\fBOSSL_ERR_STATE_save()\fR.
  100. .PP
  101. \&\fBOSSL_ERR_STATE_restore()\fR adds all the error entries from the
  102. saved state \fIes\fR to the thread error state. Existing entries in
  103. the thread error state are not affected if there is enough space
  104. for all the added entries. Any allocated data in the saved error
  105. entries is duplicated on adding to the thread state.
  106. .PP
  107. \&\fBOSSL_ERR_STATE_free()\fR frees the saved error state \fIes\fR.
  108. If the argument is NULL, nothing is done.
  109. .SH "RETURN VALUES"
  110. .IX Header "RETURN VALUES"
  111. \&\fBOSSL_ERR_STATE_new()\fR returns a pointer to the allocated ERR_STATE
  112. structure or NULL on error.
  113. .PP
  114. \&\fBOSSL_ERR_STATE_save()\fR, \fBOSSL_ERR_STATE_save_to_mark()\fR, \fBOSSL_ERR_STATE_restore()\fR,
  115. \&\fBOSSL_ERR_STATE_free()\fR do not return any values.
  116. .SH NOTES
  117. .IX Header "NOTES"
  118. \&\fBOSSL_ERR_STATE_save()\fR and \fBOSSL_ERR_STATE_save_to_mark()\fR cannot fail as it takes
  119. over any allocated data from the thread error state.
  120. .PP
  121. \&\fBOSSL_ERR_STATE_restore()\fR is a best effort function. The only failure
  122. that can happen during its operation is when memory allocation fails.
  123. Because it manipulates the thread error state it avoids raising memory
  124. errors on such failure. At worst the restored error entries will be
  125. missing the auxiliary error data.
  126. .SH "SEE ALSO"
  127. .IX Header "SEE ALSO"
  128. \&\fBERR_raise\fR\|(3), \fBERR_get_error\fR\|(3), \fBERR_clear_error\fR\|(3)
  129. .SH HISTORY
  130. .IX Header "HISTORY"
  131. All of these functions were added in OpenSSL 3.2.
  132. .SH COPYRIGHT
  133. .IX Header "COPYRIGHT"
  134. Copyright 2023\-2024 The OpenSSL Project Authors. All Rights Reserved.
  135. .PP
  136. Licensed under the Apache License 2.0 (the "License"). You may not use
  137. this file except in compliance with the License. You can obtain a copy
  138. in the file LICENSE in the source distribution or at
  139. <https://www.openssl.org/source/license.html>.