1#!/bin/bash -e
2#
3# Generate init_extensions* functions to call all the _init functions from
4# filter_init
5#
6# Usage: gen_init <suffix> filename...
7#
8# Example output:
9#
10#   void libxt_tcp_init(void);
11#   void libxt_udp_init(void);
12#   void init_extensions(void);
13#   void init_extensions(void) {
14#     libxt_tcp_init();
15#     libxt_udp_init();
16#   }
17
18EXT=$1
19shift
20
21for i in "$@"; do
22  f=${i##*/}
23  f=${f%%.*}
24  echo "void ${f}_init(void);"
25done
26
27echo "void init_extensions${EXT}(void);"
28echo "void init_extensions${EXT}(void) {"
29
30for i in "$@"; do
31  f=${i##*/}
32  f=${f%%.*}
33  echo "  ${f}_init();"
34done
35
36echo "}"
37