7c47ae1c48
Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
58 lines
1.7 KiB
Bash
Executable file
58 lines
1.7 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# 2005-2009 Nico Schottelius (nico-cinit-conf at schottelius.org)
|
|
#
|
|
# This file is part of cinit-conf.
|
|
#
|
|
# cinit-conf is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# cinit-conf is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with cinit-conf. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
#
|
|
# Dump configuration usable as a c-header file.
|
|
#
|
|
|
|
################################################################################
|
|
# standard vars stolen from cconf
|
|
set -e
|
|
__pwd="$(pwd -P)"
|
|
__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)"
|
|
__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname"
|
|
set +e
|
|
|
|
|
|
CONFS="$(cinit-conf.get-confdir)"
|
|
|
|
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
|