From 694978931f345a980e8d10006d6a14588e836468 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 3 Aug 2005 17:06:19 +0000 Subject: [PATCH] added a stringisnum function git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@460 9efc2488-bf62-4759-914b-345cdb29e865 --- src/utils/utils.c | 12 +++++++++++- src/utils/utils.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/utils/utils.c b/src/utils/utils.c index d4cb133..12cb0d0 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -119,7 +119,7 @@ int buffer_fadd(growing_buffer* gb, const char* format, ... ) { len = vsnprintf(NULL, 0, f_copy, a_copy); va_end(a_copy); - len += 1; + len += 2; char buf[len]; memset(buf, 0, len); @@ -303,6 +303,7 @@ char* uescape( const char* string, int size, int full_escape ) { return d; } + // A function to turn a process into a daemon and set it's process name in ps/top int daemonize() { int f = fork(); @@ -319,4 +320,13 @@ int daemonize() { } } +int stringisnum(char* s) { + char* w = (char*) malloc(strlen(s) * sizeof(char*)); + bzero(w, strlen(s)); + long blah = strtol(s, &w, 10); + if(strlen(w) > 0) + return 0; + return 1; +} + diff --git a/src/utils/utils.h b/src/utils/utils.h index 35c15d9..894faf3 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -76,6 +76,10 @@ int clr_fl( int fd, int flags ); double get_timestamp_millis(); +/* returns true if the whole string is a number */ +int stringisnum(char* s); + + #endif -- 2.11.0