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_func_t)(FILE *fp, FILE *fp_err, 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);
int fr_command_walk(fr_cmd_t *head, void **walk_ctx, void *ctx, fr_cmd_walk_t callback);
int fr_command_tab_expand(TALLOC_CTX *ctx, fr_cmd_t *head, fr_cmd_info_t *info, int max_expansions, char const **expansions);
char const *fr_command_help(fr_cmd_t *head, int argc, char *argv[]);
-int fr_command_run(FILE *fp, fr_cmd_t *head, fr_cmd_info_t *info);
+int fr_command_run(FILE *fp, FILE *fp_err, fr_cmd_t *head, fr_cmd_info_t *info);
void fr_command_debug(FILE *fp, fr_cmd_t *head);
int fr_command_str_to_argv(fr_cmd_t *head, fr_cmd_info_t *info, char *str);
/** Run a particular command
*
* @param fp where the output is sent
+ * @param fp_err where the error output is sent
* @param head the head of the command hierarchy.
* @param info the structure describing the command to expand
* @return
* - <0 on error
* - 0 the command was run successfully
*/
-int fr_command_run(FILE *fp, fr_cmd_t *head, fr_cmd_info_t *info)
+int fr_command_run(FILE *fp, FILE *fp_err, fr_cmd_t *head, fr_cmd_info_t *info)
{
int i;
fr_cmd_t *cmd, *start;
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);
+ rcode = cmd->func(fp, fp_err, 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, fr_cmd_info_t const *info);
+static int cmd_help(FILE *fp, FILE *fp_err, 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, &info);
+ cmd_help(stdout, stderr, NULL, &info);
goto next;
}
*/
add_history(line);
- if (fr_command_run(stdout, radmin_cmd, &info) < 0) {
+ if (fr_command_run(stdout, stderr, radmin_cmd, &info) < 0) {
fprintf(stderr, "Failing running command: %s\n", fr_strerror());
}
*/
static struct timeval start_time;
-static int cmd_exit(UNUSED FILE *fp, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
+static int cmd_exit(UNUSED FILE *fp, UNUSED FILE *fp_err, 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, fr_cmd_info_t const *info)
+static int cmd_help(FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, fr_cmd_info_t const *info)
{
char const *help;
return 0;
}
-static int cmd_uptime(FILE *fp, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
+static int cmd_uptime(FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
{
struct timeval now;
return 0;
}
-static int cmd_test(FILE *fp, UNUSED void *ctx, fr_cmd_info_t const *info)
+static int cmd_test(FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, fr_cmd_info_t const *info)
{
fprintf(fp, "woo! %s %s\n", info->argv[0], info->argv[2]);
return 0;
static fr_cmd_t *command_head = NULL;
-static int command_func(UNUSED FILE *fp, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
+static int command_func(UNUSED FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
{
return 0;
}