about summary refs log tree commit diff stats
path: root/util.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-02-18 22:51:08 +0000
committerJames Booth <boothj5@gmail.com>2012-02-18 22:51:08 +0000
commit18c97a431afb5421db21759e7ea8496ce0377abf (patch)
tree3f8d0b1b2cf15ec0bc389185568cddf93da36c6b /util.c
parent809daa9395a0475ac0ffa8bf65c99aa2a28d752c (diff)
downloadprofani-tty-18c97a431afb5421db21759e7ea8496ce0377abf.tar.gz
Start command validation
Diffstat (limited to 'util.c')
-rw-r--r--util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/util.c b/util.c
index 08737ee9..2d50cfbc 100644
--- a/util.c
+++ b/util.c
@@ -1,4 +1,6 @@
 #include <time.h>
+#include <string.h>
+#include <ctype.h>
 
 void get_time(char *thetime)
 {
@@ -11,3 +13,22 @@ void get_time(char *thetime)
     strftime(thetime, 80, "%H:%M", timeinfo);
 }
 
+char *trim(char *str)
+{
+    char *end;
+
+    while (isspace(*str)) 
+        str++;
+
+    if (*str == 0)
+      return str;
+
+    end = str + strlen(str) - 1;
+    while (end > str && isspace(*end)) 
+        end--;
+
+    *(end+1) = 0;
+
+    return str;
+}
+