Changeset 3573 for trunk/kStuff/kHlp/Bare/kHlpBareStr.c
- Timestamp:
- Aug 31, 2007, 6:09:23 AM (18 years ago)
- Location:
- trunk/kStuff/kHlp/Bare
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kHlp/Bare/kHlpBareStr.c
r3570 r3573 1 1 /* $Id$ */ 2 2 /** @file 3 * kHlpBare - String Manipulation. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kLdr - The Dynamic Loader, String Helper Functions.9 * This file is part of kStuff. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-kbuild-src@anduin.net> 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. 7 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. 8 20 * 9 * This file is part of kLdr. 10 * 11 * kLdr is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLdr 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 General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLdr; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 24 * 25 25 */ 26 27 26 28 27 /******************************************************************************* 29 28 * Header Files * 30 29 *******************************************************************************/ 31 #include <k/kLdr.h> 32 #include "kLdrHlp.h" 30 #include <k/kHlpString.h> 33 31 34 32 35 /** 36 * Converts an signed integer to an ascii string. 37 * 38 * @returns psz. 39 * @param psz Pointer to the output buffer. 40 * @param cch The size of the output buffer. 41 * @param lVal The value. 42 * @param iBase The base to format it. (2,8,10 or 16) 43 */ 44 char *kldrHlpInt2Ascii(char *psz, KSIZE cch, long lVal, unsigned iBase) 45 { 46 static const char s_szDigits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; 47 char *pszRet = psz; 48 49 if (cch >= (lVal < 0 ? 3U : 2U) && psz) 50 { 51 /* prefix */ 52 if (lVal < 0) 53 { 54 *psz++ = '-'; 55 cch--; 56 lVal = -lVal; 57 } 58 59 /* the digits */ 60 do 61 { 62 *psz++ = s_szDigits[lVal % iBase]; 63 cch--; 64 lVal /= iBase; 65 } while (lVal && cch > 1); 66 67 /* overflow indicator */ 68 if (lVal) 69 psz[-1] = '+'; 70 } 71 else if (!pszRet) 72 return pszRet; 73 else if (cch < 1 || !pszRet) 74 return pszRet; 75 else 76 *psz++ = '+'; 77 *psz = '\0'; 78 79 return pszRet; 80 } 81 82 83 KSIZE kLdrHlpStrNLen(const char *psz, KSIZE cchMax) 33 KSIZE kHlpStrNLen(const char *psz, KSIZE cchMax) 84 34 { 85 35 const char * const pszStart = psz; … … 90 40 91 41 92 int k LdrHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb)42 int kHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb) 93 43 { 94 44 const KU8 *pb1 = (const KU8 *)pv1; … … 110 60 111 61 112 int k LdrHlpStrIComp(const char *pv1, const char *pv2)62 int kHlpStrIComp(const char *pv1, const char *pv2) 113 63 { 114 64 const KU8 *pb1 = (const KU8 *)pv1; … … 132 82 133 83 134 #ifdef k LdrHlpStrChr_needed135 char *k LdrHlpStrChr(const char *psz, int ch)84 #ifdef kHlpStrChr_needed 85 char *kHlpStrChr(const char *psz, int ch) 136 86 { 137 87 while (*psz) … … 146 96 147 97 148 #ifdef k LdrHlpMemChr_needed149 void *k LdrHlpMemChr(const void *pv, int ch, KSIZE cb)98 #ifdef kHlpMemChr_needed 99 void *kHlpMemChr(const void *pv, int ch, KSIZE cb) 150 100 { 151 101 const KU8 *pb = (const KU8 *)pv; … … 162 112 163 113 164 #ifdef k LdrHlpMemMove_needed165 void *k LdrHlpMemMove(void *pv1, const void *pv2, KSIZE cb)114 #ifdef kHlpMemMove_needed 115 void *kHlpMemMove(void *pv1, const void *pv2, KSIZE cb) 166 116 { 167 117 KU8 *pbDst = (KU8 *)pv1; … … 177 127 178 128 179 #ifdef k LdrHlpStrNComp_needed180 int k LdrHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch)129 #ifdef kHlpStrNComp_needed 130 int kHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch) 181 131 { 182 132 while (cch-- > 0)
Note:
See TracChangeset
for help on using the changeset viewer.