--- /dev/null
+/* $OpenBSD: stack.h,v 1.1 2022/11/11 19:18:55 beck Exp $ */
+/*
+ * Copyright (c) 2022 Bob Beck <beck@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _LIBCRYPTO_STACK_H
+#define _LIBCRYPTO_STACK_H
+
+#include_next <openssl/stack.h>
+#include "crypto_namespace.h"
+
+LCRYPTO_USED(sk_num);
+LCRYPTO_USED(sk_value);
+LCRYPTO_USED(sk_set);
+LCRYPTO_USED(sk_new);
+LCRYPTO_USED(sk_new_null);
+LCRYPTO_USED(sk_free);
+LCRYPTO_USED(sk_pop_free);
+LCRYPTO_USED(sk_insert);
+LCRYPTO_USED(sk_delete);
+LCRYPTO_USED(sk_delete_ptr);
+LCRYPTO_USED(sk_find);
+LCRYPTO_USED(sk_find_ex);
+LCRYPTO_USED(sk_push);
+LCRYPTO_USED(sk_unshift);
+LCRYPTO_USED(sk_shift);
+LCRYPTO_USED(sk_pop);
+LCRYPTO_USED(sk_zero);
+LCRYPTO_USED(sk_set_cmp_func);
+LCRYPTO_USED(sk_dup);
+LCRYPTO_USED(sk_sort);
+LCRYPTO_USED(sk_is_sorted);
+
+#endif /* _LIBCRYPTO_STACK_H */
-/* $OpenBSD: stack.c,v 1.20 2018/04/01 00:36:28 schwarze Exp $ */
+/* $OpenBSD: stack.c,v 1.21 2022/11/11 19:18:55 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
return old;
}
+LCRYPTO_ALIAS(sk_set_cmp_func)
_STACK *
sk_dup(_STACK *sk)
sk_free(ret);
return (NULL);
}
+LCRYPTO_ALIAS(sk_dup)
_STACK *
sk_new_null(void)
{
return sk_new((int (*)(const void *, const void *))0);
}
+LCRYPTO_ALIAS(sk_new_null)
_STACK *
sk_new(int (*c)(const void *, const void *))
free(ret);
return (NULL);
}
+LCRYPTO_ALIAS(sk_new)
int
sk_insert(_STACK *st, void *data, int loc)
st->sorted = 0;
return (st->num);
}
+LCRYPTO_ALIAS(sk_insert)
void *
sk_delete_ptr(_STACK *st, void *p)
return (sk_delete(st, i));
return (NULL);
}
+LCRYPTO_ALIAS(sk_delete_ptr)
void *
sk_delete(_STACK *st, int loc)
st->num--;
return (ret);
}
+LCRYPTO_ALIAS(sk_delete)
static int
internal_find(_STACK *st, void *data, int ret_val_options)
{
return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
}
+LCRYPTO_ALIAS(sk_find)
int
sk_find_ex(_STACK *st, void *data)
{
return internal_find(st, data, OBJ_BSEARCH_VALUE_ON_NOMATCH);
}
+LCRYPTO_ALIAS(sk_find_ex)
int
sk_push(_STACK *st, void *data)
{
return (sk_insert(st, data, st->num));
}
+LCRYPTO_ALIAS(sk_push)
int
sk_unshift(_STACK *st, void *data)
{
return (sk_insert(st, data, 0));
}
+LCRYPTO_ALIAS(sk_unshift)
void *
sk_shift(_STACK *st)
return (NULL);
return (sk_delete(st, 0));
}
+LCRYPTO_ALIAS(sk_shift)
void *
sk_pop(_STACK *st)
return (NULL);
return (sk_delete(st, st->num - 1));
}
+LCRYPTO_ALIAS(sk_pop)
void
sk_zero(_STACK *st)
memset(st->data, 0, sizeof(st->data)*st->num);
st->num = 0;
}
+LCRYPTO_ALIAS(sk_zero)
void
sk_pop_free(_STACK *st, void (*func)(void *))
func(st->data[i]);
sk_free(st);
}
+LCRYPTO_ALIAS(sk_pop_free)
void
sk_free(_STACK *st)
free(st->data);
free(st);
}
+LCRYPTO_ALIAS(sk_free)
int
sk_num(const _STACK *st)
return -1;
return st->num;
}
+LCRYPTO_ALIAS(sk_num)
void *
sk_value(const _STACK *st, int i)
return NULL;
return st->data[i];
}
+LCRYPTO_ALIAS(sk_value)
void *
sk_set(_STACK *st, int i, void *value)
st->sorted = 0;
return (st->data[i] = value);
}
+LCRYPTO_ALIAS(sk_set)
void
sk_sort(_STACK *st)
st->sorted = 1;
}
}
+LCRYPTO_ALIAS(sk_sort)
int
sk_is_sorted(const _STACK *st)
return 1;
return st->sorted;
}
+LCRYPTO_ALIAS(sk_is_sorted)