]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_apple_csp/open_ssl/openssl/safestack.h
Security-57336.1.9.tar.gz
[apple/security.git] / OSX / libsecurity_apple_csp / open_ssl / openssl / safestack.h
1 /*
2 * Copyright (c) 2000-2001,2011,2014 Apple Inc. All Rights Reserved.
3 *
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
8 * using this file.
9 *
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
16 */
17
18
19 /* ====================================================================
20 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
25 *
26 * 1. Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 *
29 * 2. Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in
31 * the documentation and/or other materials provided with the
32 * distribution.
33 *
34 * 3. All advertising materials mentioning features or use of this
35 * software must display the following acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
38 *
39 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
40 * endorse or promote products derived from this software without
41 * prior written permission. For written permission, please contact
42 * openssl-core@openssl.org.
43 *
44 * 5. Products derived from this software may not be called "OpenSSL"
45 * nor may "OpenSSL" appear in their names without prior written
46 * permission of the OpenSSL Project.
47 *
48 * 6. Redistributions of any form whatsoever must retain the following
49 * acknowledgment:
50 * "This product includes software developed by the OpenSSL Project
51 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
54 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
57 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
59 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
62 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
63 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
64 * OF THE POSSIBILITY OF SUCH DAMAGE.
65 * ====================================================================
66 *
67 * This product includes cryptographic software written by Eric Young
68 * (eay@cryptsoft.com). This product includes software written by Tim
69 * Hudson (tjh@cryptsoft.com).
70 *
71 */
72
73 #ifndef HEADER_SAFESTACK_H
74 #define HEADER_SAFESTACK_H
75
76 #include <openssl/stack.h>
77
78 #define STACK_OF(type) STACK_##type
79
80 #define DECLARE_STACK_OF(type) \
81 typedef struct stack_st_##type \
82 { \
83 STACK stack; \
84 } STACK_OF(type); \
85 STACK_OF(type) *sk_##type##_new(int (*cmp)(type **,type **)); \
86 STACK_OF(type) *sk_##type##_new_null(void); \
87 void sk_##type##_free(STACK_OF(type) *sk); \
88 int sk_##type##_num(const STACK_OF(type) *sk); \
89 type *sk_##type##_value(const STACK_OF(type) *sk,int n); \
90 type *sk_##type##_set(STACK_OF(type) *sk,int n,type *v); \
91 void sk_##type##_zero(STACK_OF(type) *sk); \
92 int sk_##type##_push(STACK_OF(type) *sk,type *v); \
93 int sk_##type##_unshift(STACK_OF(type) *sk,type *v); \
94 int sk_##type##_find(STACK_OF(type) *sk,type *v); \
95 type *sk_##type##_delete(STACK_OF(type) *sk,int n); \
96 void sk_##type##_delete_ptr(STACK_OF(type) *sk,type *v); \
97 int sk_##type##_insert(STACK_OF(type) *sk,type *v,int n); \
98 int (*sk_##type##_set_cmp_func(STACK_OF(type) *sk, \
99 int (*cmp)(type **,type **)))(type **,type **); \
100 STACK_OF(type) *sk_##type##_dup(STACK_OF(type) *sk); \
101 void sk_##type##_pop_free(STACK_OF(type) *sk,void (*func)(type *)); \
102 type *sk_##type##_shift(STACK_OF(type) *sk); \
103 type *sk_##type##_pop(STACK_OF(type) *sk); \
104 void sk_##type##_sort(STACK_OF(type) *sk);
105
106 #define IMPLEMENT_STACK_OF(type) \
107 STACK_OF(type) *sk_##type##_new(int (*cmp)(type **,type **)) \
108 { return (STACK_OF(type) *)sk_new(cmp); } \
109 STACK_OF(type) *sk_##type##_new_null() \
110 { return (STACK_OF(type) *)sk_new_null(); } \
111 void sk_##type##_free(STACK_OF(type) *sk) \
112 { sk_free((STACK *)sk); } \
113 int sk_##type##_num(const STACK_OF(type) *sk) \
114 { return M_sk_num((const STACK *)sk); } \
115 type *sk_##type##_value(const STACK_OF(type) *sk,int n) \
116 { return (type *)sk_value((STACK *)sk,n); } \
117 type *sk_##type##_set(STACK_OF(type) *sk,int n,type *v) \
118 { return (type *)(sk_set((STACK *)sk,n,(char *)v)); } \
119 void sk_##type##_zero(STACK_OF(type) *sk) \
120 { sk_zero((STACK *)sk); } \
121 int sk_##type##_push(STACK_OF(type) *sk,type *v) \
122 { return sk_push((STACK *)sk,(char *)v); } \
123 int sk_##type##_unshift(STACK_OF(type) *sk,type *v) \
124 { return sk_unshift((STACK *)sk,(char *)v); } \
125 int sk_##type##_find(STACK_OF(type) *sk,type *v) \
126 { return sk_find((STACK *)sk,(char *)v); } \
127 type *sk_##type##_delete(STACK_OF(type) *sk,int n) \
128 { return (type *)sk_delete((STACK *)sk,n); } \
129 void sk_##type##_delete_ptr(STACK_OF(type) *sk,type *v) \
130 { sk_delete_ptr((STACK *)sk,(char *)v); } \
131 int sk_##type##_insert(STACK_OF(type) *sk,type *v,int n) \
132 { return sk_insert((STACK *)sk,(char *)v,n); } \
133 int (*sk_##type##_set_cmp_func(STACK_OF(type) *sk, \
134 int (*cmp)(type **,type **)))(type **,type **) \
135 { return (int (*)(type **,type **))sk_set_cmp_func((STACK *)sk,cmp); } \
136 STACK_OF(type) *sk_##type##_dup(STACK_OF(type) *sk) \
137 { return (STACK_OF(type) *)sk_dup((STACK *)sk); } \
138 void sk_##type##_pop_free(STACK_OF(type) *sk,void (*func)(type *)) \
139 { sk_pop_free((STACK *)sk,func); } \
140 type *sk_##type##_shift(STACK_OF(type) *sk) \
141 { return (type *)sk_shift((STACK *)sk); } \
142 type *sk_##type##_pop(STACK_OF(type) *sk) \
143 { return (type *)sk_pop((STACK *)sk); } \
144 void sk_##type##_sort(STACK_OF(type) *sk) \
145 { sk_sort((STACK *)sk); }
146
147 #endif /* ndef HEADER_SAFESTACK_H */