[3545] | 1 | /* $Id: kHlpString.h 3574 2007-09-02 19:30:58Z 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 |
|
---|
[3573] | 30 | #include <k/kHlpDefs.h>
|
---|
[3552] | 31 | #include <k/kTypes.h>
|
---|
| 32 |
|
---|
[3546] | 33 | #if 0 /* optimize / fix this later */
|
---|
[3545] | 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
|
---|
[3546] | 67 | #endif /* disabled */
|
---|
[3545] | 68 |
|
---|
| 69 | #ifdef __cplusplus
|
---|
| 70 | extern "C" {
|
---|
| 71 | #endif
|
---|
| 72 |
|
---|
| 73 | #ifndef kHlpMemChr
|
---|
[3574] | 74 | KHLP_DECL(void *) kHlpMemChr(const void *pv, int ch, KSIZE cb);
|
---|
[3545] | 75 | #endif
|
---|
| 76 | #ifndef kHlpMemComp
|
---|
[3574] | 77 | KHLP_DECL(int) kHlpMemComp(const void *pv1, const void *pv2, KSIZE cb);
|
---|
[3545] | 78 | #endif
|
---|
[3574] | 79 | #ifndef kHlpMemComp
|
---|
| 80 | KHLP_DECL(void *) kHlpMemPComp(const void *pv1, const void *pv2, KSIZE cb);
|
---|
| 81 | #endif
|
---|
[3545] | 82 | #ifndef kHlpMemCopy
|
---|
[3574] | 83 | KHLP_DECL(void *) kHlpMemCopy(void *pv1, const void *pv2, KSIZE cb);
|
---|
[3545] | 84 | #endif
|
---|
[3574] | 85 | #ifndef kHlpMemPCopy
|
---|
| 86 | KHLP_DECL(void *) kHlpMemPCopy(void *pv1, const void *pv2, KSIZE cb);
|
---|
| 87 | #endif
|
---|
[3545] | 88 | #ifndef kHlpMemMove
|
---|
[3574] | 89 | KHLP_DECL(void *) kHlpMemMove(void *pv1, const void *pv2, KSIZE cb);
|
---|
[3545] | 90 | #endif
|
---|
[3574] | 91 | #ifndef kHlpMemPMove
|
---|
| 92 | KHLP_DECL(void *) kHlpMemPMove(void *pv1, const void *pv2, KSIZE cb);
|
---|
| 93 | #endif
|
---|
[3545] | 94 | #ifndef kHlpMemSet
|
---|
[3574] | 95 | KHLP_DECL(void *) kHlpMemSet(void *pv1, int ch, KSIZE cb);
|
---|
[3545] | 96 | #endif
|
---|
[3574] | 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);
|
---|
[3545] | 101 |
|
---|
[3550] | 102 | #ifndef kHlpStrCat
|
---|
[3574] | 103 | KHLP_DECL(char *) kHlpStrCat(char *psz1, const char *psz2);
|
---|
[3550] | 104 | #endif
|
---|
[3574] | 105 | #ifndef kHlpStrPCat
|
---|
| 106 | KHLP_DECL(char *) kHlpStrPCat(char *psz1, const char *psz2);
|
---|
| 107 | #endif
|
---|
[3550] | 108 | #ifndef kHlpStrNCat
|
---|
[3574] | 109 | KHLP_DECL(char *) kHlpStrNCat(char *psz1, const char *psz2, KSIZE cb);
|
---|
[3550] | 110 | #endif
|
---|
[3574] | 111 | #ifndef kHlpStrPNCat
|
---|
| 112 | KHLP_DECL(char *) kHlpStrNPCat(char *psz1, const char *psz2, KSIZE cb);
|
---|
| 113 | #endif
|
---|
[3545] | 114 | #ifndef kHlpStrChr
|
---|
[3574] | 115 | KHLP_DECL(char *) kHlpStrChr(const char *psz, int ch);
|
---|
[3545] | 116 | #endif
|
---|
[3550] | 117 | #ifndef kHlpStrRChr
|
---|
[3574] | 118 | KHLP_DECL(char *) kHlpStrRChr(const char *psz, int ch);
|
---|
[3550] | 119 | #endif
|
---|
[3545] | 120 | #ifndef kHlpStrComp
|
---|
[3574] | 121 | KHLP_DECL(int) kHlpStrComp(const char *psz1, const char *psz2);
|
---|
[3545] | 122 | #endif
|
---|
[3574] | 123 | KHLP_DECL(char *) kHlpStrPComp(const char *psz1, const char *psz2);
|
---|
[3545] | 124 | #ifndef kHlpStrNComp
|
---|
[3574] | 125 | KHLP_DECL(int) kHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch);
|
---|
[3545] | 126 | #endif
|
---|
[3574] | 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);
|
---|
[3550] | 132 | #ifndef kHlpStrCopy
|
---|
[3574] | 133 | KHLP_DECL(char *) kHlpStrCopy(char *psz1, const char *psz2);
|
---|
[3550] | 134 | #endif
|
---|
[3574] | 135 | #ifndef kHlpStrPCopy
|
---|
| 136 | KHLP_DECL(char *) kHlpStrPCopy(char *psz1, const char *psz2);
|
---|
[3550] | 137 | #endif
|
---|
[3545] | 138 | #ifndef kHlpStrLen
|
---|
[3574] | 139 | KHLP_DECL(KSIZE) kHlpStrLen(const char *psz1);
|
---|
[3545] | 140 | #endif
|
---|
[3574] | 141 | #ifndef kHlpStrNLen
|
---|
| 142 | KHLP_DECL(KSIZE) kHlpStrNLen(const char *psz, KSIZE cchMax);
|
---|
| 143 | #endif
|
---|
[3545] | 144 |
|
---|
[3573] | 145 | KHLP_DECL(char *) kHlpInt2Ascii(char *psz, KSIZE cch, long lVal, unsigned iBase);
|
---|
| 146 |
|
---|
[3545] | 147 | #ifdef __cplusplus
|
---|
| 148 | }
|
---|
| 149 | #endif
|
---|
| 150 |
|
---|
| 151 | #endif
|
---|
| 152 |
|
---|