command_handler: change 'args' to CMD_ARGV
This patch converts all instances of 'args' in COMMAND_HANDLER routines to use CMD_ARGV macro.
This commit is contained in:
@@ -142,7 +142,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
|
||||
log_add_callback(tcl_output, tclOutput);
|
||||
|
||||
// turn words[0] into args[-1] with this cast
|
||||
// turn words[0] into CMD_ARGV[-1] with this cast
|
||||
retval = run_command(context, c, (const char **)words + 1, nwords);
|
||||
|
||||
log_remove_callback(tcl_output, tclOutput);
|
||||
@@ -725,7 +725,7 @@ COMMAND_HANDLER(handle_sleep_command)
|
||||
bool busy = false;
|
||||
if (CMD_ARGC == 2)
|
||||
{
|
||||
if (strcmp(args[1], "busy") == 0)
|
||||
if (strcmp(CMD_ARGV[1], "busy") == 0)
|
||||
busy = true;
|
||||
else
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
@@ -734,7 +734,7 @@ COMMAND_HANDLER(handle_sleep_command)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
unsigned long duration = 0;
|
||||
int retval = parse_ulong(args[0], &duration);
|
||||
int retval = parse_ulong(CMD_ARGV[0], &duration);
|
||||
if (ERROR_OK != retval)
|
||||
return retval;
|
||||
|
||||
@@ -758,7 +758,7 @@ COMMAND_HANDLER(handle_fast_command)
|
||||
if (CMD_ARGC != 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
fast_and_dangerous = strcmp("enable", args[0]) == 0;
|
||||
fast_and_dangerous = strcmp("enable", CMD_ARGV[0]) == 0;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ COMMAND_HANDLER(handle_rm_command)
|
||||
return ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
if (unlink(args[0]) != 0)
|
||||
if (unlink(CMD_ARGV[0]) != 0)
|
||||
{
|
||||
command_print(cmd_ctx, "failed: %d", errno);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ COMMAND_HANDLER(handle_cat_command)
|
||||
void *data;
|
||||
size_t len;
|
||||
|
||||
int retval = loadFile(args[0], &data, &len);
|
||||
int retval = loadFile(CMD_ARGV[0], &data, &len);
|
||||
if (retval == ERROR_OK)
|
||||
{
|
||||
command_print(cmd_ctx, "%s", (char *)data);
|
||||
@@ -153,7 +153,7 @@ COMMAND_HANDLER(handle_cat_command)
|
||||
}
|
||||
else
|
||||
{
|
||||
command_print(cmd_ctx, "%s not found %d", args[0], retval);
|
||||
command_print(cmd_ctx, "%s not found %d", CMD_ARGV[0], retval);
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -168,7 +168,7 @@ COMMAND_HANDLER(handle_trunc_command)
|
||||
}
|
||||
|
||||
FILE *config_file = NULL;
|
||||
config_file = fopen(args[0], "w");
|
||||
config_file = fopen(CMD_ARGV[0], "w");
|
||||
if (config_file != NULL)
|
||||
fclose(config_file);
|
||||
|
||||
@@ -211,7 +211,7 @@ COMMAND_HANDLER(handle_append_command)
|
||||
|
||||
int retval = ERROR_FAIL;
|
||||
FILE *config_file = NULL;
|
||||
config_file = fopen(args[0], "a");
|
||||
config_file = fopen(CMD_ARGV[0], "a");
|
||||
if (config_file != NULL)
|
||||
{
|
||||
fseek(config_file, 0, SEEK_END);
|
||||
@@ -219,7 +219,7 @@ COMMAND_HANDLER(handle_append_command)
|
||||
unsigned i;
|
||||
for (i = 1; i < CMD_ARGC; i++)
|
||||
{
|
||||
if (fwrite(args[i], 1, strlen(args[i]), config_file) != strlen(args[i]))
|
||||
if (fwrite(CMD_ARGV[i], 1, strlen(CMD_ARGV[i]), config_file) != strlen(CMD_ARGV[i]))
|
||||
break;
|
||||
if (i != CMD_ARGC - 1)
|
||||
{
|
||||
@@ -250,11 +250,11 @@ COMMAND_HANDLER(handle_cp_command)
|
||||
void *data;
|
||||
size_t len;
|
||||
|
||||
int retval = loadFile(args[0], &data, &len);
|
||||
int retval = loadFile(CMD_ARGV[0], &data, &len);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
FILE *f = fopen(args[1], "wb");
|
||||
FILE *f = fopen(CMD_ARGV[1], "wb");
|
||||
if (f == NULL)
|
||||
retval = ERROR_INVALID_ARGUMENTS;
|
||||
|
||||
@@ -286,7 +286,7 @@ COMMAND_HANDLER(handle_cp_command)
|
||||
|
||||
if (retval == ERROR_OK)
|
||||
{
|
||||
command_print(cmd_ctx, "Copied %s to %s", args[0], args[1]);
|
||||
command_print(cmd_ctx, "Copied %s to %s", CMD_ARGV[0], CMD_ARGV[1]);
|
||||
} else
|
||||
{
|
||||
command_print(cmd_ctx, "Failed: %d", retval);
|
||||
@@ -298,7 +298,7 @@ COMMAND_HANDLER(handle_cp_command)
|
||||
fclose(f);
|
||||
|
||||
if (retval != ERROR_OK)
|
||||
unlink(args[1]);
|
||||
unlink(CMD_ARGV[1]);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ COMMAND_HANDLER(handle_debug_level_command)
|
||||
if (CMD_ARGC == 1)
|
||||
{
|
||||
unsigned new_level;
|
||||
COMMAND_PARSE_NUMBER(uint, args[0], new_level);
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], new_level);
|
||||
debug_level = MIN(new_level, LOG_LVL_DEBUG);
|
||||
}
|
||||
else if (CMD_ARGC > 1)
|
||||
@@ -305,7 +305,7 @@ COMMAND_HANDLER(handle_log_output_command)
|
||||
{
|
||||
if (CMD_ARGC == 1)
|
||||
{
|
||||
FILE* file = fopen(args[0], "w");
|
||||
FILE* file = fopen(CMD_ARGV[0], "w");
|
||||
|
||||
if (file)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user