xref: /freebsd/crypto/openssl/include/openssl/comp.h (revision 4757b351ea9d59d71d4a38b82506d2d16fcd560d)
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 
10 
11 
12 #ifndef OPENSSL_COMP_H
13 # define OPENSSL_COMP_H
14 # pragma once
15 
16 # include <openssl/macros.h>
17 # ifndef OPENSSL_NO_DEPRECATED_3_0
18 #  define HEADER_COMP_H
19 # endif
20 
21 # include <openssl/opensslconf.h>
22 
23 # include <openssl/crypto.h>
24 # include <openssl/comperr.h>
25 # ifdef  __cplusplus
26 extern "C" {
27 # endif
28 
29 
30 
31 # ifndef OPENSSL_NO_COMP
32 
33 COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
34 const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx);
35 int COMP_CTX_get_type(const COMP_CTX* comp);
36 int COMP_get_type(const COMP_METHOD *meth);
37 const char *COMP_get_name(const COMP_METHOD *meth);
38 void COMP_CTX_free(COMP_CTX *ctx);
39 
40 int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
41                         unsigned char *in, int ilen);
42 int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
43                       unsigned char *in, int ilen);
44 
45 COMP_METHOD *COMP_zlib(void);
46 COMP_METHOD *COMP_zlib_oneshot(void);
47 COMP_METHOD *COMP_brotli(void);
48 COMP_METHOD *COMP_brotli_oneshot(void);
49 COMP_METHOD *COMP_zstd(void);
50 COMP_METHOD *COMP_zstd_oneshot(void);
51 
52 #  ifndef OPENSSL_NO_DEPRECATED_1_1_0
53 #   define COMP_zlib_cleanup() while(0) continue
54 #  endif
55 
56 #  ifdef OPENSSL_BIO_H
57 const BIO_METHOD *BIO_f_zlib(void);
58 const BIO_METHOD *BIO_f_brotli(void);
59 const BIO_METHOD *BIO_f_zstd(void);
60 #  endif
61 
62 # endif
63 
64 typedef struct ssl_comp_st SSL_COMP;
65 
66 SKM_DEFINE_STACK_OF_INTERNAL(SSL_COMP, SSL_COMP, SSL_COMP)
67 #define sk_SSL_COMP_num(sk) OPENSSL_sk_num(ossl_check_const_SSL_COMP_sk_type(sk))
68 #define sk_SSL_COMP_value(sk, idx) ((SSL_COMP *)OPENSSL_sk_value(ossl_check_const_SSL_COMP_sk_type(sk), (idx)))
69 #define sk_SSL_COMP_new(cmp) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new(ossl_check_SSL_COMP_compfunc_type(cmp)))
70 #define sk_SSL_COMP_new_null() ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_null())
71 #define sk_SSL_COMP_new_reserve(cmp, n) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_reserve(ossl_check_SSL_COMP_compfunc_type(cmp), (n)))
72 #define sk_SSL_COMP_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SSL_COMP_sk_type(sk), (n))
73 #define sk_SSL_COMP_free(sk) OPENSSL_sk_free(ossl_check_SSL_COMP_sk_type(sk))
74 #define sk_SSL_COMP_zero(sk) OPENSSL_sk_zero(ossl_check_SSL_COMP_sk_type(sk))
75 #define sk_SSL_COMP_delete(sk, i) ((SSL_COMP *)OPENSSL_sk_delete(ossl_check_SSL_COMP_sk_type(sk), (i)))
76 #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)))
77 #define sk_SSL_COMP_push(sk, ptr) OPENSSL_sk_push(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
78 #define sk_SSL_COMP_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
79 #define sk_SSL_COMP_pop(sk) ((SSL_COMP *)OPENSSL_sk_pop(ossl_check_SSL_COMP_sk_type(sk)))
80 #define sk_SSL_COMP_shift(sk) ((SSL_COMP *)OPENSSL_sk_shift(ossl_check_SSL_COMP_sk_type(sk)))
81 #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))
82 #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))
83 #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)))
84 #define sk_SSL_COMP_find(sk, ptr) OPENSSL_sk_find(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
85 #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))
86 #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)
87 #define sk_SSL_COMP_sort(sk) OPENSSL_sk_sort(ossl_check_SSL_COMP_sk_type(sk))
88 #define sk_SSL_COMP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SSL_COMP_sk_type(sk))
89 #define sk_SSL_COMP_dup(sk) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_dup(ossl_check_const_SSL_COMP_sk_type(sk)))
90 #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)))
91 #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)))
92 
93 
94 
95 # ifdef  __cplusplus
96 }
97 # endif
98 #endif
99