X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command_util.sh;h=ba5e99e2fcabb719ff0219f1ea65b2b4ded841a9;hp=ea952e5b1283589d16bff19717ba39b20964648c;hb=4346bb908d494a60f4fa52875ae10228125d82f2;hpb=6aa6fcd54de730b4dfc75ca60f8c21009d60da0d diff --git a/command_util.sh b/command_util.sh index ea952e5b..ba5e99e2 100755 --- a/command_util.sh +++ b/command_util.sh @@ -8,6 +8,7 @@ dump_array_member() if test $line_handler -eq 0; then echo ".handler = com_$name_txt," else + echo ".handler = NULL," echo ".line_handler = com_$name_txt," fi if test -n "$perms_txt"; then @@ -20,6 +21,44 @@ dump_array_member() echo '},' } +read_header() +{ + local key value i + + while read key value; do + case "$key" in + ---) + break + ;; + HC:) + header_comment="$value" + ;; + CC:) + c_file_comment="$value" + ;; + FN:) + file_name="$value" + array_name=${value%command_list}cmds + ;; + AT:) + array_type="$value" + ;; + IN:) + for i in $value; do + includes="$includes +#include \"$i.h\"" + done + includes="$includes +#include \"$file_name.h\"" + ;; + esac + done + if test -z "$header_comment" -o -z "$c_file_comment" \ + -o -z "$file_name"; then + echo "header error" 1&>2 + exit 1 + fi +} read_one_command() { @@ -138,8 +177,11 @@ com_man() done } -com_array() +com_c_file() { + echo "/** \file $file_name.c $c_file_comment */" + echo "$includes" + echo "struct $array_type $array_name[] = {" while : ; do read_one_command if test $ret -lt 0; then @@ -150,19 +192,39 @@ com_array() fi dump_array_member done + echo '{.name = NULL}};' } dump_proto() { + echo '/**' + echo " * $desc_txt" + echo ' *' + echo ' * \param fd the file descriptor to send output to' + if test $line_handler -eq 0; then + echo ' * \param argc the number of arguments' + echo ' * \param argv the argument vector' + else + echo ' * \param cmdline the full command line' + fi + echo ' * ' + echo " * synopsis: $syn_txt" + echo ' * ' + echo "$help_txt" | sed -e 's/^/ * /g' + echo ' */' if test $line_handler -eq 0; then - echo "int com_$name_txt(int, int, char **);" + echo "int com_$name_txt(int fd, int argc, char **argv);" else - echo "int com_$name_txt(int, char *);" + echo "int com_$name_txt(int fd, char *cmdline);" fi + echo } -com_proto() +com_header() { + echo "/** \file $file_name.h $header_comment */" + echo + echo "extern struct $array_type $array_name[];" while : ; do read_one_command if test $ret -lt 0; then @@ -175,14 +237,15 @@ com_proto() done } +read_header arg="$1" shift case "$arg" in - "array") - com_array + "c") + com_c_file ;; - "proto") - com_proto + "h") + com_header ;; "man") com_man $*