Beispiel #1
0
/*---------------------------------DynamicCharConverter::DynamicCharConverter-+
| Build a cross table such that translated = m_x[translatee];                 |
+----------------------------------------------------------------------------*/
DynamicCharConverter::DynamicCharConverter(
   char pad, RexxString const & tableo
) {
   int len = tableo.length();
   if (len > sizeof m_table) len = sizeof m_table;
   memcpy(m_table, tableo, len);
   memset(m_table+len, pad, sizeof m_table - len);
}
Beispiel #2
0
/*-------------------------------------------------------Arguments::Arguments-+
| Constructor for the main program                                            |
|                                                                             |
| IMPLEMENTATION:                                                             |
|   m_r(strArgs)  e.g.: "m_r refers strArgs".  This is just for convenience.  |
|   The main program is not supposed to return anything? Hmmm...              |
|   Consider using the top top top of the stack to return what                |
|   the CT_PROGRAM returned (generally a numeric return code.)                |
|   Also: why is this strArgs the blank-sep "char ** argv"                    |
|   Isn't CT_PROGRAM like anything else?                                      |
|   For today (11/07/2001) PGR has too much on his plate for taking care.     |
+----------------------------------------------------------------------------*/
Arguments::Arguments(RexxString & strArgs) : m_r(strArgs)
{
   memset(m_a, 0, sizeof m_a);
   if (strArgs.length() > 0) {
      m_a[0] = &strArgs;
      m_n = 1;
   }else {
      m_n = 0;
   }
}
Beispiel #3
0
/*---------------------------------DynamicCharConverter::DynamicCharConverter-+
| Build a cross table such that translated = table[translatee];               |
+----------------------------------------------------------------------------*/
DynamicCharConverter::DynamicCharConverter(
   RexxString const & tablei,
   char pad,
   RexxString const & tableo
) {
   for (int i=0; i < sizeof m_table; ++i) {
      m_table[i] = i;    // aka identity, which is the default
   }
   // because of the duplicates rule, do it reverse
   unsigned char const * pIn = (unsigned char const *)((char const *)tablei);
   unsigned char const * pOut = (unsigned char const *)((char const *)tableo);
   unsigned char const * pOutCur = pOut + tableo.length();
   unsigned char const * pInCur = pIn + tablei.length();
   unsigned char const * pInPeg = pIn + tableo.length();
   while (pInCur > pInPeg) {
      m_table[*(--pInCur)] = pad;
   }
   while (pInCur > pIn) {
      m_table[*(--pInCur)] = *(--pOutCur);
   }
}
Beispiel #4
0
/*---------------------------------DynamicCharConverter::DynamicCharConverter-+
| Build a cross table such that translated = table[translatee];               |
+----------------------------------------------------------------------------*/
DynamicCharConverter::DynamicCharConverter(
   RexxString const & tablei, char pad
) {
   for (int i=0; i < sizeof m_table; ++i) {
      m_table[i] = i;    // aka identity, which is the default
   }
   unsigned char const * e_p = (unsigned char const *)(char const *)tablei;
   unsigned char const * c_p = e_p + tablei.length();
   while (c_p > e_p) {
      m_table[*(--c_p)] = pad;
   }
}
Beispiel #5
0
/*----------------------------------------------------Arguments::catenateArgs-+
|                                                                             |
+----------------------------------------------------------------------------*/
RexxString Arguments::catenateArgs(
   RexxString const & cmd,
   RexxString ** stack,
   PresenceBits presenceBits,
   int & base                            // initially: top of the stack
) {
   StringBuffer res(cmd, cmd.length());
   int top = base;
   while (presenceBits != 0) {
      if (presenceBits & 1) --base;
      presenceBits >>= 1;
   }
   for (int i=base+1; i <= top; ++i) {   // stack[base] is the result
      res.append(' ');
      res .append(*stack[i], stack[i]->length());
   }
   return res;
}
Beispiel #6
0
/*-----------------------------------------------CIRexxApp::addRecordsToIndex-+
|                                                                             |
+----------------------------------------------------------------------------*/
void CIRexxApp::addRecordsToIndex(CArray<ScriptRecord *> & records, CDatabase * db, UInt16 cat, char * dbi)
{
   UInt16 index = 0;
   UInt32 rowId;
   MemHandle hMem;
   Int16 recordPosition = 0;
   CHash<unsigned int, Int16> recordPositionBySegmentId;
   ScriptRecord * scriptRecord;

   if (db == 0) { return; }
   while ((hMem = db->QueryNextInCategory(index, cat))) {
      db->GetRecordUniqueID(index, rowId);
      UInt32 size = MemHandleSize(hMem);
      const char * pMem = (char *)MemHandleLock(hMem);
      /*
      | FORMAT:
      | %6s #segment.<no>#\ndate() time() <id>\nTitle: <tit>\nCategory: <cat>
      */
      char * scanner;
      if (                    // if it's segmented, combine the segments
         (scanner = StrStr(pMem, "#segment.")) &&
         (scanner = StrChr(scanner + 1, '#'))
      ) {
         char segmentNoAsString[5];
         memcpy(segmentNoAsString, scanner - 4, 4);
         segmentNoAsString[4] = '\0';
         int segmentNo = StrAToI(segmentNoAsString);
         ++scanner;
         int peditHeaderSize = size - (scanner - pMem);
         if (peditHeaderSize > ScriptRecord::MAX_PEDITHEADERLEN) {
            peditHeaderSize = ScriptRecord::MAX_PEDITHEADERLEN;
         }
         RexxString header(scanner, peditHeaderSize);
         RexxString segmentIdAsString;
         segmentIdAsString.wordAt(header, 3);
         unsigned int segmentId = hex2uint(
            (char const *)segmentIdAsString, segmentIdAsString.length()
         );
         int titWordNo = RexxString("Title:").wordpos(header, 1);
         int catWordNo = RexxString("Category:").wordpos(header, 1);
         RexxString title;
         title.subword(header, titWordNo + 1, catWordNo - (titWordNo + 1));
         // create the script record
         Int16 * psegmentedRecordPosition = (Int16 *)recordPositionBySegmentId.Lookup(segmentId);
         // if this segment has already been encountered, then create a chain of segments
         if (psegmentedRecordPosition) {
            ScriptRecord * sr = records[*psegmentedRecordPosition];
            sr->m_indexes.Insert(sr->m_indexes.GetCount(), index);
            sr->m_segments.Insert(sr->m_segments.GetCount(), segmentNo);
         // otherwise just add it
         }else {
            scriptRecord = new ScriptRecord(db, dbi, title, index, segmentNo);
            recordPositionBySegmentId.SetAt(segmentId, recordPosition);
            records.Insert(recordPosition++, scriptRecord);
         }
      }else { // otherwise just add it
         unsigned int i;
         for (i=0; pMem[i] && pMem[i] != linefeedChr && i < ScriptRecord::MAX_TITLELEN; ++i) {
            ;
         }
         char * t = new char[i + 1];
         memcpy(t, pMem, i);
         t[i] = '\0';
         RexxString title(t);
         scriptRecord = new ScriptRecord(db, dbi, title, index);
         delete [] t;
         records.Insert(recordPosition++, scriptRecord);
      }
      MemHandleUnlock(hMem);
      ++index;
   }
}
Beispiel #7
0
/*----------------------------------------------------Routine::setEnvironment-+
|                                                                             |
+----------------------------------------------------------------------------*/
void Routine::setEnvironment(RexxString & value) {
   if (value.length() > 250) {
      m_erh << ECE__ERROR << _REX__29_1 << 250 << value << endm;
   }
   m_env = value;
}