| 1 | /* $Id: kHlpCRTString.cpp 3587 2007-09-04 20:47:59Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * kHlpString - String And Memory Routines, CRT based implementation.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /*
|
|---|
| 7 | * Copyright (c) 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
|
|---|
| 12 | * modify it under the terms of the GNU Lesser General Public
|
|---|
| 13 | * License as published by the Free Software Foundation; either
|
|---|
| 14 | * version 2.1 of the License, or (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 GNU
|
|---|
| 19 | * Lesser General Public License for more details.
|
|---|
| 20 | *
|
|---|
| 21 | * You should have received a copy of the GNU Lesser General Public
|
|---|
| 22 | * License along with kStuff; if not, write to the Free Software
|
|---|
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|---|
| 24 | *
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | /*******************************************************************************
|
|---|
| 28 | * Header Files *
|
|---|
| 29 | *******************************************************************************/
|
|---|
| 30 | #include <k/kHlpString.h>
|
|---|
| 31 | #include <string.h>
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | #ifndef kHlpMemChr
|
|---|
| 35 | void *kHlpMemChr(const void *pv, int ch, KSIZE cb)
|
|---|
| 36 | {
|
|---|
| 37 | return (void *)memchr(pv, ch, cb);
|
|---|
| 38 | }
|
|---|
| 39 | #endif
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | #ifndef kHlpMemComp
|
|---|
| 43 | int kHlpMemComp(const void *pv1, const void *pv2, KSIZE cb)
|
|---|
| 44 | {
|
|---|
| 45 | return memcmp(pv1, pv2, cb);
|
|---|
| 46 | }
|
|---|
| 47 | #endif
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 | #ifndef kHlpMemCopy
|
|---|
| 51 | void *kHlpMemCopy(void *pv1, const void *pv2, KSIZE cb)
|
|---|
| 52 | {
|
|---|
| 53 | return memcpy(pv1, pv2, cb);
|
|---|
| 54 | }
|
|---|
| 55 | #endif
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 | #ifndef kHlpMemPCopy
|
|---|
| 59 | void *kHlpMemPCopy(void *pv1, const void *pv2, KSIZE cb)
|
|---|
| 60 | {
|
|---|
| 61 | return (KU8 *)memcpy(pv1, pv2, cb) + cb;
|
|---|
| 62 | }
|
|---|
| 63 | #endif
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | #ifndef kHlpMemMove
|
|---|
| 67 | void *kHlpMemMove(void *pv1, const void *pv2, KSIZE cb)
|
|---|
| 68 | {
|
|---|
| 69 | return memmove(pv1, pv2, cb);
|
|---|
| 70 | }
|
|---|
| 71 | #endif
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | #ifndef kHlpMemPMove
|
|---|
| 75 | void *kHlpMemPMove(void *pv1, const void *pv2, KSIZE cb)
|
|---|
| 76 | {
|
|---|
| 77 | return (KU8 *)memmove(pv1, pv2, cb) + cb;
|
|---|
| 78 | }
|
|---|
| 79 | #endif
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | #ifndef kHlpMemSet
|
|---|
| 83 | void *kHlpMemSet(void *pv1, int ch, KSIZE cb)
|
|---|
| 84 | {
|
|---|
| 85 | return memset(pv1, ch, cb);
|
|---|
| 86 | }
|
|---|
| 87 | #endif
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | #ifndef kHlpMemPSet
|
|---|
| 91 | void *kHlpMemPSet(void *pv1, int ch, KSIZE cb)
|
|---|
| 92 | {
|
|---|
| 93 | return (KU8 *)memset(pv1, ch, cb) + cb;
|
|---|
| 94 | }
|
|---|
| 95 | #endif
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | #ifndef kHlpStrCat
|
|---|
| 99 | char *kHlpStrCat(char *psz1, const char *psz2)
|
|---|
| 100 | {
|
|---|
| 101 | return strcat(psz1, psz2);
|
|---|
| 102 | }
|
|---|
| 103 | #endif
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | #ifndef kHlpStrNCat
|
|---|
| 107 | char *kHlpStrNCat(char *psz1, const char *psz2, KSIZE cb)
|
|---|
| 108 | {
|
|---|
| 109 | return strncat(psz1, psz2, cb);
|
|---|
| 110 | }
|
|---|
| 111 | #endif
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 | #ifndef kHlpStrChr
|
|---|
| 115 | char *kHlpStrChr(const char *psz, int ch)
|
|---|
| 116 | {
|
|---|
| 117 | return (char *)strchr(psz, ch);
|
|---|
| 118 | }
|
|---|
| 119 | #endif
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | #ifndef kHlpStrRChr
|
|---|
| 123 | char *kHlpStrRChr(const char *psz, int ch)
|
|---|
| 124 | {
|
|---|
| 125 | return (char *)strrchr(psz, ch);
|
|---|
| 126 | }
|
|---|
| 127 | #endif
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | #ifndef kHlpStrComp
|
|---|
| 131 | int kHlpStrComp(const char *psz1, const char *psz2)
|
|---|
| 132 | {
|
|---|
| 133 | return strcmp(psz1, psz2);
|
|---|
| 134 | }
|
|---|
| 135 | #endif
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 | #ifndef kHlpStrNComp
|
|---|
| 139 | int kHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch)
|
|---|
| 140 | {
|
|---|
| 141 | return strncmp(psz1, psz2, cch);
|
|---|
| 142 | }
|
|---|
| 143 | #endif
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 | #ifndef kHlpStrCopy
|
|---|
| 147 | char *kHlpStrCopy(char *psz1, const char *psz2)
|
|---|
| 148 | {
|
|---|
| 149 | return strcpy(psz1, psz2);
|
|---|
| 150 | }
|
|---|
| 151 | #endif
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 | #ifndef kHlpStrLen
|
|---|
| 155 | KSIZE kHlpStrLen(const char *psz1)
|
|---|
| 156 | {
|
|---|
| 157 | return strlen(psz1);
|
|---|
| 158 | }
|
|---|
| 159 | #endif
|
|---|
| 160 |
|
|---|