/* Ofront+ 1.0 -sC -48 */
#include "SYSTEM.oh"




export void ooc2Strings_Append (CHAR *source, INTEGER source__len, CHAR *destination, INTEGER destination__len);
export void ooc2Strings_Assign (CHAR *source, INTEGER source__len, CHAR *destination, INTEGER destination__len);
export BOOLEAN ooc2Strings_CanAppendAll (INTEGER sourceLength, CHAR *destination, INTEGER destination__len);
export BOOLEAN ooc2Strings_CanAssignAll (INTEGER sourceLength, CHAR *destination, INTEGER destination__len);
export BOOLEAN ooc2Strings_CanConcatAll (INTEGER source1Length, INTEGER source2Length, CHAR *destination, INTEGER destination__len);
export BOOLEAN ooc2Strings_CanDeleteAll (INTEGER stringLength, INTEGER startPos, INTEGER numberToDelete);
export BOOLEAN ooc2Strings_CanExtractAll (INTEGER sourceLength, INTEGER startPos, INTEGER numberToExtract, CHAR *destination, INTEGER destination__len);
export BOOLEAN ooc2Strings_CanInsertAll (INTEGER sourceLength, INTEGER startPos, CHAR *destination, INTEGER destination__len);
export BOOLEAN ooc2Strings_CanReplaceAll (INTEGER sourceLength, INTEGER startPos, CHAR *destination, INTEGER destination__len);
export void ooc2Strings_Capitalize (CHAR *stringVar, INTEGER stringVar__len);
export SHORTINT ooc2Strings_Compare (CHAR *stringVal1, INTEGER stringVal1__len, CHAR *stringVal2, INTEGER stringVal2__len);
export void ooc2Strings_Concat (CHAR *source1, INTEGER source1__len, CHAR *source2, INTEGER source2__len, CHAR *destination, INTEGER destination__len);
export void ooc2Strings_Delete (CHAR *stringVar, INTEGER stringVar__len, INTEGER startPos, INTEGER numberToDelete);
export BOOLEAN ooc2Strings_Equal (CHAR *stringVal1, INTEGER stringVal1__len, CHAR *stringVal2, INTEGER stringVal2__len);
export void ooc2Strings_Extract (CHAR *source, INTEGER source__len, INTEGER startPos, INTEGER numberToExtract, CHAR *destination, INTEGER destination__len);
export void ooc2Strings_FindDiff (CHAR *stringVal1, INTEGER stringVal1__len, CHAR *stringVal2, INTEGER stringVal2__len, BOOLEAN *differenceFound, INTEGER *posOfDifference);
export void ooc2Strings_FindNext (CHAR *pattern, INTEGER pattern__len, CHAR *stringToSearch, INTEGER stringToSearch__len, INTEGER startPos, BOOLEAN *patternFound, INTEGER *posOfPattern);
export void ooc2Strings_FindPrev (CHAR *pattern, INTEGER pattern__len, CHAR *stringToSearch, INTEGER stringToSearch__len, INTEGER startPos, BOOLEAN *patternFound, INTEGER *posOfPattern);
export void ooc2Strings_Insert (CHAR *source, INTEGER source__len, INTEGER startPos, CHAR *destination, INTEGER destination__len);
export INTEGER ooc2Strings_Length (CHAR *stringVal, INTEGER stringVal__len);
export void ooc2Strings_Replace (CHAR *source, INTEGER source__len, INTEGER startPos, CHAR *destination, INTEGER destination__len);


/*============================================================================*/

