extern struct sched sched;
extern char *stat_item_values[NUM_STAT_ITEMS];
+typedef int audiod_command_handler_t(int, int, char **);
+static audiod_command_handler_t AUDIOD_COMMAND_HANDLERS;
+
/* Defines one command of para_audiod. */
struct audiod_command {
const char *name;
/* Pointer to the function that handles the command. */
- int (*handler)(int, int, char **);
+ audiod_command_handler_t *handler;
/* One-line description. */
const char *description;
/* Summary of the command line options. */
#include "signal.h"
#include "version.h"
+typedef int server_command_handler_t(struct command_context *);
+static server_command_handler_t SERVER_COMMAND_HANDLERS;
+server_command_handler_t AFS_COMMAND_HANDLERS;
+
/* Defines one command of para_server. */
struct server_command {
/* The name of the command. */
const char *name;
/* Pointer to the function that handles the command. */
- int (*handler)(struct command_context *);
+ server_command_handler_t *handler;
/* The privileges a user must have to execute this command. */
unsigned int perms;
/* One-line description of the command. */
done
}
-make_proto()
+cmd_handler_name()
{
- local regex='\(__noreturn \)*\(static \)*int com_'
- local source_file match="" all_commands CR='
-'
- if test -n "$prototype"; then
- result="$prototype$CR"
- return
- fi
- all_commands="$(cat $source_files | grep "$regex")"
- result=
- for source_file in $source_files; do
- match=$(grep "$regex$name_txt(" <<< "$all_commands" | head -n 1 | sed -e 's/$/;/1')
- if test -n "$match"; then
- result="$result$match$CR"
- break
- fi
- done
+ result="com_$name_txt,"
}
make_array_member()
com_header()
{
- local array_members CR='
+ local array_members handlers= CR='
'
while : ; do
break
fi
if test $template -eq 0; then
- make_proto
- printf "%s" "$result"
+ cmd_handler_name
+ handlers+="$result"
make_array_member
array_members="$array_members$result"
continue
fi
- template_loop make_proto
- printf "%s" "$result"
+ template_loop cmd_handler_name
+ handlers+="$result"
template_loop make_array_member
array_members="$array_members$result"
done
array_members="$array_members{.name = NULL} \\$CR"
- echo "#define DEFINE_$(tr 'a-z' 'A-Z' <<< "$base_name")_CMD_ARRAY $array_members"
+ echo "#define DEFINE_${base_name^^}_CMD_ARRAY $array_members"
+ echo "#define ${base_name^^}_COMMAND_HANDLERS ${handlers%,}"
}
com_completion()
return result;
}
+#include "play.command_list.h"
+
+typedef int play_command_handler_t(struct play_task *, int, char**);
+static play_command_handler_t PLAY_COMMAND_HANDLERS;
+
/* defines one command of para_play */
struct pp_command {
const char *name;
- int (*handler)(struct play_task *, int, char**);
+ play_command_handler_t *handler;
const char *description;
const char *usage;
const char *help;
};
-#include "play.command_list.h"
static struct pp_command pp_cmds[] = {DEFINE_PLAY_CMD_ARRAY};
#define FOR_EACH_COMMAND(c) for (c = 0; pp_cmds[c].name; c++)