blob: 9d27bd8d6dd3f46d0f63a76b09cde71bf63722a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#! /bin/sh
if [ $# = 0 ]
then
cat 1>&2 <<EOF
Usage: $(basename $0) ENUMPREFIX [FILES]
EOF
fi
type="$1"
shift
cat <<EOF
static
const struct {
int value;
const char *name;
} ${type}_names_vals[] = {
EOF
awk -vtype=$type -vtype_regex="^${type}_" ' \
BEGIN { IGNORECASE = 1; } \
$1 ~ type_regex { \
name=$1; \
symbol=$1; \
type_regex="^" type "_"; \
gsub(/,.*$/, "", symbol); \
gsub(type_regex, "", name); \
gsub(/,.*$/, "", name); \
gsub(/_/, "-", name); \
print "\t{ " symbol ", \"" tolower(name) "\" },"; \
}' $@
echo " { 0, NULL }"
echo "};"
|