INTEGER ooc2Strings_Length (CHAR *stringVal, INTEGER stringVal__len)
{
  INTEGER i;
  i = 0;
  while (stringVal[__X(i, stringVal__len, (CHAR*)"ooc2Strings", 16157)] != 0x00) {
    i += 1;
  }
  return i;
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_Assign (CHAR *source, INTEGER source__len, CHAR *destination, INTEGER destination__len)
{
  INTEGER i;
  i = -1;
  do {
    i += 1;
    destination[__X(i, destination__len, (CHAR*)"ooc2Strings", 20991)] = source[__X(i, source__len, (CHAR*)"ooc2Strings", 20991)];
  } while (!(destination[__X(i, destination__len, (CHAR*)"ooc2Strings", 20991)] == 0x00 || i == destination__len - 1));
  destination[__X(i, destination__len, (CHAR*)"ooc2Strings", 21503)] = 0x00;
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_Extract (CHAR *source, INTEGER source__len, INTEGER startPos, INTEGER numberToExtract, CHAR *destination, INTEGER destination__len)
{
  INTEGER sourceLength, i;
  sourceLength = ooc2Strings_Length((void*)source, source__len);
  if (startPos > sourceLength) {
    startPos = sourceLength;
  }
  if (numberToExtract >= destination__len) {
    numberToExtract = destination__len - 1;
  }
  i = 0;
  while (i < numberToExtract && source[__X(startPos + i, source__len, (CHAR*)"ooc2Strings", 29243)] != 0x00) {
    destination[__X(i, destination__len, (CHAR*)"ooc2Strings", 29482)] = source[__X(startPos + i, source__len, (CHAR*)"ooc2Strings", 29482)];
    i += 1;
  }
  destination[__X(i, destination__len, (CHAR*)"ooc2Strings", 30463)] = 0x00;
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_Delete (CHAR *stringVar, INTEGER stringVar__len, INTEGER startPos, INTEGER numberToDelete)
{
  INTEGER stringLength, i, _for__14;
  stringLength = ooc2Strings_Length((void*)stringVar, stringVar__len);
  if (startPos + numberToDelete < stringLength) {
    _for__14 = stringLength - numberToDelete;
    i = startPos;
    while (i <= _for__14) {
      stringVar[__X(i, stringVar__len, (CHAR*)"ooc2Strings", 35839)] = stringVar[__X(i + numberToDelete, stringVar__len, (CHAR*)"ooc2Strings", 35839)];
      i += 1;
    }
  } else if (startPos < stringLength) {
    stringVar[__X(startPos, stringVar__len, (CHAR*)"ooc2Strings", 36607)] = 0x00;
  }
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_Insert (CHAR *source, INTEGER source__len, INTEGER startPos, CHAR *destination, INTEGER destination__len)
{
  INTEGER sourceLength, destLength, destMax, i, _for__22, _for__21;
  destLength = ooc2Strings_Length((void*)destination, destination__len);
  sourceLength = ooc2Strings_Length((void*)source, source__len);
  destMax = destination__len - 1;
  if (startPos + sourceLength < destMax) {
    if (destLength + sourceLength > destMax) {
      destLength = destMax - sourceLength;
      destination[__X(destLength, destination__len, (CHAR*)"ooc2Strings", 44031)] = 0x00;
    }
    _for__22 = startPos;
    i = destLength;
    while (i >= _for__22) {
      destination[__X(i + sourceLength, destination__len, (CHAR*)"ooc2Strings", 45311)] = destination[__X(i, destination__len, (CHAR*)"ooc2Strings", 45311)];
      i += -1;
    }
  } else if (startPos <= destLength) {
    destination[__X(destMax, destination__len, (CHAR*)"ooc2Strings", 46112)] = 0x00;
    sourceLength = destMax - startPos;
  } else {
    sourceLength = 0;
  }
  _for__21 = sourceLength - 1;
  i = 0;
  while (i <= _for__21) {
    destination[__X(startPos + i, destination__len, (CHAR*)"ooc2Strings", 48127)] = source[__X(i, source__len, (CHAR*)"ooc2Strings", 48127)];
    i += 1;
  }
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_Replace (CHAR *source, INTEGER source__len, INTEGER startPos, CHAR *destination, INTEGER destination__len)
{
  INTEGER destLength, i;
  destLength = ooc2Strings_Length((void*)destination, destination__len);
  if (startPos < destLength) {
    i = 0;
    while (startPos != destLength && source[__X(i, source__len, (CHAR*)"ooc2Strings", 54070)] != 0x00) {
      destination[__X(startPos, destination__len, (CHAR*)"ooc2Strings", 54314)] = source[__X(i, source__len, (CHAR*)"ooc2Strings", 54314)];
      startPos += 1;
      i += 1;
    }
  }
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_Append (CHAR *source, INTEGER source__len, CHAR *destination, INTEGER destination__len)
{
  INTEGER destLength, i;
  destLength = ooc2Strings_Length((void*)destination, destination__len);
  i = 0;
  while (destLength < destination__len - 1 && source[__X(i, source__len, (CHAR*)"ooc2Strings", 57919)] != 0x00) {
    destination[__X(destLength, destination__len, (CHAR*)"ooc2Strings", 58154)] = source[__X(i, source__len, (CHAR*)"ooc2Strings", 58154)];
    destLength += 1;
    i += 1;
  }
  destination[__X(destLength, destination__len, (CHAR*)"ooc2Strings", 59391)] = 0x00;
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_Concat (CHAR *source1, INTEGER source1__len, CHAR *source2, INTEGER source2__len, CHAR *destination, INTEGER destination__len)
{
  INTEGER i, j;
  i = 0;
  while (source1[__X(i, source1__len, (CHAR*)"ooc2Strings", 62262)] != 0x00 && i < destination__len - 1) {
    destination[__X(i, destination__len, (CHAR*)"ooc2Strings", 62498)] = source1[__X(i, source1__len, (CHAR*)"ooc2Strings", 62498)];
    i += 1;
  }
  j = 0;
  while (source2[__X(j, source2__len, (CHAR*)"ooc2Strings", 64055)] != 0x00 && i < destination__len - 1) {
    destination[__X(i, destination__len, (CHAR*)"ooc2Strings", 64290)] = source2[__X(j, source2__len, (CHAR*)"ooc2Strings", 64290)];
    j += 1;
    i += 1;
  }
  destination[__X(i, destination__len, (CHAR*)"ooc2Strings", 65279)] = 0x00;
}

/*----------------------------------------------------------------------------*/
BOOLEAN ooc2Strings_CanAssignAll (INTEGER sourceLength, CHAR *destination, INTEGER destination__len)
{
  return sourceLength < destination__len;
}

/*----------------------------------------------------------------------------*/
BOOLEAN ooc2Strings_CanExtractAll (INTEGER sourceLength, INTEGER startPos, INTEGER numberToExtract, CHAR *destination, INTEGER destination__len)
{
  return startPos + numberToExtract <= sourceLength && numberToExtract < destination__len;
}

/*----------------------------------------------------------------------------*/
BOOLEAN ooc2Strings_CanDeleteAll (INTEGER stringLength, INTEGER startPos, INTEGER numberToDelete)
{
  return startPos + numberToDelete <= stringLength;
}

/*----------------------------------------------------------------------------*/
BOOLEAN ooc2Strings_CanInsertAll (INTEGER sourceLength, INTEGER startPos, CHAR *destination, INTEGER destination__len)
{
  INTEGER lenDestination;
  lenDestination = ooc2Strings_Length((void*)destination, destination__len);
  return startPos <= lenDestination && sourceLength + lenDestination < destination__len;
}

/*----------------------------------------------------------------------------*/
BOOLEAN ooc2Strings_CanReplaceAll (INTEGER sourceLength, INTEGER startPos, CHAR *destination, INTEGER destination__len)
{
  return sourceLength + startPos <= ooc2Strings_Length((void*)destination, destination__len);
}

/*----------------------------------------------------------------------------*/
BOOLEAN ooc2Strings_CanAppendAll (INTEGER sourceLength, CHAR *destination, INTEGER destination__len)
{
  return ooc2Strings_Length((void*)destination, destination__len) + sourceLength < destination__len;
}

/*----------------------------------------------------------------------------*/
BOOLEAN ooc2Strings_CanConcatAll (INTEGER source1Length, INTEGER source2Length, CHAR *destination, INTEGER destination__len)
{
  return source1Length + source2Length < destination__len;
}

/*----------------------------------------------------------------------------*/
SHORTINT ooc2Strings_Compare (CHAR *stringVal1, INTEGER stringVal1__len, CHAR *stringVal2, INTEGER stringVal2__len)
{
  INTEGER i;
  i = 0;
  while (stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 94272)] != 0x00 && stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 94272)] == stringVal2[__X(i, stringVal2__len, (CHAR*)"ooc2Strings", 94272)]) {
    i += 1;
  }
  if (stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 96767)] < stringVal2[__X(i, stringVal2__len, (CHAR*)"ooc2Strings", 96767)]) {
    return -1;
  } else if (stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 95249)] > stringVal2[__X(i, stringVal2__len, (CHAR*)"ooc2Strings", 95249)]) {
    return 1;
  } else {
    return 0;
  }
  __RETCHK((CHAR*)"ooc2Strings", 96511);
}

