aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c10
-rw-r--r--lib/lib.h1
-rw-r--r--lib/pending.c18
-rw-r--r--lib/pending.h6
4 files changed, 11 insertions, 24 deletions
diff --git a/lib/lib.c b/lib/lib.c
index de8c7be0..14de91df 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -203,6 +203,16 @@ long atolx(char *numstr)
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;
diff --git a/lib/lib.h b/lib/lib.h
index 2d3e2734..6edfa0fc 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -134,6 +134,7 @@ int64_t peek(void *ptr, int size);
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);
diff --git a/lib/pending.c b/lib/pending.c
index a804d5b8..df3207ef 100644
--- a/lib/pending.c
+++ b/lib/pending.c
@@ -30,24 +30,6 @@ void names_to_pid(char **names, int (*callback)(pid_t pid, char *name))
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);
diff --git a/lib/pending.h b/lib/pending.h
index fbd72c46..43885719 100644
--- a/lib/pending.h
+++ b/lib/pending.h
@@ -23,11 +23,5 @@ int read_password(char * buff, int buflen, char* mesg);
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);