home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / SQLSVR.ZIP / SQLSVR.TXT
Text File  |  1993-04-19  |  4KB  |  173 lines

  1. The following are changes to the SQL Server 4.2 include files
  2. in order to use SQL Server with the IBM C/Set2 compiler.
  3.  
  4.  
  5. In the file sqlfront.h change:
  6.  
  7.  
  8. Lines 18-22 from
  9.  
  10. #if !defined(M_I86SM)  && !defined(DBNTWIN32)
  11. #define SQLAPI            cdecl far
  12. #else
  13. #define SQLAPI            cdecl
  14. #endif
  15.  
  16. to
  17.  
  18. #if defined(DBOS2_20)
  19. #define SQLAPI                  _Far16 _Cdecl
  20. #elif !defined(M_I86SM)  && !defined(DBNTWIN32)
  21. #define SQLAPI                  cdecl far
  22. #else
  23. #define SQLAPI                  cdecl
  24. #endif
  25.  
  26.  
  27. Lines 30 from
  28.  
  29. #define DBUBOOL            unsigned int
  30.  
  31. to
  32.  
  33. #if !defined(DBOS2_20)
  34. #define DBUBOOL                 unsigned int
  35. #else
  36. #define DBUBOOL                 unsigned short
  37. #endif
  38.  
  39.  
  40. Lines 36-38 from
  41.  
  42. #ifndef INT
  43. #define INT            int
  44. #endif
  45.  
  46. to
  47.  
  48. #if !defined(DBOS2_20)
  49. #ifndef INT
  50. #define INT                     int
  51. #define INT16                   INT
  52. #endif
  53. #else
  54. #if !defined(INT16)
  55. #define INT16                   short
  56. #endif
  57. #endif
  58.  
  59.  
  60. Lines 60-62 from
  61.  
  62. #if !defined(OS2_INCLUDED) && !defined(DBMSWIN) && !defined(DBNTWIN32)
  63. typedef DBUBOOL         BOOL;
  64. #endif
  65.  
  66. to
  67.  
  68. #if !defined(DBOS2_20)
  69. #if !defined(OS2_INCLUDED) && !defined(DBMSWIN) && !defined(DBNTWIN32)
  70. typedef DBUBOOL                 BOOL;
  71. #endif
  72. #endif
  73.  
  74.  
  75. In the DBDATEREC structure change all the 'int's to 'INT16's.  They are
  76. on lines 406-416.
  77.  
  78. Lines 422-423 from
  79.  
  80. #define RETCODE   INT
  81. #define STATUS    INT
  82.  
  83. to
  84.  
  85. #define RETCODE   INT16
  86. #define STATUS    INT16
  87.  
  88.  
  89.  
  90. In the file sqldb.h change:
  91.  
  92. Line 54 from
  93.  
  94. #ifndef DBNTWIN32
  95.  
  96. to
  97.  
  98. #if !defined(DBNTWIN32) && !defined(DBOS2_20)
  99.  
  100.  
  101. Line 265 from
  102.  
  103. #ifdef DBMSOS2
  104.  
  105. to
  106.  
  107. #ifdef DBMSOS2      /* 16 bit os2 */
  108.  
  109.  
  110.  
  111. Copy the DBMSOS2 section (lines 265-441) changing the following in
  112. the new section:
  113.  
  114.     '#ifdef DBMSOS2' to '#ifdef DBOS2_20  /* 32 bit OS/2 2.0 */'
  115.  
  116.     'INT'      to 'INT16'       (don't change DBINT to DBINT16)
  117.     'int'      to 'INT16'
  118.     'far *'    to '* _Seg16'
  119.     'SQLAPI *' to '* SQLAPI'
  120.  
  121.    'extern BOOL SQLAPI dbiscount' to 'extern DBUBOOL SQLAPI dbiscount'
  122.  
  123.  
  124.  
  125. In the programs you write:
  126.  
  127. *  Define DBOS2_20
  128.    ex:   #define DBOS2_20
  129.  
  130. *  All pointers (even those inside structures) which are passed to a
  131.    16 bit routine needs to be declared _Seg16.
  132.    ex:   DBPROCESS * _Seg16 dbproc;
  133.          LOGINREC  * _Seg16 login;
  134.  
  135. *  All other variables passed to a 16 bit routine need a
  136.    #pragma seg16(variable).
  137.    ex:   #pragma seg16(userid)
  138.          DBSMALLINT  userid;
  139.          #pragma seg16(name)
  140.          DBCHAR      name[PLEN+1];
  141.  
  142. *  For the callbacks to 32 bit code from the 16 bit code, it is best to
  143.    have a local variable for each parameter passed in from the 16 bit
  144.    routine.  You also need to use a pragma which tells the compiler
  145.    to install an exception handler in the callback routine.
  146.  
  147.    ex:
  148.  
  149.    #pragma handler(msg_handler)
  150.    INT16 SQLAPI msg_handler(DBPROCESS * _Seg16 dbproc,
  151.                             DBINT msgno,
  152.                             INT16 msgstate,
  153.                             INT16 severity,
  154.                             char * _Seg16 msgtext)
  155.    {
  156.       DBPROCESS  *mydbproc   = dbproc;
  157.       DBINT       mymsgno    = msgno;
  158.       INT16       mymsgstate = msgstate;
  159.       INT16       myseverity = severity;
  160.       char       *mymsgtext  = msgtext;
  161.  
  162.       printf("SQL Server message %ld, state %d, severity %d:\n\t%s\n",
  163.              mymsgno, mymsgstate, myseverity, mymsgtext);
  164.       return(0);
  165.    }
  166.  
  167. *  The library routine dbfcmd takes a variable number of parameters.
  168.    As a result, the compiler doesn't perform the necessary conversions
  169.    on the optional parms.  To correct this, use a cast for all optional
  170.    parms.
  171.  
  172.    ex:  dbfcmd(dbproc, "values(%s) \n", (char * _Seg16) cmdbuf);
  173.