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
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()
{
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
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
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 $*