comparison 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
comparison
equal deleted inserted replaced
463:6c990eae11b2 464:35d67bd0613b
2 * NNChat - Custom chat client for NewbieNudes.com chatrooms 2 * NNChat - Custom chat client for NewbieNudes.com chatrooms
3 * Written by Matti 'ccr' Hämäläinen 3 * Written by Matti 'ccr' Hämäläinen
4 * (C) Copyright 2008-2012 Tecnic Software productions (TNSP) 4 * (C) Copyright 2008-2012 Tecnic Software productions (TNSP)
5 */ 5 */
6 #include "util.h" 6 #include "util.h"
7
8
9 BOOL str_get_timestamp(char *str, size_t len, const char *fmt)
10 {
11 time_t stamp = time(NULL);
12 struct tm *stamp_tm;
13 if ((stamp_tm = localtime(&stamp)) != NULL)
14 {
15 strftime(str, len, fmt, stamp_tm);
16 return TRUE;
17 }
18 else
19 {
20 str[0] = 0;
21 return FALSE;
22 }
23 }
24
25
26 char * str_trim_left(char *buf)
27 {
28 while (*buf != 0 && th_isspace(*buf)) buf++;
29 return buf;
30 }
31
32
33 int str_compare(const void *s1, const void *s2)
34 {
35 return th_strcasecmp((const char *) s1, (const char *) s2);
36 }
7 37
8 38
9 #define PUSHCHAR(x) th_vputch(&result, &resSize, &resPos, x) 39 #define PUSHCHAR(x) th_vputch(&result, &resSize, &resPos, x)
10 #define PUSHSTR(x) th_vputs(&result, &resSize, &resPos, x) 40 #define PUSHSTR(x) th_vputs(&result, &resSize, &resPos, x)
11 41