Subversion Repositories WoWGM

Rev

Rev 3 | Rev 13 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include "../H/STPL.h"


/****************************************************************************
*
*       Private functions
*
***/

//===========================================================================
int ToLower(int ch)
{
        if (ch > 64 && ch < 91)
                ch+=32;
        return ch;
}

//===========================================================================
int ToUpper(int ch)
{
        if (ch > 96 && ch < 123)
                ch-=32;
        return ch;
}


/****************************************************************************
*
*       External functions
*
***/

//===========================================================================
char const* SStrChr(char const* string, char ch)
{
        // TODO: ASSERT(string);
        if (*string == 0)
                return 0;
        char const* copy = string;
        char currChar = *string;
        while (currChar != ch) {
                currChar = *++copy;
                if (currChar == 0)
                        return 0;
        }
        return copy;
}

//===========================================================================
char* SStrChr(char* string, char ch)
{
        // TODO: ASSERT(string);
        if (*string == 0)
                return 0;
        char* copy = string;
        char currChar = *string;
        while (currChar != ch) {
                currChar = *++copy;
                if (currChar == 0)
                        return 0;
        }
        return copy;
}

//===========================================================================
extern char const* SStrChrR(char const* string, char ch)
{
        return 0;
}

//===========================================================================
extern char* SStrChrR(char* string, char ch)
{
        return 0;
}

//===========================================================================
extern DWORD SStrCopy(char* dest, char const* source, DWORD destsize)
{
        // TODO: ASSERT(dest);
        // TODO: ASSERT(source);

        DWORD i;
        for (i = 0; i < destsize; i++)
        {
                dest[i] = source[i];
                if (*source == '\0')
                        break;
        }
        return i;
}

//===========================================================================
extern int SStrCmp(char const* string1, char const* string2, DWORD maxchars)
{
        // TODO: ASSERT(string1);
        // TODO: ASSERT(string2);
        return 0;
}

//===========================================================================
extern int SStrCmpI(char const* string1, char const* string2, DWORD maxchars)
{
        // TODO: ASSERT(string1);
        // TODO: ASSERT(string2);
        return 0;
}

//===========================================================================
inline DWORD SStrLen(char const* string)
{
        // TODO: ASSERT(string);

        char const* i;
        for (i = string; *i; ++i);
        return static_cast<DWORD>(i - string);
}

//===========================================================================
inline DWORD SStrLen(unsigned short const* string)
{
        // TODO: ASSERT(string);

        unsigned short const* i;
        for (i = string; *i; ++i);
        return static_cast<DWORD>(i - string);
}

//===========================================================================
void SStrLower(char* string)
{
        // TODO: ASSERT(string);
        while(*string)
        {
                *string = ToLower(*string);
                ++string;
        }
}

//===========================================================================
void SStrUpper(char* string)
{
        // TODO: ASSERT(string);
        while(*string)
        {
                *string = ToUpper(*string);
                ++string;
        }
}