1 | /* $Id: kHlpString.h 2 2007-11-16 16:07:14Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * kHlpString - String And Memory Routines.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
---|
8 | *
|
---|
9 | * This file is part of kStuff.
|
---|
10 | *
|
---|
11 | * kStuff is free software; you can redistribute it and/or modify
|
---|
12 | * it under the terms of the GNU Lesser General Public License as published
|
---|
13 | * by the Free Software Foundation; either version 2 of the License, or
|
---|
14 | * (at your option) any later version.
|
---|
15 | *
|
---|
16 | * kStuff is distributed in the hope that it will be useful,
|
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | * GNU Lesser General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU Lesser General Public License
|
---|
22 | * along with kStuff; if not, write to the Free Software
|
---|
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | *
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef ___k_kHlpString_h___
|
---|
28 | #define ___k_kHlpString_h___
|
---|
29 |
|
---|
30 | #include <k/kHlpDefs.h>
|
---|
31 | #include <k/kTypes.h>
|
---|
32 |
|
---|
33 | #if 0 /* optimize / fix this later */
|
---|
34 | #ifdef __GNUC__
|
---|
35 | /** memchr */
|
---|
36 | # define kHlpMemChr(a,b,c) __builtin_memchr(a,b,c)
|
---|
37 | /** memcmp */
|
---|
38 | # define kHlpMemComp(a,b,c) __builtin_memcmp(a,b,c)
|
---|
39 | /** memcpy */
|
---|
40 | # define kHlpMemCopy(a,b,c) __builtin_memcpy(a,b,c)
|
---|
41 | /** memset */
|
---|
42 | # define kHlpMemSet(a,b,c) __builtin_memset(a,b,c)
|
---|
43 | /** strchr */
|
---|
44 | # define kHlpStrChr(a, b) __builtin_strchr(a, b)
|
---|
45 | /** strcmp */
|
---|
46 | # define kHlpStrComp(a, b) __builtin_strcmp(a, b)
|
---|
47 | /** strncmp */
|
---|
48 | # define kHlpStrNComp(a,b,c) __builtin_strncmp(a, b, c)
|
---|
49 | /** strlen */
|
---|
50 | # define kHlpStrLen(a) __builtin_strlen(a)
|
---|
51 |
|
---|
52 | #elif defined(_MSC_VER)
|
---|
53 | # pragma intrinsic(memcmp, memcpy, memset, strcmp, strlen)
|
---|
54 | /** memcmp */
|
---|
55 | # define kHlpMemComp(a,b,c) memcmp(a,b,c)
|
---|
56 | /** memcpy */
|
---|
57 | # define kHlpMemCopy(a,b,c) memcpy(a,b,c)
|
---|
58 | /** memset */
|
---|
59 | # define kHlpMemSet(a,b,c) memset(a,b,c)
|
---|
60 | /** strcmp */
|
---|
61 | # define kHlpStrComp(a, b) strcmp(a, b)
|
---|
62 | /** strlen */
|
---|
63 | # define kHlpStrLen(a) strlen(a)
|
---|
64 | #else
|
---|
65 | # error "Port Me"
|
---|
66 | #endif
|
---|
67 | #endif /* disabled */
|
---|
68 |
|
---|
69 | #ifdef __cplusplus
|
---|
70 | extern "C" {
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | #ifndef kHlpMemChr
|
---|
74 | KHLP_DECL(void *) kHlpMemChr(const void *pv, int ch, KSIZE cb);
|
---|
75 | #endif
|
---|
76 | #ifndef kHlpMemComp
|
---|
77 | KHLP_DECL(int) kHlpMemComp(const void *pv1, const void *pv2, KSIZE cb);
|
---|
78 | #endif
|
---|
79 | #ifndef kHlpMemComp
|
---|
80 | KHLP_DECL(void *) kHlpMemPComp(const void *pv1, const void *pv2, KSIZE cb);
|
---|
81 | #endif
|
---|
82 | #ifndef kHlpMemCopy
|
---|
83 | KHLP_DECL(void *) kHlpMemCopy(void *pv1, const void *pv2, KSIZE cb);
|
---|
84 | #endif
|
---|
85 | #ifndef kHlpMemPCopy
|
---|
86 | KHLP_DECL(void *) kHlpMemPCopy(void *pv1, const void *pv2, KSIZE cb);
|
---|
87 | #endif
|
---|
88 | #ifndef kHlpMemMove
|
---|
89 | KHLP_DECL(void *) kHlpMemMove(void *pv1, const void *pv2, KSIZE cb);
|
---|
90 | #endif
|
---|
91 | #ifndef kHlpMemPMove
|
---|
92 | KHLP_DECL(void *) kHlpMemPMove(void *pv1, const void *pv2, KSIZE cb);
|
---|
93 | #endif
|
---|
94 | #ifndef kHlpMemSet
|
---|
95 | KHLP_DECL(void *) kHlpMemSet(void *pv1, int ch, KSIZE cb);
|
---|
96 | #endif
|
---|
97 | #ifndef kHlpMemPSet
|
---|
98 | KHLP_DECL(void *) kHlpMemPSet(void *pv1, int ch, KSIZE cb);
|
---|
99 | #endif
|
---|
100 | KHLP_DECL(int) kHlpMemICompAscii(const void *pv1, const void *pv2, KSIZE cb);
|
---|
101 |
|
---|
102 | #ifndef kHlpStrCat
|
---|
103 | KHLP_DECL(char *) kHlpStrCat(char *psz1, const char *psz2);
|
---|
104 | #endif
|
---|
105 | #ifndef kHlpStrPCat
|
---|
106 | KHLP_DECL(char *) kHlpStrPCat(char *psz1, const char *psz2);
|
---|
107 | #endif
|
---|
108 | #ifndef kHlpStrNCat
|
---|
109 | KHLP_DECL(char *) kHlpStrNCat(char *psz1, const char *psz2, KSIZE cb);
|
---|
110 | #endif
|
---|
111 | #ifndef kHlpStrPNCat
|
---|
112 | KHLP_DECL(char *) kHlpStrNPCat(char *psz1, const char *psz2, KSIZE cb);
|
---|
113 | #endif
|
---|
114 | #ifndef kHlpStrChr
|
---|
115 | KHLP_DECL(char *) kHlpStrChr(const char *psz, int ch);
|
---|
116 | #endif
|
---|
117 | #ifndef kHlpStrRChr
|
---|
118 | KHLP_DECL(char *) kHlpStrRChr(const char *psz, int ch);
|
---|
119 | #endif
|
---|
120 | #ifndef kHlpStrComp
|
---|
121 | KHLP_DECL(int) kHlpStrComp(const char *psz1, const char *psz2);
|
---|
122 | #endif
|
---|
123 | KHLP_DECL(char *) kHlpStrPComp(const char *psz1, const char *psz2);
|
---|
124 | #ifndef kHlpStrNComp
|
---|
125 | KHLP_DECL(int) kHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch);
|
---|
126 | #endif
|
---|
127 | KHLP_DECL(char *) kHlpStrNPComp(const char *psz1, const char *psz2, KSIZE cch);
|
---|
128 | KHLP_DECL(int) kHlpStrICompAscii(const char *pv1, const char *pv2);
|
---|
129 | KHLP_DECL(char *) kHlpStrIPCompAscii(const char *pv1, const char *pv2);
|
---|
130 | KHLP_DECL(int) kHlpStrNICompAscii(const char *pv1, const char *pv2, KSIZE cch);
|
---|
131 | KHLP_DECL(char *) kHlpStrNIPCompAscii(const char *pv1, const char *pv2, KSIZE cch);
|
---|
132 | #ifndef kHlpStrCopy
|
---|
133 | KHLP_DECL(char *) kHlpStrCopy(char *psz1, const char *psz2);
|
---|
134 | #endif
|
---|
135 | #ifndef kHlpStrPCopy
|
---|
136 | KHLP_DECL(char *) kHlpStrPCopy(char *psz1, const char *psz2);
|
---|
137 | #endif
|
---|
138 | #ifndef kHlpStrLen
|
---|
139 | KHLP_DECL(KSIZE) kHlpStrLen(const char *psz1);
|
---|
140 | #endif
|
---|
141 | #ifndef kHlpStrNLen
|
---|
142 | KHLP_DECL(KSIZE) kHlpStrNLen(const char *psz, KSIZE cchMax);
|
---|
143 | #endif
|
---|
144 |
|
---|
145 | KHLP_DECL(char *) kHlpInt2Ascii(char *psz, KSIZE cch, long lVal, unsigned iBase);
|
---|
146 |
|
---|
147 | #ifdef __cplusplus
|
---|
148 | }
|
---|
149 | #endif
|
---|
150 |
|
---|
151 | #endif
|
---|
152 |
|
---|