Mercurial > hg > nnchat
diff util.c @ 464:35d67bd0613b
Move str_*() functions to util.c
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 26 May 2012 06:01:06 +0300 |
parents | d55cc0b73c62 |
children | 796508f828f6 |
line wrap: on
line diff
--- a/util.c Sat May 26 06:00:02 2012 +0300 +++ b/util.c Sat May 26 06:01:06 2012 +0300 @@ -6,6 +6,36 @@ #include "util.h" +BOOL str_get_timestamp(char *str, size_t len, const char *fmt) +{ + time_t stamp = time(NULL); + struct tm *stamp_tm; + if ((stamp_tm = localtime(&stamp)) != NULL) + { + strftime(str, len, fmt, stamp_tm); + return TRUE; + } + else + { + str[0] = 0; + return FALSE; + } +} + + +char * str_trim_left(char *buf) +{ + while (*buf != 0 && th_isspace(*buf)) buf++; + return buf; +} + + +int str_compare(const void *s1, const void *s2) +{ + return th_strcasecmp((const char *) s1, (const char *) s2); +} + + #define PUSHCHAR(x) th_vputch(&result, &resSize, &resPos, x) #define PUSHSTR(x) th_vputs(&result, &resSize, &resPos, x)