comp.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright 2015-2024 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. /* clang-format off */
  10. /* clang-format on */
  11. #ifndef OPENSSL_COMP_H
  12. #define OPENSSL_COMP_H
  13. #pragma once
  14. #include <openssl/macros.h>
  15. #ifndef OPENSSL_NO_DEPRECATED_3_0
  16. #define HEADER_COMP_H
  17. #endif
  18. #include <openssl/opensslconf.h>
  19. #include <openssl/crypto.h>
  20. #include <openssl/comperr.h>
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #ifndef OPENSSL_NO_COMP
  25. COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
  26. const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx);
  27. int COMP_CTX_get_type(const COMP_CTX *comp);
  28. int COMP_get_type(const COMP_METHOD *meth);
  29. const char *COMP_get_name(const COMP_METHOD *meth);
  30. void COMP_CTX_free(COMP_CTX *ctx);
  31. int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
  32. unsigned char *in, int ilen);
  33. int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
  34. unsigned char *in, int ilen);
  35. COMP_METHOD *COMP_zlib(void);
  36. COMP_METHOD *COMP_zlib_oneshot(void);
  37. COMP_METHOD *COMP_brotli(void);
  38. COMP_METHOD *COMP_brotli_oneshot(void);
  39. COMP_METHOD *COMP_zstd(void);
  40. COMP_METHOD *COMP_zstd_oneshot(void);
  41. #ifndef OPENSSL_NO_DEPRECATED_1_1_0
  42. #define COMP_zlib_cleanup() \
  43. while (0) \
  44. continue
  45. #endif
  46. #ifdef OPENSSL_BIO_H
  47. const BIO_METHOD *BIO_f_zlib(void);
  48. const BIO_METHOD *BIO_f_brotli(void);
  49. const BIO_METHOD *BIO_f_zstd(void);
  50. #endif
  51. #endif
  52. typedef struct ssl_comp_st SSL_COMP;
  53. /* clang-format off */
  54. SKM_DEFINE_STACK_OF_INTERNAL(SSL_COMP, SSL_COMP, SSL_COMP)
  55. #define sk_SSL_COMP_num(sk) OPENSSL_sk_num(ossl_check_const_SSL_COMP_sk_type(sk))
  56. #define sk_SSL_COMP_value(sk, idx) ((SSL_COMP *)OPENSSL_sk_value(ossl_check_const_SSL_COMP_sk_type(sk), (idx)))
  57. #define sk_SSL_COMP_new(cmp) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new(ossl_check_SSL_COMP_compfunc_type(cmp)))
  58. #define sk_SSL_COMP_new_null() ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_null())
  59. #define sk_SSL_COMP_new_reserve(cmp, n) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_reserve(ossl_check_SSL_COMP_compfunc_type(cmp), (n)))
  60. #define sk_SSL_COMP_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SSL_COMP_sk_type(sk), (n))
  61. #define sk_SSL_COMP_free(sk) OPENSSL_sk_free(ossl_check_SSL_COMP_sk_type(sk))
  62. #define sk_SSL_COMP_zero(sk) OPENSSL_sk_zero(ossl_check_SSL_COMP_sk_type(sk))
  63. #define sk_SSL_COMP_delete(sk, i) ((SSL_COMP *)OPENSSL_sk_delete(ossl_check_SSL_COMP_sk_type(sk), (i)))
  64. #define sk_SSL_COMP_delete_ptr(sk, ptr) ((SSL_COMP *)OPENSSL_sk_delete_ptr(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)))
  65. #define sk_SSL_COMP_push(sk, ptr) OPENSSL_sk_push(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
  66. #define sk_SSL_COMP_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
  67. #define sk_SSL_COMP_pop(sk) ((SSL_COMP *)OPENSSL_sk_pop(ossl_check_SSL_COMP_sk_type(sk)))
  68. #define sk_SSL_COMP_shift(sk) ((SSL_COMP *)OPENSSL_sk_shift(ossl_check_SSL_COMP_sk_type(sk)))
  69. #define sk_SSL_COMP_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_freefunc_type(freefunc))
  70. #define sk_SSL_COMP_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr), (idx))
  71. #define sk_SSL_COMP_set(sk, idx, ptr) ((SSL_COMP *)OPENSSL_sk_set(ossl_check_SSL_COMP_sk_type(sk), (idx), ossl_check_SSL_COMP_type(ptr)))
  72. #define sk_SSL_COMP_find(sk, ptr) OPENSSL_sk_find(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
  73. #define sk_SSL_COMP_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
  74. #define sk_SSL_COMP_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr), pnum)
  75. #define sk_SSL_COMP_sort(sk) OPENSSL_sk_sort(ossl_check_SSL_COMP_sk_type(sk))
  76. #define sk_SSL_COMP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SSL_COMP_sk_type(sk))
  77. #define sk_SSL_COMP_dup(sk) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_dup(ossl_check_const_SSL_COMP_sk_type(sk)))
  78. #define sk_SSL_COMP_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_deep_copy(ossl_check_const_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_copyfunc_type(copyfunc), ossl_check_SSL_COMP_freefunc_type(freefunc)))
  79. #define sk_SSL_COMP_set_cmp_func(sk, cmp) ((sk_SSL_COMP_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_compfunc_type(cmp)))
  80. /* clang-format on */
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif