5 #-------------------------------------------------------------------------------
6 # Copyright (C) 2004, 2005, 2006 Sylvain Fourmanoit <syfou@users.sourceforge.net>
8 # Permission is hereby granted, free of charge, to any person obtaining a copy
9 # of this software and associated documentation files (the "Software"), to
10 # deal in the Software without restriction, including without limitation the
11 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 # sell copies of the Software, and to permit persons to whom the Software is
13 # furnished to do so, subject to the following conditions:
15 # The above copyright notice and this permission notice shall be included in
16 # all copies of the Software and its documentation and acknowledgment shall be
17 # given in the documentation and software packages that this Software was
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 # THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #-------------------------------------------------------------------------------
28 # Quick and dirty but hopefully portable script to generate
29 # command list from const COMMAND COMMANDS[] in command.c
31 # Usage: command_enum.sh [--with-help]
33 # Note: Only tested with GNU sed 4.0.9. Will anyway probably only work
34 # with it, since we make use of many GNU extensions.
36 #-------------------------------------------------------------------------------
38 name_and_description
() {
39 sed -n '/const COMMAND/,/NULL, NULL/p' command.c | \
41 sed 's/[^"]*"\([^"]\+\)"[^"]*/\1\n/g' | \
43 sed '/^[a-z]/{s/.*/CMD_\U&/;h;d};/^[A-Z]/{x;G;s/\n/\t/}'
46 if test "x$1" != "x--with-help" ; then
48 /* Automatically generated by `basename $0`
51 name_and_description |
sed 's/\(.*\)\t.*/\1/;1s/$/=0/;s/$/,/'