xref: /freebsd/crypto/openssl/include/openssl/stack.h (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1 /*
2  * Copyright 1995-2021 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 #ifndef OPENSSL_STACK_H
11 # define OPENSSL_STACK_H
12 # pragma once
13 
14 # include <openssl/macros.h>
15 # ifndef OPENSSL_NO_DEPRECATED_3_0
16 #  define HEADER_STACK_H
17 # endif
18 
19 #ifdef  __cplusplus
20 extern "C" {
21 #endif
22 
23 typedef struct stack_st OPENSSL_STACK; /* Use STACK_OF(...) instead */
24 
25 typedef int (*OPENSSL_sk_compfunc)(const void *, const void *);
26 typedef void (*OPENSSL_sk_freefunc)(void *);
27 typedef void *(*OPENSSL_sk_copyfunc)(const void *);
28 
29 int OPENSSL_sk_num(const OPENSSL_STACK *);
30 void *OPENSSL_sk_value(const OPENSSL_STACK *, int);
31 
32 void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data);
33 
34 OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp);
35 OPENSSL_STACK *OPENSSL_sk_new_null(void);
36 OPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n);
37 int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n);
38 void OPENSSL_sk_free(OPENSSL_STACK *);
39 void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *));
40 OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *,
41                                     OPENSSL_sk_copyfunc c,
42                                     OPENSSL_sk_freefunc f);
43 int OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where);
44 void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc);
45 void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p);
46 int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data);
47 int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data);
48 int OPENSSL_sk_find_all(OPENSSL_STACK *st, const void *data, int *pnum);
49 int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data);
50 int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data);
51 void *OPENSSL_sk_shift(OPENSSL_STACK *st);
52 void *OPENSSL_sk_pop(OPENSSL_STACK *st);
53 void OPENSSL_sk_zero(OPENSSL_STACK *st);
54 OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk,
55                                             OPENSSL_sk_compfunc cmp);
56 OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st);
57 void OPENSSL_sk_sort(OPENSSL_STACK *st);
58 int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st);
59 
60 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
61 #  define _STACK OPENSSL_STACK
62 #  define sk_num OPENSSL_sk_num
63 #  define sk_value OPENSSL_sk_value
64 #  define sk_set OPENSSL_sk_set
65 #  define sk_new OPENSSL_sk_new
66 #  define sk_new_null OPENSSL_sk_new_null
67 #  define sk_free OPENSSL_sk_free
68 #  define sk_pop_free OPENSSL_sk_pop_free
69 #  define sk_deep_copy OPENSSL_sk_deep_copy
70 #  define sk_insert OPENSSL_sk_insert
71 #  define sk_delete OPENSSL_sk_delete
72 #  define sk_delete_ptr OPENSSL_sk_delete_ptr
73 #  define sk_find OPENSSL_sk_find
74 #  define sk_find_ex OPENSSL_sk_find_ex
75 #  define sk_push OPENSSL_sk_push
76 #  define sk_unshift OPENSSL_sk_unshift
77 #  define sk_shift OPENSSL_sk_shift
78 #  define sk_pop OPENSSL_sk_pop
79 #  define sk_zero OPENSSL_sk_zero
80 #  define sk_set_cmp_func OPENSSL_sk_set_cmp_func
81 #  define sk_dup OPENSSL_sk_dup
82 #  define sk_sort OPENSSL_sk_sort
83 #  define sk_is_sorted OPENSSL_sk_is_sorted
84 # endif
85 
86 #ifdef  __cplusplus
87 }
88 #endif
89 
90 #endif
91