typedef struct fr_cmd_t fr_cmd_t;
-typedef int (*fr_cmd_func_t)(FILE *fp, void *ctx, int argc, char *argv[]);
-
typedef struct fr_cmd_info_t {
int argc; //!< current argument count
int max_argc; //!< maximum number of arguments
fr_value_box_t **box; //!< value_box version of commands.
} fr_cmd_info_t;
+typedef int (*fr_cmd_func_t)(FILE *fp, void *ctx, fr_cmd_info_t const *info);
+
typedef int (*fr_cmd_tab_t)(TALLOC_CTX *talloc_ctx, void *ctx, fr_cmd_info_t *info, int max_expansions, char const **expansions);
typedef struct fr_cmd_table_t {
for (i = 0; i < info->argc; i++) {
int rcode;
+ fr_cmd_info_t my_info;
cmd = fr_command_find(&start, info->argv[i], NULL);
if (!cmd) {
* fr_command_str_to_argv().
*/
run:
- rcode = cmd->func(fp, cmd->ctx, info->argc - i - 1, &info->argv[i + 1]);
+ my_info.argc = info->argc - i - 1;
+ my_info.max_argc = info->max_argc - info->argc;
+ my_info.runnable = true;
+ my_info.argv = &info->argv[i + 1];
+ my_info.box = &info->box[i + 1];
+ rcode = cmd->func(fp, cmd->ctx, &my_info);
// @todo - clean up value boxes, too!
info->argc = 0;
#define CMD_MAX_ARGV (32)
-static int cmd_help(FILE *fp, UNUSED void *ctx, int argc, char *argv[]);
+static int cmd_help(FILE *fp, UNUSED void *ctx, fr_cmd_info_t const *info);
static void *fr_radmin(UNUSED void *input_ctx)
{
* It's just polite.
*/
if (strcmp(line, "help") == 0) {
- cmd_help(stdout, NULL, context, info.argv);
+ cmd_help(stdout, NULL, &info);
goto next;
}
*/
static struct timeval start_time;
-static int cmd_exit(UNUSED FILE *fp, UNUSED void *ctx, UNUSED int argc, UNUSED char *argv[])
+static int cmd_exit(UNUSED FILE *fp, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
{
radius_signal_self(RADIUS_SIGNAL_SELF_TERM);
stop = true;
return 0;
}
-static int cmd_help(FILE *fp, UNUSED void *ctx, int argc, char *argv[])
+static int cmd_help(FILE *fp, UNUSED void *ctx, fr_cmd_info_t const *info)
{
char const *help;
- if (argc == 0) {
+ if (info->argc == 0) {
fr_command_debug(fp, radmin_cmd);
return 0;
}
- help = fr_command_help(radmin_cmd, argc, argv);
+ help = fr_command_help(radmin_cmd, info->argc, info->argv);
if (help) {
fprintf(fp, "%s\n", help);
return 0;
return 0;
}
-static int cmd_uptime(FILE *fp, UNUSED void *ctx, UNUSED int argc, UNUSED char *argv[])
+static int cmd_uptime(FILE *fp, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
{
struct timeval now;
return 0;
}
-static int cmd_test(FILE *fp, UNUSED void *ctx, UNUSED int argc, char *argv[])
+static int cmd_test(FILE *fp, UNUSED void *ctx, fr_cmd_info_t const *info)
{
- fprintf(fp, "woo! %s %s\n", argv[0], argv[2]);
+ fprintf(fp, "woo! %s %s\n", info->argv[0], info->argv[2]);
return 0;
}