diff options
author | James Booth <boothj5@gmail.com> | 2012-02-18 22:51:08 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-02-18 22:51:08 +0000 |
commit | 18c97a431afb5421db21759e7ea8496ce0377abf (patch) | |
tree | 3f8d0b1b2cf15ec0bc389185568cddf93da36c6b /util.c | |
parent | 809daa9395a0475ac0ffa8bf65c99aa2a28d752c (diff) | |
download | profani-tty-18c97a431afb5421db21759e7ea8496ce0377abf.tar.gz |
Start command validation
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 21 |
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; +} + |