Mercurial > hg > th-libs
view th_string.h @ 153:4cd94649475d
Move header includes before C++ guard.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 07 Feb 2015 00:19:43 +0200 |
parents | 51eec969b07a |
children | 578d9298cc1e |
line wrap: on
line source
/* * Miscellaneous string-handling related utility-functions * Programmed and designed by Matti 'ccr' Hamalainen * (C) Copyright 2002-2015 Tecnic Software productions (TNSP) * * Please read file 'COPYING' for information on license and distribution. */ #ifndef TH_STRING_H #define TH_STRING_H #include "th_util.h" #include <stdlib.h> #include <ctype.h> #include <stdarg.h> #ifdef __cplusplus extern "C" { #endif /* Macros */ #define th_isalnum(c) isalnum((int)(unsigned char) c) #define th_isalpha(c) isalpha((int)(unsigned char) c) #define th_isascii(c) isascii((int)(unsigned char) c) #define th_isblank(c) isblank((int)(unsigned char) c) #define th_iscntrl(c) iscntrl((int)(unsigned char) c) #define th_isdigit(c) isdigit((int)(unsigned char) c) #define th_isgraph(c) isgraph((int)(unsigned char) c) #define th_islower(c) islower((int)(unsigned char) c) #define th_isprint(c) isprint((int)(unsigned char) c) #define th_ispunct(c) ispunct((int)(unsigned char) c) #define th_isspace(c) isspace((int)(unsigned char) c) #define th_isupper(c) isupper((int)(unsigned char) c) #define th_isxdigit(c) isxdigit((int)(unsigned char) c) #define th_iscrlf(c) ((c=='\r')||(c=='\n')) #define th_isspecial(q) (((q >= 0x5b) && (q <= 0x60)) || ((q >= 0x7b) && (q <= 0x7d))) #define th_tolower(c) tolower((int)(unsigned char) c) #define th_toupper(c) toupper((int)(unsigned char) c) enum { TH_TRIM_START = 1, TH_TRIM_END = 2, TH_TRIM_BOTH = 3 }; /* Normal NUL-terminated string functions */ char *th_strdup(const char *); char *th_strndup(const char *, const size_t); char *th_strdup_trim(const char *, const int); int th_strcasecmp(const char *, const char *); int th_strncasecmp(const char *, const char *, size_t); char *th_strrcasecmp(char *str, const char *needle); void th_strip_ctrlchars(char *); char *th_strdup_vprintf(const char *, va_list); char *th_strdup_printf(const char *, ...); void th_pstr_vprintf(char **, const char *, va_list); void th_pstr_printf(char **, const char *, ...); int th_pstrcpy(char **, const char *); int th_pstrcat(char **, const char *); /* Parsing, matching */ const char *th_findnext(const char *, size_t *); const char *th_findsep(const char *, size_t *, char); const char *th_findseporspace(const char *, size_t *, char); BOOL th_strmatch(const char *, const char *); BOOL th_strcasematch(const char *, const char *); int th_get_hex_triplet(const char *); #ifdef __cplusplus } #endif #endif // TH_STRING_H