8 while read key value; do
14 header_comment="$value"
17 c_file_comment="$value"
21 array_name=${value%command_list}cmds
31 system_includes="$system_includes
41 #include \"$output_file.h\""
47 template_members="$value"
50 if test -z "$header_comment" -o -z "$c_file_comment" \
51 -o -z "$output_file"; then
52 echo "header error" 1&>2
71 while read key value; do
80 template_name="$value"
84 template_prototype="$value"
102 if test "$line" = "---"; then
113 if test $template -eq 0; then
114 if test -n "$name_txt" -a -n "$desc_txt" -a -n "$usage_txt" \
115 -a -n "$help_txt"; then
120 if test -n "$template_name" -a -n "$template_prototype" \
121 -a -n "$name_txt " -a -n "$template_members" \
122 -a -n "$desc_txt" -a -n "$usage_txt" \
123 -a -n "$help_txt"; then
128 if test -z "$name_txt" -a -z "$desc_txt" -a -z "$usage_txt" \
129 -a -z "$help_txt"; then
141 echo "O: $template_prototype"
146 if test $template -eq 0; then
147 echo ".SS \"$name_txt\""
150 echo "\\fBUsage: \\fP$usage_txt"
152 for member in $template_members; do
153 local sed_cmd="sed -e s/@member@/$member/g"
154 local t_name_txt=$(echo $name_txt | $sed_cmd)
155 echo ".SS \"$t_name_txt\""
157 echo "$desc_txt" | sed -e "s/@member@/{$(echo $template_members | sed -e 's/ / | /g')}/g"
159 echo "\\fBUsage: \\fP"
162 for member in $template_members; do
163 local sed_cmd="sed -e s/@member@/$member/g"
164 local t_usage_txt=$(echo $usage_txt | $sed_cmd)
165 printf "\t$t_usage_txt\n"
170 echo "$help_txt" | sed -e 's/^ //'
172 if test -n "$perms_txt"; then
173 echo -n "\\fBpermissions:\\fP "
174 if test "$perms_txt" = "0"; then
186 echo "[$section_name]"
190 if test $ret -lt 0; then
193 if test $ret -eq 0; then
202 local source_file match=""
207 echo ' * \param fd The file descriptor to send output to.'
208 if test $line_handler -eq 0; then
209 echo ' * \param argc The number of arguments.'
210 echo ' * \param argv The argument vector.'
212 echo ' * \param cmdline The full command line.'
215 echo " * Usage: $usage_txt"
217 echo "$help_txt" | sed -e 's/^/ * /g'
219 if test -n "$prototype"; then
224 for source_file in $source_files; do
225 match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1')
226 if test -n "$match"; then
237 echo ".name = \"$name_txt\","
238 if test $line_handler -eq 0; then
239 echo ".handler = com_$name_txt,"
241 echo ".handler = NULL,"
242 echo ".line_handler = com_$name_txt,"
244 if test -n "$perms_txt"; then
245 echo ".perms = $perms_txt,"
247 echo ".description = \"$desc_txt\","
248 echo ".usage = \"$usage_txt\","
250 printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g'
257 local t_name="$name_txt"
258 local t_perms="$perms_txt"
259 local t_desc="$desc_txt"
260 local t_usage="$usage_txt"
261 local t_help="$help_txt"
262 local t_source_files="$source_files"
264 for member in $template_members; do
265 local sed_cmd="sed -e s/@member@/$member/g"
266 #echo "sed_cmd: $sed_cmd"
267 name_txt=$(echo $t_name | $sed_cmd)
269 perms_txt=$(echo $t_perms | $sed_cmd)
270 desc_txt=$(echo $t_desc | $sed_cmd)
271 usage_txt=$(echo $t_usage | $sed_cmd)
272 help_txt=$(printf "%s\n" "$t_help" | $sed_cmd)
273 prototype=$(echo "$template_prototype" | $sed_cmd)
281 echo "/** \file $output_file.c $c_file_comment */"
282 echo "$system_includes"
284 echo "struct $array_type $array_name[] = {"
287 if test $ret -lt 0; then
290 if test $ret -eq 0; then
293 if test $template -eq 0; then
297 template_loop dump_array_member
299 echo '{.name = NULL}};'
304 echo "/** \file $output_file.h $header_comment */"
306 echo "extern struct $array_type $array_name[];"
309 if test $ret -lt 0; then
312 if test $ret -eq 0; then
315 if test $template -eq 0; then
319 template_loop dump_proto