changeset 1131:f9678ea553c8

Oops, cleaned up ifconfig uses atolx_range() instead of get_int_list(). Check that in.
author Rob Landley <rob@landley.net>
date Thu, 28 Nov 2013 21:11:34 -0600
parents 6df194c6de88
children 615505bb38b6
files lib/lib.c lib/lib.h lib/pending.c lib/pending.h
diffstat 4 files changed, 11 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/lib/lib.c	Thu Nov 28 21:06:15 2013 -0600
+++ b/lib/lib.c	Thu Nov 28 21:11:34 2013 -0600
@@ -203,6 +203,16 @@
   return val;
 }
 
+long atolx_range(char *numstr, long low, long high)
+{
+  long val = atolx(numstr);
+
+  if (val < low) error_exit("%ld < %ld", val, low);
+  if (val > high) error_exit("%ld > %ld", val, high);
+
+  return val;
+}
+
 int numlen(long l)
 {
   int len = 0;
--- a/lib/lib.h	Thu Nov 28 21:06:15 2013 -0600
+++ b/lib/lib.h	Thu Nov 28 21:11:34 2013 -0600
@@ -134,6 +134,7 @@
 void poke(void *ptr, uint64_t val, int size);
 struct string_list *find_in_path(char *path, char *filename);
 long atolx(char *c);
+long atolx_range(char *numstr, long low, long high);
 int numlen(long l);
 int stridx(char *haystack, char needle);
 off_t fdlength(int fd);
--- a/lib/pending.c	Thu Nov 28 21:06:15 2013 -0600
+++ b/lib/pending.c	Thu Nov 28 21:11:34 2013 -0600
@@ -30,24 +30,6 @@
   closedir(dp);
 }
 
-/*
- * used to get the interger value.
- */
-unsigned long get_int_value(const char *numstr, unsigned long lowrange, unsigned long highrange)
-{
-  unsigned long rvalue = 0;
-  char *ptr;
-
-  if (!isdigit(*numstr)) perror_exit("bad number '%s'", numstr);
-  errno = 0;
-  rvalue = strtoul(numstr, &ptr, 10);
-
-  if (errno || numstr == ptr || *ptr || rvalue < lowrange || rvalue > highrange)
-    perror_exit("bad number '%s'", numstr);
-
-  return rvalue;
-}
-
 void daemonize(void)
 {
   int fd = open("/dev/null", O_RDWR);
--- a/lib/pending.h	Thu Nov 28 21:06:15 2013 -0600
+++ b/lib/pending.h	Thu Nov 28 21:11:34 2013 -0600
@@ -23,11 +23,5 @@
 int update_password(char *filename, char* username, char* encrypted);
 
 // cut helper functions
-unsigned long get_int_value(const char *numstr, unsigned long lowrange, unsigned long highrange);
-
-// grep helper functions
-char  *astrcat (char *, char *);
-char *xastrcat (char *, char *);
-
 void daemonize(void);
 char *human_readable(unsigned long long size);