stack.h revision 160814
1251881Speter/* crypto/stack/stack.h */ 2251881Speter/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3251881Speter * All rights reserved. 4251881Speter * 5251881Speter * This package is an SSL implementation written 6251881Speter * by Eric Young (eay@cryptsoft.com). 7251881Speter * The implementation was written so as to conform with Netscapes SSL. 8251881Speter * 9251881Speter * This library is free for commercial and non-commercial use as long as 10251881Speter * the following conditions are aheared to. The following conditions 11251881Speter * apply to all code found in this distribution, be it the RC4, RSA, 12251881Speter * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13251881Speter * included with this distribution is covered by the same copyright terms 14251881Speter * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15251881Speter * 16251881Speter * Copyright remains Eric Young's, and as such any Copyright notices in 17251881Speter * the code are not to be removed. 18251881Speter * If this package is used in a product, Eric Young should be given attribution 19251881Speter * as the author of the parts of the library used. 20251881Speter * This can be in the form of a textual message at program startup or 21251881Speter * in documentation (online or textual) provided with the package. 22251881Speter * 23251881Speter * Redistribution and use in source and binary forms, with or without 24251881Speter * modification, are permitted provided that the following conditions 25251881Speter * are met: 26251881Speter * 1. Redistributions of source code must retain the copyright 27251881Speter * notice, this list of conditions and the following disclaimer. 28251881Speter * 2. Redistributions in binary form must reproduce the above copyright 29251881Speter * notice, this list of conditions and the following disclaimer in the 30251881Speter * documentation and/or other materials provided with the distribution. 31251881Speter * 3. All advertising materials mentioning features or use of this software 32251881Speter * must display the following acknowledgement: 33251881Speter * "This product includes cryptographic software written by 34251881Speter * Eric Young (eay@cryptsoft.com)" 35251881Speter * The word 'cryptographic' can be left out if the rouines from the library 36251881Speter * being used are not cryptographic related :-). 37251881Speter * 4. If you include any Windows specific code (or a derivative thereof) from 38251881Speter * the apps directory (application code) you must include an acknowledgement: 39251881Speter * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40251881Speter * 41251881Speter * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42251881Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43251881Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44251881Speter * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45251881Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46251881Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47251881Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48251881Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49251881Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50251881Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51251881Speter * SUCH DAMAGE. 52251881Speter * 53251881Speter * The licence and distribution terms for any publically available version or 54251881Speter * derivative of this code cannot be changed. i.e. this code cannot simply be 55251881Speter * copied and put under another distribution licence 56251881Speter * [including the GNU Public Licence.] 57262253Speter */ 58251881Speter 59251881Speter#ifndef HEADER_STACK_H 60251881Speter#define HEADER_STACK_H 61251881Speter 62251881Speter#ifdef __cplusplus 63251881Speterextern "C" { 64251881Speter#endif 65251881Speter 66251881Spetertypedef struct stack_st 67251881Speter { 68251881Speter int num; 69251881Speter char **data; 70251881Speter int sorted; 71251881Speter 72251881Speter int num_alloc; 73251881Speter int (*comp)(const char * const *, const char * const *); 74251881Speter } STACK; 75251881Speter 76251881Speter#define M_sk_num(sk) ((sk) ? (sk)->num:-1) 77251881Speter#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) 78251881Speter 79251881Speterint sk_num(const STACK *); 80251881Speterchar *sk_value(const STACK *, int); 81251881Speter 82251881Speterchar *sk_set(STACK *, int, char *); 83251881Speter 84251881SpeterSTACK *sk_new(int (*cmp)(const char * const *, const char * const *)); 85251881SpeterSTACK *sk_new_null(void); 86251881Spetervoid sk_free(STACK *); 87251881Spetervoid sk_pop_free(STACK *st, void (*func)(void *)); 88251881Speterint sk_insert(STACK *sk,char *data,int where); 89251881Speterchar *sk_delete(STACK *st,int loc); 90251881Speterchar *sk_delete_ptr(STACK *st, char *p); 91251881Speterint sk_find(STACK *st,char *data); 92251881Speterint sk_find_ex(STACK *st,char *data); 93251881Speterint sk_push(STACK *st,char *data); 94251881Speterint sk_unshift(STACK *st,char *data); 95251881Speterchar *sk_shift(STACK *st); 96251881Speterchar *sk_pop(STACK *st); 97251881Spetervoid sk_zero(STACK *st); 98251881Speterint (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *, 99251881Speter const char * const *))) 100251881Speter (const char * const *, const char * const *); 101251881SpeterSTACK *sk_dup(STACK *st); 102251881Spetervoid sk_sort(STACK *st); 103251881Speterint sk_is_sorted(const STACK *st); 104251881Speter 105251881Speter#ifdef __cplusplus 106251881Speter} 107251881Speter#endif 108251881Speter 109251881Speter#endif 110251881Speter