Mercurial > hg > nnchat
annotate th_string.h @ 322:b9c15c57dc8f
Clean up message functions, add new printMsgQ() helper function for messages that should not
go into the log file. Add skeleton help function, accessible via F1 key. And other cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 11 Jun 2011 09:48:26 +0300 |
parents | eb74097b73f5 |
children | fae4651d37bc |
rev | line source |
---|---|
0 | 1 /* |
2 * Miscellaneous string-handling related utility-functions | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
249 | 4 * (C) Copyright 2002-2011 Tecnic Software productions (TNSP) |
0 | 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 char *th_strdup_vprintf(const char *, va_list); |
51 char *th_strdup_printf(const char *, ...); | |
52 | |
282
3dc86d8eb0a9
Added helper functions for easier string manipulation.
Matti Hamalainen <ccr@tnsp.org>
parents:
249
diff
changeset
|
53 void th_pstr_vprintf(char **, const char *, va_list); |
3dc86d8eb0a9
Added helper functions for easier string manipulation.
Matti Hamalainen <ccr@tnsp.org>
parents:
249
diff
changeset
|
54 void th_pstr_printf(char **, const char *, ...); |
3dc86d8eb0a9
Added helper functions for easier string manipulation.
Matti Hamalainen <ccr@tnsp.org>
parents:
249
diff
changeset
|
55 |
79 | 56 char *th_strdup(const char *); |
124 | 57 int th_pstrcpy(char **, const char *); |
58 int th_pstrcat(char **, const char *); | |
0 | 59 |
124 | 60 const char *th_findnext(const char *, size_t *); |
61 const char *th_findsep(const char *, size_t *, char); | |
62 const char *th_findseporspace(const char *, size_t *, char); | |
11 | 63 |
124 | 64 BOOL th_strmatch(const char *, const char *); |
65 BOOL th_strcasematch(const char *, const char *); | |
11 | 66 |
131
3896861974ac
Added th_get_hex_triplet().
Matti Hamalainen <ccr@tnsp.org>
parents:
126
diff
changeset
|
67 int th_get_hex_triplet(const char *); |
0 | 68 |
241
a1ee6c76ca1c
Functions for growing a string buffer when needed.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
69 |
287
eb74097b73f5
Make th_vputch() and th_vputs() return a boolean value for success and failure respectively. Also fix a grave bug in th_growbuf().
Matti Hamalainen <ccr@tnsp.org>
parents:
282
diff
changeset
|
70 BOOL th_vputch(char **buf, size_t *bufsize, size_t *len, const char ch); |
eb74097b73f5
Make th_vputch() and th_vputs() return a boolean value for success and failure respectively. Also fix a grave bug in th_growbuf().
Matti Hamalainen <ccr@tnsp.org>
parents:
282
diff
changeset
|
71 BOOL th_vputs(char **buf, size_t *bufsize, size_t *len, const char *str); |
241
a1ee6c76ca1c
Functions for growing a string buffer when needed.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
72 |
a1ee6c76ca1c
Functions for growing a string buffer when needed.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
73 #define TH_BUFGROW (32) |
a1ee6c76ca1c
Functions for growing a string buffer when needed.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
74 |
0 | 75 #ifdef __cplusplus |
76 } | |
77 #endif | |
78 #endif /* _TH_STRING_H */ |