Ignore:
Timestamp:
Aug 31, 2007, 6:09:23 AM (18 years ago)
Author:
bird
Message:

kHlp work...

Location:
trunk/kStuff/kHlp/Bare
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/kStuff/kHlp/Bare/kHlpBareStr.c

    r3570 r3573  
    11/* $Id$ */
    22/** @file
     3 * kHlpBare - String Manipulation.
     4 */
     5
     6/*
     7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
    38 *
    4  * kLdr - The Dynamic Loader, String Helper Functions.
     9 * This file is part of kStuff.
    510 *
    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.
    715 *
     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.
    820 *
    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
    2424 *
    2525 */
    26 
    2726
    2827/*******************************************************************************
    2928*   Header Files                                                               *
    3029*******************************************************************************/
    31 #include <k/kLdr.h>
    32 #include "kLdrHlp.h"
     30#include <k/kHlpString.h>
    3331
    3432
    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)
     33KSIZE  kHlpStrNLen(const char *psz, KSIZE cchMax)
    8434{
    8535    const char * const pszStart = psz;
     
    9040
    9141
    92 int     kLdrHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb)
     42int     kHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb)
    9343{
    9444    const KU8 *pb1 = (const KU8 *)pv1;
     
    11060
    11161
    112 int     kLdrHlpStrIComp(const char *pv1, const char *pv2)
     62int     kHlpStrIComp(const char *pv1, const char *pv2)
    11363{
    11464    const KU8 *pb1 = (const KU8 *)pv1;
     
    13282
    13383
    134 #ifdef kLdrHlpStrChr_needed
    135 char   *kLdrHlpStrChr(const char *psz, int ch)
     84#ifdef kHlpStrChr_needed
     85char   *kHlpStrChr(const char *psz, int ch)
    13686{
    13787    while (*psz)
     
    14696
    14797
    148 #ifdef kLdrHlpMemChr_needed
    149 void   *kLdrHlpMemChr(const void *pv, int ch, KSIZE cb)
     98#ifdef kHlpMemChr_needed
     99void   *kHlpMemChr(const void *pv, int ch, KSIZE cb)
    150100{
    151101    const KU8 *pb = (const KU8 *)pv;
     
    162112
    163113
    164 #ifdef kLdrHlpMemMove_needed
    165 void   *kLdrHlpMemMove(void *pv1, const void *pv2, KSIZE cb)
     114#ifdef kHlpMemMove_needed
     115void   *kHlpMemMove(void *pv1, const void *pv2, KSIZE cb)
    166116{
    167117    KU8            *pbDst = (KU8 *)pv1;
     
    177127
    178128
    179 #ifdef kLdrHlpStrNComp_needed
    180 int     kLdrHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch)
     129#ifdef kHlpStrNComp_needed
     130int     kHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch)
    181131{
    182132    while (cch-- > 0)
Note: See TracChangeset for help on using the changeset viewer.