# HG changeset patch # User Matti Hamalainen # Date 1206154321 0 # Node ID 707e35b03f8988cb96ac86db6cf6a318c4fbfdf2 # Parent 53e127854dca9c12255416981a2c38e67edc7c74 Synced th-libs. diff -r 53e127854dca -r 707e35b03f89 th_args.c --- a/th_args.c Sat Mar 22 00:55:03 2008 +0000 +++ b/th_args.c Sat Mar 22 02:52:01 2008 +0000 @@ -213,8 +213,8 @@ /* Long option */ for (optN = -1, optLen = i = 0; (i < optListN) && (optN < 0); i++) if (optList[i].optLong) { - optLen = th_strlen(optList[i].optLong); - if (th_strncmp(currArg, optList[i].optLong, optLen) == 0) + optLen = strlen(optList[i].optLong); + if (strncmp(currArg, optList[i].optLong, optLen) == 0) optN = i; } diff -r 53e127854dca -r 707e35b03f89 th_string.c --- a/th_string.c Sat Mar 22 00:55:03 2008 +0000 +++ b/th_string.c Sat Mar 22 02:52:01 2008 +0000 @@ -15,117 +15,56 @@ /* Allocate memory for a string with given length */ -char_t *th_stralloc(const size_t l) +char *th_stralloc(const size_t l) { assert(l > 0); - return th_malloc(sizeof(char_t) * l); -} - - -char_t *th_strrealloc(char_t * s, const size_t l) -{ - assert(l > 0); - return th_realloc(s, sizeof(char_t) * l); + return th_malloc(sizeof(char) * l); } -/* Calculate the length of a string [strlen] - */ -size_t th_strlen(char_t * pStr) +char *th_strrealloc(char * s, const size_t l) { - size_t l = 0; - char_t *s = pStr; - assert(pStr); - - while (*s) { - s++; - l++; - } - - return l; + assert(l > 0); + return th_realloc(s, sizeof(char) * l); } /* Duplicate a string [strdup] */ -char_t *th_strdup(char_t * pStr) +char *th_strdup(char * str) { - char_t *pResult, *s, *d; + char *result, *s, *d; - if (!pStr) return NULL; + if (!str) return NULL; /* Allocate memory for destination */ - pResult = th_stralloc(th_strlen(pStr) + 1); - if (!pResult) + result = th_stralloc(strlen(str) + 1); + if (!result) return NULL; /* Copy to the destination */ - s = pStr; - d = pResult; + s = str; + d = result; while (*s) { *(d++) = *(s++); } *d = 0; - return pResult; -} - - -/* Concatenate a string [strcat] - */ -char_t *th_strcat(char_t * pDest, char_t * pSource) -{ - char_t *s, *d; - assert(pSource); - assert(pDest); - - /* Copy to the destination */ - s = pSource; - d = pDest; - - while (*d) d++; - - while (*s) { - *(d++) = *(s++); - } - *d = 0; - - return pDest; + return result; } -/* Copy a string [strcpy, strncpy] - */ -char_t *th_strcpy(char_t * pDest, char_t * pSource) +char *th_strncpy(char * dst, char * src, size_t n) { - char_t *s, *d; - assert(pSource); - assert(pDest); - - /* Copy to the destination */ - s = pSource; - d = pDest; - - while (*s) { - *(d++) = *(s++); - } - *d = 0; - - return pDest; -} - - -char_t *th_strncpy(char_t * pDest, char_t * pSource, size_t n) -{ - char_t *s, *d; + char *s, *d; size_t i; - assert(pSource); - assert(pDest); + assert(src); + assert(dst); /* Copy to the destination */ i = n; - s = pSource; - d = pDest; + s = src; + d = dst; while (*s && (i > 0)) { *(d++) = *(s++); i--; @@ -138,49 +77,25 @@ } /* Ensure that last is always zero */ - pDest[n - 1] = 0; + dst[n - 1] = 0; - return pDest; + return dst; } -/* Compare given strings [strcmp, strncmp] - */ -int th_strcmp(char_t * pStr1, char_t * pStr2) +int th_strncmp(char * str1, char * str2, size_t n) { - char_t *s1, *s2; - assert(pStr1); - assert(pStr2); + char *s1, *s2; + assert(str1); + assert(str2); /* Check the string pointers */ - if (pStr1 == pStr2) + if (str1 == str2) return 0; /* Go through the string */ - s1 = pStr1; - s2 = pStr2; - while (*s1 && *s2 && (*s1 == *s2)) { - s1++; - s2++; - } - - return ((*s1) - (*s2)); -} - - -int th_strncmp(char_t * pStr1, char_t * pStr2, size_t n) -{ - char_t *s1, *s2; - assert(pStr1); - assert(pStr2); - - /* Check the string pointers */ - if (pStr1 == pStr2) - return 0; - - /* Go through the string */ - s1 = pStr1; - s2 = pStr2; + s1 = str1; + s2 = str2; while ((n > 0) && *s1 && *s2 && (*s1 == *s2)) { s1++; s2++; @@ -196,19 +111,17 @@ /* Compare two strings ignoring case [strcasecmp, strncasecmp] */ -int th_strcasecmp(char_t * pStr1, char_t * pStr2) +int th_strcasecmp(char * str1, char * str2) { - char_t *s1, *s2; - assert(pStr1); - assert(pStr2); + char *s1 = str1, *s2 = str2; + assert(str1); + assert(str2); /* Check the string pointers */ - if (pStr1 == pStr2) + if (str1 == str2) return 0; /* Go through the string */ - s1 = pStr1; - s2 = pStr2; while (*s1 && *s2 && (th_tolower(*s1) == th_tolower(*s2))) { s1++; s2++; @@ -218,19 +131,17 @@ } -int th_strncasecmp(char_t * pStr1, char_t * pStr2, size_t n) +int th_strncasecmp(char * str1, char * str2, size_t n) { - char_t *s1, *s2; - assert(pStr1); - assert(pStr2); + char *s1 = str1, *s2 = str2; + assert(str1); + assert(str2); /* Check the string pointers */ - if (pStr1 == pStr2) + if (str1 == str2) return 0; /* Go through the string */ - s1 = pStr1; - s2 = pStr2; while ((n > 0) && *s1 && *s2 && (th_tolower(*s1) == th_tolower(*s2))) { s1++; s2++; @@ -247,13 +158,13 @@ /* Remove all occurences of control characters, in-place. * Resulting string is always shorter or same length than original. */ -void th_strip_ctrlchars(char_t * pStr) +void th_strip_ctrlchars(char * str) { - char_t *i, *j; - assert(pStr); + char *i, *j; + assert(str); - i = pStr; - j = pStr; + i = str; + j = str; while (*i) { if (!th_iscntrl(*i)) *(j++) = *i; @@ -264,93 +175,51 @@ } -/* Locate a substring [strstr] +/* Copy a given string over in *result. */ -char_t *th_strstr(char_t * haystack, char_t * needle) +int th_pstrcpy(char ** result, char * str) { - char_t *h, *n, *s; - assert(haystack); - assert(needle); - - /* If 'needle' is empty, we return 'haystack' */ - if (!*needle) - return haystack; - - /* Search for 'needle' in 'haystack' */ - h = haystack; - n = needle; - while (*h) { - /* Find possible start of 'needle' */ - while (*h && (*h != *n)) - h++; - - if (*h == *n) { - /* Found, check rest */ - s = h; - n = needle; - while (*h) { - if (!*n) - return s; - else - if (*h != *n) - break; - n++; - h++; - } - h = s; - h++; - } - } - - return NULL; -} - - -/* Copy a given string over in *ppResult. - */ -int th_pstrcpy(char_t ** ppResult, char_t * pStr) -{ - assert(ppResult); + assert(result); /* Check the string pointers */ - if (!pStr) + if (!str) return -1; /* Allocate memory for destination */ - th_free(*ppResult); - *ppResult = th_stralloc(th_strlen(pStr) + 1); - if (!*ppResult) + th_free(*result); + *result = th_stralloc(strlen(str) + 1); + if (!*result) return -2; /* Copy to the destination */ - th_strcpy(*ppResult, pStr); + strcpy(*result, str); return 0; } -/* Concatenates a given string into string pointed by *ppResult. +/* Concatenates a given string into string pointed by *result. */ -int th_pstrcat(char_t ** ppResult, char_t * pStr) +int th_pstrcat(char ** result, char * str) { - assert(ppResult); + assert(result); /* Check the string pointers */ - if (!pStr) + if (!str) return -1; - if (*ppResult != NULL) { - *ppResult = th_strrealloc(*ppResult, th_strlen(*ppResult) + th_strlen(pStr) + 1); - if (*ppResult == NULL) + if (*result != NULL) { + *result = th_strrealloc(*result, strlen(*result) + strlen(str) + 1); + if (*result == NULL) return -1; - th_strcat(*ppResult, pStr); + strcat(*result, str); } else { - *ppResult = th_stralloc(th_strlen(pStr) + 1); - if (*ppResult == NULL) + *result = th_stralloc(strlen(str) + 1); + if (*result == NULL) return -1; - th_strcpy(*ppResult, pStr); + strcpy(*result, str); } return 0; @@ -361,40 +230,40 @@ * Updates iPos into the position of such character and * returns pointer to the string. */ -char_t *th_findnext(char_t * pStr, size_t * iPos) +char *th_findnext(char * str, size_t * iPos) { - assert(pStr); + assert(str); /* Terminating NULL-character is not whitespace! */ - while (th_isspace(pStr[*iPos])) + while (th_isspace(str[*iPos])) (*iPos)++; - return &pStr[*iPos]; + return &str[*iPos]; } /* Find next chSep-character from string */ -char_t *th_findsep(char_t * pStr, size_t * iPos, char_t chSep) +char *th_findsep(char * str, size_t * iPos, char chSep) { - assert(pStr); + assert(str); /* Terminating NULL-character is not digit! */ - while (pStr[*iPos] && (pStr[*iPos] != chSep)) + while (str[*iPos] && (str[*iPos] != chSep)) (*iPos)++; - return &pStr[*iPos]; + return &str[*iPos]; } /* Find next chSep- or whitespace from string */ -char_t *th_findseporspace(char_t * pStr, size_t * iPos, char_t chSep) +char *th_findseporspace(char * str, size_t * iPos, char chSep) { - assert(pStr); + assert(str); /* Terminating NULL-character is not digit! */ - while (!th_isspace(pStr[*iPos]) && (pStr[*iPos] != chSep)) + while (!th_isspace(str[*iPos]) && (str[*iPos] != chSep)) (*iPos)++; - return &pStr[*iPos]; + return &str[*iPos]; } @@ -403,15 +272,15 @@ * wildcards ? and *. "?" matches any character and "*" matches * any number of characters. */ -BOOL th_strmatch(char_t * pStr, char_t * pPattern) +BOOL th_strmatch(char * str, char * pattern) { BOOL didMatch, isAnyMode, isEnd; - char_t *tmpPattern; + char *tmpPattern; /* Check given pattern and string */ - if (!pStr) + if (!str) return FALSE; - if (!pPattern) + if (!pattern) return FALSE; /* Initialize */ @@ -423,36 +292,36 @@ /* Start comparision */ do { didMatch = FALSE; - switch (*pPattern) { + switch (*pattern) { case '?': /* Any single character matches */ - if (*pStr) { + if (*str) { didMatch = TRUE; - pPattern++; - pStr++; + pattern++; + str++; } break; case '*': didMatch = TRUE; - pPattern++; - if (!*pPattern) + pattern++; + if (!*pattern) isEnd = TRUE; isAnyMode = TRUE; - tmpPattern = pPattern; + tmpPattern = pattern; break; case 0: if (isAnyMode) { - if (*pStr) - pStr++; + if (*str) + str++; else isEnd = TRUE; } else { - if (*pStr) { + if (*str) { if (tmpPattern) { isAnyMode = TRUE; - pPattern = tmpPattern; + pattern = tmpPattern; } else didMatch = FALSE; } else @@ -461,32 +330,32 @@ break; default: if (isAnyMode) { - if ((*pPattern) == (*pStr)) { + if ((*pattern) == (*str)) { isAnyMode = FALSE; didMatch = TRUE; } else { - if (*pStr) { + if (*str) { didMatch = TRUE; - pStr++; + str++; } } } else { - if ((*pPattern) == (*pStr)) { + if ((*pattern) == (*str)) { didMatch = TRUE; - if (*pPattern) - pPattern++; - if (*pStr) - pStr++; + if (*pattern) + pattern++; + if (*str) + str++; } else { if (tmpPattern) { didMatch = TRUE; isAnyMode = TRUE; - pPattern = tmpPattern; + pattern = tmpPattern; } } } - if (!*pStr && !*pPattern) + if (!*str && !*pattern) isEnd = TRUE; break; @@ -500,15 +369,15 @@ /* Compare a string to a pattern. Case-INSENSITIVE version. */ -BOOL th_strcasematch(char_t * pStr, char_t * pPattern) +BOOL th_strcasematch(char * str, char * pattern) { BOOL didMatch, isAnyMode, isEnd; - char_t *tmpPattern; + char *tmpPattern; /* Check given pattern and string */ - if (!pStr) + if (!str) return FALSE; - if (!pPattern) + if (!pattern) return FALSE; /* Initialize */ @@ -519,35 +388,35 @@ /* Start comparision */ do { - switch (*pPattern) { + switch (*pattern) { case '?': /* Any single character matches */ - if (*pStr) { - pPattern++; - pStr++; + if (*str) { + pattern++; + str++; } else didMatch = FALSE; break; case '*': - pPattern++; - if (!*pPattern || (*pPattern == '?')) + pattern++; + if (!*pattern || (*pattern == '?')) isEnd = TRUE; isAnyMode = TRUE; - tmpPattern = pPattern; + tmpPattern = pattern; break; case 0: if (isAnyMode) { - if (*pStr) - pStr++; + if (*str) + str++; else isEnd = TRUE; } else { - if (*pStr) { + if (*str) { if (tmpPattern) { isAnyMode = TRUE; - pPattern = tmpPattern; + pattern = tmpPattern; } else didMatch = FALSE; } else @@ -557,30 +426,30 @@ default: if (isAnyMode) { - if (th_tolower(*pPattern) == th_tolower(*pStr)) { + if (th_tolower(*pattern) == th_tolower(*str)) { isAnyMode = FALSE; } else { - if (*pStr) - pStr++; + if (*str) + str++; else didMatch = FALSE; } } else { - if (th_tolower(*pPattern) == th_tolower(*pStr)) { - if (*pPattern) - pPattern++; - if (*pStr) - pStr++; + if (th_tolower(*pattern) == th_tolower(*str)) { + if (*pattern) + pattern++; + if (*str) + str++; } else { if (tmpPattern) { isAnyMode = TRUE; - pPattern = tmpPattern; + pattern = tmpPattern; } else didMatch = FALSE; } } - if (!*pStr && !*pPattern) + if (!*str && !*pattern) isEnd = TRUE; break; @@ -591,336 +460,3 @@ return didMatch; } - -/* - * Handling of string-lists and hashes - */ -t_str_node *th_strnode_new(char_t * pcStr, ulint_t nUsed, void *pData) -{ - t_str_node *pResult; - - /* Allocate memory for new node */ - pResult = (t_str_node *) th_calloc(1, sizeof(t_str_node)); - if (!pResult) - return NULL; - - /* Set fields */ - th_pstrcpy(&pResult->pcStr, pcStr); - pResult->nUsed = nUsed; - pResult->pData = pData; - - return pResult; -} - - -void th_strnode_free(t_str_node * pNode) -{ - assert(pNode); - - th_free(pNode->pcStr); - th_free(pNode); -} - - -/* Insert a new node into strlist - */ -void th_strlist_insert(t_str_node ** strList, t_str_node * pNode) -{ - assert(strList); - assert(pNode); - - /* Insert into linked list */ - if (*strList) { - /* The first node's pPrev points to last node */ - LPREV = (*strList)->pPrev; /* New node's prev = Previous last node */ - (*strList)->pPrev->pNext = pNode; /* Previous last node's next = New node */ - (*strList)->pPrev = pNode; /* New last node = New node */ - LNEXT = NULL; /* But next is NULL! */ - } else { - (*strList) = pNode; /* First node ... */ - LPREV = pNode; /* ... it's also last */ - LNEXT = NULL; /* But next is NULL! */ - } - -} - - -/* Free a given strlist - */ -void th_strlist_free(t_str_node * strList) -{ - t_str_node *pNode, *nNode; - - pNode = strList; - while (pNode) { - nNode = pNode->pNext; - th_strnode_free(pNode); - pNode = nNode; - } -} - - -/* Create a strIndex from strlist - */ -t_str_index *th_strlist_makeindex(t_str_node * strList) -{ - t_str_index *pResult; - t_str_node *pCurr; - ulint_t n; - assert(strList); - - /* Computer number of nodes */ - for (n = 0, pCurr = strList; pCurr; pCurr = pCurr->pNext) - n++; - - /* Check number of nodes */ - if (n == 0) - return NULL; - - /* Allocate memory for index */ - pResult = (t_str_index *) th_calloc(1, sizeof(t_str_index)); - if (!pResult) - return NULL; - - pResult->n = n; - pResult->ppIndex = (t_str_node **) th_calloc(n, sizeof(t_str_node *)); - if (!pResult->ppIndex) { - th_free(pResult); - return NULL; - } - - /* Create the index */ - for (n = 0, pCurr = strList; pCurr && (n < pResult->n); pCurr = pCurr->pNext) - pResult->ppIndex[n++] = pCurr; - - return pResult; -} - - -/* Insert a node into given strhash - */ -int th_strhash_insert(t_str_hash strHash, t_str_node * pNode, BOOL ignoreCase) -{ - int i; - assert(strHash); - assert(pNode); - assert(pNode->pcStr); - - if (ignoreCase) - i = th_tolower(pNode->pcStr[0]); - else - i = pNode->pcStr[0]; - - /* Check the hashcode */ - if ((i < 0) && (i >= SET_HASH_MAXINDEX)) - return -1; - - if (strHash[i]) { - /* The first node's pPrev points to last node */ - pNode->pPrev = strHash[i]->pPrev; /* New node's prev = Previous last node */ - strHash[i]->pPrev->pNext = pNode; /* Previous last node's next = New node */ - strHash[i]->pPrev = pNode; /* New last node = New node */ - pNode->pNext = NULL; /* But next is NULL! */ - } else { - strHash[i] = pNode; /* First node */ - pNode->pPrev = pNode; /* But also last */ - pNode->pNext = NULL; /* But next is NULL! */ - } - - return 0; -} - - -/* Free a given strhash - */ -void th_strhash_free(t_str_hash strHash) -{ - int i; - assert(strHash); - - for (i = 0; i < SET_HASH_MAXINDEX; i++) - th_strlist_free(strHash[i]); -} - - -/* Change pData for matching entries to new value - */ -void th_strhash_change_pdata(t_str_hash strHash, void *pFind, void *pNew) -{ - t_str_node *pCurr; - int i; - assert(strHash); - - for (i = 0; i < SET_HASH_MAXINDEX; i++) { - /* Find from linked list */ - pCurr = strHash[i]; - while (pCurr) { - if (pCurr->pData == pFind) - pCurr->pData = pNew; - - pCurr = pCurr->pNext; - } - } -} - - -/* Search a string from a given stringhash, either case-sensitive or insensitive - */ -t_str_node *th_strhash_search(t_str_hash strHash, char_t * findStr, BOOL ignoreCase) -{ - t_str_node *pCurr; - int i; - BOOL isFound; - assert(strHash); - assert(findStr); - - isFound = FALSE; - pCurr = NULL; - - /* Check hashcode */ - if (ignoreCase) - i = ((unsigned char) th_tolower(findStr[0])); - else - i = ((unsigned char) findStr[0]); - - if ((i < 0) && (i >= SET_HASH_MAXINDEX)) - return NULL; - - /* Find from linked list */ - pCurr = strHash[i]; - - if (ignoreCase) { - /* Case in-sensitive search */ - while (pCurr && !isFound) { - if (th_strcasecmp(findStr, pCurr->pcStr) == 0) - isFound = TRUE; - else - pCurr = pCurr->pNext; - } - } else { - /* Case sensitive search */ - while (pCurr && !isFound) { - if (th_strcmp(findStr, pCurr->pcStr) == 0) - isFound = TRUE; - else - pCurr = pCurr->pNext; - } - } - - /* Return result */ - if (isFound) - return pCurr; - else - return NULL; -} - - -/* Create a strIndex from strHash - */ -t_str_index *th_strhash_makeindex(t_str_hash strHash) -{ - t_str_index *pResult; - t_str_node *pCurr; - unsigned int n, i; - assert(strHash); - - /* Computer number of nodes */ - for (n = i = 0; i < SET_HASH_MAXINDEX; i++) { - pCurr = strHash[i]; - while (pCurr) { - n++; - pCurr = pCurr->pNext; - } - } - - /* Check number of nodes */ - if (n <= 0) - return NULL; - - /* Allocate memory for index */ - pResult = (t_str_index *) th_calloc(1, sizeof(t_str_index)); - if (!pResult) - return NULL; - - pResult->n = n; - pResult->ppIndex = (t_str_node **) th_calloc(n, sizeof(t_str_node *)); - if (!pResult->ppIndex) { - th_free(pResult); - return NULL; - } - - /* Create the index */ - for (n = i = 0; (i < SET_HASH_MAXINDEX) && (n < pResult->n); i++) { - pCurr = strHash[i]; - while (pCurr && (n < pResult->n)) { - pResult->ppIndex[n++] = pCurr; - pCurr = pCurr->pNext; - } - } - - return pResult; -} - - -/* Free a given strIndex - */ -void th_strindex_free(t_str_index * strIndex) -{ - if (strIndex) { - th_free(strIndex->ppIndex); - th_free(strIndex); - } -} - - -/* Compare two t_str_nodes by nUsed - */ -int th_strindex_cmp_used(const void *pNode1, const void *pNode2) -{ - t_str_node *pStr1, *pStr2; - - pStr1 = *(t_str_node **) pNode1; - pStr2 = *(t_str_node **) pNode2; - - if (pStr1->nUsed > pStr2->nUsed) - return -1; - else if (pStr1->nUsed < pStr2->nUsed) - return 1; - else - return 0; -} - - -/* Sort an strIndex by nUsed, using th_strindex_cmp_used() - */ -void th_strindex_sort_nused(t_str_index * strIndex) -{ - assert(strIndex); - assert(strIndex->ppIndex); - - qsort(strIndex->ppIndex, strIndex->n, sizeof(t_str_node *), th_strindex_cmp_used); -} - - -/* Compare two t_str_nodes via strcmp() - */ -int th_strindex_cmp_alpha(const void *pNode1, const void *pNode2) -{ - t_str_node *pStr1, *pStr2; - - pStr1 = *(t_str_node **) pNode1; - pStr2 = *(t_str_node **) pNode2; - - return th_strcmp(pStr1->pcStr, pStr2->pcStr); -} - - -/* Sort an strIndex by nUsed, using th_strindex_cmp_used() - */ -void th_strindex_sort_alpha(t_str_index * strIndex) -{ - assert(strIndex); - assert(strIndex->ppIndex); - - qsort(strIndex->ppIndex, strIndex->n, sizeof(t_str_node *), th_strindex_cmp_alpha); -} diff -r 53e127854dca -r 707e35b03f89 th_string.h --- 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 #include -/* - * 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 }