- 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
+}
+
+make_proto()
+{
+ local regex='\(__noreturn \)*\(static \)*int com_'
+ local source_file match="" all_commands CR='
+'
+ if test -n "$prototype"; then
+ result="$prototype$CR"
+ return
+ fi
+ all_commands="$(cat $source_files | grep "$regex")"
+ result=
+ for source_file in $source_files; do
+ match=$(grep "$regex$name_txt(" <<< "$all_commands" | head -n 1 | sed -e 's/$/;/1')
+ if test -n "$match"; then
+ result="$result$match$CR"
+ break
+ fi
+ done
+}
+
+make_array_member()
+{
+ local TAB=' ' CR='
+'
+ local tmp
+
+ result="{.name = \"$name_txt\", .handler = com_$name_txt, "
+ if test -n "$perms_txt"; then
+ result="$result .perms = $perms_txt,"
+ fi
+ result="$result.description = \"$desc_txt\", .usage = \"$usage_txt\", \\$CR .help = "
+ tmp="$(printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
+ -e "s/$TAB/\\\t/g" -e's/$/\\/g')"
+ result="$result$tmp$CR}, \\$CR"
+}
+
+make_completion()
+{
+ local CR='
+'
+ result=" {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\$CR"
+}
+
+template_loop()
+{
+ local loop_result=
+
+ local t_name="$name_txt"
+ local t_perms="$perms_txt"
+ local t_desc="$desc_txt"
+ local t_usage="$usage_txt"
+ local t_help="$help_txt"
+ local t_source_files="$source_files"
+ local member
+ for member in $template_members; do
+ name_txt="${t_name//@member@/$member}"
+ perms_txt="${t_perms//@member@/$member}"
+ desc_txt="${t_desc//@member@/$member}"
+ usage_txt="${t_usage//@member@/$member}"
+ help_txt="${t_help//@member@/$member}"
+ prototype="${template_prototype//@member@/$member}"
+ result=
+ $1
+ loop_result="$loop_result$result"