Mercurial > hg > nnchat
diff th_string.h @ 11:707e35b03f89
Synced th-libs.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 22 Mar 2008 02:52:01 +0000 |
parents | 728243125263 |
children | 4e3616709752 |
line wrap: on
line diff
--- a/th_string.h Sat Mar 22 00:55:03 2008 +0000 +++ b/th_string.h Sat Mar 22 02:52:01 2008 +0000 @@ -16,11 +16,7 @@ #include <stdlib.h> #include <ctype.h> -/* - * Macros - */ -/* TODO - Remove usage of libc functions for increased portability. - * Possible issues are locales, impossible to implement them... +/* Macros */ #define th_isalnum(c) isalnum((int)(unsigned char) c) #define th_isalpha(c) isalpha((int)(unsigned char) c) @@ -42,73 +38,27 @@ #define th_tolower(c) tolower((int)(unsigned char) c) #define th_toupper(c) toupper((int)(unsigned char) c) -/* - * Typedefs and structures - */ -typedef struct tstrnode { - char_t *pcStr; /* String */ - ulint_t nUsed; /* Times this string has been referenced */ - void *pData; /* Extra data */ - - struct tstrnode *pPrev, *pNext; -} t_str_node; - -#define SET_HASH_MAXINDEX (256) - -typedef t_str_node *t_str_hash[SET_HASH_MAXINDEX]; - - -typedef struct tstrindex { - t_str_node **ppIndex; - ulint_t n; -} t_str_index; - - -/* - * Normal NUL-terminated string functions +/* Normal NUL-terminated string functions */ -char_t *th_stralloc(size_t); -char_t *th_strrealloc(char_t *, size_t); -size_t th_strlen(char_t *); -char_t *th_strdup(char_t *); -char_t *th_strcat(char_t *, char_t *); -char_t *th_strcpy(char_t *, char_t *); -char_t *th_strncpy(char_t *, char_t *, size_t); -int th_strcmp(char_t *, char_t *); -int th_strncmp(char_t *, char_t *, size_t); -int th_strcasecmp(char_t *, char_t *); -int th_strncasecmp(char_t *, char_t *, size_t); -void th_strip_ctrlchars(char_t *); -char_t *th_strstr(char_t *, char_t *); - -int th_pstrcpy(char_t **, char_t *); -int th_pstrcat(char_t **, char_t *); - -char_t *th_findnext(char_t *, size_t *); -char_t *th_findsep(char_t *, size_t *, char_t); -char_t *th_findseporspace(char_t *, size_t *, char_t); +char *th_stralloc(size_t); +char *th_strrealloc(char *, size_t); +char *th_strdup(char *); +char *th_strncpy(char *, char *, size_t); +int th_strcasecmp(char *, char *); +int th_strncasecmp(char *, char *, size_t); +void th_strip_ctrlchars(char *); -BOOL th_strmatch(char_t *, char_t *); -BOOL th_strcasematch(char_t *, char_t *); - +int th_pstrcpy(char **, char *); +int th_pstrcat(char **, char *); -/* - * Handling of string-lists and hashes - */ -t_str_node * th_strnode_new(char_t *, ulint_t, void *); -void th_strnode_free(t_str_node *); -void th_strlist_free(t_str_node *); -void th_strlist_insert(t_str_node **, t_str_node *); -int th_strhash_insert(t_str_node **, t_str_node *, BOOL); -void th_strhash_free(t_str_node **); -void th_strhash_change_pdata(t_str_hash, void *, void *); -t_str_node * th_strhash_search(t_str_node **, char_t *, BOOL); -t_str_index * th_strhash_makeindex(t_str_node **); -t_str_index * th_strlist_makeindex(t_str_node *); -void th_strindex_free(t_str_index *); -void th_strindex_sort_nused(t_str_index *); -void th_strindex_sort_alpha(t_str_index *); +char *th_findnext(char *, size_t *); +char *th_findsep(char *, size_t *, char); +char *th_findseporspace(char *, size_t *, char); + +BOOL th_strmatch(char *, char *); +BOOL th_strcasematch(char *, char *); + #ifdef __cplusplus }