ERR_get_error.pod 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. =pod
  2. =head1 NAME
  3. ERR_get_error, ERR_peek_error, ERR_peek_last_error,
  4. ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line,
  5. ERR_peek_error_func, ERR_peek_last_error_func,
  6. ERR_peek_error_data, ERR_peek_last_error_data,
  7. ERR_get_error_all, ERR_peek_error_all, ERR_peek_last_error_all,
  8. ERR_get_error_line_data, ERR_peek_error_line_data, ERR_peek_last_error_line_data
  9. - obtain error code and data
  10. =head1 SYNOPSIS
  11. #include <openssl/err.h>
  12. unsigned long ERR_get_error(void);
  13. unsigned long ERR_peek_error(void);
  14. unsigned long ERR_peek_last_error(void);
  15. unsigned long ERR_peek_error_line(const char **file, int *line);
  16. unsigned long ERR_peek_last_error_line(const char **file, int *line);
  17. unsigned long ERR_peek_error_func(const char **func);
  18. unsigned long ERR_peek_last_error_func(const char **func);
  19. unsigned long ERR_peek_error_data(const char **data, int *flags);
  20. unsigned long ERR_peek_last_error_data(const char **data, int *flags);
  21. unsigned long ERR_get_error_all(const char **file, int *line,
  22. const char **func,
  23. const char **data, int *flags);
  24. unsigned long ERR_peek_error_all(const char **file, int *line,
  25. const char **func,
  26. const char **data, int *flags);
  27. unsigned long ERR_peek_last_error_all(const char **file, int *line,
  28. const char *func,
  29. const char **data, int *flags);
  30. The following functions have been deprecated since OpenSSL 3.0, and can be
  31. hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
  32. see L<openssl_user_macros(7)>:
  33. unsigned long ERR_get_error_line(const char **file, int *line);
  34. unsigned long ERR_get_error_line_data(const char **file, int *line,
  35. const char **data, int *flags);
  36. unsigned long ERR_peek_error_line_data(const char **file, int *line,
  37. const char **data, int *flags);
  38. unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
  39. const char **data, int *flags);
  40. =head1 DESCRIPTION
  41. ERR_get_error() returns the earliest error code from the thread's error
  42. queue and removes the entry. This function can be called repeatedly
  43. until there are no more error codes to return.
  44. ERR_peek_error() returns the earliest error code from the thread's
  45. error queue without modifying it.
  46. ERR_peek_last_error() returns the latest error code from the thread's
  47. error queue without modifying it.
  48. See L<ERR_GET_LIB(3)> for obtaining further specific information
  49. such as the reason of the error,
  50. and L<ERR_error_string(3)> for human-readable error messages.
  51. ERR_get_error_all() is the same as ERR_get_error(), but on success it
  52. additionally stores the filename, line number and function where the error
  53. occurred in *I<file>, *I<line> and *I<func>, and also extra text and flags
  54. in *I<data>, *I<flags>. If any of those parameters are NULL, it will not
  55. be changed.
  56. An unset filename is indicated as "", i.e. an empty string.
  57. An unset line number is indicated as 0.
  58. An unset function name is indicated as "", i.e. an empty string.
  59. A pointer returned this way by these functions and the ones below
  60. is valid until the respective entry is overwritten in the error queue.
  61. ERR_peek_error_line() and ERR_peek_last_error_line() are the same as
  62. ERR_peek_error() and ERR_peek_last_error(), but on success they additionally
  63. store the filename and line number where the error occurred in *I<file> and
  64. *I<line>, as far as they are not NULL.
  65. An unset filename is indicated as "", i.e., an empty string.
  66. An unset line number is indicated as 0.
  67. ERR_peek_error_func() and ERR_peek_last_error_func() are the same as
  68. ERR_peek_error() and ERR_peek_last_error(), but on success they additionally
  69. store the name of the function where the error occurred in *I<func>, unless
  70. it is NULL.
  71. An unset function name is indicated as "".
  72. ERR_peek_error_data() and ERR_peek_last_error_data() are the same as
  73. ERR_peek_error() and ERR_peek_last_error(), but on success they additionally
  74. store additional data and flags associated with the error code in *I<data>
  75. and *I<flags>, as far as they are not NULL.
  76. Unset data is indicated as "".
  77. In this case the value given for the flag is irrelevant (and equals 0).
  78. *I<data> contains a string if *I<flags>&B<ERR_TXT_STRING> is true.
  79. ERR_peek_error_all() and ERR_peek_last_error_all() are combinations of all
  80. of the above.
  81. ERR_get_error_line(), ERR_get_error_line_data(), ERR_peek_error_line_data()
  82. and ERR_peek_last_error_line_data() are older variants of ERR_get_error_all(),
  83. ERR_peek_error_all() and ERR_peek_last_error_all(), and may give confusing
  84. results. They should no longer be used and are therefore deprecated.
  85. An application B<MUST NOT> free the *I<data> pointer (or any other pointers
  86. returned by these functions) with OPENSSL_free() as freeing is handled
  87. automatically by the error library.
  88. =head1 RETURN VALUES
  89. The error code, or 0 if there is no error in the queue.
  90. =head1 SEE ALSO
  91. L<ERR_error_string(3)>,
  92. L<ERR_GET_LIB(3)>
  93. =head1 HISTORY
  94. ERR_peek_error_func(), ERR_peek_last_error_func(),
  95. ERR_peek_error_data(), ERR_peek_last_error_data(),
  96. ERR_peek_error_all() and ERR_peek_last_error_all()
  97. were added in OpenSSL 3.0.
  98. ERR_get_error_line(), ERR_get_error_line_data(), ERR_peek_error_line_data()
  99. and ERR_peek_last_error_line_data() became deprecated in OpenSSL 3.0.
  100. =head1 COPYRIGHT
  101. Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
  102. Licensed under the Apache License 2.0 (the "License"). You may not use
  103. this file except in compliance with the License. You can obtain a copy
  104. in the file LICENSE in the source distribution or at
  105. L<https://www.openssl.org/source/license.html>.
  106. =cut