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