[3552] | 1 | /* $Id: kHlpCRTString.cpp 3607 2007-10-29 00:48:50Z bird $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * kHlpString - String And Memory Routines, CRT based implementation.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[3607] | 7 | * Copyright (c) 2006-2007 knut st. osmundsen <bird-kStuff-spam@anduin.net>
|
---|
[3552] | 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 | *
|
---|
[3607] | 16 | * In addition to the permissions in the GNU Lesser General Public
|
---|
| 17 | * License, you are granted unlimited permission to link the compiled
|
---|
| 18 | * version of this file into combinations with other programs, and to
|
---|
| 19 | * distribute those combinations without any restriction coming from
|
---|
| 20 | * the use of this file.
|
---|
| 21 | *
|
---|
[3552] | 22 | * kStuff is distributed in the hope that it will be useful,
|
---|
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 25 | * Lesser General Public License for more details.
|
---|
| 26 | *
|
---|
| 27 | * You should have received a copy of the GNU Lesser General Public
|
---|
| 28 | * License along with kStuff; if not, write to the Free Software
|
---|
[3607] | 29 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
---|
| 30 | * 02110-1301, USA
|
---|
[3552] | 31 | */
|
---|
| 32 |
|
---|
| 33 | /*******************************************************************************
|
---|
| 34 | * Header Files *
|
---|
| 35 | *******************************************************************************/
|
---|
| 36 | #include <k/kHlpString.h>
|
---|
| 37 | #include <string.h>
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | #ifndef kHlpMemChr
|
---|
| 41 | void *kHlpMemChr(const void *pv, int ch, KSIZE cb)
|
---|
| 42 | {
|
---|
[3587] | 43 | return (void *)memchr(pv, ch, cb);
|
---|
[3552] | 44 | }
|
---|
| 45 | #endif
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | #ifndef kHlpMemComp
|
---|
| 49 | int kHlpMemComp(const void *pv1, const void *pv2, KSIZE cb)
|
---|
| 50 | {
|
---|
| 51 | return memcmp(pv1, pv2, cb);
|
---|
| 52 | }
|
---|
| 53 | #endif
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | #ifndef kHlpMemCopy
|
---|
| 57 | void *kHlpMemCopy(void *pv1, const void *pv2, KSIZE cb)
|
---|
| 58 | {
|
---|
| 59 | return memcpy(pv1, pv2, cb);
|
---|
| 60 | }
|
---|
| 61 | #endif
|
---|
| 62 |
|
---|
| 63 |
|
---|
[3575] | 64 | #ifndef kHlpMemPCopy
|
---|
| 65 | void *kHlpMemPCopy(void *pv1, const void *pv2, KSIZE cb)
|
---|
| 66 | {
|
---|
| 67 | return (KU8 *)memcpy(pv1, pv2, cb) + cb;
|
---|
| 68 | }
|
---|
| 69 | #endif
|
---|
| 70 |
|
---|
| 71 |
|
---|
[3552] | 72 | #ifndef kHlpMemMove
|
---|
| 73 | void *kHlpMemMove(void *pv1, const void *pv2, KSIZE cb)
|
---|
| 74 | {
|
---|
| 75 | return memmove(pv1, pv2, cb);
|
---|
| 76 | }
|
---|
| 77 | #endif
|
---|
| 78 |
|
---|
| 79 |
|
---|
[3575] | 80 | #ifndef kHlpMemPMove
|
---|
| 81 | void *kHlpMemPMove(void *pv1, const void *pv2, KSIZE cb)
|
---|
| 82 | {
|
---|
| 83 | return (KU8 *)memmove(pv1, pv2, cb) + cb;
|
---|
| 84 | }
|
---|
| 85 | #endif
|
---|
| 86 |
|
---|
| 87 |
|
---|
[3552] | 88 | #ifndef kHlpMemSet
|
---|
| 89 | void *kHlpMemSet(void *pv1, int ch, KSIZE cb)
|
---|
| 90 | {
|
---|
| 91 | return memset(pv1, ch, cb);
|
---|
| 92 | }
|
---|
| 93 | #endif
|
---|
| 94 |
|
---|
| 95 |
|
---|
[3575] | 96 | #ifndef kHlpMemPSet
|
---|
| 97 | void *kHlpMemPSet(void *pv1, int ch, KSIZE cb)
|
---|
| 98 | {
|
---|
| 99 | return (KU8 *)memset(pv1, ch, cb) + cb;
|
---|
| 100 | }
|
---|
| 101 | #endif
|
---|
| 102 |
|
---|
| 103 |
|
---|
[3552] | 104 | #ifndef kHlpStrCat
|
---|
| 105 | char *kHlpStrCat(char *psz1, const char *psz2)
|
---|
| 106 | {
|
---|
| 107 | return strcat(psz1, psz2);
|
---|
| 108 | }
|
---|
| 109 | #endif
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 | #ifndef kHlpStrNCat
|
---|
| 113 | char *kHlpStrNCat(char *psz1, const char *psz2, KSIZE cb)
|
---|
| 114 | {
|
---|
| 115 | return strncat(psz1, psz2, cb);
|
---|
| 116 | }
|
---|
| 117 | #endif
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 | #ifndef kHlpStrChr
|
---|
| 121 | char *kHlpStrChr(const char *psz, int ch)
|
---|
| 122 | {
|
---|
[3587] | 123 | return (char *)strchr(psz, ch);
|
---|
[3552] | 124 | }
|
---|
| 125 | #endif
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 | #ifndef kHlpStrRChr
|
---|
| 129 | char *kHlpStrRChr(const char *psz, int ch)
|
---|
| 130 | {
|
---|
[3587] | 131 | return (char *)strrchr(psz, ch);
|
---|
[3552] | 132 | }
|
---|
| 133 | #endif
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 | #ifndef kHlpStrComp
|
---|
| 137 | int kHlpStrComp(const char *psz1, const char *psz2)
|
---|
| 138 | {
|
---|
| 139 | return strcmp(psz1, psz2);
|
---|
| 140 | }
|
---|
| 141 | #endif
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | #ifndef kHlpStrNComp
|
---|
| 145 | int kHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch)
|
---|
| 146 | {
|
---|
| 147 | return strncmp(psz1, psz2, cch);
|
---|
| 148 | }
|
---|
| 149 | #endif
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 | #ifndef kHlpStrCopy
|
---|
| 153 | char *kHlpStrCopy(char *psz1, const char *psz2)
|
---|
| 154 | {
|
---|
| 155 | return strcpy(psz1, psz2);
|
---|
| 156 | }
|
---|
| 157 | #endif
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 | #ifndef kHlpStrLen
|
---|
| 161 | KSIZE kHlpStrLen(const char *psz1)
|
---|
| 162 | {
|
---|
| 163 | return strlen(psz1);
|
---|
| 164 | }
|
---|
| 165 | #endif
|
---|
| 166 |
|
---|