--- /dev/null
+#! /bin/sh
+
+set -e
+type=$1
+include=$2
+list=$3
+
+cat <<EOF
+/* -*-c-*-
+ *
+ * ${include}tab.c [generated]
+ */
+
+#include <string.h>
+
+#include "$2.h"
+
+EOF
+for i in $list; do
+ echo "#include \"$i.h\""
+done
+
+cat <<EOF
+
+const $type *const ${include}tab[] = {
+EOF
+for i in $list; do
+ c=`echo $i | sed 's/[^A-Za-z0-9_][^A-Za-z0-9_]*/_/g'`
+ echo " &$c,"
+done
+cat <<EOF
+ 0
+};
+
+const $type *${include}_byname(const char *p)
+{
+ const $type *const *c;
+
+ for (c = ${include}tab; *c; c++) {
+ if (strcmp(p, (*c)->name) == 0)
+ return (*c);
+ }
+ return (0);
+}
+
+EOF