www.nico.schottelius.org/software/cinit/browse_source/cinit-0.3pre17/scripts/cinit.mkheader
Nico Schottelius 759b58c293 released cinit-0.3pre17
Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
2009-10-05 19:14:52 +02:00

32 lines
742 B
Bash
Executable file

#!/bin/sh
# Nico Schottelius
# cinit: create header file
#
CONFS=$($(dirname $0)/cinit.get-confdir)/../conf/*
echo "/* Warning: Autogenerated by $0, do not edit. */"
for conf in $CONFS; do
NAME="$(basename $conf | tr a-z A-Z)"
value=$(head -n 1 $conf)
# check if numeric: no quotes needed
is_numeric=$(echo $value | awk '/^((0[xX])[0-9a-fA-F]+)|([0-9]+)$/ { print }')
is_string="$(echo $value | grep '^"')"
#
# Check for quote type
#
if [ ! "$is_numeric" -a ! "$is_string" ]; then
one_char=$(echo -n $value | wc -c)
if [ "$one_char" -eq 1 ]; then
value="'$value'"
else
# is a string
value="\"$value\""
fi
fi
echo "#define" "$NAME" "$value"
done