*/
#include "cli.h"
-#include "common.h"
-
-#include <string.h>
+#include "command.h"
#include <ctype.h>
-#include <stdlib.h>
-#include <stdio.h>
#include "config.h"
-#include "command.h"
-#include "xmalloc.h"
#include "debug.h"
#include "env.h"
#include "cli_readline.h"
outp = output;
} else {
int outputlen = outp - output;
- outp = xrealloc(output, outputlen);
+ outp = realloc(output, outputlen);
+ if (outp == NULL) {
+ free(output);
+ output = outp;
+ break;
+ }
output = outp;
}
* @returns
*
*/
-static int cli_run_command(const char *cmd, int flag)
+static int cli_run_command(const char *cmd, uint_fast8_t flag)
{
char *cmdbuf; /* working copy of cmd */
char *token; /* start of token in cmdbuf */
/* find macros in this token and replace them */
finaltoken = process_macros(token, finaltoken);
+ if (finaltoken == NULL) {
+ rc = -1; /* no command at all */
+ break;
+ }
/* Extract arguments */
argc = cli_parse_line(finaltoken, argv);
* @param flag Execution flags (CMD_FLAG_...)
* @return 0 on success, or != 0 on error.
*/
-int run_command(const char *cmd, int flag)
+int run_command(const char *cmd, uint_fast8_t flag)
{
/*
* cli_run_command can return 0 or 1 for success, so clean up
* @param flag Execution flags (CMD_FLAG_...)
* @return 0 (not repeatable) or 1 (repeatable) on success, -1 on error.
*/
-static int run_command_repeatable(const char *cmd, int flag)
+static int run_command_repeatable(const char *cmd, uint_fast8_t flag)
{
return cli_run_command(cmd, flag);
}
{
char *lastcommand = NULL;
int len;
- int flag;
+ uint_fast8_t flag;
int rc = 1;
for (;;) {