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
70 while read key value; do
79 template_name="$value"
83 template_prototype="$value"
98 if test "$line" = "---"; then
109 if test $template -eq 0; then
110 if test -n "$name_txt" -a -n "$desc_txt" -a -n "$usage_txt" \
111 -a -n "$help_txt"; then
116 if test -n "$template_name" -a -n "$template_prototype" \
117 -a -n "$name_txt " -a -n "$template_members" \
118 -a -n "$desc_txt" -a -n "$usage_txt" \
119 -a -n "$help_txt"; then
124 if test -z "$name_txt" -a -z "$desc_txt" -a -z "$usage_txt" \
125 -a -z "$help_txt"; then
137 echo "O: $template_prototype"
142 if test $template -eq 0; then
143 echo ".SS \"$name_txt\""
146 echo "\\fBUsage: \\fP$usage_txt"
148 for member in $template_members; do
149 local sed_cmd="sed -e s/@member@/$member/g"
150 local t_name_txt=$(echo $name_txt | $sed_cmd)
151 echo ".SS \"$t_name_txt\""
153 echo "$desc_txt" | sed -e "s/@member@/{$(echo $template_members | sed -e 's/ / | /g')}/g"
155 echo "\\fBUsage: \\fP"
158 for member in $template_members; do
159 local sed_cmd="sed -e s/@member@/$member/g"
160 local t_usage_txt=$(echo $usage_txt | $sed_cmd)
161 printf "\t$t_usage_txt\n"
166 echo "$help_txt" | sed -e 's/^ //'
168 if test -n "$perms_txt"; then
169 echo -n "\\fBpermissions:\\fP "
170 if test "$perms_txt" = "0"; then
182 echo "[$section_name]"
186 if test $ret -lt 0; then
189 if test $ret -eq 0; then
198 local source_file match=""
203 echo " * Usage: $usage_txt"
205 echo "$help_txt" | sed -e 's/^/ * /g'
207 if test -n "$prototype"; then
212 for source_file in $source_files; do
213 match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1')
214 if test -n "$match"; then
226 echo ".name = \"$name_txt\","
227 echo ".handler = com_$name_txt,"
228 if test -n "$perms_txt"; then
229 echo ".perms = $perms_txt,"
231 echo ".description = \"$desc_txt\","
232 echo ".usage = \"$usage_txt\","
234 printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
242 local t_name="$name_txt"
243 local t_perms="$perms_txt"
244 local t_desc="$desc_txt"
245 local t_usage="$usage_txt"
246 local t_help="$help_txt"
247 local t_source_files="$source_files"
249 for member in $template_members; do
250 local sed_cmd="sed -e s/@member@/$member/g"
251 #echo "sed_cmd: $sed_cmd"
252 name_txt=$(echo $t_name | $sed_cmd)
254 perms_txt=$(echo $t_perms | $sed_cmd)
255 desc_txt=$(echo $t_desc | $sed_cmd)
256 usage_txt=$(echo $t_usage | $sed_cmd)
257 help_txt=$(printf "%s\n" "$t_help" | $sed_cmd)
258 prototype=$(echo "$template_prototype" | $sed_cmd)
266 echo "/** \file $output_file.c $c_file_comment */"
267 echo "$system_includes"
269 echo "struct $array_type $array_name[] = {"
272 if test $ret -lt 0; then
275 if test $ret -eq 0; then
278 if test $template -eq 0; then
282 template_loop dump_array_member
284 echo '{.name = NULL}};'
289 echo "/** \file $output_file.h $header_comment */"
291 echo "extern struct $array_type $array_name[];"
294 if test $ret -lt 0; then
297 if test $ret -eq 0; then
300 if test $template -eq 0; then
304 template_loop dump_proto