1 |
dpavlin |
1 |
/* |
2 |
|
|
* HT Editor |
3 |
|
|
* strtools.h |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 1999-2002 Stefan Weyergraf |
6 |
|
|
* Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) |
7 |
|
|
* |
8 |
|
|
* This program is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License version 2 as |
10 |
|
|
* published by the Free Software Foundation. |
11 |
|
|
* |
12 |
|
|
* This program is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with this program; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
#ifndef __STRTOOLS_H__ |
23 |
|
|
#define __STRTOOLS_H__ |
24 |
|
|
|
25 |
|
|
#include "system/types.h" |
26 |
|
|
#include "data.h" |
27 |
|
|
|
28 |
|
|
char *ht_strdup(const char *str); |
29 |
|
|
char *ht_strndup(const char *str, size_t maxlen); |
30 |
|
|
int ht_strncpy(char *s1, const char *s2, size_t maxlen); |
31 |
|
|
int ht_strncmp(const char *s1, const char *s2, size_t max); |
32 |
|
|
int ht_strnicmp(const char *s1, const char *s2, size_t max); |
33 |
|
|
int ht_stricmp(const char *s1, const char *s2); |
34 |
|
|
|
35 |
|
|
int strcicomm(const char *s1, const char *s2); |
36 |
|
|
int strccomm(const char *s1, const char *s2); |
37 |
|
|
#define strend(s) ((s)+strlen(s)) |
38 |
|
|
int escape_special_str(char *result, int resultmaxlen, const char *s, const char *specialchars = NULL, bool bit7 = true); |
39 |
|
|
int escape_special(char *result, int resultmaxlen, const void *s, int len, const char *specialchars = NULL, bool bit7 = true); |
40 |
|
|
int unescape_special_str(char *result, int resultmaxlen, const char *s); |
41 |
|
|
int unescape_special(void *result, int resultmaxlen, const char *s); |
42 |
|
|
int bin2str(char *result, const void *s, int len); |
43 |
|
|
void wide_char_to_multi_byte(char *result, const byte *unicode, int maxlen); |
44 |
|
|
|
45 |
|
|
void memdowncase(byte *buf, int len); |
46 |
|
|
byte *ht_memmem(const byte *haystack, int haystack_len, const byte *needle, int needle_len); |
47 |
|
|
|
48 |
|
|
/* common string parsing functions */ |
49 |
|
|
void non_whitespaces(char *&str); |
50 |
|
|
void whitespaces(char *&str); |
51 |
|
|
bool waitforchar(char *&str, char b); |
52 |
|
|
|
53 |
|
|
/* string evaluation functions */ |
54 |
|
|
bool parseIntStr(const char *&str, uint64 &u64, int defaultbase); |
55 |
|
|
|
56 |
|
|
/* hex/string functions */ |
57 |
|
|
int hexdigit(char a); |
58 |
|
|
|
59 |
|
|
bool hexb_ex(uint8 &result, const char *s); |
60 |
|
|
bool hexw_ex(uint16 &result, const char *s); |
61 |
|
|
bool hexd_ex(uint32 &result, const char *s); |
62 |
|
|
|
63 |
|
|
char *mkhexb(char *buf, uint8 d); |
64 |
|
|
char *mkhexw(char *buf, uint16 d); |
65 |
|
|
char *mkhexd(char *buf, uint32 d); |
66 |
|
|
char *mkhexq(char *buf, uint64 q); |
67 |
|
|
|
68 |
|
|
#endif /* !__STRTOOLS_H__ */ |