| 1 | /* $Id: kHlpString.h 3552 2007-08-26 02:15:22Z 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/kDefs.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 | void *kHlpMemChr(const void *pv, int ch, KSIZE cb);
|
|---|
| 75 | #endif
|
|---|
| 76 | #ifndef kHlpMemComp
|
|---|
| 77 | int kHlpMemComp(const void *pv1, const void *pv2, KSIZE cb);
|
|---|
| 78 | #endif
|
|---|
| 79 | #ifndef kHlpMemCopy
|
|---|
| 80 | void *kHlpMemCopy(void *pv1, const void *pv2, KSIZE cb);
|
|---|
| 81 | #endif
|
|---|
| 82 | #ifndef kHlpMemMove
|
|---|
| 83 | void *kHlpMemMove(void *pv1, const void *pv2, KSIZE cb);
|
|---|
| 84 | #endif
|
|---|
| 85 | #ifndef kHlpMemSet
|
|---|
| 86 | void *kHlpMemSet(void *pv1, int ch, KSIZE cb);
|
|---|
| 87 | #endif
|
|---|
| 88 | int kHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb);
|
|---|
| 89 |
|
|---|
| 90 | #ifndef kHlpStrCat
|
|---|
| 91 | char *kHlpStrCat(char *psz1, const char *psz2);
|
|---|
| 92 | #endif
|
|---|
| 93 | #ifndef kHlpStrNCat
|
|---|
| 94 | char *kHlpStrNCat(char *psz1, const char *psz2, KSIZE cb);
|
|---|
| 95 | #endif
|
|---|
| 96 | #ifndef kHlpStrChr
|
|---|
| 97 | char *kHlpStrChr(const char *psz, int ch);
|
|---|
| 98 | #endif
|
|---|
| 99 | #ifndef kHlpStrRChr
|
|---|
| 100 | char *kHlpStrRChr(const char *psz, int ch);
|
|---|
| 101 | #endif
|
|---|
| 102 | #ifndef kHlpStrComp
|
|---|
| 103 | int kHlpStrComp(const char *psz1, const char *psz2);
|
|---|
| 104 | #endif
|
|---|
| 105 | #ifndef kHlpStrNComp
|
|---|
| 106 | int kHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch);
|
|---|
| 107 | #endif
|
|---|
| 108 | #ifndef kHlpStrCopy
|
|---|
| 109 | char *kHlpStrCopy(char *psz1, const char *psz2);
|
|---|
| 110 | #endif
|
|---|
| 111 | #ifndef kHlpStrNCopy
|
|---|
| 112 | char *kHlpStrNCopy(char *psz1, const char *psz2, KSIZE cb);
|
|---|
| 113 | #endif
|
|---|
| 114 | #ifndef kHlpStrLen
|
|---|
| 115 | KSIZE kHlpStrLen(const char *psz1);
|
|---|
| 116 | #endif
|
|---|
| 117 | KSIZE kHlpStrNLen(const char *psz, KSIZE cchMax);
|
|---|
| 118 | int kHlpStrIComp(const char *pv1, const char *pv2);
|
|---|
| 119 |
|
|---|
| 120 | #ifdef __cplusplus
|
|---|
| 121 | }
|
|---|
| 122 | #endif
|
|---|
| 123 |
|
|---|
| 124 | #endif
|
|---|
| 125 |
|
|---|