/*----------------------------------------------------------------------------*/
BOOLEAN ooc2Strings_Equal (CHAR *stringVal1, INTEGER stringVal1__len, CHAR *stringVal2, INTEGER stringVal2__len)
{
  INTEGER i;
  i = 0;
  while (stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 99136)] != 0x00 && stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 99136)] == stringVal2[__X(i, stringVal2__len, (CHAR*)"ooc2Strings", 99136)]) {
    i += 1;
  }
  return stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 100095)] == 0x00 && stringVal2[__X(i, stringVal2__len, (CHAR*)"ooc2Strings", 100095)] == 0x00;
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_FindNext (CHAR *pattern, INTEGER pattern__len, CHAR *stringToSearch, INTEGER stringToSearch__len, INTEGER startPos, BOOLEAN *patternFound, INTEGER *posOfPattern)
{
  INTEGER patternPos;
  if (startPos < ooc2Strings_Length((void*)stringToSearch, stringToSearch__len)) {
    patternPos = 0;
    for (;;) {
      if (pattern[__X(patternPos, pattern__len, (CHAR*)"ooc2Strings", 110847)] == 0x00) {
        *patternFound = 1;
        *posOfPattern = startPos - patternPos;
        break;
      } else if (stringToSearch[__X(startPos, stringToSearch__len, (CHAR*)"ooc2Strings", 107519)] == 0x00) {
        *patternFound = 0;
        break;
      } else if (stringToSearch[__X(startPos, stringToSearch__len, (CHAR*)"ooc2Strings", 108543)] == pattern[__X(patternPos, pattern__len, (CHAR*)"ooc2Strings", 108543)]) {
        startPos += 1;
        patternPos += 1;
      } else {
        startPos = (startPos - patternPos) + 1;
        patternPos = 0;
      }
    }
  } else {
    *patternFound = 0;
  }
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_FindPrev (CHAR *pattern, INTEGER pattern__len, CHAR *stringToSearch, INTEGER stringToSearch__len, INTEGER startPos, BOOLEAN *patternFound, INTEGER *posOfPattern)
{
  INTEGER patternPos, stringLength, patternLength;
  stringLength = ooc2Strings_Length((void*)stringToSearch, stringToSearch__len);
  patternLength = ooc2Strings_Length((void*)pattern, pattern__len);
  if (startPos > stringLength - patternLength) {
    startPos = stringLength - patternLength;
  }
  if (startPos >= 0) {
    patternPos = 0;
    for (;;) {
      if (pattern[__X(patternPos, pattern__len, (CHAR*)"ooc2Strings", 123903)] == 0x00) {
        *patternFound = 1;
        *posOfPattern = startPos - patternPos;
        break;
      } else if (stringToSearch[__X(startPos, stringToSearch__len, (CHAR*)"ooc2Strings", 120319)] != pattern[__X(patternPos, pattern__len, (CHAR*)"ooc2Strings", 120319)]) {
        if (startPos > patternPos) {
          startPos = (startPos - patternPos) - 1;
          patternPos = 0;
        } else {
          *patternFound = 0;
          break;
        }
      } else {
        startPos += 1;
        patternPos += 1;
      }
    }
  } else {
    *patternFound = 0;
  }
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_FindDiff (CHAR *stringVal1, INTEGER stringVal1__len, CHAR *stringVal2, INTEGER stringVal2__len, BOOLEAN *differenceFound, INTEGER *posOfDifference)
{
  INTEGER i;
  i = 0;
  while (stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 128576)] != 0x00 && stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 128576)] == stringVal2[__X(i, stringVal2__len, (CHAR*)"ooc2Strings", 128576)]) {
    i += 1;
  }
  *differenceFound = stringVal1[__X(i, stringVal1__len, (CHAR*)"ooc2Strings", 129347)] != 0x00 || stringVal2[__X(i, stringVal2__len, (CHAR*)"ooc2Strings", 129347)] != 0x00;
  if (*differenceFound) {
    *posOfDifference = i;
  }
}

/*----------------------------------------------------------------------------*/
void ooc2Strings_Capitalize (CHAR *stringVar, INTEGER stringVar__len)
{
  INTEGER i;
  i = 0;
  while (stringVar[__X(i, stringVar__len, (CHAR*)"ooc2Strings", 132893)] != 0x00) {
    stringVar[__X(i, stringVar__len, (CHAR*)"ooc2Strings", 133160)] = __CAP(stringVar[__X(i, stringVar__len, (CHAR*)"ooc2Strings", 133160)]);
    i += 1;
  }
}

/*----------------------------------------------------------------------------*/

export void *ooc2Strings__init (void)
{
  __DEFMOD;
  __REGMOD("ooc2Strings", 0);
/* BEGIN */
  __ENDMOD;
}
