8 while read key value; do
15 array_name=${value%command_list}cmds
25 system_includes="$system_includes
35 #include \"$output_file.h\""
41 template_members="$value"
44 if test -z "$output_file"; then
45 echo "header error" 1&>2
63 while read key value; do
72 template_name="$value"
76 template_prototype="$value"
91 if test "$line" = "---"; then
102 if test $template -eq 0; then
103 if test -n "$name_txt" -a -n "$desc_txt" -a -n "$usage_txt" \
104 -a -n "$help_txt"; then
109 if test -n "$template_name" -a -n "$template_prototype" \
110 -a -n "$name_txt " -a -n "$template_members" \
111 -a -n "$desc_txt" -a -n "$usage_txt" \
112 -a -n "$help_txt"; then
117 if test -z "$name_txt" -a -z "$desc_txt" -a -z "$usage_txt" \
118 -a -z "$help_txt"; then
130 echo "O: $template_prototype"
135 if test $template -eq 0; then
136 echo ".SS \"$name_txt\""
139 echo "\\fBUsage: \\fP$usage_txt"
141 for member in $template_members; do
142 local sed_cmd="sed -e s/@member@/$member/g"
143 local t_name_txt=$(echo $name_txt | $sed_cmd)
144 echo ".SS \"$t_name_txt\""
146 echo "$desc_txt" | sed -e "s/@member@/{$(echo $template_members | sed -e 's/ / | /g')}/g"
148 echo "\\fBUsage: \\fP"
151 for member in $template_members; do
152 local sed_cmd="sed -e s/@member@/$member/g"
153 local t_usage_txt=$(echo $usage_txt | $sed_cmd)
154 printf "\t$t_usage_txt\n"
159 echo "$help_txt" | sed -e 's/^ //'
161 if test -n "$perms_txt"; then
162 echo -n "\\fBpermissions:\\fP "
163 if test "$perms_txt" = "0"; then
175 echo "[$section_name]"
179 if test $ret -lt 0; then
182 if test $ret -eq 0; then
191 local source_file match="" CR='
193 if test -n "$prototype"; then
194 result="$prototype$CR"
198 for source_file in $source_files; do
199 match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1')
200 if test -n "$match"; then
201 result="$result $match$CR"
215 .name = \"$name_txt\",
216 .handler = com_$name_txt,
218 if test -n "$perms_txt"; then
219 result="$result .perms = $perms_txt,"
222 .description = \"$desc_txt\",
223 .usage = \"$usage_txt\",
225 tmp="$(printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
227 result="$result $tmp },"
232 result=" {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\"
237 local t_name="$name_txt"
238 local t_perms="$perms_txt"
239 local t_desc="$desc_txt"
240 local t_usage="$usage_txt"
241 local t_help="$help_txt"
242 local t_source_files="$source_files"
244 for member in $template_members; do
245 local sed_cmd="sed -e s/@member@/$member/g"
246 #echo "sed_cmd: $sed_cmd"
247 name_txt=$(echo "$t_name" | $sed_cmd)
249 perms_txt=$(echo "$t_perms" | $sed_cmd)
250 desc_txt=$(echo "$t_desc" | $sed_cmd)
251 usage_txt=$(echo "$t_usage" | $sed_cmd)
252 help_txt=$(printf "%s\n" "$t_help" | $sed_cmd)
253 prototype=$(echo "$template_prototype" | $sed_cmd)
263 echo "$system_includes"
265 echo "struct $array_type $array_name[] = {"
268 if test $ret -lt 0; then
271 if test $ret -eq 0; then
274 if test $template -eq 0; then
279 template_loop make_array_member
281 echo '{.name = NULL}};'
286 echo "extern struct $array_type $array_name[];"
289 if test $ret -lt 0; then
292 if test $ret -eq 0; then
295 if test $template -eq 0; then
300 template_loop make_proto
310 if test $ret -lt 0; then
313 if test $ret -eq 0; then
316 if test $template -eq 0; then
321 template_loop make_completion