File: configtoh

package info (click to toggle)
apex 1.4.15.2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,760 kB
  • ctags: 9,106
  • sloc: ansic: 174,449; cpp: 2,833; makefile: 1,385; asm: 891; yacc: 568; lex: 350; sh: 204; perl: 51
file content (34 lines) | stat: -rwxr-xr-x 762 bytes parent folder | download | duplicates (3)
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
34
#!/bin/sh
# converts a config file to a C header with appropriate definitions 
#
# usage: configtoh CONFIG

echo "#if !defined (__CONFIG_H__)"
echo "#    define   __CONFIG_H__"
echo
cat $1 | sed -e '/CONFIG_/!d' \
             -e 's/^[ \t]*#.*//' \
             -e 's/"\([^ "]*\)"/\1/g' \
             -e 's/\([^=]*\)=\(\.*\)/#define \1 \2/'
echo
echo
echo "#endif /* __CONFIG_H__ */"


# Below is the original perl code.  We've replaced it with sh/sed
# because perl isn't always available.

# #!/bin/perl
# 
# print "#if !defined (__CONFIG_H__)\n";
# print "#define __CONFIG_H__\n";
# 
# while (<>) {
# 
#     next if m/^\s*#/;
#     
#     next if ! m/\s*([^=\s]+)\s*=\s*([^\s]+)/;
#     print "#define $1 $2\n";
# }
# 
# print "#endif /* __CONFIG_H__ */\n";