/*
        cstring.cpp

        V2.00 - 180297  Kimmo Teräväinen
        -----   ------  ----------------
        See cstring.h

*/

#include "cstring.h"

int cstring::cstrlength(const char *text) const
{
  int i=0;
  if(text) for(i=0; text[i] ; i++ );
  return i;
}

void cstring::cstrcopy(const char *src,char *dest,int Size)
{
  if(Size<=0 || !dest) return;
  dest[0]=0;
  if(src) {
    for(int i=0; i<Size ; i++)
      if((dest[i]=src[i]) == 0) break;
    dest[Size-1]=0;
  }
}

char cstring::lastchar() const
{
  if(data) {
    int l=length()-1;
    if(l>=0) return data[l];
  }
  return 0;
}

int cstring::operator==(const char *text) const
{
  int i,l=cstrlength(text);
  if(length() != l) return FALSE;
  for(i=0; i<l; i++) if(data[i]!=text[i]) return FALSE;
  return TRUE;
}