Make tables of standard encryption schemes etc.
[u/mdw/catacomb] / gengctab
CommitLineData
59919ae4 1#! /bin/sh
2
3set -e
4type=$1
5include=$2
6list=$3
7
8cat <<EOF
9/* -*-c-*-
10 *
11 * ${include}tab.c [generated]
12 */
13
14#include <string.h>
15
16#include "$2.h"
17
18EOF
19for i in $list; do
20 echo "#include \"$i.h\""
21done
22
23cat <<EOF
24
25const $type *const ${include}tab[] = {
26EOF
27for i in $list; do
28 c=`echo $i | sed 's/[^A-Za-z0-9_][^A-Za-z0-9_]*/_/g'`
29 echo " &$c,"
30done
31cat <<EOF
32 0
33};
34
35const $type *${include}_byname(const char *p)
36{
37 const $type *const *c;
38
39 for (c = ${include}tab; *c; c++) {
40 if (strcmp(p, (*c)->name) == 0)
41 return (*c);
42 }
43 return (0);
44}
45
46EOF