home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vgserv45.zip / BASE / HPTWGS2 / include / fcwcmn.h < prev    next >
C/C++ Source or Header  |  2001-03-21  |  26KB  |  940 lines

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /*                           OCO SOURCE MATERIALS                            */
  4. /*                             IBM CONFIDENTIAL                              */
  5. /*                                    OR                                     */
  6. /*                        IBM CONFIDENTIAL RESTRICTED                        */
  7. /*            WHEN COMBINED WITH THE AGGREGATED OCO SOURCE MODULES           */
  8. /*                           FOR THIS PROGRAM PRODUCT                        */
  9. /*                                                                           */
  10. /*   VisualAge Generator Server for OS/2, AIX, HP-UX, SUN, Windows NT, and   */
  11. /*                      SCO OpenServer  -  Version 4.1                       */
  12. /*                    (C) COPYRIGHT IBM CORP. 1994, 2000                     */
  13. /*                                                                           */
  14. /*****************************************************************************/
  15. /*****************************************************************************/
  16. /*                                                                           */
  17. /*    Date     Userid          Description of problem                        */
  18. /*                                                                           */
  19. /*  04/09/98   koch       F8559   -  Add support for MVS open edit.       @A1*/
  20. /*  08/19/98   proffer    F4070   -  Add support for Sun                     */
  21. /*  05/27/99   proffer    F10913  -  Add Version 4.0 support                 */
  22. /*  08/07/99   Lui        F11712  -  Add Unicode support                  @A2*/
  23. /*  01/19/00   proffer    F12650  -  Add support for SCO Openserver          */
  24. /*                                                                           */
  25. /*****************************************************************************/
  26.  
  27. #ifndef FCWCMN_H
  28. #  define FCWCMN_H
  29.  
  30. #include <stdlib.h>
  31. #include <stdio.h>
  32. #include <string.h>
  33. #include <iostream.h>
  34.  
  35. #include "fcwdbcs.h"
  36.  
  37. #ifndef min
  38. # define min(a, b)  (((a) < (b)) ? (a) : (b))
  39. #endif
  40.  
  41. #ifndef max
  42. # define max(a, b)  (((a) > (b)) ? (a) : (b))
  43. #endif
  44.  
  45. #if defined FCW_UNIX || defined FCW_MVS /* @A1 */
  46. #define CRLFSIZE     1
  47. #else
  48. #define CRLFSIZE     2
  49. #endif
  50.  
  51. // *********************************************************************
  52. // Boolean portable implementation
  53. // *********************************************************************
  54.  
  55. enum BoolState { False=0, True=1 };
  56.  
  57. class Bool
  58. {
  59.   private:
  60.     BoolState state;
  61.  
  62.   public:
  63.     Bool() { state = False; }
  64.     Bool(BoolState st) { state = st; }
  65.     Bool(int st) { state = st ? True : False; }
  66.     operator int() { return state == True ? 1 : 0; }
  67.     Bool& operator = (const Bool& st) { state = st.state; return *this; }
  68.     int operator == (const Bool& st) { return state == st.state; }
  69.     int operator == (BoolState st) { return state == st; }
  70. //  Bool operator || (Bool st) { return int(*this) || int(st); }
  71. //  Bool operator && (Bool st) { return int(*this) && int(st); }
  72.     Bool operator !() { return state ? False : True; }
  73. };
  74.  
  75. // *********************************************************************
  76. // Internal portable string class implementation
  77. // *********************************************************************
  78. class FCWString;
  79.  
  80. class str
  81. {
  82.    friend class FCWString;
  83.  
  84.    protected:
  85.       str(int l=0) :
  86.          size(max(l, 100)),  // 100 is an arbitary amount
  87.          len(l),
  88.          count(1)
  89.       {
  90.          s = new char[size+1];
  91.          s[len]=0;
  92.       }
  93.  
  94.       str(str& o) :
  95.          size(o.size),
  96.          len(o.len),
  97.          count(1)
  98.       {
  99.          s = new char[size+1];
  100.          memcpy(s, o.s, len+1);
  101.       }
  102.  
  103.       ~str()
  104.       {
  105.          delete [] s;
  106.       }
  107.  
  108.  
  109.       int   count;
  110.       int   size;
  111.       int   len;
  112.       char* s;
  113.  
  114.       str&  operator ++(int)
  115.       {
  116.          count++;
  117.          return *this;
  118.       }
  119.       str&  operator --(int)
  120.       {
  121.          count--;
  122.          if (!count)
  123.             delete this;
  124.          return *this;
  125.       }
  126.  
  127.       void re_alloc(int l)
  128.       {
  129.          char* ptmp = new char[l+1];
  130.          memcpy(ptmp, s, len+1);  // include null
  131.          delete [] s;
  132.          s = ptmp;
  133.          size = l;
  134.       }
  135. };
  136.  
  137.  
  138. class FCWString
  139. {
  140.   private:
  141.  
  142.     str* pStr;
  143.  
  144.     void makeunique()
  145.     {
  146.        if (pStr->count > 1)
  147.        {
  148.           str* ptmp = new str(*pStr);
  149.           (*pStr)--;
  150.           pStr = ptmp;
  151.        }
  152.     }
  153.  
  154.   public:
  155.     FCWString()
  156.     {
  157.        pStr = new str;
  158.     }
  159.  
  160.     FCWString(char* s)
  161.     {
  162.        pStr = new str((s) ? strlen(s) : 0);
  163.        if (s)
  164.           strcpy(pStr->s, s);
  165.        else
  166.           pStr->s[0] = 0;
  167.     }
  168.  
  169.     FCWString(char c)
  170.     {
  171.        pStr = new str(sizeof(c));
  172.        pStr->s[0] = c;
  173.        pStr->s[1] = 0;
  174.     }
  175.  
  176.     FCWString(char* s, unsigned l, char pad = ' ')
  177.     {
  178.        pStr = new str(l);
  179.        if (l)
  180.        {
  181.           int strl = (s) ? strlen(s) : 0;
  182.           if (strl)
  183.              strncpy(pStr->s, s, l);
  184.           if (strl < l)
  185.              memset(&(pStr->s[strl]), pad, l - strl);
  186.        }
  187.        pStr->s[l] = 0;
  188.     }
  189.  
  190.     FCWString(char* s, unsigned l, wchar_t pad)
  191.     {
  192.        pStr = new str(l);
  193.        if (l)
  194.        {
  195.           int strl = (s) ? strlen(s) : 0;
  196.           if (strl)
  197.              fcw_strncpy(pStr->s, s, l);
  198.           if (strl < l)
  199.           {
  200.              char* p = &(pStr->s[strl]);
  201.              for (int j = (l - strl)/2; j; j--)
  202.              {
  203.                 wctomb(p, pad);
  204.                 p += MB_CUR_MAX;
  205.              }
  206.           }
  207.        }
  208.        *((short*)&(pStr->s[l])) = 0;
  209.     }
  210.  
  211.     FCWString(int n)
  212.     {
  213.        char x[10];
  214.        sprintf (x, "%d", n);
  215.        pStr = new str(strlen(x));
  216.        strcpy(pStr->s, x);
  217.     }
  218.  
  219.     FCWString(FCWString const& s)
  220.     {
  221.        pStr = s.pStr;
  222.        (*pStr)++;
  223.     }
  224.  
  225.     ~FCWString()
  226.     {
  227.        (*pStr)--;
  228.     }
  229.  
  230. //HP  operator char*()
  231. //  {
  232. //     makeunique();
  233. //     return pStr->s;
  234. //  }
  235.  
  236.     operator char*() const
  237.     {
  238.        return pStr->s;
  239.     }
  240.  
  241.     int operator == (char* s) const
  242.     {
  243.        if (pStr->len != strlen(s))
  244.           return 0;
  245.        else if (pStr->s == s)
  246.           return 1;
  247.        else if (s)
  248.           return (!memcmp(pStr->s, s, pStr->len));
  249.        else
  250.           return 0;
  251.     }
  252.  
  253.     int operator != ( char* s) const
  254.     {
  255.        return !( *this == s );
  256.     }
  257.  
  258.     int operator == (FCWString const& s) const
  259.     {
  260.        if (pStr == s.pStr)
  261.           return 1;
  262.        if (pStr->len != s.pStr->len)
  263.           return 0;
  264.        else
  265.           return (!memcmp(pStr->s, s.pStr->s, pStr->len));
  266.     }
  267.  
  268.     int operator != (FCWString const& s) const
  269.     {
  270.        return !( *this == s );
  271.     }
  272.  
  273.     FCWString& operator = (FCWString const& s)
  274.     {
  275.        if ( pStr != s.pStr )
  276.        {
  277.           (*pStr)--;
  278.           pStr = s.pStr;
  279.           (*pStr)++;
  280.        }
  281.        return *this;
  282.     }
  283.  
  284.     FCWString& operator = (char* s)
  285.     {
  286.        (*pStr)--;
  287.        pStr = new str((s) ? strlen(s) : 0);
  288.        if (s)
  289.           strcpy(pStr->s, s);
  290.        else
  291.           pStr->s[0] = 0;
  292.        return *this;
  293.     }
  294.  
  295.     char& operator [] (int i)
  296.     {
  297.        makeunique();
  298.        return pStr->s[i];   // extend if i>len ?
  299.     }
  300.  
  301.     int Length() const
  302.     {
  303.        return pStr->len;
  304.     }
  305.  
  306.     // indx is zero based
  307.     FCWString  SubString(int indx, int length, char pad=' ') const
  308.     {
  309.        FCWString t(NULL, length, pad);
  310.        if (indx < pStr->len)
  311.        {
  312.           int mlen = min(length, pStr->len - indx);
  313.           memcpy(t.pStr->s, &(pStr->s[indx]), mlen);
  314.        }
  315.        return t;
  316.     }
  317.  
  318.     FCWString& StripLeading(char ch=' ')
  319.     {
  320.        makeunique();
  321.        if (pStr->count > 1)
  322.        {
  323.           str* ptmp = new str(*pStr);
  324.           (*pStr)--;
  325.           pStr = ptmp;
  326.        }
  327.        int i;
  328.        for (i=0; i < pStr->len && pStr->s[i] == ch; i++);
  329.        if (i)
  330.        {
  331.           pStr->len -= i;
  332.           if (pStr->len)
  333.              memcpy(pStr->s, &(pStr->s[i]), pStr->len);
  334.           pStr->s[pStr->len] = 0;
  335.        }
  336.        return *this;
  337.     }
  338.  
  339.     FCWString& StripLeading(FCWString const& s)
  340.     {
  341.        makeunique();
  342.        int i, j;
  343.        for (i=0; i < pStr->len; i++)
  344.        {
  345.           for (j=0; j < s.pStr->len; j++)
  346.              if (pStr->s[i] == s.pStr->s[j])
  347.                 break;
  348.           if (j == s.pStr->len)
  349.              break;
  350.        }
  351.  
  352.        if (i)
  353.        {
  354.           pStr->len -= i;
  355.           if (pStr->len)
  356.              memcpy(pStr->s, &(pStr->s[i]), pStr->len);
  357.           pStr->s[pStr->len] = 0;
  358.        }
  359.        return *this;
  360.     }
  361.  
  362.     FCWString& StripLeading(wchar_t wch)
  363.     {
  364.        short wc;
  365.        wctomb((char*)&wc, wch);
  366.        makeunique();
  367.        short *p;
  368.        for (p=(short*)pStr->s; p < (short*)&(pStr->s[pStr->len]) && *p == wc; p++);
  369.        if (p != (short*)pStr->s)
  370.        {
  371.           pStr->len = (char*)p - pStr->s;
  372.           if (pStr->len)
  373.              fcw_memcpy(pStr->s, p, pStr->len);
  374.           *((short*)&(pStr->s[pStr->len])) = 0;
  375.        }
  376.        return *this;
  377.     }
  378.  
  379.     FCWString& StripTrailing(char ch=' ')
  380.     {
  381.        makeunique();
  382.        int i;
  383.        for (i=pStr->len; i && pStr->s[i-1] == ch; i--);
  384.  
  385.        pStr->len = i;
  386.        pStr->s[pStr->len] = 0;
  387.  
  388.        return *this;
  389.     }
  390.  
  391.     FCWString& StripTrailing(FCWString const& s)
  392.     {
  393.        makeunique();
  394.        int i;
  395.        for (i=pStr->len; i ; i--)
  396.        {
  397.           int j;
  398.           for (j=0; j < s.pStr->len; j++)
  399.              if (pStr->s[i-1] == s.pStr->s[j])
  400.                 break;
  401.           if (j == s.pStr->len)
  402.              break;
  403.        }
  404.  
  405.        pStr->len = i;
  406.        pStr->s[pStr->len] = 0;
  407.  
  408.        return *this;
  409.     }
  410.  
  411.     FCWString& StripTrailing(wchar_t wch)
  412.     {
  413.        short wc;
  414.        wctomb((char*)&wc, wch);
  415.        makeunique();
  416.        short *p;
  417.        for (p=(short*)&(pStr->s[pStr->len-2]); p >= (short*)pStr->s && *p == wc; p--);
  418.        p++;
  419.  
  420.        pStr->len = (char*)p - pStr->s;
  421.        *((short*)&(pStr->s[pStr->len])) = 0;
  422.  
  423.        return *this;
  424.     }
  425.  
  426.     FCWString& Strip(char ch=' ')
  427.     {
  428.        StripTrailing(ch);
  429.        StripLeading(ch);
  430.  
  431.        return *this;
  432.     }
  433.  
  434.     FCWString& Strip(FCWString const &s)
  435.     {
  436.        StripTrailing(s);
  437.        StripLeading(s);
  438.  
  439.        return *this;
  440.     }
  441.  
  442.     FCWString& Strip(wchar_t wch)
  443.     {
  444.        StripTrailing(wch);
  445.        StripLeading(wch);
  446.  
  447.        return *this;
  448.     }
  449.  
  450.     FCWString& RightJustify(int l, char pad=' ')
  451.     {
  452.        Strip();
  453.  
  454.        if (l <= pStr->len)
  455.           pStr->len = l;
  456.        else
  457.           *this = FCWString((char*)NULL, l-pStr->len, pad) + *this;
  458.  
  459.        pStr->s[pStr->len] = 0;
  460.  
  461.        return *this;
  462.     }
  463.  
  464.     FCWString& LeftJustify(int l, char pad=' ')
  465.     {
  466.        Strip();
  467.  
  468.        if (l <= pStr->len)
  469.           pStr->len = l;
  470.        else
  471.           *this += FCWString((char*)NULL, l-pStr->len, pad);
  472.  
  473.        pStr->s[pStr->len] = 0;
  474.  
  475.        return *this;
  476.     }
  477.  
  478.     // startpos and returned value are 0 based
  479.     // A -1 is returned for not found
  480.     int IndexOf(char ch, int startpos = 0) const
  481.     {
  482.        for (int i=startpos; i < pStr->len; i++)
  483.           if (pStr->s[i] == ch)
  484.              return i;
  485.  
  486.        return -1;
  487.     }
  488.  
  489.     // startpos and returned value are 0 based
  490.     // A -1 is returned for not found
  491.     int IndexOf(char* s, int startpos = 0) const
  492.     {
  493.        int slen = (s) ? strlen(s) : 0;
  494.        for (int i=startpos; slen && i < pStr->len-slen+1; i++)
  495.           if (!memcmp(&(pStr->s[i]), s, slen))
  496.              return i;
  497.  
  498.        return -1;
  499.     }
  500.  
  501.     // startpos and returned value are 0 based
  502.     // A -1 is returned for not found
  503.     int IndexOfAnyBut(char* s, int startpos = 0) const
  504.     {
  505.        int i;
  506.        for (i=startpos; s && i < pStr->len; i++)
  507.        {
  508.           int j;
  509.           for (j=0; s[j]; j++)
  510.              if (pStr->s[i] == s[j])
  511.                 break;
  512.           if (j == strlen(s))
  513.              return i;         // the ith character was not found in s
  514.        }
  515.        return -1;
  516.     }
  517.  
  518.     // startpos and returned value are 0 based
  519.     // A -1 is returned for not found
  520.     int IndexOfAnyOf(char* s, int startpos = 0) const
  521.     {
  522.        for (int i=startpos; s && i < pStr->len; i++)
  523.        {
  524.           for (int j=0; s[j]; j++)
  525.              if (pStr->s[i] == s[j])
  526.                 return i;
  527.        }
  528.        return -1;
  529.     }
  530.  
  531.     // startpos is 0 based
  532.     FCWString& Remove(int startpos, int length = 1)
  533.     {
  534.        makeunique();
  535.        if (startpos >=0 && startpos < pStr->len)
  536.        {
  537.           if (length > (pStr->len - startpos))
  538.              length = pStr->len - startpos;
  539.           memcpy(&(pStr->s[startpos]), &(pStr->s[startpos+length]), pStr->len-startpos-length+1);
  540.           pStr->len -= length;
  541.           pStr->s[pStr->len] = 0;
  542.        }
  543.        return *this;
  544.     }
  545.  
  546.     // startpos is 0 based
  547.     int OccurencesOf(char ch, int startpos = 0) const
  548.     {
  549.        int count = 0;
  550.        for (int i=startpos; i < pStr->len; i++)
  551.           if (pStr->s[i] == ch)
  552.              count++;
  553.  
  554.        return count;
  555.     }
  556.  
  557.     // startpos is 0 based
  558.     int OccurencesOf(FCWString& str, int startpos = 0) const
  559.     {
  560.        int count = 0;
  561.        for (int i=startpos; i < pStr->len; i+=str.Length())
  562.           if (!strncmp(&(pStr->s[i]), str, str.Length()))
  563.              count++;
  564.  
  565.        return count;
  566.     }
  567.  
  568.     // startpos is 0 based
  569.     FCWString& Insert(char* s, int startpos)
  570.     {
  571.        makeunique();
  572.        if (s && strlen(s) && startpos < pStr->len)
  573.        {
  574.           if (pStr->size < pStr->len+strlen(s))
  575.              pStr->re_alloc(pStr->len+strlen(s));
  576.  
  577.           int tar=pStr->len+strlen(s)-1;
  578.           int src=pStr->len-1;
  579.           for (; src >= startpos; tar--, src--)
  580.              pStr->s[tar] = pStr->s[src];
  581.  
  582.           memcpy(&(pStr->s[startpos]), s, strlen(s));
  583.           pStr->len += strlen(s);
  584.           pStr->s[pStr->len] = 0;
  585.        }
  586.  
  587.        return *this;
  588.     }
  589.  
  590.     // startpos is 0 based
  591.     FCWString& Replace(char* target, char* replacement, int startpos=0)
  592.     {
  593.        if (target && replacement && strlen(target) && strlen(replacement))
  594.        {
  595.           for (int index = IndexOf(target, startpos);
  596.                index>=0;
  597.                index = IndexOf(target, index))
  598.           {
  599.              Remove(index, strlen(target));
  600.              Insert(replacement, index);
  601.           }
  602.        }
  603.        return *this;
  604.     }
  605.  
  606.     FCWString& operator += (char *s)               // FCWString concatenation
  607.     {
  608.        makeunique();
  609.        if (s && strlen(s))
  610.        {
  611.           if (pStr->size < pStr->len + strlen(s))
  612.              pStr->re_alloc(pStr->len+strlen(s));
  613.  
  614.           strcpy( &(pStr->s[pStr->len]), s );
  615.           pStr->len += strlen(s);
  616.           pStr->s[pStr->len] = 0;
  617.        }
  618.  
  619.        return *this;
  620.     }
  621.  
  622.     FCWString& operator += (long l)
  623.     {
  624.        makeunique();
  625.        char x[10];
  626.  
  627.        sprintf (x, "%ld", l);
  628.        *this += x;
  629.  
  630.        return *this;
  631.     }
  632.  
  633.     FCWString& operator +=  (FCWString const& s)
  634.     {
  635.        makeunique();
  636.        if (pStr->size < pStr->len + s.pStr->len)
  637.           pStr->re_alloc(pStr->len+s.pStr->len);
  638.  
  639.        memcpy( &(pStr->s[pStr->len]), s.pStr->s, s.pStr->len);
  640.        pStr->len += s.pStr->len;
  641.        pStr->s[pStr->len] = 0;
  642.  
  643.        return *this;
  644.     }
  645.  
  646.     FCWString&  operator +=(char c)              /* FCWString concatenation*/
  647.     {
  648.        makeunique();
  649.        if (pStr->size < pStr->len +1)
  650.           pStr->re_alloc(pStr->len+1);
  651.  
  652.        pStr->s[pStr->len] = c;
  653.        pStr->len++;
  654.        pStr->s[pStr->len] = 0;
  655.  
  656.        return *this;
  657.     }
  658.  
  659.     int AsInt()
  660.     {
  661.         return atoi(pStr->s);
  662.     }
  663.  
  664.     FCWString  operator + (char *s)    /* FCWString concatenation          */
  665.     {
  666.        FCWString t(*this);
  667.        t += s;
  668.  
  669.        return t;
  670.     }
  671.  
  672.     FCWString operator + (FCWString const & s)
  673.     {
  674.        FCWString t(*this);
  675.        t += s;
  676.  
  677.        return t;
  678.     }
  679.  
  680.     FCWString operator + ( char c)
  681.     {
  682.        FCWString t(*this);
  683.        t += c;
  684.  
  685.        return t;
  686.     }
  687.  
  688.     friend ostream & operator << ( ostream & aStream,
  689.                                    const FCWString & aString )
  690.     {
  691.       return aStream << (const char*) aString;
  692.     }
  693.  
  694. };
  695.  
  696. // ---------------------------------------------------------------------
  697. // Data item types...
  698. // ---------------------------------------------------------------------
  699. enum ItemType{ tSQLCHA=1,     tSQLBIN2=2,  tSQLBIN4=3,
  700.                tSQLPACK=4,    tSQLHEX=5,   tSQLDBCS=6,
  701.                tCHA=7,        tBIN2=8,     tBIN4=9,
  702.                tBIN8=10,      tPACK=11,    tPACF=12,
  703.                tNUM=13,       tNUMC=14,    tDBCS=15,
  704.                tHEX=16,       tMIX=17,     tMAPCHA=18,             /* @6653*/
  705.                tMAPNUM=19,    tMAPMIX=20,  tMAPDBCS=21,
  706.                tMAP=22,       tRECORD=23,  tEZEDLPSB=24,
  707.                tUIRBIN2=25,   tUIRBIN4=26, tUIRBIN8=27,
  708.                tUIRCHA=28,    tUIRDBCS=29, tUIRHEX=30,
  709.                tUIRNUM=31,    tUIRNUMC=32, tUIRPACK=33,
  710.                tUIRPACF=34,   tUNICODE=35, tTBLUNICODE=36,           /* @A2*/
  711.                tSQLUNICODE=37, tUIRUNICODE=38, tUIRMIX=39
  712.                };
  713.  
  714. // --------------------------------------------------------------------
  715. //            FCW process options for File/SQL
  716. // --------------------------------------------------------------------
  717.                                                 //   used to be ...
  718. const  int  INQUIRY_OPR  =  1;                  // 0x0001;
  719. const  int  SETINQ_OPR   =  2;                  // 0x0002;
  720. const  int  UPDATE_OPR   =  3;                  // 0x0004;
  721. const  int  SETUPD_OPR   =  4;                  // 0x0008;
  722. const  int  SCAN_OPR     =  5;                  // 0x0010;
  723. const  int  ADD_OPR      =  6;                  // 0x0020;
  724. const  int  REPLACE_OPR  =  7;                  // 0x0040;
  725. const  int  DELETE_OPR   =  8;                  // 0x0080;
  726. const  int  CLOSE_OPR    =  9;                  // 0x0100;
  727. const  int  SQLEXEC_OPR  =  10;                 // 0x0200;
  728.  
  729. // --------------------------------------------------------------------
  730. //            FCW File/SQL I/O status
  731. // --------------------------------------------------------------------
  732.  
  733. const short rcNRF =  0x0001;
  734. const short rcDUP =  0x0002;
  735. const short rcUNQ =  0x0004;
  736. const short rcDED =  0x0008;
  737.  
  738. const short rcHRD =  0x0010;
  739. const short rcEOF =  0x0020;
  740. const short rcERR =  0x0040;                                   // @7775
  741.  
  742. // *********************************************************************
  743. // overflow values
  744. // *********************************************************************
  745. enum OverflowType { NO_OVERFLOW=0, MAX_OVERFLOW=1, USER_OVERFLOW=2 };
  746.  
  747. // ---------------------------------------------------------------------
  748. //  global constants
  749. // ---------------------------------------------------------------------
  750. const int LENGTH_TABLE_NAME = 7;
  751. const int LENGTH_ITEM_NAME = 32;
  752.  
  753. const int JULIAN_FORMAT = 0;
  754. const int GREGORIAN_FORMAT = 1;
  755. const int JULIAN_SHORT_FORMAT = 2;
  756. const int GREGORIAN_SHORT_FORMAT = 3;
  757.  
  758. const int LENGTH_DB_NAME        = 18;
  759.  
  760. const int CONV_NORMAL           = 0;
  761. const int CONV_REMOTE_CREATX    = 1;
  762.  
  763. #define   BUILD_DESCRIPTOR      "BUILDESC"
  764.  
  765. // -------------------------------------------------------------------
  766. //    Macro for Generator
  767. // -------------------------------------------------------------------
  768. #define   FCWReturn          { PrcPop(); return; }
  769.  
  770. #define   FCWRTN()           { PrcPop(); return; }
  771. #define   FCWCLOS()          { CtlMode=cm_End; PrcPop(); return; }
  772. #define   FCWFLO()           { CtlMode=cm_ezeFlow; PrcPop(); return; }
  773.  
  774. #define   EZERTN()           { PrcPop(); return; }
  775. #define   EZECLOS()          { CtlMode=cm_End; PrcPop(); return; }
  776. #define   EZEFLO()           { CtlMode=cm_ezeFlow; PrcPop(); return; }
  777.  
  778. #define   EZEREPLY           EZEReply()
  779.      /* -------------------------------------------------------------------*/
  780.                         /* Rununit initialization and termination interface*/
  781.      /* -------------------------------------------------------------------*/
  782. enum  InitType { CICS, Native, CICSWebTrans, WebTrans };
  783. enum  TermType { NormalExit, ErrorExit, SegmentExit, XferExit };
  784. extern "C" void  RunUnitTerm( TermType ttype=ErrorExit );
  785. extern "C" void  RunUnitInit( InitType itype=Native );
  786. extern "C" void  WebtControl( );
  787. void   SysCallRCLConstructors(void* addr);
  788. void   SysCallRCLDestructors();
  789.  
  790. class TraceFile;
  791. extern "C" TraceFile& Trace( );
  792.  
  793. // -------------------------------------------------------------------
  794. //  main entry inlines into Workgroup Services
  795. // -------------------------------------------------------------------
  796. extern "C" int FCWRun (int argc, char* argv[]);
  797.  
  798. #if defined FCW_OS2
  799.    #include <os2def.h>
  800.    #define INCL_ERRORS
  801.    #include <bseerr.h>
  802.    #define INCL_DOSSEMAPHORES
  803.    #include <bsedos.h>
  804.    #if defined __IBMCPP__              /* if IBM C++ (OS2)                 */
  805.       #define EXPORT
  806.       #define SYSCALL _System
  807.  
  808.    #elif defined __BCPLUSPLUS__        /* if Borland C++ (OS2)             */
  809.       #define EXPORT _export
  810.       #define SYSCALL _stdcall
  811.    #endif
  812.  
  813.  
  814. #elif defined FCW_NT
  815.    #include <windows.h>
  816.    #define EXPORT
  817.    #if defined FCW_VA_CPP
  818.       #define SYSCALL __cdecl
  819.    #else
  820.       #define SYSCALL __cdecl        /* changed from __stdcall <ODBC> */
  821.    #endif
  822.    typedef int (SYSCALL *PFN)();
  823.  
  824. #elif defined FCW_UNIX || defined FCW_MVS /* @A1 */
  825.    #define EXPORT
  826.    #define SYSCALL
  827.    #define _Optlink
  828.    typedef unsigned long ULONG;
  829.    typedef unsigned short USHORT;
  830.    typedef unsigned char UCHAR;
  831.    typedef int (*PFN)();
  832. #endif
  833.  
  834. #include <cso2api.h>
  835.  
  836. typedef int (SYSCALL * PMAINAPP) (void);
  837.  
  838. extern "C"
  839. {
  840. typedef int (SYSCALL * PCALLAPP) ( ... );
  841. }
  842.  
  843. // -------------------------------------------------------------------
  844. // System independent call parameter list structure
  845. // -------------------------------------------------------------------
  846. #define FCWAPP    1
  847. #define NONFCWAPP 0
  848.  
  849. struct FCWCallBlock
  850. {
  851.   int count;
  852.   int callerFlag;
  853.   struct
  854.   {
  855.     long  size;
  856.     void* data;
  857.   } parm[30];
  858. };
  859.  
  860. typedef struct
  861. {
  862.   int   linktype;
  863.   long  commsize;
  864.   CMCOD BaseLinkage;
  865. } FCWCICSLinkage;
  866.  
  867.  
  868. // -------------------------------------------------------------------
  869. // Call and Transfer options
  870. // -------------------------------------------------------------------
  871. #define OPT_FCW        0x00000000
  872. #define OPT_NOREPLY    0x00000000
  873. #define OPT_REPLY      0x00000001
  874. #define OPT_NONFCW     0x00000002
  875. #define OPT_NOMAPS     0x00000004
  876. #define OPT_NOEXTEND   0x00000008
  877. #define OPT_HIGHVALUES 0x00000010
  878. #define OPT_AIXLOAD    0x00000020
  879. #define OPT_APPLOAD    0x00000040
  880. #define OPT_SYSLOAD    0x00000080
  881.  
  882. /*---------------------------------------------------------------------------*/
  883. /* DLL handle types                                                          */
  884. /*---------------------------------------------------------------------------*/
  885. #if defined FCW_OS2
  886. #define   APP_MODULE_TYPE     HMODULE
  887. #define   FILE_MAP_HANDLE     PVOID
  888.  
  889. #elif defined FCW_NT
  890. #define   APP_MODULE_TYPE     HMODULE
  891. #define   FILE_MAP_HANDLE     HANDLE
  892.  
  893. #elif defined FCW_UNIX || defined FCW_MVS  /* @A1 */
  894. typedef void* APP_MODULE_TYPE;
  895. typedef void* FILE_MAP_HANDLE;
  896. #endif
  897.  
  898. /***************************************************************************/
  899. /* The TransInfo Structure and RunMode enum were moved from fcw.h          */
  900. /* The Dll handle type section was moved from fcwsys.h                     */
  901. /* These were moved because for NTCICS, the VAGEN application needed to    */
  902. /* know about Transinfo and Runmode.                              D7557    */
  903. /***************************************************************************/
  904.  
  905. /*-------------------------------------------------------------------------*/
  906. /*  Transfer type information                                              */
  907. /*-------------------------------------------------------------------------*/
  908.  
  909. enum TransType { dxfr, xfer, creatx, init };
  910.  
  911. struct TransInfo
  912. {
  913.   TransType       Type;
  914.   FCWString       Appname;
  915.   int             Options;
  916.   char*           pBlock;
  917.   TransInfo() :   pBlock(NULL), pMapBlock(NULL), pMapName(NULL) {};
  918.   char*           pMapBlock;
  919.   char*           pMapName;
  920.   FILE_MAP_HANDLE pBlockHandle;
  921. };
  922.  
  923. enum RunMode { normal, terminat, transfer, abend, segment, dxfer, xferwmap, xferwuir, xferwoap };
  924.  
  925.      /* -------------------------------------------------------------------*/
  926. // Misc defines
  927. // -------------------------------------------------------------------
  928. #define ERROR_IN_CALLAPP 693
  929. #define ERROR_IN_WEBAPP  899                                    // VG 4.0
  930.  
  931. enum InitKey   { key_dbms=1 };                                  // ODBC
  932. enum InitValue { val_db2=1, val_odbc=2, val_oracle=4};
  933.  
  934. enum segType { segmented_Converse, segmented_Help, segmented_Message, segmented_UIR };
  935.  
  936. enum TimerControl { tc_start = 1, tc_stop = 2 };                // ODBC
  937. extern "C" int TimeIt( TimerControl tc, char* msg );
  938.  
  939. #endif
  940.