Add new parse_uinttype wrappers for strtoul in src/helper/command.[ch].

- Used to improve command argument parsing of unsigned integers values.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2206 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
zwelch
2009-06-12 01:39:44 +00:00
parent 5bb0f1d29a
commit 5c123481a1
2 changed files with 31 additions and 0 deletions

View File

@@ -848,3 +848,18 @@ long jim_global_long(const char *variable)
}
return 0;
}
int parse_ullong(const char *str, unsigned long long *ul)
{
char *end;
*ul = strtoull(str, &end, 0);
bool okay = *str && !*end && ULLONG_MAX != *ul;
return okay ? ERROR_OK : ERROR_COMMAND_SYNTAX_ERROR;
}
int parse_ulong(const char *str, unsigned long *ul)
{
char *end;
*ul = strtoul(str, &end, 0);
bool okay = *str && !*end && ULONG_MAX != *ul;
return okay ? ERROR_OK : ERROR_COMMAND_SYNTAX_ERROR;
}