2014-06-20 20:00:00 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-08-15 18:49:12 +01:00
|
|
|
include_dir=../../include/openssl
|
|
|
|
|
|
|
|
cat > "${include_dir}/stack_macros.h" << EOF
|
2014-06-20 20:00:00 +01:00
|
|
|
/* Copyright (c) 2014, Google Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or 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. */
|
|
|
|
|
|
|
|
#if !defined(IN_STACK_H)
|
|
|
|
#error "Don't include this file directly. Include stack.h."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
output_stack () {
|
|
|
|
type=$1
|
2014-08-15 18:49:12 +01:00
|
|
|
ptrtype=$2
|
2014-06-20 20:00:00 +01:00
|
|
|
|
2014-08-15 18:49:12 +01:00
|
|
|
cat >> "${include_dir}/stack_macros.h" << EOF
|
2014-06-20 20:00:00 +01:00
|
|
|
/* ${type} */
|
|
|
|
#define sk_${type}_new(comp)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
((STACK_OF(${type})*) sk_new(CHECKED_CAST(stack_cmp_func, int (*) (const ${ptrtype} *a, const ${ptrtype} *b), comp)))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_new_null()\\
|
|
|
|
((STACK_OF(${type})*) sk_new_null())
|
|
|
|
|
|
|
|
#define sk_${type}_num(sk)\\
|
2016-05-13 18:14:28 +01:00
|
|
|
sk_num(CHECKED_CAST(const _STACK*, const STACK_OF(${type})*, sk))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_zero(sk)\\
|
|
|
|
sk_zero(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk));
|
|
|
|
|
|
|
|
#define sk_${type}_value(sk, i)\\
|
2016-05-13 18:14:28 +01:00
|
|
|
((${ptrtype}) sk_value(CHECKED_CAST(const _STACK*, const STACK_OF(${type})*, sk), (i)))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_set(sk, i, p)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
((${ptrtype}) sk_set(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), (i), CHECKED_CAST(void*, ${ptrtype}, p)))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_free(sk)\\
|
|
|
|
sk_free(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk))
|
|
|
|
|
|
|
|
#define sk_${type}_pop_free(sk, free_func)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
sk_pop_free(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void (*) (void*), void (*) (${ptrtype}), free_func))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_insert(sk, p, where)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
sk_insert(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void*, ${ptrtype}, p), (where))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_delete(sk, where)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
((${ptrtype}) sk_delete(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), (where)))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_delete_ptr(sk, p)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
((${ptrtype}) sk_delete_ptr(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void*, ${ptrtype}, p)))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_find(sk, out_index, p)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
sk_find(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), (out_index), CHECKED_CAST(void*, ${ptrtype}, p))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_shift(sk)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
((${ptrtype}) sk_shift(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk)))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_push(sk, p)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
sk_push(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void*, ${ptrtype}, p))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_pop(sk)\\
|
2014-08-15 18:49:12 +01:00
|
|
|
((${ptrtype}) sk_pop(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk)))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_dup(sk)\\
|
2016-05-13 18:14:28 +01:00
|
|
|
((STACK_OF(${type})*) sk_dup(CHECKED_CAST(const _STACK*, const STACK_OF(${type})*, sk)))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_sort(sk)\\
|
|
|
|
sk_sort(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk))
|
|
|
|
|
|
|
|
#define sk_${type}_is_sorted(sk)\\
|
2016-05-13 18:14:28 +01:00
|
|
|
sk_is_sorted(CHECKED_CAST(const _STACK*, const STACK_OF(${type})*, sk))
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
#define sk_${type}_set_cmp_func(sk, comp)\\
|
|
|
|
((int (*) (const ${type} **a, const ${type} **b)) sk_set_cmp_func(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(stack_cmp_func, int (*) (const ${type} **a, const ${type} **b), comp)))
|
|
|
|
|
2015-02-11 22:27:21 +00:00
|
|
|
#define sk_${type}_deep_copy(sk, copy_func, free_func)\\
|
|
|
|
((STACK_OF(${type})*) sk_deep_copy(CHECKED_CAST(const _STACK*, const STACK_OF(${type})*, sk), CHECKED_CAST(void* (*) (void*), ${ptrtype} (*) (${ptrtype}), copy_func), CHECKED_CAST(void (*) (void*), void (*) (${ptrtype}), free_func)))
|
|
|
|
|
2014-06-20 20:00:00 +01:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2014-08-15 18:49:12 +01:00
|
|
|
stack_types=$(cat "${include_dir}/stack.h" | grep '^ \* STACK_OF:' | sed -e 's/.*STACK_OF://' -e 's/ .*//')
|
|
|
|
const_stack_types=$(cat "${include_dir}/stack.h" | grep '^ \* CONST_STACK_OF:' | sed -e 's/.*CONST_STACK_OF://' -e 's/ .*//')
|
|
|
|
special_stack_types=$(cat "${include_dir}/stack.h" | grep '^ \* SPECIAL_STACK_OF:' | sed -e 's/.*SPECIAL_STACK_OF://' -e 's/ .*//')
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
for type in $stack_types; do
|
|
|
|
echo Stack of ${type}
|
2014-08-15 18:49:12 +01:00
|
|
|
output_stack "${type}" "${type} *"
|
|
|
|
done
|
|
|
|
|
|
|
|
for type in $const_stack_types; do
|
|
|
|
echo Stack of ${type}
|
|
|
|
output_stack "${type}" "const ${type} *"
|
2014-06-20 20:00:00 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
for type in $special_stack_types; do
|
|
|
|
echo Stack of ${type}
|
2014-08-15 18:49:12 +01:00
|
|
|
output_stack "${type}" "${type}"
|
2014-06-20 20:00:00 +01:00
|
|
|
done
|
|
|
|
|
2014-08-15 18:49:12 +01:00
|
|
|
clang-format -i "${include_dir}/stack_macros.h"
|