8 while read key value; do
14 header_comment="$value"
17 c_file_comment="$value"
21 array_name=${value%command_list}cmds
35 #include \"$output_file.h\""
41 template_members="$value"
44 if test -z "$header_comment" -o -z "$c_file_comment" \
45 -o -z "$output_file"; then
46 echo "header error" 1&>2
65 while read key value; do
74 template_name="$value"
78 template_prototype="$value"
96 if test "$line" = "---"; then
107 if test $template -eq 0; then
108 if test -n "$name_txt" -a -n "$desc_txt" -a -n "$usage_txt" \
109 -a -n "$help_txt"; then
114 if test -n "$template_name" -a -n "$template_prototype" \
115 -a -n "$name_txt " -a -n "$template_members" \
116 -a -n "$desc_txt" -a -n "$usage_txt" \
117 -a -n "$help_txt"; then
122 if test -z "$name_txt" -a -z "$desc_txt" -a -z "$usage_txt" \
123 -a -z "$help_txt"; then
135 echo "O: $template_prototype"
140 echo ".SS \"$name_txt\""
143 echo "\\fBusage: \\fP$usage_txt"
147 if test -n "$perms_txt"; then
148 echo -n "\\fBpermissions:\\fP "
149 if test "$perms_txt" = "0"; then
161 echo "[$section_name]"
165 if test $ret -lt 0; then
168 if test $ret -eq 0; then
177 local source_file match=""
182 echo ' * \param fd The file descriptor to send output to.'
183 if test $line_handler -eq 0; then
184 echo ' * \param argc The number of arguments.'
185 echo ' * \param argv The argument vector.'
187 echo ' * \param cmdline The full command line.'
190 echo " * Usage: $usage_txt"
192 echo "$help_txt" | sed -e 's/^/ * /g'
194 if test -n "$prototype"; then
199 for source_file in $source_files; do
200 match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1')
201 if test -n "$match"; then
212 echo ".name = \"$name_txt\","
213 if test $line_handler -eq 0; then
214 echo ".handler = com_$name_txt,"
216 echo ".handler = NULL,"
217 echo ".line_handler = com_$name_txt,"
219 if test -n "$perms_txt"; then
220 echo ".perms = $perms_txt,"
222 echo ".description = \"$desc_txt\","
223 echo ".usage = \"$usage_txt\","
225 echo "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g'
232 local t_name="$name_txt"
233 local t_perms="$perms_txt"
234 local t_desc="$desc_txt"
235 local t_usage="$usage_txt"
236 local t_help="$help_txt"
237 local t_source_files="$source_files"
239 for member in $template_members; do
240 local sed_cmd="sed -e s/@member@/$member/g"
241 #echo "sed_cmd: $sed_cmd"
242 name_txt=$(echo $t_name | $sed_cmd)
244 perms_txt=$(echo $t_perms | $sed_cmd)
245 desc_txt=$(echo $t_desc | $sed_cmd)
246 usage_txt=$(echo $t_usage | $sed_cmd)
247 help_txt=$(echo $t_help | $sed_cmd)
248 prototype=$(echo "$template_prototype" | $sed_cmd)
256 echo "/** \file $output_file.c $c_file_comment */"
258 echo "struct $array_type $array_name[] = {"
261 if test $ret -lt 0; then
264 if test $ret -eq 0; then
267 if test $template -eq 0; then
271 template_loop dump_array_member
273 echo '{.name = NULL}};'
278 echo "/** \file $output_file.h $header_comment */"
280 echo "extern struct $array_type $array_name[];"
283 if test $ret -lt 0; then
286 if test $ret -eq 0; then
289 if test $template -eq 0; then
293 template_loop dump_proto