2004-10-31 Paul Jakma <paul@dishone.st>
* keychain.c: Convert some more strtoul users to VTY_GET_INTEGER.
diff --git a/lib/keychain.c b/lib/keychain.c
index 1d38167..a3219ef 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -278,16 +278,10 @@
struct keychain *keychain;
struct key *key;
u_int32_t index;
- char *endptr = NULL;
keychain = vty->index;
- index = strtoul (argv[0], &endptr, 10);
- if (index == ULONG_MAX || *endptr != '\0')
- {
- vty_out (vty, "Key identifier number error%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ VTY_GET_INTEGER ("key identifier", index, argv[0]);
key = key_get (keychain, index);
vty->index_sub = key;
vty->node = KEYCHAIN_KEY_NODE;
@@ -305,17 +299,10 @@
struct keychain *keychain;
struct key *key;
u_int32_t index;
- char *endptr = NULL;
keychain = vty->index;
- index = strtoul (argv[0], &endptr, 10);
- if (index == ULONG_MAX || *endptr != '\0')
- {
- vty_out (vty, "Key identifier number error%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
+ VTY_GET_INTEGER ("key identifier", index, argv[0]);
key = key_lookup (keychain, index);
if (! key)
{
@@ -462,7 +449,7 @@
tm.tm_year = year - 1900;
time = mktime (&tm);
-
+
return time;
}
@@ -475,7 +462,7 @@
{
time_t time_start;
time_t time_end;
-
+
time_start = key_str2time (stime_str, sday_str, smonth_str, syear_str);
if (time_start < 0)
{
@@ -510,7 +497,6 @@
{
time_t time_start;
u_int32_t duration;
- char *endptr = NULL;
time_start = key_str2time (stime_str, sday_str, smonth_str, syear_str);
if (time_start < 0)
@@ -520,12 +506,7 @@
}
krange->start = time_start;
- duration = strtoul (duration_str, &endptr, 10);
- if (duration == ULONG_MAX || *endptr != '\0')
- {
- vty_out (vty, "Malformed duration%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ VTY_GET_INTEGER ("duration", duration, duration_str);
krange->duration = 1;
krange->end = time_start + duration;