0
|
1 /*
|
|
2 * Miscellaneous string-handling related utility-functions
|
|
3 * Programmed and designed by Matti 'ccr' Hamalainen
|
|
4 * (C) Copyright 2002-2008 Tecnic Software productions (TNSP)
|
|
5 *
|
|
6 * Please read file 'COPYING' for information on license and distribution.
|
|
7 */
|
|
8 #ifndef _TH_STRING_H
|
|
9 #define _TH_STRING_H
|
|
10
|
|
11 #ifdef __cplusplus
|
|
12 extern "C" {
|
|
13 #endif
|
|
14
|
|
15 #include "th_util.h"
|
|
16 #include <stdlib.h>
|
|
17 #include <ctype.h>
|
124
|
18 #include <stdarg.h>
|
0
|
19
|
11
|
20 /* Macros
|
0
|
21 */
|
81
|
22 #define th_isalnum(c) isalnum((int)(unsigned char) c)
|
|
23 #define th_isalpha(c) isalpha((int)(unsigned char) c)
|
|
24 #define th_isascii(c) isascii((int)(unsigned char) c)
|
|
25 #define th_isblank(c) isblank((int)(unsigned char) c)
|
|
26 #define th_iscntrl(c) iscntrl((int)(unsigned char) c)
|
|
27 #define th_isdigit(c) isdigit((int)(unsigned char) c)
|
|
28 #define th_isgraph(c) isgraph((int)(unsigned char) c)
|
|
29 #define th_islower(c) islower((int)(unsigned char) c)
|
|
30 #define th_isprint(c) isprint((int)(unsigned char) c)
|
|
31 #define th_ispunct(c) ispunct((int)(unsigned char) c)
|
|
32 #define th_isspace(c) isspace((int)(unsigned char) c)
|
|
33 #define th_isupper(c) isupper((int)(unsigned char) c)
|
|
34 #define th_isxdigit(c) isxdigit((int)(unsigned char) c)
|
|
35 #define th_iscrlf(c) ((c=='\r')||(c=='\n'))
|
0
|
36
|
81
|
37 #define th_isspecial(q) (((q >= 0x5b) && (q <= 0x60)) || ((q >= 0x7b) && (q <= 0x7d)))
|
0
|
38
|
81
|
39 #define th_tolower(c) tolower((int)(unsigned char) c)
|
|
40 #define th_toupper(c) toupper((int)(unsigned char) c)
|
0
|
41
|
|
42
|
11
|
43 /* Normal NUL-terminated string functions
|
0
|
44 */
|
81
|
45 char *th_strncpy(char *, const char *, size_t);
|
124
|
46 int th_strcasecmp(const char *, const char *);
|
|
47 int th_strncasecmp(const char *, const char *, size_t);
|
81
|
48 void th_strip_ctrlchars(char *);
|
0
|
49
|
124
|
50 #ifdef STRDUP_PRINTF
|
|
51 char *th_strdup_vprintf(const char *, va_list);
|
|
52 char *th_strdup_printf(const char *, ...);
|
|
53 #endif
|
|
54
|
79
|
55 char *th_strdup(const char *);
|
124
|
56 int th_pstrcpy(char **, const char *);
|
|
57 int th_pstrcat(char **, const char *);
|
0
|
58
|
124
|
59 const char *th_findnext(const char *, size_t *);
|
|
60 const char *th_findsep(const char *, size_t *, char);
|
|
61 const char *th_findseporspace(const char *, size_t *, char);
|
11
|
62
|
124
|
63 BOOL th_strmatch(const char *, const char *);
|
|
64 BOOL th_strcasematch(const char *, const char *);
|
11
|
65
|
0
|
66
|
|
67 #ifdef __cplusplus
|
|
68 }
|
|
69 #endif
|
|
70 #endif /* _TH_STRING_H */
|