X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command_util.sh;h=5119f58bc7f264aff2cd17f965bb1e2cfd1cbf47;hp=0e67af1aba21883e86f2c138f9a3d45b69e0c539;hb=3e5fc3eb04d048d7b30c857e12107799beb39c31;hpb=4c034f8d2e17a35b8f94408996a0bd1de4a2533a diff --git a/command_util.sh b/command_util.sh index 0e67af1a..5119f58b 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,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" + 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\"" + ;; + SN:) + section_name="$value" + 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() { @@ -88,39 +129,29 @@ ${line# }" dump_man() { - echo "NAME" - printf "\t$name_txt - $desc_txt\n" - echo "SYNOPSIS" - printf "\t$syn_txt\n" - echo "DESCRIPTION" + echo ".SS \"$name_txt\"" + echo "$desc_txt" + echo + echo "\\fBusage: \\fP$syn_txt" + echo echo "$help_txt" + echo if test -n "$perms_txt"; then - echo "PERMISSIONS" + echo -n "\\fBpermissions:\\fP " if test "$perms_txt" = "0"; then - printf "\t(none)\n" + echo "(none)" else - printf "\t$perms_txt\n" + echo "$perms_txt" fi fi - + echo } com_man() { - local cn="$(grep ^codename Makefile.in)" - local ver="$(grep ^AC_INIT configure.ac \ - | cut -f 2 -d ',')" - cn=${cn#*=} - ver=${ver# *[} - ver=${ver%]} - echo "r=paraslash-$ver (cn: $cn)" - local n - local txtdir=txt - local mandir=man/man1 - local htmldir=html - local pfx="$1" - mkdir -p $txtdir $mandir $htmldir || exit 1 + echo "[$section_name]" + echo while : ; do read_one_command if test $ret -lt 0; then @@ -129,17 +160,15 @@ com_man() if test $ret -eq 0; then break fi - n=$pfx-$name_txt - echo "pfx: $pfx, name: $n" - dump_man > $txtdir/$n.txt - txt2man -t "$n" -r "$r" < $txtdir/$n.txt \ - | sed -e 1d > $mandir/$n.1 - man2html $mandir/$n.1 > $htmldir/$n.html + dump_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 +179,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 "static int com_$name_txt(int, int, char **);" + echo "int com_$name_txt(int fd, int argc, char **argv);" else - echo "static 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 +224,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 $*