diff options
Diffstat (limited to 'src/lib/libcrypto/stack')
-rw-r--r-- | src/lib/libcrypto/stack/safestack.h | 129 | ||||
-rw-r--r-- | src/lib/libcrypto/stack/stack.c | 311 | ||||
-rw-r--r-- | src/lib/libcrypto/stack/stack.h | 107 |
3 files changed, 0 insertions, 547 deletions
diff --git a/src/lib/libcrypto/stack/safestack.h b/src/lib/libcrypto/stack/safestack.h deleted file mode 100644 index 38934981e3..0000000000 --- a/src/lib/libcrypto/stack/safestack.h +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | /* ==================================================================== | ||
2 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in | ||
13 | * the documentation and/or other materials provided with the | ||
14 | * distribution. | ||
15 | * | ||
16 | * 3. All advertising materials mentioning features or use of this | ||
17 | * software must display the following acknowledgment: | ||
18 | * "This product includes software developed by the OpenSSL Project | ||
19 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
20 | * | ||
21 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
22 | * endorse or promote products derived from this software without | ||
23 | * prior written permission. For written permission, please contact | ||
24 | * openssl-core@openssl.org. | ||
25 | * | ||
26 | * 5. Products derived from this software may not be called "OpenSSL" | ||
27 | * nor may "OpenSSL" appear in their names without prior written | ||
28 | * permission of the OpenSSL Project. | ||
29 | * | ||
30 | * 6. Redistributions of any form whatsoever must retain the following | ||
31 | * acknowledgment: | ||
32 | * "This product includes software developed by the OpenSSL Project | ||
33 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
34 | * | ||
35 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
36 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
38 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
41 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
44 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
46 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
47 | * ==================================================================== | ||
48 | * | ||
49 | * This product includes cryptographic software written by Eric Young | ||
50 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
51 | * Hudson (tjh@cryptsoft.com). | ||
52 | * | ||
53 | */ | ||
54 | |||
55 | #ifndef HEADER_SAFESTACK_H | ||
56 | #define HEADER_SAFESTACK_H | ||
57 | |||
58 | #include <openssl/stack.h> | ||
59 | |||
60 | #define STACK_OF(type) STACK_##type | ||
61 | |||
62 | #define DECLARE_STACK_OF(type) \ | ||
63 | typedef struct stack_st_##type \ | ||
64 | { \ | ||
65 | STACK stack; \ | ||
66 | } STACK_OF(type); \ | ||
67 | STACK_OF(type) *sk_##type##_new(int (*cmp)(type **,type **)); \ | ||
68 | STACK_OF(type) *sk_##type##_new_null(void); \ | ||
69 | void sk_##type##_free(STACK_OF(type) *sk); \ | ||
70 | int sk_##type##_num(const STACK_OF(type) *sk); \ | ||
71 | type *sk_##type##_value(const STACK_OF(type) *sk,int n); \ | ||
72 | type *sk_##type##_set(STACK_OF(type) *sk,int n,type *v); \ | ||
73 | void sk_##type##_zero(STACK_OF(type) *sk); \ | ||
74 | int sk_##type##_push(STACK_OF(type) *sk,type *v); \ | ||
75 | int sk_##type##_unshift(STACK_OF(type) *sk,type *v); \ | ||
76 | int sk_##type##_find(STACK_OF(type) *sk,type *v); \ | ||
77 | type *sk_##type##_delete(STACK_OF(type) *sk,int n); \ | ||
78 | void sk_##type##_delete_ptr(STACK_OF(type) *sk,type *v); \ | ||
79 | int sk_##type##_insert(STACK_OF(type) *sk,type *v,int n); \ | ||
80 | int (*sk_##type##_set_cmp_func(STACK_OF(type) *sk, \ | ||
81 | int (*cmp)(type **,type **)))(type **,type **); \ | ||
82 | STACK_OF(type) *sk_##type##_dup(STACK_OF(type) *sk); \ | ||
83 | void sk_##type##_pop_free(STACK_OF(type) *sk,void (*func)(type *)); \ | ||
84 | type *sk_##type##_shift(STACK_OF(type) *sk); \ | ||
85 | type *sk_##type##_pop(STACK_OF(type) *sk); \ | ||
86 | void sk_##type##_sort(STACK_OF(type) *sk); | ||
87 | |||
88 | #define IMPLEMENT_STACK_OF(type) \ | ||
89 | STACK_OF(type) *sk_##type##_new(int (*cmp)(type **,type **)) \ | ||
90 | { return (STACK_OF(type) *)sk_new(cmp); } \ | ||
91 | STACK_OF(type) *sk_##type##_new_null() \ | ||
92 | { return (STACK_OF(type) *)sk_new_null(); } \ | ||
93 | void sk_##type##_free(STACK_OF(type) *sk) \ | ||
94 | { sk_free((STACK *)sk); } \ | ||
95 | int sk_##type##_num(const STACK_OF(type) *sk) \ | ||
96 | { return M_sk_num((const STACK *)sk); } \ | ||
97 | type *sk_##type##_value(const STACK_OF(type) *sk,int n) \ | ||
98 | { return (type *)sk_value((STACK *)sk,n); } \ | ||
99 | type *sk_##type##_set(STACK_OF(type) *sk,int n,type *v) \ | ||
100 | { return (type *)(sk_set((STACK *)sk,n,(char *)v)); } \ | ||
101 | void sk_##type##_zero(STACK_OF(type) *sk) \ | ||
102 | { sk_zero((STACK *)sk); } \ | ||
103 | int sk_##type##_push(STACK_OF(type) *sk,type *v) \ | ||
104 | { return sk_push((STACK *)sk,(char *)v); } \ | ||
105 | int sk_##type##_unshift(STACK_OF(type) *sk,type *v) \ | ||
106 | { return sk_unshift((STACK *)sk,(char *)v); } \ | ||
107 | int sk_##type##_find(STACK_OF(type) *sk,type *v) \ | ||
108 | { return sk_find((STACK *)sk,(char *)v); } \ | ||
109 | type *sk_##type##_delete(STACK_OF(type) *sk,int n) \ | ||
110 | { return (type *)sk_delete((STACK *)sk,n); } \ | ||
111 | void sk_##type##_delete_ptr(STACK_OF(type) *sk,type *v) \ | ||
112 | { sk_delete_ptr((STACK *)sk,(char *)v); } \ | ||
113 | int sk_##type##_insert(STACK_OF(type) *sk,type *v,int n) \ | ||
114 | { return sk_insert((STACK *)sk,(char *)v,n); } \ | ||
115 | int (*sk_##type##_set_cmp_func(STACK_OF(type) *sk, \ | ||
116 | int (*cmp)(type **,type **)))(type **,type **) \ | ||
117 | { return (int (*)(type **,type **))sk_set_cmp_func((STACK *)sk,cmp); } \ | ||
118 | STACK_OF(type) *sk_##type##_dup(STACK_OF(type) *sk) \ | ||
119 | { return (STACK_OF(type) *)sk_dup((STACK *)sk); } \ | ||
120 | void sk_##type##_pop_free(STACK_OF(type) *sk,void (*func)(type *)) \ | ||
121 | { sk_pop_free((STACK *)sk,func); } \ | ||
122 | type *sk_##type##_shift(STACK_OF(type) *sk) \ | ||
123 | { return (type *)sk_shift((STACK *)sk); } \ | ||
124 | type *sk_##type##_pop(STACK_OF(type) *sk) \ | ||
125 | { return (type *)sk_pop((STACK *)sk); } \ | ||
126 | void sk_##type##_sort(STACK_OF(type) *sk) \ | ||
127 | { sk_sort((STACK *)sk); } | ||
128 | |||
129 | #endif /* ndef HEADER_SAFESTACK_H */ | ||
diff --git a/src/lib/libcrypto/stack/stack.c b/src/lib/libcrypto/stack/stack.c deleted file mode 100644 index 8b96713884..0000000000 --- a/src/lib/libcrypto/stack/stack.c +++ /dev/null | |||
@@ -1,311 +0,0 @@ | |||
1 | /* crypto/stack/stack.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | /* Code for stacks | ||
60 | * Author - Eric Young v 1.0 | ||
61 | * 1.2 eay 12-Mar-97 - Modified sk_find so that it _DOES_ return the | ||
62 | * lowest index for the seached item. | ||
63 | * | ||
64 | * 1.1 eay - Take from netdb and added to SSLeay | ||
65 | * | ||
66 | * 1.0 eay - First version 29/07/92 | ||
67 | */ | ||
68 | #include <stdio.h> | ||
69 | #include "cryptlib.h" | ||
70 | #include <openssl/stack.h> | ||
71 | |||
72 | #undef MIN_NODES | ||
73 | #define MIN_NODES 4 | ||
74 | |||
75 | const char *STACK_version="Stack" OPENSSL_VERSION_PTEXT; | ||
76 | |||
77 | #define FP_ICC (int (*)(const void *,const void *)) | ||
78 | #include <errno.h> | ||
79 | |||
80 | int (*sk_set_cmp_func(STACK *sk, int (*c)()))(void) | ||
81 | { | ||
82 | int (*old)()=sk->comp; | ||
83 | |||
84 | if (sk->comp != c) | ||
85 | sk->sorted=0; | ||
86 | sk->comp=c; | ||
87 | |||
88 | return old; | ||
89 | } | ||
90 | |||
91 | STACK *sk_dup(STACK *sk) | ||
92 | { | ||
93 | STACK *ret; | ||
94 | char **s; | ||
95 | |||
96 | if ((ret=sk_new(sk->comp)) == NULL) goto err; | ||
97 | s=(char **)Realloc((char *)ret->data, | ||
98 | (unsigned int)sizeof(char *)*sk->num_alloc); | ||
99 | if (s == NULL) goto err; | ||
100 | ret->data=s; | ||
101 | |||
102 | ret->num=sk->num; | ||
103 | memcpy(ret->data,sk->data,sizeof(char *)*sk->num); | ||
104 | ret->sorted=sk->sorted; | ||
105 | ret->num_alloc=sk->num_alloc; | ||
106 | ret->comp=sk->comp; | ||
107 | return(ret); | ||
108 | err: | ||
109 | return(NULL); | ||
110 | } | ||
111 | |||
112 | STACK *sk_new(int (*c)()) | ||
113 | { | ||
114 | STACK *ret; | ||
115 | int i; | ||
116 | |||
117 | if ((ret=(STACK *)Malloc(sizeof(STACK))) == NULL) | ||
118 | goto err0; | ||
119 | if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL) | ||
120 | goto err1; | ||
121 | for (i=0; i<MIN_NODES; i++) | ||
122 | ret->data[i]=NULL; | ||
123 | ret->comp=c; | ||
124 | ret->num_alloc=MIN_NODES; | ||
125 | ret->num=0; | ||
126 | ret->sorted=0; | ||
127 | return(ret); | ||
128 | err1: | ||
129 | Free((char *)ret); | ||
130 | err0: | ||
131 | return(NULL); | ||
132 | } | ||
133 | |||
134 | int sk_insert(STACK *st, char *data, int loc) | ||
135 | { | ||
136 | char **s; | ||
137 | |||
138 | if(st == NULL) return 0; | ||
139 | if (st->num_alloc <= st->num+1) | ||
140 | { | ||
141 | s=(char **)Realloc((char *)st->data, | ||
142 | (unsigned int)sizeof(char *)*st->num_alloc*2); | ||
143 | if (s == NULL) | ||
144 | return(0); | ||
145 | st->data=s; | ||
146 | st->num_alloc*=2; | ||
147 | } | ||
148 | if ((loc >= (int)st->num) || (loc < 0)) | ||
149 | st->data[st->num]=data; | ||
150 | else | ||
151 | { | ||
152 | int i; | ||
153 | char **f,**t; | ||
154 | |||
155 | f=(char **)st->data; | ||
156 | t=(char **)&(st->data[1]); | ||
157 | for (i=st->num; i>=loc; i--) | ||
158 | t[i]=f[i]; | ||
159 | |||
160 | #ifdef undef /* no memmove on sunos :-( */ | ||
161 | memmove( (char *)&(st->data[loc+1]), | ||
162 | (char *)&(st->data[loc]), | ||
163 | sizeof(char *)*(st->num-loc)); | ||
164 | #endif | ||
165 | st->data[loc]=data; | ||
166 | } | ||
167 | st->num++; | ||
168 | st->sorted=0; | ||
169 | return(st->num); | ||
170 | } | ||
171 | |||
172 | char *sk_delete_ptr(STACK *st, char *p) | ||
173 | { | ||
174 | int i; | ||
175 | |||
176 | for (i=0; i<st->num; i++) | ||
177 | if (st->data[i] == p) | ||
178 | return(sk_delete(st,i)); | ||
179 | return(NULL); | ||
180 | } | ||
181 | |||
182 | char *sk_delete(STACK *st, int loc) | ||
183 | { | ||
184 | char *ret; | ||
185 | int i,j; | ||
186 | |||
187 | if ((st == NULL) || (st->num == 0) || (loc < 0) | ||
188 | || (loc >= st->num)) return(NULL); | ||
189 | |||
190 | ret=st->data[loc]; | ||
191 | if (loc != st->num-1) | ||
192 | { | ||
193 | j=st->num-1; | ||
194 | for (i=loc; i<j; i++) | ||
195 | st->data[i]=st->data[i+1]; | ||
196 | /* In theory memcpy is not safe for this | ||
197 | * memcpy( &(st->data[loc]), | ||
198 | * &(st->data[loc+1]), | ||
199 | * sizeof(char *)*(st->num-loc-1)); | ||
200 | */ | ||
201 | } | ||
202 | st->num--; | ||
203 | return(ret); | ||
204 | } | ||
205 | |||
206 | int sk_find(STACK *st, char *data) | ||
207 | { | ||
208 | char **r; | ||
209 | int i; | ||
210 | int (*comp_func)(); | ||
211 | if(st == NULL) return -1; | ||
212 | |||
213 | if (st->comp == NULL) | ||
214 | { | ||
215 | for (i=0; i<st->num; i++) | ||
216 | if (st->data[i] == data) | ||
217 | return(i); | ||
218 | return(-1); | ||
219 | } | ||
220 | sk_sort(st); | ||
221 | if (data == NULL) return(-1); | ||
222 | comp_func=(int (*)())st->comp; | ||
223 | r=(char **)bsearch(&data,(char *)st->data, | ||
224 | st->num,sizeof(char *),FP_ICC comp_func); | ||
225 | if (r == NULL) return(-1); | ||
226 | i=(int)(r-st->data); | ||
227 | for ( ; i>0; i--) | ||
228 | if ((*st->comp)(&(st->data[i-1]),&data) < 0) | ||
229 | break; | ||
230 | return(i); | ||
231 | } | ||
232 | |||
233 | int sk_push(STACK *st, char *data) | ||
234 | { | ||
235 | return(sk_insert(st,data,st->num)); | ||
236 | } | ||
237 | |||
238 | int sk_unshift(STACK *st, char *data) | ||
239 | { | ||
240 | return(sk_insert(st,data,0)); | ||
241 | } | ||
242 | |||
243 | char *sk_shift(STACK *st) | ||
244 | { | ||
245 | if (st == NULL) return(NULL); | ||
246 | if (st->num <= 0) return(NULL); | ||
247 | return(sk_delete(st,0)); | ||
248 | } | ||
249 | |||
250 | char *sk_pop(STACK *st) | ||
251 | { | ||
252 | if (st == NULL) return(NULL); | ||
253 | if (st->num <= 0) return(NULL); | ||
254 | return(sk_delete(st,st->num-1)); | ||
255 | } | ||
256 | |||
257 | void sk_zero(STACK *st) | ||
258 | { | ||
259 | if (st == NULL) return; | ||
260 | if (st->num <= 0) return; | ||
261 | memset((char *)st->data,0,sizeof(st->data)*st->num); | ||
262 | st->num=0; | ||
263 | } | ||
264 | |||
265 | void sk_pop_free(STACK *st, void (*func)()) | ||
266 | { | ||
267 | int i; | ||
268 | |||
269 | if (st == NULL) return; | ||
270 | for (i=0; i<st->num; i++) | ||
271 | if (st->data[i] != NULL) | ||
272 | func(st->data[i]); | ||
273 | sk_free(st); | ||
274 | } | ||
275 | |||
276 | void sk_free(STACK *st) | ||
277 | { | ||
278 | if (st == NULL) return; | ||
279 | if (st->data != NULL) Free((char *)st->data); | ||
280 | Free((char *)st); | ||
281 | } | ||
282 | |||
283 | int sk_num(STACK *st) | ||
284 | { | ||
285 | if(st == NULL) return -1; | ||
286 | return st->num; | ||
287 | } | ||
288 | |||
289 | char *sk_value(STACK *st, int i) | ||
290 | { | ||
291 | if(st == NULL) return NULL; | ||
292 | return st->data[i]; | ||
293 | } | ||
294 | |||
295 | char *sk_set(STACK *st, int i, char *value) | ||
296 | { | ||
297 | if(st == NULL) return NULL; | ||
298 | return (st->data[i] = value); | ||
299 | } | ||
300 | |||
301 | void sk_sort(STACK *st) | ||
302 | { | ||
303 | if (!st->sorted) | ||
304 | { | ||
305 | int (*comp_func)(); | ||
306 | |||
307 | comp_func=(int (*)())st->comp; | ||
308 | qsort(st->data,st->num,sizeof(char *),FP_ICC comp_func); | ||
309 | st->sorted=1; | ||
310 | } | ||
311 | } | ||
diff --git a/src/lib/libcrypto/stack/stack.h b/src/lib/libcrypto/stack/stack.h deleted file mode 100644 index 0f825cc0c4..0000000000 --- a/src/lib/libcrypto/stack/stack.h +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | /* crypto/stack/stack.h */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #ifndef HEADER_STACK_H | ||
60 | #define HEADER_STACK_H | ||
61 | |||
62 | #ifdef __cplusplus | ||
63 | extern "C" { | ||
64 | #endif | ||
65 | |||
66 | typedef struct stack_st | ||
67 | { | ||
68 | int num; | ||
69 | char **data; | ||
70 | int sorted; | ||
71 | |||
72 | int num_alloc; | ||
73 | int (*comp)(); | ||
74 | } STACK; | ||
75 | |||
76 | |||
77 | #define sk_new_null() sk_new(NULL) | ||
78 | |||
79 | #define M_sk_num(sk) ((sk)->num) | ||
80 | #define M_sk_value(sk,n) ((sk)->data[n]) | ||
81 | |||
82 | int sk_num(STACK *); | ||
83 | char *sk_value(STACK *, int); | ||
84 | |||
85 | char *sk_set(STACK *, int, char *); | ||
86 | |||
87 | STACK *sk_new(int (*cmp)()); | ||
88 | void sk_free(STACK *); | ||
89 | void sk_pop_free(STACK *st, void (*func)()); | ||
90 | int sk_insert(STACK *sk,char *data,int where); | ||
91 | char *sk_delete(STACK *st,int loc); | ||
92 | char *sk_delete_ptr(STACK *st, char *p); | ||
93 | int sk_find(STACK *st,char *data); | ||
94 | int sk_push(STACK *st,char *data); | ||
95 | int sk_unshift(STACK *st,char *data); | ||
96 | char *sk_shift(STACK *st); | ||
97 | char *sk_pop(STACK *st); | ||
98 | void sk_zero(STACK *st); | ||
99 | int (*sk_set_cmp_func(STACK *sk, int (*c)()))(); | ||
100 | STACK *sk_dup(STACK *st); | ||
101 | void sk_sort(STACK *st); | ||
102 | |||
103 | #ifdef __cplusplus | ||
104 | } | ||
105 | #endif | ||
106 | |||
107 | #endif | ||