X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command_util.sh;h=f388b2cfb152db7cf34e0b2f84313ba26a209903;hp=a71bb6518f9194c999298e114b25636086d19ba8;hb=672e27768e31a6eaa6854d4fc75ee6885db9abd8;hpb=02691a995a6ee0fe4d9078f1d82465edd4814f74 diff --git a/command_util.sh b/command_util.sh index a71bb651..f388b2cf 100755 --- a/command_util.sh +++ b/command_util.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash read_header() @@ -26,6 +26,12 @@ read_header() AT:) array_type="$value" ;; + SI:) + for i in $value; do + system_includes="$system_includes +#include <$i.h>" + done + ;; IN:) for i in $value; do includes="$includes @@ -57,7 +63,6 @@ read_one_command() usage_txt="" help_txt="" perms_txt="" - line_handler=0 template=0 template_name="" template_prototype="" @@ -84,9 +89,6 @@ read_one_command() D:) desc_txt="$value" ;; - L:) - line_handler=1 - ;; U:) usage_txt="$value" ;; @@ -137,12 +139,31 @@ ${line# }" dump_man() { - echo ".SS \"$name_txt\"" - echo "$desc_txt" - echo - echo "\\fBusage: \\fP$usage_txt" + if test $template -eq 0; then + echo ".SS \"$name_txt\"" + echo "$desc_txt" + echo + echo "\\fBUsage: \\fP$usage_txt" + else + for member in $template_members; do + local sed_cmd="sed -e s/@member@/$member/g" + local t_name_txt=$(echo $name_txt | $sed_cmd) + echo ".SS \"$t_name_txt\"" + done + echo "$desc_txt" | sed -e "s/@member@/{$(echo $template_members | sed -e 's/ / | /g')}/g" + echo + echo "\\fBUsage: \\fP" + echo + echo ".nf" + for member in $template_members; do + local sed_cmd="sed -e s/@member@/$member/g" + local t_usage_txt=$(echo $usage_txt | $sed_cmd) + printf "\t$t_usage_txt\n" + done + echo ".fi" + fi echo - echo "$help_txt" + echo "$help_txt" | sed -e 's/^ //' echo if test -n "$perms_txt"; then echo -n "\\fBpermissions:\\fP " @@ -179,13 +200,13 @@ 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.' + if [[ "$system_includes" =~ openssl/rc4.h ]]; then + echo ' * \param rc4c The rc4 crypt context.' else - echo ' * \param cmdline The full command line.' + echo ' * \param fd The file descriptor to send output to.' fi + echo ' * \param argc The number of arguments.' + echo ' * \param argv The argument vector.' echo ' * ' echo " * Usage: $usage_txt" echo ' * ' @@ -210,19 +231,14 @@ dump_array_member() { echo '{' echo ".name = \"$name_txt\"," - if test $line_handler -eq 0; then - echo ".handler = com_$name_txt," - else - echo ".handler = NULL," - echo ".line_handler = com_$name_txt," - fi + echo ".handler = com_$name_txt," if test -n "$perms_txt"; then echo ".perms = $perms_txt," fi echo ".description = \"$desc_txt\"," echo ".usage = \"$usage_txt\"," echo ".help = " - echo "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' + printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' echo '},' } @@ -244,7 +260,7 @@ template_loop() perms_txt=$(echo $t_perms | $sed_cmd) desc_txt=$(echo $t_desc | $sed_cmd) usage_txt=$(echo $t_usage | $sed_cmd) - help_txt=$(echo $t_help | $sed_cmd) + help_txt=$(printf "%s\n" "$t_help" | $sed_cmd) prototype=$(echo "$template_prototype" | $sed_cmd) $1 done @@ -254,6 +270,7 @@ template_loop() com_c_file() { echo "/** \file $output_file.c $c_file_comment */" + echo "$system_includes" echo "$includes" echo "struct $array_type $array_name[] = {" while : ; do