7 while read key value; do
22 template_members="$value"
40 while read key value; do
49 template_name="$value"
53 template_prototype="$value"
68 if test "$line" = "---"; then
79 if test $template -eq 0; then
80 if test -n "$name_txt" -a -n "$desc_txt" -a -n "$usage_txt" \
81 -a -n "$help_txt"; then
86 if test -n "$template_name" -a -n "$template_prototype" \
87 -a -n "$name_txt " -a -n "$template_members" \
88 -a -n "$desc_txt" -a -n "$usage_txt" \
89 -a -n "$help_txt"; then
94 if test -z "$name_txt" -a -z "$desc_txt" -a -z "$usage_txt" \
95 -a -z "$help_txt"; then
107 echo "O: $template_prototype"
112 if test $template -eq 0; then
113 echo ".SS \"$name_txt\""
116 echo "\\fBUsage: \\fP$usage_txt"
118 for member in $template_members; do
119 local sed_cmd="sed -e s/@member@/$member/g"
120 local t_name_txt=$(echo $name_txt | $sed_cmd)
121 echo ".SS \"$t_name_txt\""
123 echo "$desc_txt" | sed -e "s/@member@/{$(echo $template_members | sed -e 's/ / | /g')}/g"
125 echo "\\fBUsage: \\fP"
128 for member in $template_members; do
129 local sed_cmd="sed -e s/@member@/$member/g"
130 local t_usage_txt=$(echo $usage_txt | $sed_cmd)
131 printf "\t$t_usage_txt\n"
136 echo "$help_txt" | sed -e 's/^ //'
138 if test -n "$perms_txt"; then
139 echo -n "\\fBpermissions:\\fP "
140 if test "$perms_txt" = "0"; then
152 echo "[$section_name]"
156 if test $ret -lt 0; then
159 if test $ret -eq 0; then
168 local source_file match="" CR='
170 if test -n "$prototype"; then
171 result="$prototype$CR"
175 for source_file in $source_files; do
176 match=$(grep "^\(__noreturn \)*\(static \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1')
177 if test -n "$match"; then
178 result="$result$match$CR"
190 result="{.name = \"$name_txt\", .handler = com_$name_txt, "
191 if test -n "$perms_txt"; then
192 result="$result .perms = $perms_txt,"
194 result="$result.description = \"$desc_txt\", .usage = \"$usage_txt\", \\$CR .help = "
195 tmp="$(printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
196 -e "s/$TAB/\\\t/g" -e's/$/\\/g')"
197 result="$result$tmp$CR}, \\$CR"
204 result=" {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\$CR"
211 local t_name="$name_txt"
212 local t_perms="$perms_txt"
213 local t_desc="$desc_txt"
214 local t_usage="$usage_txt"
215 local t_help="$help_txt"
216 local t_source_files="$source_files"
218 for member in $template_members; do
219 local sed_cmd="sed -e s/@member@/$member/g"
220 #echo "sed_cmd: $sed_cmd"
221 name_txt=$(echo "$t_name" | $sed_cmd)
223 perms_txt=$(echo "$t_perms" | $sed_cmd)
224 desc_txt=$(echo "$t_desc" | $sed_cmd)
225 usage_txt=$(echo "$t_usage" | $sed_cmd)
226 help_txt=$(printf "%s\n" "$t_help" | $sed_cmd)
227 prototype=$(echo "$template_prototype" | $sed_cmd)
230 loop_result="$loop_result$result"
232 result="$loop_result"
233 # reset global variables
239 source_files="$t_source_files"
244 local array_members CR='
249 if test $ret -lt 0; then
252 if test $ret -eq 0; then
255 if test $template -eq 0; then
257 printf "%s" "$result"
259 array_members="$array_members$result"
262 template_loop make_proto
263 printf "%s" "$result"
264 template_loop make_array_member
265 array_members="$array_members$result"
267 array_members="$array_members{.name = NULL} \\$CR"
268 echo "#define DEFINE_$(tr 'a-z' 'A-Z' <<< "$base_name")_CMD_ARRAY $array_members"
277 if test $ret -lt 0; then
280 if test $ret -eq 0; then
283 if test $template -eq 0; then
285 printf "%s" "$result"
288 template_loop make_completion
289 printf "%s" "$result"