const char *t2="";
const char *t3="";
/* maximum of two levels :-) */
- if (c->parent!=NULL)
+ if (c->parent != NULL)
{
t1=c->parent->name;
t2="_";
Jim_Obj *cmd_list=Jim_NewListObj(interp, NULL, 0);
/* maximum of two levels :-) */
- if (c->parent!=NULL)
+ if (c->parent != NULL)
{
Jim_ListAppendElement(interp, cmd_list, Jim_NewStringObj(interp, c->parent->name, -1));
}
if (context == NULL)
return ERROR_OK;
- while(NULL != context->commands)
+ while (NULL != context->commands)
{
c = context->commands;
- while(NULL != c->children)
+ while (NULL != c->children)
{
c2 = c->children;
c->children = c->children->next;
/* find command */
c = context->commands;
- while(NULL != c)
+ while (NULL != c)
{
if (strcmp(name, c->name) == 0)
{
}
/* unregister children */
- while(NULL != c->children)
+ while (NULL != c->children)
{
c2 = c->children;
c->children = c->children->next;
void command_output_text(command_context_t *context, const char *data)
{
- if( context && context->output_handler && data ){
+ if ( context && context->output_handler && data ){
context->output_handler( context, data );
}
}
const char *t2="";
const char *t3="";
/* maximum of two levels :-) */
- if (c->parent!=NULL)
+ if (c->parent != NULL)
{
t1=c->parent->name;
t2=" ";
Jim_DeleteAssocData(interp, "context");
}
if (retcode == JIM_ERR) {
- if (retval!=ERROR_COMMAND_CLOSE_CONNECTION)
+ if (retval != ERROR_COMMAND_CLOSE_CONNECTION)
{
/* We do not print the connection closed error message */
Jim_PrintErrorMessage(interp);
va_list ap;
va_start(ap, format);
string = alloc_vprintf(format, ap);
- if (string!=NULL)
+ if (string != NULL)
{
retval=command_run_line(context, string);
}
int handle_fast_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- if (argc!=1)
+ if (argc != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
fast_and_dangerous = strcmp("enable", args[0])==0;
int parse##name(const char *str, type *ul) \
{ \
if (!*str) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
+ return ERROR_COMMAND_ARGUMENT_INVALID; \
char *end; \
*ul = func(str, &end, 0); \
if (*end) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
- if (*ul == max || (min && min == *ul)) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
+ return ERROR_COMMAND_ARGUMENT_INVALID; \
+ if ((max == *ul) && (ERANGE == errno)) \
+ return ERROR_COMMAND_ARGUMENT_OVERFLOW; \
+ if (min && (min == *ul) && (ERANGE == errno)) \
+ return ERROR_COMMAND_ARGUMENT_UNDERFLOW; \
return ERROR_OK; \
}
DEFINE_PARSE_NUM_TYPE(_ulong, unsigned long , strtoul, 0, ULONG_MAX)
DEFINE_PARSE_NUM_TYPE(_llong, long long, strtoll, LLONG_MIN, LLONG_MAX)
#define DEFINE_PARSE_WRAPPER(name, type, min, max, functype, funcname) \
- int parse_##name(const char *str, type *ul) \
+ int parse##name(const char *str, type *ul) \
{ \
functype n; \
int retval = parse##funcname(str, &n); \
if (ERROR_OK != retval) \
return retval; \
if (n > max) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
+ return ERROR_COMMAND_ARGUMENT_OVERFLOW; \
if (min) \
- return ERROR_COMMAND_SYNTAX_ERROR; \
+ return ERROR_COMMAND_ARGUMENT_UNDERFLOW; \
*ul = n; \
return ERROR_OK; \
}
#define DEFINE_PARSE_ULONG(name, type, min, max) \
DEFINE_PARSE_WRAPPER(name, type, min, max, unsigned long, _ulong)
-DEFINE_PARSE_ULONG(uint, unsigned, 0, UINT_MAX)
-DEFINE_PARSE_ULONG(u32, uint32_t, 0, UINT32_MAX)
-DEFINE_PARSE_ULONG(u16, uint16_t, 0, UINT16_MAX)
-DEFINE_PARSE_ULONG(u8, uint8_t, 0, UINT8_MAX)
+DEFINE_PARSE_ULONG(_uint, unsigned, 0, UINT_MAX)
+DEFINE_PARSE_ULONG(_u32, uint32_t, 0, UINT32_MAX)
+DEFINE_PARSE_ULONG(_u16, uint16_t, 0, UINT16_MAX)
+DEFINE_PARSE_ULONG(_u8, uint8_t, 0, UINT8_MAX)
#define DEFINE_PARSE_LONG(name, type, min, max) \
DEFINE_PARSE_WRAPPER(name, type, min, max, long, _long)
-DEFINE_PARSE_LONG(int, int, n < INT_MIN, INT_MAX)
-DEFINE_PARSE_LONG(s32, int32_t, n < INT32_MIN, INT32_MAX)
-DEFINE_PARSE_LONG(s16, int16_t, n < INT16_MIN, INT16_MAX)
-DEFINE_PARSE_LONG(s8, int8_t, n < INT8_MIN, INT8_MAX)
+DEFINE_PARSE_LONG(_int, int, n < INT_MIN, INT_MAX)
+DEFINE_PARSE_LONG(_s32, int32_t, n < INT32_MIN, INT32_MAX)
+DEFINE_PARSE_LONG(_s16, int16_t, n < INT16_MIN, INT16_MAX)
+DEFINE_PARSE_LONG(_s8, int8_t, n < INT8_MIN, INT8_MAX)