#!/bin/sh


out='tmp.h'

>$out


echo '/* '                                                      >> $out
echo ' * Copyright (C) 2020,  Paul Sheer. All rights reserved.' >> $out
echo ' * '                                                      >> $out
echo ' * This software is provided without warranty. The author(s) disclaim liability for damages'      >> $out
echo ' * related to this software. All risk is assumed by you.' >> $out
echo ' * '                                                      >> $out
echo ' */'                                                      >> $out

echo '' >> $out
echo '/* This file is autogenerated. Do not edit. */' >> $out
echo '' >> $out
echo '#include <dfwmalloc.h>' >> $out
echo '' >> $out
echo '#ifndef DFWMALLOC_INLINE_H' >> $out
echo '#define DFWMALLOC_INLINE_H' >> $out
echo '' >> $out
echo '#ifdef __cplusplus' >> $out
echo 'extern "C" {' >> $out
echo '#endif' >> $out
echo '' >> $out
echo '#include <stdint.h>' >> $out
echo '' >> $out
echo '#define STATICFNINLINE static inline' >> $out
echo '' >> $out
echo '#define dfwmalloc_assert(c)      (void) (c)' >> $out
echo '' >> $out
echo '#define MIN_ALIGN               3' >> $out
echo '' >> $out
cat dfwmalloc.c | sed -e "/@INLINE4START@/,/@INLINE4END@/!D" >> $out
echo '' >> $out
cat dfwmalloc.c | grep '^typedef.*LONG[0-9]*[;]$' >> $out
echo '' >> $out
cat dfwmalloc.c | sed -e "/@INLINE6START@/,/@INLINE6END@/!D" >> $out
echo '};' >> $out

echo '' >> $out
for i in 7 3 1 8 2 5 ; do
    cat dfwmalloc.c | sed -e "/@INLINE${i}START@/,/@INLINE${i}END@/!D" >> $out
    echo >> $out
done
echo '' >> $out

cat dfwmalloc_inline_.h >> $out

echo '' >> $out
echo '#ifdef __cplusplus' >> $out
echo '}' >> $out
echo '#endif' >> $out
echo '' >> $out
echo '#endif /* !DFWMALLOC_INLINE_H */' >> $out
echo '' >> $out

cat $out | grep -v '^[/][*][ ][@]' > dfwmalloc_inline.h
rm -f $out


