X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command_util.sh;h=b757b2e0d29741097e649aeca38bd889b7541e70;hp=ea952e5b1283589d16bff19717ba39b20964648c;hb=e090f7343634d5f68acf961367ee256d0bf831d7;hpb=b43af255d4514b68c98b23fb220306cf5ba1df60 diff --git a/command_util.sh b/command_util.sh index ea952e5b..b757b2e0 100755 --- a/command_util.sh +++ b/command_util.sh @@ -20,6 +20,46 @@ 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" + ;; + AT:) + array_type="$value" + ;; + AN:) + array_name="$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() { @@ -140,6 +180,9 @@ com_man() com_array() { + 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 +193,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() { + 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,6 +238,7 @@ com_proto() done } +read_header arg="$1" shift case "$arg" in