home *** CD-ROM | disk | FTP | other *** search
/ Datatid 1999 #6 / Datatid_1999-06.iso / internet / Tango352Promo / P.SQL / PTKPKG.1 / SQLAPI.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-27  |  101.2 KB  |  3,437 lines

  1. #if !defined(BTI_DOS) && !defined(BTI_NLM) && !defined(BTI_DOS_32R) && \
  2.   !defined(BTI_DOS_32P) && !defined(BTI_DOS_32B) && \
  3.   !defined(BTI_DOS_16B)
  4. #error Define one of the following: BTI_DOS, BTI_NLM, BTI_DOS_32R,\
  5.  BTI_DOS_32P, BTI_DOS_32B, BTI_DOS_16B
  6. #endif
  7. /***************************************************************************
  8. **
  9. **  Copyright 1982-1997 Pervasive Software Inc. All Rights Reserved
  10. **
  11. ***************************************************************************/
  12. /***************************************************************************
  13.    SQLAPI.C
  14.       This module implements the Scalable SQL Interface for C/C++
  15.       applications using DOS, Extended DOS (with Rational SSQLSTUB, Phar Lap
  16.       or Borland Power Pack) and NLMs.  No interface code is required for
  17.       MS-Windows, since the functions are available from DLLs.
  18.  
  19. ***************************************************************************/
  20. #include <stddef.h>
  21. #include <sqlapi.h>
  22. #include <sqlconst.h>
  23. #include <btitypes.h>
  24.  
  25. #if defined(BTI_DOS) || defined(BTI_DOS_32R) || \
  26.   defined(BTI_DOS_32B) || defined(BTI_DOS_32P) || defined(BTI_DOS_16B)
  27. #include <dos.h>
  28. #include <string.h>
  29. #endif
  30.  
  31. #if defined(BTI_DOS_32P)
  32. #include <i86.h>
  33. #include <pharlap.h>
  34. #include <fixparms.h>
  35. #include <malloc.h>
  36.  
  37. BTI_ULONG startOfRealPtr;
  38. #endif
  39.  
  40. #if defined(BTI_DOS_32B)
  41. #include <stdlib.h>
  42. #include <fixparms.h>
  43. #include <malloc.h>
  44.  
  45. BTI_ULONG startOfRealPtr;
  46.  
  47. /***************************************************************************
  48. ** Define Far pointer data type (selector:offset32)
  49. **
  50. ** The Borland C 32-bit compiler does not support far pointers.  For this
  51. ** compiler, a FARPTR is defined as a structure which has the same
  52. ** organization in memory as a standard 48-bit far pointer.
  53. **
  54. ** The following macros are used to get and set the selector and offset
  55. ** fields of far pointers, and work both for compilers that directly
  56. ** support far pointers and compilers that don't have far pointer support.
  57. ** The FP_SEL macro returns the 16-bit selector number field
  58. ** of a far pointer.  The FP_OFF macro returns the 32-bit offset
  59. ** field of a far pointer.  The FP_SET macro is used to construct a far
  60. ** pointer from a selector number and offset.  It takes three arguments:
  61. ** the name of the far pointer to be set, an offset, and a selector number.
  62. ** The FP_INCR macro increments the offset field of a far pointer.
  63. ***************************************************************************/
  64. typedef struct
  65. {
  66.    BTI_ULONG Off;
  67.    BTI_WORD Sel;
  68. } FARPTR;
  69.  
  70. #ifndef FP_SEL
  71. #define FP_SEL(fp) ((fp).Sel)
  72. #endif
  73.  
  74. #ifndef FP_OFF
  75. #define FP_OFF(fp) ((fp).Off)
  76. #endif
  77.  
  78. #ifndef FP_SET
  79. #define FP_SET(fp, off, sel) \
  80. {\
  81. (fp).Sel = (BTI_WORD) (sel);\
  82. (fp).Off = (BTI_ULONG) (off);\
  83. }
  84. #endif
  85.  
  86. #ifndef FP_INCR
  87. #define FP_INCR(fp, incr) ((fp).Off += (BTI_ULONG) (incr))
  88. #endif
  89. #endif
  90.  
  91. #if defined(BTI_DOS_16B)
  92. #include <stdlib.h>
  93. #include <fixparms.h>
  94. #include <malloc.h>
  95. #include <mem.h>
  96.  
  97. BTI_ULONG startOfRealPtr;
  98.  
  99. #define FARPTR BTI_ULONG
  100. #endif
  101.  
  102. #ifdef __cplusplus
  103. extern "C" {
  104. #endif
  105.  
  106. /***************************************************************************
  107.    Constants
  108. ***************************************************************************/
  109. #define INVALID_SESSION_ID    -1
  110. #define SQL_INT               0x7B                  /* SQL interrupt vector */
  111. #define SQL_OFFSET            0x33             /* SQL offset within segment */
  112. #define XQLP_CALL             10
  113. #define XQLM_CALL             11
  114.  
  115. /***************************************************************************
  116.    PROCESS7B IS IN PMSWITCH, AND IS RESOLVED AT RUN-TIME
  117. ***************************************************************************/
  118. #if defined(BTI_DOS_32R)
  119. typedef struct
  120. {
  121.    char  *Name;
  122.    void  cdecl (*functionPtr) (pmswParmBlock *bP);
  123. } IMPORTS[];
  124. #define PROCESS7B 75
  125. IMPORTS * _ImportedFunctions_ = 0;
  126. #endif
  127.  
  128. /***************************************************************************
  129.    PLATFORM-DEPENDENT SUPPORT FUNCTIONS PROTOTYPES
  130. ***************************************************************************/
  131. #if defined(BTI_DOS) || defined(BTI_DOS_32R) || \
  132.    defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  133. BTI_API callsql(BTI_CHAR_PTR SQLParms);
  134. BTI_API callPrimitive(BTI_VOID);
  135. BTI_API callSQLFunction(BTI_VOID);
  136. BTI_API sql_loaded(BTI_VOID);
  137. BTI_API Primitives_Loaded(BTI_VOID);
  138. BTI_API CallPMSW(pmswParmBlock *pb);
  139. #endif
  140.  
  141. #if defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  142. BTI_VOID freeRealModeBuffer(BTI_WORD);
  143. BTI_SINT getRealModeBuffer(FARPTR *, BTI_ULONG *, BTI_ULONG);
  144. BTI_SINT SRBFormat(PARMBLOCK *from, PARMBLOCK *srb, BTI_SINT *fcn);
  145. BTI_SINT SRBUnformat(PARMBLOCK *to, PARMBLOCK *srb, BTI_SINT fcn);
  146. #endif
  147.  
  148. #if defined(BTI_DOS_32P) || defined(BTI_DOS_32B)
  149. /***************************************************************************
  150.    The following function are in assembly language: define with CDECL
  151. ***************************************************************************/
  152. extern void cdecl copyToLow(unsigned short dst_sel, unsigned dst_offset,
  153.                             void * src, unsigned int size);
  154. extern void cdecl copyFromLow(void * dst, unsigned short src_sel,
  155.                               unsigned src_offset, unsigned int size);
  156. #endif
  157.  
  158. #ifdef BTI_NLM
  159. BTI_SINT XQLEntry(BTI_VOID *);              /* This API must be imported. */
  160. BTI_SINT callxqlm(BTI_VOID);
  161. BTI_VOID callxqlp(BTI_VOID);
  162. #endif
  163.  
  164. /***************************************************************************
  165.    PLATFORM-DEPENDENT MACROS FOR FUNCTION NAMES
  166. ***************************************************************************/
  167. #ifdef BTI_NLM
  168. #define callSQLFunction callxqlm
  169. #define callPrimitive callxqlp
  170. #endif
  171.  
  172. /***************************************************************************
  173.    COMPILER DEPENDENCIES
  174. ***************************************************************************/
  175. /* Microsoft changed function and structure names in 7.x */
  176. #if defined _MSC_VER
  177.    #if (_MSC_VER > 600)
  178.    #define segread _segread
  179.    #define int86x  _int86x
  180.    #define REGS    _REGS
  181.    #define SREGS   _SREGS
  182.    #endif
  183. #endif
  184.  
  185. /***************************************************************************
  186.    MACROS
  187. ***************************************************************************/
  188. #if defined(BTI_DOS) || defined(BTI_DOS_32R) || defined(BTI_DOS_16B)
  189. #undef FP_SEG
  190. #undef FP_OFF
  191. #define FP_SEG(fp) (*((BTI_WORD_PTR)&(fp) + 1))
  192. #define FP_OFF(fp) (*((BTI_WORD_PTR)&(fp)))
  193. #endif
  194.  
  195. #if defined(BTI_DOS_16B)
  196. #undef MK_FP
  197. #define MK_FP(seg,ofs) ((BTI_ULONG)(seg)<<16 + (BTI_WORD)(ofs))
  198. #endif
  199.  
  200. /***************************************************************************
  201.    GLOBAL VARIABLES
  202. ***************************************************************************/
  203. BTI_SINT SQLCODE;
  204. BTI_SINT SQL_SessionID = INVALID_SESSION_ID;
  205.  
  206. #ifdef BTI_NLM
  207. BTI_SINT NSAgentID = 0x4D58;  /* "XM" = Default, if SetNSAgentID not called */
  208. #endif
  209.  
  210. #if defined(BTI_DOS) || defined(BTI_DOS_16B)
  211. typedef struct { BTI_WORD es, cs, ss, ds; } SQL_SREGS;
  212. typedef struct { BTI_WORD ax, bx, cx, dx, si, di, cy, flags; } SQL_REGS;
  213. SQL_REGS  regs;
  214. SQL_SREGS sregs;
  215. #endif
  216.  
  217. #if defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  218. extern BTI_WORD MaxSRBDataSize;
  219. #endif
  220.  
  221. /**************************************************************************
  222.    PLATFORM-INDEPENDENT SESSION MANAGEMENT PRIMITIVES
  223.       The following primitives are required by applications which
  224.       want to use multiple SQL logins:
  225.          xGetSessionID
  226.          xPutSessionID
  227. ***************************************************************************/
  228. /***************************************************************************
  229.    xGetSessionID
  230. ***************************************************************************/
  231. BTI_API xGetSessionID(BTI_SINT_PTR iSessionID)
  232. {
  233.    /* assumes -1 is uninitialized SQL_SessionID */
  234.    if (SQL_SessionID == - 1)
  235.       return SQL_NO_DICTIONARY_ACTIVE;
  236.    *iSessionID = SQL_SessionID;
  237.    return (0);
  238. }
  239.  
  240. /***************************************************************************
  241.    xPutSessionID
  242. ***************************************************************************/
  243. BTI_API xPutSessionID(BTI_SINT iSessionID)
  244. {
  245.    SQL_SessionID = iSessionID;
  246.    return (0);
  247. }
  248.  
  249. /**************************************************************************
  250.    PLATFORM-SPECIFIC MISCELLANEOUS FUNCTIONS
  251.       SetNSAgentID    (NLM)
  252. **************************************************************************/
  253. /**************************************************************************
  254.    SetNSAgentID
  255. **************************************************************************/
  256. #ifdef BTI_NLM
  257. BTI_VOID SetNSAgentID(BTI_CHAR_PTR newID)
  258. {
  259.    NSAgentID = ((BTI_WORD)*(newID+1) << 8) + *newID;
  260. }
  261. #endif
  262.  
  263. /**************************************************************************
  264.    DATABASE NAMES APIs FOR DOS
  265. **************************************************************************/
  266. /**************************************************************************
  267.    SQLGetCountDatabaseNames
  268. **************************************************************************/
  269. #if defined(BTI_DOS) || defined(BTI_DOS_32R) ||\
  270.    defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  271. BTI_API SQLGetCountDatabaseNames(
  272.            BTI_SIZE_PTR tCount )
  273. {
  274.    BTI_SINT      stat = 0;
  275.    PARMBLOCK     dbnpb;
  276.    pmswParmBlock pb;
  277.  
  278.    *((BTI_LONG_PTR) &(dbnpb.XQL_ID)) = DBNM_SIG;
  279.    dbnpb.fcn = 2;
  280.  
  281.    dbnpb.v.dbnGetCntData.count = *tCount;
  282.  
  283.    *((BTI_LONG_PTR) &(pb.sign)) = *((BTI_LONG_PTR) PMSW_SIGN);
  284.    pb.flags = 0;
  285.    pb.func = DBNM_FUNC;
  286.    pb.len = sizeof(dbnpb);
  287.    pb.data = &dbnpb;
  288.  
  289.    stat = CallPMSW(&pb);
  290.  
  291.    *tCount = (BTI_SIZE)dbnpb.v.dbnGetCntData.count;
  292.  
  293.    if (stat == 0)
  294.       stat = dbnpb.stat;
  295.  
  296.    return(stat);
  297. }
  298.  
  299. BTI_API SQLGetDatabaseNames(
  300.            BTI_SIZE_PTR tBufLen, BTI_CHAR_PTR bDataBuf )
  301. {
  302.    BTI_SINT      stat = 0;
  303.    PARMBLOCK     dbnpb;
  304.    pmswParmBlock pb;
  305.  
  306.    *((BTI_LONG_PTR) &(dbnpb.XQL_ID)) = DBNM_SIG;
  307.    dbnpb.fcn = 4;
  308.  
  309.    dbnpb.v.dbnGetNameData.bufLen = *tBufLen;
  310.    dbnpb.v.dbnGetNameData.buffer = bDataBuf;
  311.  
  312.    *((BTI_LONG_PTR) &(pb.sign)) = *((BTI_LONG_PTR) PMSW_SIGN);
  313.    pb.flags = 0;
  314.    pb.func = DBNM_FUNC;
  315.    pb.len = sizeof(dbnpb);
  316.    pb.data = &dbnpb;
  317.  
  318.    stat = CallPMSW(&pb);
  319.  
  320.    *tBufLen = (BTI_SIZE)dbnpb.v.dbnGetNameData.bufLen;
  321.  
  322.    if (stat == 0)
  323.        stat = dbnpb.stat;
  324.  
  325.    return(stat);
  326. }
  327.  
  328. BTI_API SQLUnloadDBNames(BTI_SINT iReserved)
  329. {
  330.     BTI_SINT      stat = 0;
  331.     PARMBLOCK     dbnpb;
  332.     pmswParmBlock pb;
  333.  
  334.     iReserved = 0;         /* prevent compiler warning by using 'iReserved' */
  335.  
  336.     *((BTI_LONG_PTR) &(dbnpb.XQL_ID)) = DBNM_SIG;
  337.     dbnpb.fcn = 7;
  338.  
  339.     dbnpb.v.dbnUnloadData.reserved = 0;
  340.  
  341.     *((BTI_LONG_PTR) &(pb.sign)) = *((BTI_LONG_PTR) PMSW_SIGN);
  342.     pb.flags = 0;
  343.     pb.func = DBNM_FUNC;
  344.     pb.len = sizeof(dbnpb);
  345.     pb.data = &dbnpb;
  346.  
  347.     stat = CallPMSW(&pb);
  348.  
  349.     if (stat == 0)
  350.         stat = dbnpb.stat;
  351.  
  352.     return(stat);
  353. }
  354. #endif
  355.  
  356. /**************************************************************************
  357.    PLATFORM-INDEPENDENT SQL-LEVEL FUNCTIONS
  358.       XQLCursor           XQLSPUtility
  359.       XQLCompile          XQLStatus
  360.       XQLDescribe         XQLStop
  361.       XQLExec             XQLSubst
  362.       XQLFetch            XQLVersion
  363.       XQLFormat           XQLConvert
  364.       XQLFree             XQLValidate
  365.       XQLLogin            XQLMask
  366.       XQLLogout
  367. **************************************************************************/
  368. /******  SQL-Level Function Numbers  *******/
  369. #define  lLogInFcn     0
  370. #define  lLogOutFcn    1
  371. #define  lCursorFcn    2
  372. #define  lCompFcn      3
  373. #define  lFormatFcn    4
  374. #define  lFetchFcn     5
  375. #define  lDescribeFcn  6
  376. #define  lSubstFcn     7
  377. #define  lExecFcn      8
  378. #define  lFreeFcn      9
  379. #define  lStatFcn      10
  380. #define  lStopFcn      11
  381. #define  lVersFcn      12
  382. #define  lConvFcn      13
  383. #define  lValFcn       14
  384. #define  lMaskFcn      15
  385. #define  lSPUtilityFcn 16
  386.  
  387. /***************************************************************************
  388.    SQL-Level Functions Call Parameter Block
  389. ***************************************************************************/
  390. PARMBLOCK XQLMPARMS;
  391.  
  392. /***************************************************************************
  393.    XQLCompile
  394. ***************************************************************************/
  395. BTI_API XQLCompile(
  396.            BTI_SINT     iCursorID,
  397.            BTI_SIZE_PTR tStatementLen,
  398.            BTI_CHAR_PTR sStatement)
  399. {
  400.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  401.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  402.    if (!sql_loaded ())
  403.       return (SQLCODE);
  404.    #endif
  405.  
  406.    XQLMPARMS.fcn                = lCompFcn;
  407.    XQLMPARMS.cursorid           = iCursorID;
  408.    XQLMPARMS.v.xcData.length    = *tStatementLen;
  409.    XQLMPARMS.v.xcData.statement = (BTI_CHAR_PTR) sStatement;
  410.  
  411.    callSQLFunction ();
  412.  
  413.    *tStatementLen = (BTI_SIZE)XQLMPARMS.v.xcData.length;
  414.    SQLCODE = XQLMPARMS.stat;
  415.    return (XQLMPARMS.stat);
  416. }
  417.  
  418. /***************************************************************************
  419.    XQLCursor
  420. ***************************************************************************/
  421. BTI_API XQLCursor(
  422.            BTI_SINT_PTR iCursorID)
  423. {
  424.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  425.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  426.    if (!sql_loaded ())
  427.       return (SQLCODE);
  428.    #endif
  429.  
  430.    XQLMPARMS.fcn      = lCursorFcn;
  431.    XQLMPARMS.cursorid = -1;
  432.  
  433.    callSQLFunction ();
  434.  
  435.    *iCursorID = XQLMPARMS.cursorid;
  436.    SQLCODE = XQLMPARMS.stat;
  437.    return (XQLMPARMS.stat);
  438. }
  439.  
  440. /***************************************************************************
  441.    XQLDescribe
  442. ***************************************************************************/
  443. BTI_API XQLDescribe(
  444.            BTI_SINT     iCursorID,
  445.            BTI_SIZE     tPosition,
  446.            BTI_SINT_PTR iDataType,
  447.            BTI_SIZE_PTR tSize,
  448.            BTI_SIZE_PTR tDecPlaces,
  449.            BTI_SIZE_PTR tDisplayLen,
  450.            BTI_SIZE_PTR tNameLen,
  451.            BTI_CHAR_PTR sName )
  452. {
  453.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  454.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  455.    if (!sql_loaded ())
  456.       return (SQLCODE);
  457.    #endif
  458.  
  459.    XQLMPARMS.fcn                 = lDescribeFcn;
  460.    XQLMPARMS.cursorid            = iCursorID;
  461.    XQLMPARMS.v.xdData.position   = tPosition;
  462.    XQLMPARMS.v.xdData.namelength = *tNameLen;
  463.    XQLMPARMS.v.xdData.namebuf    = (BTI_CHAR_PTR) sName;
  464.  
  465.    callSQLFunction ();
  466.  
  467.    *iDataType   = XQLMPARMS.v.xdData.datatype;
  468.    *tSize       = (BTI_SIZE)XQLMPARMS.v.xdData.datasize;
  469.    *tDecPlaces  = (BTI_SIZE)XQLMPARMS.v.xdData.deccount;
  470.    *tDisplayLen = (BTI_SIZE)XQLMPARMS.v.xdData.dsize;
  471.    *tNameLen    = (BTI_SIZE)XQLMPARMS.v.xdData.namelength;
  472.  
  473.    SQLCODE = XQLMPARMS.stat;
  474.    return (XQLMPARMS.stat);
  475. }
  476.  
  477. /***************************************************************************
  478.    XQLExec
  479. ***************************************************************************/
  480. BTI_API XQLExec(
  481.            BTI_SINT iCursorID)
  482. {
  483.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  484.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  485.    if (!sql_loaded ())
  486.       return (SQLCODE);
  487.    #endif
  488.  
  489.    XQLMPARMS.fcn      = lExecFcn;
  490.    XQLMPARMS.cursorid = iCursorID;
  491.  
  492.    callSQLFunction ();
  493.  
  494.    SQLCODE = XQLMPARMS.stat;
  495.    return (XQLMPARMS.stat);
  496. }
  497.  
  498. /***************************************************************************
  499.    XQLFetch
  500. ***************************************************************************/
  501. BTI_API XQLFetch(
  502.            BTI_SINT     iCursorID,
  503.            BTI_SINT     iOption,
  504.            BTI_SIZE_PTR tBufLen,
  505.            BTI_CHAR_PTR bDataBuf,
  506.            BTI_LONG_PTR lCount,
  507.            BTI_SINT     iASCIIFlag,
  508.            BTI_SINT     iSpacing )
  509. {
  510.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  511.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  512.    if (!sql_loaded ())
  513.       return (SQLCODE);
  514.    #endif
  515.  
  516.    XQLMPARMS.fcn               = lFetchFcn;
  517.    XQLMPARMS.cursorid          = iCursorID;
  518.    XQLMPARMS.v.xfData.datalen  = *tBufLen;
  519.    XQLMPARMS.v.xfData.operation= iOption;
  520.    XQLMPARMS.v.xfData.databuf  = (BTI_CHAR_PTR) bDataBuf;
  521.    XQLMPARMS.v.xfData.select   = *lCount;
  522.    XQLMPARMS.v.xfData.ASCIIFlag= iASCIIFlag;
  523.    XQLMPARMS.v.xfData.spacing  = iSpacing;
  524.  
  525.    callSQLFunction ();
  526.  
  527.    *tBufLen = (BTI_SIZE)XQLMPARMS.v.xfData.datalen;
  528.    *lCount  = XQLMPARMS.v.xfData.select;
  529.    SQLCODE  = XQLMPARMS.stat;
  530.    return (XQLMPARMS.stat);
  531. }
  532.  
  533. /***************************************************************************
  534.    XQLFormat
  535. ***************************************************************************/
  536. BTI_API XQLFormat(
  537.            BTI_SINT     iCursorID,
  538.            BTI_SIZE     tPosition,
  539.            BTI_SIZE     tMaskLen,
  540.            BTI_CHAR_PTR sMask)
  541. {
  542.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  543.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  544.    if (!sql_loaded ())
  545.       return (SQLCODE);
  546.    #endif
  547.  
  548.    XQLMPARMS.fcn                = lFormatFcn;
  549.    XQLMPARMS.cursorid           = iCursorID;
  550.    XQLMPARMS.v.xfmData.position = tPosition;
  551.    XQLMPARMS.v.xfmData.masklen  = tMaskLen;
  552.    XQLMPARMS.v.xfmData.mask     = (BTI_CHAR_PTR) sMask;
  553.  
  554.    callSQLFunction ();
  555.  
  556.    SQLCODE = XQLMPARMS.stat;
  557.    return (XQLMPARMS.stat);
  558. }
  559.  
  560. /***************************************************************************
  561.    XQLFree
  562. ***************************************************************************/
  563. BTI_API XQLFree(
  564.            BTI_SINT iCursorID)
  565. {
  566.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  567.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  568.    if (!sql_loaded ())
  569.       return (SQLCODE);
  570.    #endif
  571.  
  572.    XQLMPARMS.fcn      = lFreeFcn;
  573.    XQLMPARMS.cursorid = iCursorID;
  574.  
  575.    callSQLFunction ();
  576.  
  577.    SQLCODE = XQLMPARMS.stat;
  578.    return (XQLMPARMS.stat);
  579. }
  580.  
  581. /***************************************************************************
  582.    XQLLogin
  583. ***************************************************************************/
  584. BTI_API XQLLogin(
  585.            BTI_CHAR_PTR sUser,
  586.            BTI_CHAR_PTR sPassword,
  587.            BTI_CHAR_PTR sDDPath,
  588.            BTI_CHAR_PTR sDataPath,
  589.            BTI_CHAR_PTR sReserved,
  590.            BTI_SINT     iFeaturesUsed )
  591. {
  592.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  593.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  594.    if (!sql_loaded ())
  595.       return (SQLCODE);
  596.    #endif
  597.  
  598.    XQLMPARMS.fcn = lLogInFcn;
  599.    XQLMPARMS.cursorid = 0;
  600.  
  601.    #ifdef BTI_NLM
  602.    XQLMPARMS.stat = NSAgentID;
  603.    #endif
  604.  
  605.    XQLMPARMS.v.tloginData.username   = (BTI_CHAR_PTR) sUser;
  606.    XQLMPARMS.v.tloginData.pswd       = (BTI_CHAR_PTR) sPassword;
  607.    XQLMPARMS.v.tloginData.dictionary = (BTI_CHAR_PTR) sDDPath;
  608.    XQLMPARMS.v.tloginData.filepath   = (BTI_CHAR_PTR) sDataPath;
  609.    XQLMPARMS.v.tloginData.sreserved  = (BTI_CHAR_PTR) sReserved;
  610.    XQLMPARMS.v.tloginData.iFeaturesUsed  = iFeaturesUsed;
  611.  
  612.    callSQLFunction ();
  613.  
  614.    if (XQLMPARMS.stat == 0)
  615.       SQL_SessionID = XQLMPARMS.sessionid;
  616.    SQLCODE = XQLMPARMS.stat;
  617.    return (XQLMPARMS.stat);
  618. }
  619.  
  620. /***************************************************************************
  621.    XQLLogout
  622. ***************************************************************************/
  623. BTI_API XQLLogout
  624.            (void)
  625. {
  626.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  627.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  628.    if (!sql_loaded ())
  629.       return (SQLCODE);
  630.    #endif
  631.  
  632.    XQLMPARMS.fcn    = lLogOutFcn;
  633.  
  634.    callSQLFunction ();
  635.  
  636.    SQLCODE = XQLMPARMS.stat;
  637.    SQL_SessionID = -1;
  638.    return (XQLMPARMS.stat);
  639. }
  640.  
  641. /***************************************************************************
  642.    XQLStatus
  643. ***************************************************************************/
  644. BTI_API XQLStatus(
  645.            BTI_SINT     iCursorID,
  646.            BTI_SINT     iOption,
  647.            BTI_CHAR_PTR sStatBuf)
  648. {
  649.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  650.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  651.    if (!sql_loaded ())
  652.       return (SQLCODE);
  653.    #endif
  654.  
  655.    XQLMPARMS.fcn              = lStatFcn;
  656.    XQLMPARMS.cursorid         = iCursorID;
  657.    XQLMPARMS.v.xstData.option = iOption;
  658.    XQLMPARMS.v.xstData.buf    = (BTI_CHAR_PTR) sStatBuf;
  659.  
  660.    callSQLFunction ();
  661.  
  662.    SQLCODE = XQLMPARMS.stat;
  663.    return (XQLMPARMS.stat);
  664. }
  665.  
  666. /***************************************************************************
  667.    XQLStop
  668. ***************************************************************************/
  669. BTI_API XQLStop
  670.            (void)
  671. {
  672.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  673.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  674.    if (!sql_loaded ())
  675.       return (SQLCODE);
  676.    #endif
  677.  
  678.    XQLMPARMS.fcn    = lStopFcn;
  679.  
  680.    callSQLFunction ();
  681.  
  682.    SQLCODE = XQLMPARMS.stat;
  683.    return (XQLMPARMS.stat);
  684. }
  685.  
  686. /***************************************************************************
  687.    XQLSubst
  688. ***************************************************************************/
  689. BTI_API XQLSubst(
  690.            BTI_SINT      iCursorID,
  691.            BTI_SIZE      tCount,
  692.            BTI_SIZE      tNameLen,
  693.            BTI_CHAR_PTR  sVarNames,
  694.            BTI_SIZE      tTextLen,
  695.            BTI_CHAR_PTR  sValueText)
  696. {
  697.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  698.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  699.    if (!sql_loaded ())
  700.       return (SQLCODE);
  701.    #endif
  702.  
  703.    XQLMPARMS.fcn            = lSubstFcn;
  704.    XQLMPARMS.cursorid       = iCursorID;
  705.    XQLMPARMS.v.xsData.count = tCount;
  706.    XQLMPARMS.v.xsData.nlen  = tNameLen;
  707.    XQLMPARMS.v.xsData.vname = (BTI_CHAR_PTR) sVarNames;
  708.    XQLMPARMS.v.xsData.tlen  = tTextLen;
  709.    XQLMPARMS.v.xsData.vtext = (BTI_CHAR_PTR) sValueText;
  710.  
  711.    callSQLFunction ();
  712.  
  713.    SQLCODE = XQLMPARMS.stat;
  714.    return (XQLMPARMS.stat);
  715. }
  716.  
  717. /***************************************************************************
  718.    XQLVersion
  719. ***************************************************************************/
  720. BTI_API XQLVersion(
  721.            BTI_CHAR_PTR sVersion)
  722. {
  723.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  724.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  725.    if (!sql_loaded ())
  726.       return (SQLCODE);
  727.    #endif
  728.  
  729.    XQLMPARMS.fcn             = lVersFcn;
  730.    XQLMPARMS.v.xvData.buffer = (BTI_CHAR_PTR) sVersion;
  731.  
  732.    callSQLFunction ();
  733.  
  734.    SQLCODE = XQLMPARMS.stat;
  735.    return (XQLMPARMS.stat);
  736. }
  737.  
  738. /***************************************************************************
  739.    XQLConvert
  740. ***************************************************************************/
  741. BTI_API XQLConvert(
  742.            BTI_SINT     iOption,
  743.            BTI_SINT     iType,
  744.            BTI_SIZE     tSize,
  745.            BTI_SIZE     tDec,
  746.            BTI_SIZE     tdSize,
  747.            BTI_CHAR_PTR sValue,
  748.            BTI_CHAR_PTR sRetVal,
  749.            BTI_CHAR_PTR sMask,
  750.            BTI_SINT     sJustify)
  751. {
  752.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  753.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  754.    if (!sql_loaded ())
  755.       return (SQLCODE);
  756.    #endif
  757.  
  758.    XQLMPARMS.fcn                = lConvFcn;
  759.    XQLMPARMS.v.tcnvData.option  = iOption;
  760.    XQLMPARMS.v.tcnvData.type    = iType;
  761.    XQLMPARMS.v.tcnvData.size    = tSize;
  762.    XQLMPARMS.v.tcnvData.dec     = tDec;
  763.    XQLMPARMS.v.tcnvData.dsize   = tdSize;
  764.    XQLMPARMS.v.tcnvData.value   = (BTI_CHAR_PTR) sValue;
  765.    XQLMPARMS.v.tcnvData.retval  = (BTI_CHAR_PTR) sRetVal;
  766.    XQLMPARMS.v.tcnvData.mask    = (BTI_CHAR_PTR) sMask;
  767.    XQLMPARMS.v.tcnvData.justify = sJustify;
  768.  
  769.    callSQLFunction ();
  770.  
  771.    SQLCODE = XQLMPARMS.stat;
  772.    return (XQLMPARMS.stat);
  773. }
  774.  
  775. /***************************************************************************
  776.    XQLValidate
  777. ***************************************************************************/
  778. BTI_API XQLValidate(
  779.            BTI_SIZE_PTR tCount,
  780.            BTI_CHAR_PTR sFieldName,
  781.            BTI_SIZE     tBufLen,
  782.            BTI_CHAR_PTR bDataBuf )
  783. {
  784.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  785.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  786.    if (!sql_loaded ())
  787.       return (SQLCODE);
  788.    #endif
  789.  
  790.    XQLMPARMS.fcn                  = lValFcn;
  791.    XQLMPARMS.v.tvalData.fieldname = (BTI_CHAR_PTR) sFieldName;
  792.    XQLMPARMS.v.tvalData.count     = *tCount;
  793.    XQLMPARMS.v.tvalData.buflen    = tBufLen;
  794.    XQLMPARMS.v.tvalData.data      = (BTI_CHAR_PTR) bDataBuf;
  795.  
  796.    callSQLFunction ();
  797.  
  798.    *tCount = (BTI_SIZE)XQLMPARMS.v.tvalData.count;
  799.    SQLCODE = XQLMPARMS.stat;
  800.    return (XQLMPARMS.stat);
  801. }
  802.  
  803. /***************************************************************************
  804.    XQLMask
  805. ***************************************************************************/
  806. BTI_API XQLMask(
  807.            BTI_SINT     iOption,
  808.            BTI_SINT     iType,
  809.            BTI_SIZE     tSize,
  810.            BTI_SIZE     tDec,
  811.            BTI_SIZE_PTR tLen,
  812.            BTI_CHAR_PTR sMask)
  813. {
  814.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  815.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  816.    if (!sql_loaded ())
  817.       return (SQLCODE);
  818.    #endif
  819.  
  820.    XQLMPARMS.fcn                  = lMaskFcn;
  821.    XQLMPARMS.v.tmaskData.option   = iOption;
  822.    XQLMPARMS.v.tmaskData.type     = iType;
  823.    XQLMPARMS.v.tmaskData.size     = tSize;
  824.    XQLMPARMS.v.tmaskData.dec      = tDec;
  825.    XQLMPARMS.v.tmaskData.mlen     = *tLen;
  826.    XQLMPARMS.v.tmaskData.mask     = (BTI_CHAR_PTR) sMask;
  827.  
  828.    callSQLFunction ();
  829.  
  830.    *tLen = (BTI_SIZE)XQLMPARMS.v.tmaskData.mlen;
  831.    SQLCODE = XQLMPARMS.stat;
  832.    return (XQLMPARMS.stat);
  833. }
  834.  
  835. /***************************************************************************
  836.    XQLSPUtility
  837. ***************************************************************************/
  838. BTI_API XQLSPUtility(
  839.            BTI_SINT     iCursorID,
  840.            BTI_SINT     iOption,
  841.            BTI_SIZE_PTR tStatementCount,
  842.            BTI_SIZE_PTR tStatementExec,
  843.            BTI_SIZE_PTR tBufLen,
  844.            BTI_CHAR_PTR bDataBuf )
  845. {
  846.    #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
  847.        defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  848.    if (!sql_loaded ())
  849.       return (SQLCODE);
  850.    #endif
  851.  
  852.    XQLMPARMS.fcn                = lSPUtilityFcn;
  853.    XQLMPARMS.cursorid           = iCursorID;
  854.    XQLMPARMS.v.xspData.option    = iOption;
  855.    XQLMPARMS.v.xspData.stmntCnt  = *tStatementCount;
  856.    XQLMPARMS.v.xspData.stmntExec = *tStatementExec;
  857.    XQLMPARMS.v.xspData.bufLen    = *tBufLen;
  858.    XQLMPARMS.v.xspData.statBuf   = (BTI_CHAR_PTR) bDataBuf;
  859.  
  860.    callSQLFunction ();
  861.  
  862.    *tStatementCount = (BTI_SIZE)XQLMPARMS.v.xspData.stmntCnt;
  863.    *tStatementExec  = XQLMPARMS.v.xspData.stmntExec;
  864.    *tBufLen         = (BTI_SIZE)XQLMPARMS.v.xspData.bufLen;
  865.  
  866.    SQLCODE = XQLMPARMS.stat;
  867.    return (XQLMPARMS.stat);
  868. }
  869.  
  870. /**************************************************************************
  871.    PLATFORM-INDEPENDENT HISTORICAL RELATIONAL PRIMITIVES
  872.       The following functions will be phased out over time.  They
  873.       are included in the interface modules to support existing
  874.       applications.  New applications should not use these functions.
  875.  
  876.       xCompute    xOrder         xDD            xAccess
  877.       xDescribe   xRemall        xDDAttr        xPassword
  878.       xMovefld    xRemove        xDDModify      xSecurity
  879.       xFetch      xReset         xDDCreate      xUser
  880.       xField      xRestrict      xDDDrop        xChar
  881.       xFree       xStop          xDDField       xVersion
  882.       xInsert     xTrans         xDDFile        xStatus
  883.       xJoin       xStore         xDDIndex       xConvert
  884.       xLogin      xRecall        xDDPath        xValidate
  885.       xLogout     xUpdate        xDDView        xMask
  886.       xNew        xUpdall
  887.  *********************************************************************/
  888. /****** Relational Primitives Function Numbers *******/
  889. #define  tLogInFcn    0
  890. #define  tLogOutFcn   1
  891. #define  tNewFcn      2
  892. #define  tFreeFcn     3
  893. #define  tMoveFldFcn  4
  894. #define  tFieldFcn    5
  895. #define  tDescribeFcn 6
  896. #define  tFetchFcn    7
  897. #define  tComputeFcn  8
  898. #define  tOrderFcn    9
  899. #define  tRestrictFcn 10
  900. #define  tJoinFcn     11
  901. #define  tInsertFcn   12
  902. #define  tUpdateFcn   13
  903. #define  tUpdallFcn   14
  904. #define  tRemoveFcn   15
  905. #define  tRemallFcn   16
  906. #define  tResetFcn    17
  907. #define  tTransFcn    18
  908. #define  tStatFcn     19
  909. #define  tDDCreFcn    20
  910. #define  tStoreFcn    21
  911. #define  tRecallFcn   22
  912. #define  tStopFcn     23
  913. #define  tDDFileFcn   24
  914. #define  tDDFieldFcn  25
  915. #define  tDDIndexFcn  26
  916. #define  tDDModFcn    27
  917. #define  tDDViewFcn   28
  918. #define  tDDDrpFcn    29
  919. #define  tDDPathFcn   30
  920. #define  tDDAttrFcn   31
  921. #define  tDDFcn       32
  922. #define  tSecurFcn    33
  923. #define  tUserFcn     34
  924. #define  tAccessFcn   35
  925. #define  tPswdFcn     36
  926. #define  tCharFcn     37
  927. #define  tVersionFcn  38
  928. #define  tCnvFcn      39
  929. #define  tValFcn      40
  930. #define  tMaskFcn     41
  931.  
  932. /***************************************************************************
  933.    Primitive-Level Functions Parameter Block
  934. ***************************************************************************/
  935. PARMBLOCK XQLPPARMS;
  936.  
  937. /***************************************************************************
  938.    xCompute
  939. ***************************************************************************/
  940. BTI_API xCompute(
  941.            BTI_SINT     iCursorID,
  942.            BTI_CHAR_PTR sFldName,
  943.            BTI_SINT     iFldType,
  944.            BTI_SIZE     tFldLen,
  945.            BTI_SIZE     tDecPlaces,
  946.            BTI_SIZE_PTR tExpLen,
  947.            BTI_CHAR_PTR sExpression )
  948. {
  949.    #ifdef BTI_DOS
  950.    if (!Primitives_Loaded())
  951.       return(SQL_PRIM_COMPONENT_NOT_LOADED);
  952.    #endif
  953.  
  954.    XQLPPARMS.fcn                 = tComputeFcn;
  955.    XQLPPARMS.cursorid            = iCursorID;
  956.    XQLPPARMS.v.tcompData.fldname = (BTI_CHAR_PTR) sFldName;
  957.    XQLPPARMS.v.tcompData.fldtype = iFldType;
  958.    XQLPPARMS.v.tcompData.fldsize = tFldLen;
  959.    XQLPPARMS.v.tcompData.flddec  = tDecPlaces;
  960.    XQLPPARMS.v.tcompData.explen  = *tExpLen;
  961.    XQLPPARMS.v.tcompData.expbuf  = (BTI_CHAR_PTR) sExpression;
  962.  
  963.    callPrimitive ();
  964.  
  965.    if (XQLPPARMS.stat > 0)
  966.       *tExpLen = (BTI_SIZE)XQLPPARMS.v.tcompData.explen;
  967.  
  968.    return (XQLPPARMS.stat);
  969. }
  970.  
  971. /***************************************************************************
  972.    xDescribe
  973. ***************************************************************************/
  974. BTI_API xDescribe(
  975.            BTI_SINT     iCursorID,
  976.            BTI_SINT     iOption,
  977.            BTI_SIZE_PTR tBufLen,
  978.            BTI_SIZE     tPosition,
  979.            BTI_SIZE_PTR tCount,
  980.            BTI_CHAR_PTR bDataBuf )
  981. {
  982.    #ifdef BTI_DOS
  983.    if (!Primitives_Loaded ())
  984.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  985.    #endif
  986.  
  987.    XQLPPARMS.fcn                  = tDescribeFcn;
  988.    XQLPPARMS.cursorid             = iCursorID;
  989.    XQLPPARMS.v.tdescData.option   = iOption;
  990.    XQLPPARMS.v.tdescData.desclen  = *tBufLen;
  991.    XQLPPARMS.v.tdescData.position = tPosition;
  992.    XQLPPARMS.v.tdescData.count    = *tCount;
  993.    XQLPPARMS.v.tdescData.desclist = (BTI_CHAR_PTR) bDataBuf;
  994.  
  995.    callPrimitive ();
  996.  
  997.    *tBufLen = (BTI_SIZE)XQLPPARMS.v.tdescData.desclen;
  998.    *tCount  = (BTI_SIZE)XQLPPARMS.v.tdescData.count;
  999.    return (XQLPPARMS.stat);
  1000. }
  1001.  
  1002. /***************************************************************************
  1003.    xMovefld
  1004. ***************************************************************************/
  1005. BTI_API xMovefld(
  1006.            BTI_SINT iCursorID,
  1007.            BTI_SIZE tFromPosition,
  1008.            BTI_SIZE tToPosition)
  1009. {
  1010.    #ifdef BTI_DOS
  1011.    if (!Primitives_Loaded ())
  1012.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1013.    #endif
  1014.  
  1015.    XQLPPARMS.fcn                = tMoveFldFcn;
  1016.    XQLPPARMS.cursorid           = iCursorID;
  1017.    XQLPPARMS.v.tmovData.frompos = tFromPosition;
  1018.    XQLPPARMS.v.tmovData.topos   = tToPosition;
  1019.  
  1020.    callPrimitive ();
  1021.    return (XQLPPARMS.stat);
  1022. }
  1023.  
  1024. /***************************************************************************
  1025.    xFetch
  1026. ***************************************************************************/
  1027. BTI_API xFetch(
  1028.            BTI_SINT     iCursorID,
  1029.            BTI_SIZE_PTR tBufLen,
  1030.            BTI_SINT     iOption,
  1031.            BTI_LONG_PTR lRecordCount,
  1032.            BTI_LONG_PTR lRejectCount,
  1033.            BTI_CHAR_PTR bDataBuf )
  1034. {
  1035.    #ifdef BTI_DOS
  1036.    if (!Primitives_Loaded ())
  1037.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1038.    #endif
  1039.  
  1040.    XQLPPARMS.fcn                   = tFetchFcn;
  1041.    XQLPPARMS.cursorid              = iCursorID;
  1042.    XQLPPARMS.v.tfetchData.datalen  = *tBufLen;
  1043.    XQLPPARMS.v.tfetchData.option   = iOption;
  1044.    XQLPPARMS.v.tfetchData.select   = *lRecordCount;
  1045.    XQLPPARMS.v.tfetchData.reject   = *lRejectCount;
  1046.    XQLPPARMS.v.tfetchData.databuf  = (BTI_CHAR_PTR) bDataBuf;
  1047.  
  1048.    callPrimitive ();
  1049.  
  1050.    *tBufLen = (BTI_SIZE)XQLPPARMS.v.tfetchData.datalen;
  1051.    *lRecordCount = XQLPPARMS.v.tfetchData.select;
  1052.    *lRejectCount = XQLPPARMS.v.tfetchData.reject;
  1053.    return (XQLPPARMS.stat);
  1054. }
  1055.  
  1056. /***************************************************************************
  1057.    xField
  1058. ***************************************************************************/
  1059. BTI_API xField(
  1060.            BTI_SINT     iCursorID,
  1061.            BTI_SINT     iOption,
  1062.            BTI_SIZE     tPosition,
  1063.            BTI_SIZE_PTR tCount,
  1064.            BTI_CHAR_PTR sFldNames )
  1065. {
  1066.    #ifdef BTI_DOS
  1067.    if (!Primitives_Loaded ())
  1068.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1069.    #endif
  1070.  
  1071.    XQLPPARMS.fcn                 = tFieldFcn;
  1072.    XQLPPARMS.cursorid            = iCursorID;
  1073.    XQLPPARMS.v.tfldData.option   = iOption;
  1074.    XQLPPARMS.v.tfldData.position = tPosition;
  1075.    XQLPPARMS.v.tfldData.count    = *tCount;
  1076.    XQLPPARMS.v.tfldData.fldlist  = (BTI_CHAR_PTR) sFldNames;
  1077.  
  1078.    callPrimitive ();
  1079.  
  1080.    if (XQLPPARMS.stat >= 0)
  1081.      *tCount  = (BTI_SIZE)XQLPPARMS.v.tfldData.count;
  1082.    return (XQLPPARMS.stat);
  1083. }
  1084.  
  1085. /***************************************************************************
  1086.    xFree
  1087. ***************************************************************************/
  1088. BTI_API xFree(
  1089.            BTI_SINT iCursorID )
  1090. {
  1091.    #ifdef BTI_DOS
  1092.    if (!Primitives_Loaded ())
  1093.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1094.    #endif
  1095.  
  1096.    XQLPPARMS.fcn      = tFreeFcn;
  1097.    XQLPPARMS.cursorid = iCursorID;
  1098.  
  1099.    callPrimitive ();
  1100.  
  1101.    return (XQLPPARMS.stat);
  1102. }
  1103.  
  1104. /***************************************************************************
  1105.    xInsert
  1106. ***************************************************************************/
  1107. BTI_API xInsert(
  1108.            BTI_SINT     iCursorID,
  1109.            BTI_SIZE_PTR tFileCount,
  1110.            BTI_CHAR_PTR sFileNames,
  1111.            BTI_LONG_PTR lRecordCount,
  1112.            BTI_CHAR_PTR bDataBuf )
  1113. {
  1114.    #ifdef BTI_DOS
  1115.    if (!Primitives_Loaded ())
  1116.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1117.    #endif
  1118.  
  1119.    XQLPPARMS.fcn                   = tInsertFcn;
  1120.    XQLPPARMS.cursorid              = iCursorID;
  1121.    XQLPPARMS.v.teditData.filecount = *tFileCount;
  1122.    XQLPPARMS.v.teditData.filelist  = (BTI_CHAR_PTR) sFileNames;
  1123.    XQLPPARMS.v.teditData.editcount = *lRecordCount;
  1124.    XQLPPARMS.v.teditData.buf       = (BTI_CHAR_PTR) bDataBuf;
  1125.  
  1126.    callPrimitive ();
  1127.  
  1128.    *lRecordCount = XQLPPARMS.v.teditData.editcount;
  1129.    *tFileCount  = (BTI_SIZE)XQLPPARMS.v.teditData.filecount;
  1130.    return (XQLPPARMS.stat);
  1131. }
  1132.  
  1133. /***************************************************************************
  1134.    xJoin
  1135. ***************************************************************************/
  1136. BTI_API xJoin(
  1137.            BTI_SINT     iCursorID,
  1138.            BTI_CHAR_PTR sSecFile,
  1139.            BTI_CHAR_PTR sOwner,
  1140.            BTI_SINT     iOption,
  1141.            BTI_SIZE     tPriFldCount,
  1142.            BTI_CHAR_PTR sPriFlds,
  1143.            BTI_SIZE     tSecFldCount,
  1144.            BTI_CHAR_PTR sSecFlds)
  1145. {
  1146.    #ifdef BTI_DOS
  1147.    if (!Primitives_Loaded ())
  1148.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1149.    #endif
  1150.  
  1151.    XQLPPARMS.fcn                  = tJoinFcn;
  1152.    XQLPPARMS.cursorid             = iCursorID;
  1153.    XQLPPARMS.v.tjoinData.filename = (BTI_CHAR_PTR) sSecFile;
  1154.    XQLPPARMS.v.tjoinData.owner    = (BTI_CHAR_PTR) sOwner;
  1155.    XQLPPARMS.v.tjoinData.joinType = iOption;
  1156.    XQLPPARMS.v.tjoinData.pCount   = tPriFldCount;
  1157.    XQLPPARMS.v.tjoinData.pNames   = (BTI_CHAR_PTR) sPriFlds;
  1158.    XQLPPARMS.v.tjoinData.sCount   = tSecFldCount;
  1159.    XQLPPARMS.v.tjoinData.sNames   = (BTI_CHAR_PTR) sSecFlds;
  1160.  
  1161.    callPrimitive ();
  1162.  
  1163.    return (XQLPPARMS.stat);
  1164. }
  1165.  
  1166. /***************************************************************************
  1167.    xLogin
  1168. ***************************************************************************/
  1169. BTI_API xLogin(
  1170.            BTI_CHAR_PTR sUser,
  1171.            BTI_CHAR_PTR sPassword,
  1172.            BTI_CHAR_PTR sDDPath,
  1173.            BTI_CHAR_PTR sDataPath,
  1174.            BTI_CHAR_PTR sReserved,
  1175.            BTI_SINT     iFeaturesUsed)
  1176. {
  1177.    #ifdef BTI_DOS
  1178.    if (!Primitives_Loaded ())
  1179.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1180.    #endif
  1181.  
  1182.    XQLPPARMS.fcn                     = tLogInFcn;
  1183.    #ifdef BTI_NLM
  1184.    XQLPPARMS.stat                    = NSAgentID;
  1185.    #endif
  1186.    XQLPPARMS.cursorid                = 0;
  1187.    XQLPPARMS.v.tloginData.username   = (BTI_CHAR_PTR) sUser;
  1188.    XQLPPARMS.v.tloginData.pswd       = (BTI_CHAR_PTR) sPassword;
  1189.    XQLPPARMS.v.tloginData.dictionary = (BTI_CHAR_PTR) sDDPath;
  1190.    XQLPPARMS.v.tloginData.filepath   = (BTI_CHAR_PTR) sDataPath;
  1191.    XQLPPARMS.v.tloginData.sreserved  = (BTI_CHAR_PTR) sReserved;
  1192.    XQLPPARMS.v.tloginData.iFeaturesUsed  = iFeaturesUsed;
  1193.  
  1194.    callPrimitive ();
  1195.  
  1196.    if (XQLPPARMS.stat == 0)
  1197.      SQL_SessionID = XQLPPARMS.sessionid;
  1198.    return (XQLPPARMS.stat);
  1199. }
  1200.  
  1201. /***************************************************************************
  1202.    xLogout
  1203. ***************************************************************************/
  1204. BTI_API xLogout ()
  1205. {
  1206.    #ifdef BTI_DOS
  1207.    if (!Primitives_Loaded ())
  1208.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1209.    #endif
  1210.  
  1211.    XQLPPARMS.fcn    = tLogOutFcn;
  1212.  
  1213.    callPrimitive ();
  1214.  
  1215.    SQL_SessionID = -1;
  1216.    return (XQLPPARMS.stat);
  1217. }
  1218.  
  1219. /***************************************************************************
  1220.    xNew
  1221. ***************************************************************************/
  1222. BTI_API xNew(
  1223.            BTI_SINT_PTR iCursorID,
  1224.            BTI_CHAR_PTR sFileName,
  1225.            BTI_CHAR_PTR sOwner,
  1226.            BTI_SINT     iOpenMode)
  1227. {
  1228.    #ifdef BTI_DOS
  1229.    if (!Primitives_Loaded ())
  1230.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1231.    #endif
  1232.  
  1233.    XQLPPARMS.fcn                 = tNewFcn;
  1234.    XQLPPARMS.cursorid            = *iCursorID;
  1235.    XQLPPARMS.v.tnewData.filename = (BTI_CHAR_PTR) sFileName;
  1236.    XQLPPARMS.v.tnewData.owner    = (BTI_CHAR_PTR) sOwner;
  1237.    XQLPPARMS.v.tnewData.openmode = iOpenMode;
  1238.  
  1239.    callPrimitive ();
  1240.  
  1241.    if (XQLPPARMS.stat == 0)
  1242.      *iCursorID = XQLPPARMS.cursorid;
  1243.    return (XQLPPARMS.stat);
  1244. }
  1245.  
  1246. /***************************************************************************
  1247.    xOrder
  1248. ***************************************************************************/
  1249. BTI_API xOrder(
  1250.            BTI_SINT     iCursorID,
  1251.            BTI_SIZE     tCount,
  1252.            BTI_CHAR_PTR sOrderFld)
  1253. {
  1254.    #ifdef BTI_DOS
  1255.    if (!Primitives_Loaded ())
  1256.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1257.    #endif
  1258.  
  1259.    XQLPPARMS.fcn                = tOrderFcn;
  1260.    XQLPPARMS.cursorid           = iCursorID;
  1261.    XQLPPARMS.v.tordData.count   = tCount;
  1262.    XQLPPARMS.v.tordData.fldlist = (BTI_CHAR_PTR) sOrderFld;
  1263.  
  1264.    callPrimitive ();
  1265.  
  1266.    return (XQLPPARMS.stat);
  1267. }
  1268.  
  1269. /***************************************************************************
  1270.    xRemall
  1271. ***************************************************************************/
  1272. BTI_API xRemall(
  1273.            BTI_SINT     iCursorID,
  1274.            BTI_SIZE_PTR tFileCount,
  1275.            BTI_CHAR_PTR sFileNames,
  1276.            BTI_SINT     iOption,
  1277.            BTI_LONG_PTR lRecordCount,
  1278.            BTI_LONG_PTR lRejectCount )
  1279. {
  1280.    #ifdef BTI_DOS
  1281.    if (!Primitives_Loaded ())
  1282.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1283.    #endif
  1284.  
  1285.    XQLPPARMS.fcn                     = tRemallFcn;
  1286.    XQLPPARMS.cursorid                = iCursorID;
  1287.    XQLPPARMS.v.tremallData.filecount = *tFileCount;
  1288.    XQLPPARMS.v.tremallData.filelist  = (BTI_CHAR_PTR) sFileNames;
  1289.    XQLPPARMS.v.tremallData.option    = iOption;
  1290.    XQLPPARMS.v.tremallData.select    = *lRecordCount;
  1291.    XQLPPARMS.v.tremallData.reject    = *lRejectCount;
  1292.  
  1293.    callPrimitive ();
  1294.  
  1295.    *lRecordCount = XQLPPARMS.v.tremallData.select;
  1296.    *lRejectCount = XQLPPARMS.v.tremallData.reject;
  1297.    *tFileCount   = (BTI_SIZE)XQLPPARMS.v.tremallData.filecount;
  1298.  
  1299.    return (XQLPPARMS.stat);
  1300. }
  1301.  
  1302. /***************************************************************************
  1303.    xRemove
  1304. ***************************************************************************/
  1305. BTI_API xRemove(
  1306.            BTI_SINT     iCursorID,
  1307.            BTI_SIZE_PTR tFileCount,
  1308.            BTI_CHAR_PTR sFileNames,
  1309.            BTI_LONG_PTR lRecordCount )
  1310. {
  1311.    #ifdef BTI_DOS
  1312.    if (!Primitives_Loaded ())
  1313.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1314.    #endif
  1315.  
  1316.    XQLPPARMS.fcn                   = tRemoveFcn;
  1317.    XQLPPARMS.cursorid              = iCursorID;
  1318.    XQLPPARMS.v.teditData.filecount = *tFileCount;
  1319.    XQLPPARMS.v.teditData.filelist  = (BTI_CHAR_PTR) sFileNames;
  1320.    XQLPPARMS.v.teditData.editcount = *lRecordCount;
  1321.    XQLPPARMS.v.teditData.buf       = 0;
  1322.  
  1323.    callPrimitive ();
  1324.  
  1325.    *lRecordCount = XQLPPARMS.v.teditData.editcount;
  1326.    *tFileCount   = (BTI_SIZE)XQLPPARMS.v.teditData.filecount;
  1327.    return (XQLPPARMS.stat);
  1328. }
  1329.  
  1330. /***************************************************************************
  1331.    xReset
  1332. ***************************************************************************/
  1333. BTI_API xReset(
  1334.            BTI_CHAR_PTR sReserved)
  1335. {
  1336.    #ifdef BTI_DOS
  1337.    if (!Primitives_Loaded ())
  1338.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1339.    #endif
  1340.  
  1341.    XQLPPARMS.fcn    = tResetFcn;
  1342.    XQLPPARMS.v.tresetData.sreserved = (BTI_CHAR_PTR) sReserved;
  1343.  
  1344.    callPrimitive ();
  1345.  
  1346.    return (XQLPPARMS.stat);
  1347. }
  1348.  
  1349. /***************************************************************************
  1350.    xRestrict
  1351. ***************************************************************************/
  1352. BTI_API xRestrict(
  1353.            BTI_SINT     iCursorID,
  1354.            BTI_SINT     iOption,
  1355.            BTI_SIZE_PTR tExpLen,
  1356.            BTI_CHAR_PTR sExpression )
  1357. {
  1358.    #ifdef BTI_DOS
  1359.    if (!Primitives_Loaded ())
  1360.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1361.    #endif
  1362.  
  1363.    XQLPPARMS.fcn                 = tRestrictFcn;
  1364.    XQLPPARMS.cursorid            = iCursorID;
  1365.    XQLPPARMS.v.trestData.option  = iOption;
  1366.    XQLPPARMS.v.trestData.explen  = *tExpLen;
  1367.    XQLPPARMS.v.trestData.expbuf  = (BTI_CHAR_PTR) sExpression;
  1368.  
  1369.    callPrimitive ();
  1370.  
  1371.    if (XQLPPARMS.stat != 0)
  1372.      *tExpLen = (BTI_SIZE)XQLPPARMS.v.trestData.explen;
  1373.  
  1374.    return (XQLPPARMS.stat);
  1375. }
  1376.  
  1377. /***************************************************************************
  1378.    xStop
  1379. ***************************************************************************/
  1380. BTI_API xStop(
  1381.            void )
  1382. {
  1383.    #ifdef BTI_DOS
  1384.    if (!Primitives_Loaded ())
  1385.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1386.    #endif
  1387.  
  1388.    XQLPPARMS.fcn    = tStopFcn;
  1389.  
  1390.    callPrimitive ();
  1391.  
  1392.    return (XQLPPARMS.stat);
  1393. }
  1394.  
  1395. /***************************************************************************
  1396.    xTrans
  1397. ***************************************************************************/
  1398. BTI_API xTrans(
  1399.            BTI_SINT iOption )
  1400. {
  1401.    #ifdef BTI_DOS
  1402.    if (!Primitives_Loaded ())
  1403.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1404.    #endif
  1405.  
  1406.    XQLPPARMS.fcn                 = tTransFcn;
  1407.    XQLPPARMS.v.ttransData.option = iOption;
  1408.  
  1409.    callPrimitive ();
  1410.  
  1411.    return (XQLPPARMS.stat);
  1412. }
  1413.  
  1414. /***************************************************************************
  1415.    xUpdate
  1416. ***************************************************************************/
  1417. BTI_API xUpdate(
  1418.            BTI_SINT     iCursorID,
  1419.            BTI_SIZE_PTR tFileCount,
  1420.            BTI_CHAR_PTR sFileNames,
  1421.            BTI_LONG_PTR lRecordCount,
  1422.            BTI_CHAR_PTR bDataBuf )
  1423. {
  1424.    #ifdef BTI_DOS
  1425.    if (!Primitives_Loaded ())
  1426.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1427.    #endif
  1428.  
  1429.    XQLPPARMS.fcn                   = tUpdateFcn;
  1430.    XQLPPARMS.cursorid              = iCursorID;
  1431.    XQLPPARMS.v.teditData.filecount = *tFileCount;
  1432.    XQLPPARMS.v.teditData.filelist  = (BTI_CHAR_PTR) sFileNames;
  1433.    XQLPPARMS.v.teditData.editcount = *lRecordCount;
  1434.    XQLPPARMS.v.teditData.buf       = (BTI_CHAR_PTR) bDataBuf;
  1435.  
  1436.    callPrimitive ();
  1437.  
  1438.    *lRecordCount = XQLPPARMS.v.teditData.editcount;
  1439.    *tFileCount  = (BTI_SIZE)XQLPPARMS.v.teditData.filecount;
  1440.    return (XQLPPARMS.stat);
  1441. }
  1442.  
  1443. /***************************************************************************
  1444.    xStore
  1445. ***************************************************************************/
  1446. BTI_API xStore(
  1447.            BTI_SINT     iCursorID,
  1448.            BTI_CHAR_PTR sViewName,
  1449.            BTI_SIZE     tTextLen,
  1450.            BTI_CHAR_PTR sText )
  1451. {
  1452.    #ifdef BTI_DOS
  1453.    if (!Primitives_Loaded ())
  1454.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1455.    #endif
  1456.  
  1457.    XQLPPARMS.fcn                    = tStoreFcn;
  1458.    XQLPPARMS.cursorid               = iCursorID;
  1459.    XQLPPARMS.v.tstoreData.StoreName = (BTI_CHAR_PTR) sViewName;
  1460.    XQLPPARMS.v.tstoreData.BufLen    = tTextLen;
  1461.    XQLPPARMS.v.tstoreData.Buf       = (BTI_CHAR_PTR) sText;
  1462.  
  1463.    callPrimitive ();
  1464.  
  1465.    return (XQLPPARMS.stat);
  1466. }
  1467.  
  1468. /***************************************************************************
  1469.    xRecall
  1470. ***************************************************************************/
  1471. BTI_API xRecall(
  1472.            BTI_SINT_PTR iCursorID,
  1473.            BTI_CHAR_PTR sViewName,
  1474.            BTI_SIZE     tOwnerCount,
  1475.            BTI_CHAR_PTR sOwner,
  1476.            BTI_SINT     iOpenMode,
  1477.            BTI_SIZE_PTR tTextLen,
  1478.            BTI_CHAR_PTR sText )
  1479. {
  1480.    #ifdef BTI_DOS
  1481.    if (!Primitives_Loaded ())
  1482.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1483.    #endif
  1484.  
  1485.    XQLPPARMS.fcn                      = tRecallFcn;
  1486.    XQLPPARMS.cursorid                 = 0;
  1487.    XQLPPARMS.v.trecallData.RecallName = (BTI_CHAR_PTR) sViewName;
  1488.    XQLPPARMS.v.trecallData.ownernum   = tOwnerCount;
  1489.    XQLPPARMS.v.trecallData.ownerlst   = (BTI_CHAR_PTR) sOwner;
  1490.    XQLPPARMS.v.trecallData.openmode   = iOpenMode;
  1491.    XQLPPARMS.v.trecallData.buflen     = *tTextLen;
  1492.    XQLPPARMS.v.trecallData.buf        = (BTI_CHAR_PTR) sText;
  1493.  
  1494.    callPrimitive ();
  1495.  
  1496.    if (XQLPPARMS.stat == 0)
  1497.      *iCursorID = XQLPPARMS.cursorid;
  1498.    *tTextLen = (BTI_SIZE)XQLPPARMS.v.trecallData.buflen;
  1499.    return (XQLPPARMS.stat);
  1500. }
  1501.  
  1502. /***************************************************************************
  1503.    xUpdall
  1504. ***************************************************************************/
  1505. BTI_API xUpdall(
  1506.            BTI_SINT     iCursorID,
  1507.            BTI_SIZE_PTR tFileCount,
  1508.            BTI_CHAR_PTR sFileNames,
  1509.            BTI_SINT     iOption,
  1510.            BTI_LONG_PTR lRecordCount,
  1511.            BTI_LONG_PTR lRejectCount,
  1512.            BTI_SIZE     tFldCount,
  1513.            BTI_CHAR_PTR sUpdateFld,
  1514.            BTI_CHAR_PTR sReplaceFld )
  1515. {
  1516.    #ifdef BTI_DOS
  1517.    if (!Primitives_Loaded ())
  1518.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1519.    #endif
  1520.  
  1521.    XQLPPARMS.fcn                     = tUpdallFcn;
  1522.    XQLPPARMS.cursorid                = iCursorID;
  1523.    XQLPPARMS.v.tupdallData.filecount = *tFileCount;
  1524.    XQLPPARMS.v.tupdallData.filelist  = (BTI_CHAR_PTR) sFileNames;
  1525.    XQLPPARMS.v.tupdallData.option    = iOption;
  1526.    XQLPPARMS.v.tupdallData.select    = *lRecordCount;
  1527.    XQLPPARMS.v.tupdallData.reject    = *lRejectCount;
  1528.    XQLPPARMS.v.tupdallData.count     = tFldCount;
  1529.    XQLPPARMS.v.tupdallData.result    = (BTI_CHAR_PTR) sUpdateFld;
  1530.    XQLPPARMS.v.tupdallData.value     = (BTI_CHAR_PTR) sReplaceFld;
  1531.  
  1532.    callPrimitive ();
  1533.  
  1534.    *lRecordCount = XQLPPARMS.v.tupdallData.select;
  1535.    *lRejectCount = XQLPPARMS.v.tupdallData.reject;
  1536.    *tFileCount = (BTI_SIZE)XQLPPARMS.v.tupdallData.filecount;
  1537.    return (XQLPPARMS.stat);
  1538. }
  1539.  
  1540. /***************      Dictionary Primitives              ******************/
  1541. /***************************************************************************
  1542.    xDD
  1543. ***************************************************************************/
  1544. BTI_API xDD(
  1545.            BTI_CHAR_PTR sPathName,
  1546.            BTI_SINT     iOption)
  1547. {
  1548.    #ifdef BTI_DOS
  1549.    if (!Primitives_Loaded ())
  1550.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1551.    #endif
  1552.  
  1553.    XQLPPARMS.fcn                = tDDFcn;
  1554.    XQLPPARMS.v.tddData.dirpath  = (BTI_CHAR_PTR) sPathName;
  1555.    XQLPPARMS.v.tddData.function = iOption;
  1556.  
  1557.    callPrimitive ();
  1558.  
  1559.    return (XQLPPARMS.stat);
  1560. }
  1561.  
  1562. /***************************************************************************
  1563.    xDDAttr
  1564. ***************************************************************************/
  1565. BTI_API xDDAttr(
  1566.            BTI_SINT     iOption,
  1567.            BTI_CHAR_PTR sFldName,
  1568.            BTI_SINT     iAttrType,
  1569.            BTI_SIZE_PTR tBufLen,
  1570.            BTI_CHAR_PTR sAttrBuf )
  1571. {
  1572.    #ifdef BTI_DOS
  1573.    if (!Primitives_Loaded ())
  1574.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1575.    #endif
  1576.  
  1577.    XQLPPARMS.fcn                     = tDDAttrFcn;
  1578.    XQLPPARMS.v.tddattrData.fcn       = iOption;
  1579.    XQLPPARMS.v.tddattrData.fieldname = (BTI_CHAR_PTR) sFldName;
  1580.    XQLPPARMS.v.tddattrData.attr      = iAttrType;
  1581.    XQLPPARMS.v.tddattrData.bufsize   = *tBufLen;
  1582.    XQLPPARMS.v.tddattrData.attrbuf   = (BTI_CHAR_PTR) sAttrBuf;
  1583.  
  1584.    callPrimitive ();
  1585.  
  1586.    *tBufLen = (BTI_SIZE)XQLPPARMS.v.tddattrData.bufsize;
  1587.    return (XQLPPARMS.stat);
  1588. }
  1589.  
  1590. /***************************************************************************
  1591.    xDDModify
  1592. ***************************************************************************/
  1593. BTI_API xDDModify(
  1594.            BTI_SINT     iOption,
  1595.            BTI_CHAR_PTR sFileName,
  1596.            BTI_SINT     iCreate,
  1597.            BTI_CHAR_PTR sPathName,
  1598.            BTI_CHAR_PTR sOwner,
  1599.            BTI_SINT     iOwnerFlag,
  1600.            BTI_SIZE     tFldCount,
  1601.            BTI_CHAR_PTR bFldBuf,
  1602.            BTI_SIZE     tIndxCount,
  1603.            BTI_CHAR_PTR bIndxBuf)
  1604. {
  1605.    #ifdef BTI_DOS
  1606.    if (!Primitives_Loaded ())
  1607.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1608.    #endif
  1609.  
  1610.    XQLPPARMS.fcn                  = tDDModFcn;
  1611.    XQLPPARMS.v.tmodData.option    = iOption;
  1612.    XQLPPARMS.v.tmodData.filename  = (BTI_CHAR_PTR) sFileName;
  1613.    XQLPPARMS.v.tmodData.create    = iCreate;
  1614.    XQLPPARMS.v.tmodData.pathname  = (BTI_CHAR_PTR) sPathName;
  1615.    XQLPPARMS.v.tmodData.owner     = (BTI_CHAR_PTR) sOwner;
  1616.    XQLPPARMS.v.tmodData.oaccess   = iOwnerFlag;
  1617.    XQLPPARMS.v.tmodData.fieldlist = (BTI_CHAR_PTR) bFldBuf;
  1618.    XQLPPARMS.v.tmodData.keylist   = (BTI_CHAR_PTR) bIndxBuf;
  1619.    XQLPPARMS.v.tmodData.fldcount  = tFldCount;
  1620.    XQLPPARMS.v.tmodData.kcount    = tIndxCount;
  1621.  
  1622.    callPrimitive ();
  1623.  
  1624.    return (XQLPPARMS.stat);
  1625. }
  1626.  
  1627. /***************************************************************************
  1628.    xDDCreate
  1629. ***************************************************************************/
  1630. BTI_API xDDCreate(
  1631.            BTI_SINT     iOption,
  1632.            BTI_CHAR_PTR sFileName,
  1633.            BTI_SINT     iCreate,
  1634.            BTI_CHAR_PTR sPathName,
  1635.            BTI_CHAR_PTR sOwner,
  1636.            BTI_SINT     iOwnerFlag,
  1637.            BTI_SIZE     tFldCount,
  1638.            BTI_CHAR_PTR bFldBuf,
  1639.            BTI_SIZE     tIndxCount,
  1640.            BTI_CHAR_PTR bIndxBuf,
  1641.            BTI_SIZE     tBufLen,
  1642.            BTI_CHAR_PTR bCreateParmsBuf )
  1643. {
  1644.    #ifdef BTI_DOS
  1645.    if (!Primitives_Loaded ())
  1646.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1647.    #endif
  1648.  
  1649.    XQLPPARMS.fcn                    = tDDCreFcn;
  1650.    XQLPPARMS.v.tcreData.option      = iOption;
  1651.    XQLPPARMS.v.tcreData.filename    = (BTI_CHAR_PTR) sFileName;
  1652.    XQLPPARMS.v.tcreData.create      = iCreate;
  1653.    XQLPPARMS.v.tcreData.pathname    = (BTI_CHAR_PTR) sPathName;
  1654.    XQLPPARMS.v.tcreData.owner       = (BTI_CHAR_PTR) sOwner;
  1655.    XQLPPARMS.v.tcreData.oaccess     = iOwnerFlag;
  1656.    XQLPPARMS.v.tcreData.fieldlist   = (BTI_CHAR_PTR) bFldBuf;
  1657.    XQLPPARMS.v.tcreData.keylist     = (BTI_CHAR_PTR) bIndxBuf;
  1658.    XQLPPARMS.v.tcreData.fldcount    = tFldCount;
  1659.    XQLPPARMS.v.tcreData.kcount      = tIndxCount;
  1660.    XQLPPARMS.v.tcreData.buflen      = tBufLen;
  1661.    XQLPPARMS.v.tcreData.createparms = (BTI_CHAR_PTR) bCreateParmsBuf;
  1662.  
  1663.    callPrimitive ();
  1664.  
  1665.    return (XQLPPARMS.stat);
  1666. }
  1667.  
  1668. /***************************************************************************
  1669.    xDDrop
  1670. ***************************************************************************/
  1671. BTI_API xDDDrop(
  1672.            BTI_CHAR_PTR sName,
  1673.            BTI_SINT     iType,
  1674.            BTI_SINT     iDelete )
  1675. {
  1676.    #ifdef BTI_DOS
  1677.    if (!Primitives_Loaded ())
  1678.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1679.    #endif
  1680.  
  1681.    XQLPPARMS.fcn                      = tDDDrpFcn;
  1682.    XQLPPARMS.v.tdddropData.filename   = (BTI_CHAR_PTR) sName;
  1683.    XQLPPARMS.v.tdddropData.filetype   = iType;
  1684.    XQLPPARMS.v.tdddropData.deletepath = iDelete;
  1685.  
  1686.    callPrimitive ();
  1687.  
  1688.    return (XQLPPARMS.stat);
  1689. }
  1690.  
  1691. /***************************************************************************
  1692.    xDDField
  1693. ***************************************************************************/
  1694. BTI_API xDDField(
  1695.            BTI_SINT     iOption,
  1696.            BTI_SIZE_PTR tCount,
  1697.            BTI_CHAR_PTR sFldNames,
  1698.            BTI_SIZE_PTR tBufLen,
  1699.            BTI_CHAR_PTR bDataBuf )
  1700. {
  1701.    #ifdef BTI_DOS
  1702.    if (!Primitives_Loaded ())
  1703.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1704.    #endif
  1705.  
  1706.    XQLPPARMS.fcn                     = tDDFieldFcn;
  1707.    XQLPPARMS.v.tddfieldData.rtype    = iOption;
  1708.    XQLPPARMS.v.tddfieldData.count    = *tCount;
  1709.    XQLPPARMS.v.tddfieldData.buflen   = *tBufLen;
  1710.    XQLPPARMS.v.tddfieldData.fieldbuf = (BTI_CHAR_PTR) sFldNames;
  1711.    XQLPPARMS.v.tddfieldData.outbuf   = (BTI_CHAR_PTR) bDataBuf;
  1712.  
  1713.    callPrimitive ();
  1714.  
  1715.    if (XQLPPARMS.stat >= 0)
  1716.    {
  1717.       *tCount  = XQLPPARMS.v.tddfieldData.count;
  1718.       *tBufLen = XQLPPARMS.v.tddfieldData.buflen;
  1719.    }
  1720.    return (XQLPPARMS.stat);
  1721. }
  1722.  
  1723. /***************************************************************************
  1724.    xDDFile
  1725. ***************************************************************************/
  1726. BTI_API xDDFile(
  1727.            BTI_SINT     iOption,
  1728.            BTI_SIZE_PTR tCount,
  1729.            BTI_CHAR_PTR sFileNames,
  1730.            BTI_SIZE_PTR tBufLen,
  1731.            BTI_CHAR_PTR bDataBuf )
  1732. {
  1733.    #ifdef BTI_DOS
  1734.    if (!Primitives_Loaded ())
  1735.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1736.    #endif
  1737.  
  1738.    XQLPPARMS.fcn                   = tDDFileFcn;
  1739.    XQLPPARMS.v.tddfileData.rtype   = iOption;
  1740.    XQLPPARMS.v.tddfileData.count   = *tCount;
  1741.    XQLPPARMS.v.tddfileData.filebuf = (BTI_CHAR_PTR) sFileNames;
  1742.    XQLPPARMS.v.tddfileData.buflen  = *tBufLen;
  1743.    XQLPPARMS.v.tddfileData.outbuf  = (BTI_CHAR_PTR) bDataBuf;
  1744.  
  1745.    callPrimitive ();
  1746.  
  1747.    if (XQLPPARMS.stat >= 0)
  1748.    {
  1749.       *tCount  = (BTI_SIZE)XQLPPARMS.v.tddfileData.count;
  1750.       *tBufLen = (BTI_SIZE)XQLPPARMS.v.tddfileData.buflen;
  1751.    }
  1752.    return (XQLPPARMS.stat);
  1753. }
  1754.  
  1755. /***************************************************************************
  1756.    xDDIndex
  1757. ***************************************************************************/
  1758. BTI_API xDDIndex(
  1759.            BTI_SINT     iOption,
  1760.            BTI_SIZE_PTR tCount,
  1761.            BTI_CHAR_PTR sIndexName,
  1762.            BTI_SIZE_PTR tBufLen,
  1763.            BTI_CHAR_PTR bDataBuf )
  1764. {
  1765.    #ifdef BTI_DOS
  1766.    if (!Primitives_Loaded ())
  1767.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1768.    #endif
  1769.  
  1770.    XQLPPARMS.fcn                     = tDDIndexFcn;
  1771.    XQLPPARMS.v.tddindexData.rtype    = iOption;
  1772.    XQLPPARMS.v.tddindexData.count    = *tCount;
  1773.    XQLPPARMS.v.tddindexData.buflen   = *tBufLen;
  1774.    XQLPPARMS.v.tddindexData.fieldbuf = (BTI_CHAR_PTR) sIndexName;
  1775.    XQLPPARMS.v.tddindexData.outbuf   = (BTI_CHAR_PTR) bDataBuf;
  1776.  
  1777.    callPrimitive ();
  1778.  
  1779.    if (XQLPPARMS.stat >= 0)
  1780.    {
  1781.       *tCount  = (BTI_SIZE)XQLPPARMS.v.tddindexData.count;
  1782.       *tBufLen = (BTI_SIZE)XQLPPARMS.v.tddindexData.buflen;
  1783.    }
  1784.    return (XQLPPARMS.stat);
  1785. }
  1786.  
  1787. /***************************************************************************
  1788.    xDDPath
  1789. ***************************************************************************/
  1790. BTI_API xDDPath(
  1791.         BTI_SINT     iOption,
  1792.         BTI_CHAR_PTR sPathName )
  1793. {
  1794.    #ifdef BTI_DOS
  1795.    if (!Primitives_Loaded ())
  1796.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1797.    #endif
  1798.  
  1799.    XQLPPARMS.fcn                    = tDDPathFcn;
  1800.    XQLPPARMS.v.tddpathData.dirtype  = iOption;
  1801.    XQLPPARMS.v.tddpathData.pathname = (BTI_CHAR_PTR) sPathName;
  1802.  
  1803.    callPrimitive ();
  1804.  
  1805.    return (XQLPPARMS.stat);
  1806. }
  1807.  
  1808. /***************************************************************************
  1809.    xDDView
  1810. ***************************************************************************/
  1811. BTI_API xDDView(
  1812.         BTI_SIZE_PTR tCount,
  1813.         BTI_CHAR_PTR sViewName,
  1814.         BTI_SIZE_PTR tBufLen,
  1815.         BTI_CHAR_PTR bDataBuf )
  1816. {
  1817.    #ifdef BTI_DOS
  1818.    if (!Primitives_Loaded ())
  1819.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1820.    #endif
  1821.  
  1822.    XQLPPARMS.fcn                    = tDDViewFcn;
  1823.    XQLPPARMS.v.tddviewData.count    = *tCount;
  1824.    XQLPPARMS.v.tddviewData.viewname = (BTI_CHAR_PTR) sViewName;
  1825.    XQLPPARMS.v.tddviewData.buflen   = *tBufLen;
  1826.    XQLPPARMS.v.tddviewData.outbuf   = (BTI_CHAR_PTR) bDataBuf;
  1827.  
  1828.    callPrimitive ();
  1829.  
  1830.    if (XQLPPARMS.stat >= 0)
  1831.    {
  1832.       *tCount  = (BTI_SIZE)XQLPPARMS.v.tddviewData.count;
  1833.       *tBufLen = (BTI_SIZE)XQLPPARMS.v.tddviewData.buflen;
  1834.    }
  1835.    return (XQLPPARMS.stat);
  1836. }
  1837.  
  1838. /***************      Security Primitives                ******************/
  1839. /***************************************************************************
  1840.    xAccess
  1841. ***************************************************************************/
  1842. BTI_API xAccess(
  1843.            BTI_CHAR_PTR sMstrPswd,
  1844.            BTI_CHAR_PTR sUser,
  1845.            BTI_SINT     iOption,
  1846.            BTI_SINT     iAccRights,
  1847.            BTI_CHAR_PTR sFileName,
  1848.            BTI_SIZE_PTR tCount,
  1849.            BTI_CHAR_PTR sFldNames,
  1850.            BTI_SIZE_PTR tBufLen,
  1851.            BTI_CHAR_PTR bDataBuf )
  1852. {
  1853.    #ifdef BTI_DOS
  1854.    if (!Primitives_Loaded ())
  1855.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1856.    #endif
  1857.  
  1858.    XQLPPARMS.fcn                    = tAccessFcn;
  1859.    XQLPPARMS.v.taccessData.mpswd    = (BTI_CHAR_PTR) sMstrPswd;
  1860.    XQLPPARMS.v.taccessData.username = (BTI_CHAR_PTR) sUser;
  1861.    XQLPPARMS.v.taccessData.fcn      = iOption;
  1862.    XQLPPARMS.v.taccessData.rights   = iAccRights;
  1863.    XQLPPARMS.v.taccessData.filename = (BTI_CHAR_PTR) sFileName;
  1864.    XQLPPARMS.v.taccessData.count    = *tCount;
  1865.    XQLPPARMS.v.taccessData.name     = (BTI_CHAR_PTR) sFldNames;
  1866.    XQLPPARMS.v.taccessData.buflen   = *tBufLen;
  1867.    XQLPPARMS.v.taccessData.outbuf   = (BTI_CHAR_PTR) bDataBuf;
  1868.  
  1869.    callPrimitive ();
  1870.  
  1871.    if (XQLPPARMS.stat == 0)
  1872.    {
  1873.       *tCount  = (BTI_SIZE)XQLPPARMS.v.taccessData.count;
  1874.       *tBufLen = (BTI_SIZE)XQLPPARMS.v.taccessData.buflen;
  1875.    }
  1876.    return (XQLPPARMS.stat);
  1877. }
  1878.  
  1879. /***************************************************************************
  1880.    xPassword
  1881. ***************************************************************************/
  1882. BTI_API xPassword(
  1883.            BTI_CHAR_PTR sUser,
  1884.            BTI_CHAR_PTR sPassword )
  1885. {
  1886.    #ifdef BTI_DOS
  1887.    if (!Primitives_Loaded ())
  1888.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1889.    #endif
  1890.  
  1891.    XQLPPARMS.fcn              = tPswdFcn;
  1892.    XQLPPARMS.v.tpswdData.user = (BTI_CHAR_PTR) sUser;
  1893.    XQLPPARMS.v.tpswdData.pswd = (BTI_CHAR_PTR) sPassword;
  1894.  
  1895.    callPrimitive ();
  1896.  
  1897.    return (XQLPPARMS.stat);
  1898. }
  1899.  
  1900. /***************************************************************************
  1901.    xSecurity
  1902. ***************************************************************************/
  1903. BTI_API xSecurity(
  1904.         BTI_CHAR_PTR sMstrPswd,
  1905.         BTI_SINT     iOption )
  1906. {
  1907.    #ifdef BTI_DOS
  1908.    if (!Primitives_Loaded ())
  1909.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1910.    #endif
  1911.  
  1912.    XQLPPARMS.fcn                        = tSecurFcn;
  1913.    XQLPPARMS.v.tsecureData.mpswd        = (BTI_CHAR_PTR) sMstrPswd;
  1914.    XQLPPARMS.v.tsecureData.securityflag = iOption;
  1915.  
  1916.    callPrimitive ();
  1917.  
  1918.    return (XQLPPARMS.stat);
  1919. }
  1920.  
  1921. /***************************************************************************
  1922.    xUser
  1923. ***************************************************************************/
  1924. BTI_API xUser(
  1925.            BTI_CHAR_PTR sMstPswd,
  1926.            BTI_SINT     iOption,
  1927.            BTI_CHAR_PTR sUser,
  1928.            BTI_CHAR_PTR sPassword,
  1929.            BTI_SINT     iFlags,
  1930.            BTI_SIZE_PTR tCount,
  1931.            BTI_SIZE_PTR tBufLen,
  1932.            BTI_CHAR_PTR bDataBuf )
  1933. {
  1934.    #ifdef BTI_DOS
  1935.    if (!Primitives_Loaded ())
  1936.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1937.    #endif
  1938.  
  1939.    XQLPPARMS.fcn                  = tUserFcn;
  1940.    XQLPPARMS.v.tuserData.mpswd    = (BTI_CHAR_PTR) sMstPswd;
  1941.    XQLPPARMS.v.tuserData.fcn      = iOption;
  1942.    XQLPPARMS.v.tuserData.username = (BTI_CHAR_PTR) sUser;
  1943.    XQLPPARMS.v.tuserData.pswd     = (BTI_CHAR_PTR) sPassword;
  1944.    XQLPPARMS.v.tuserData.grights  = iFlags;
  1945.    XQLPPARMS.v.tuserData.count    = *tCount;
  1946.    XQLPPARMS.v.tuserData.buflen   = *tBufLen;
  1947.    XQLPPARMS.v.tuserData.userbuf  = (BTI_CHAR_PTR) bDataBuf;
  1948.  
  1949.    callPrimitive ();
  1950.  
  1951.    *tCount  = (BTI_SIZE)XQLPPARMS.v.tuserData.count;
  1952.    *tBufLen = (BTI_SIZE)XQLPPARMS.v.tuserData.buflen;
  1953.    return (XQLPPARMS.stat);
  1954. }
  1955.  
  1956. /***************      Miscellaneous Primitives           ******************/
  1957. /***************************************************************************
  1958.    xChar
  1959. ***************************************************************************/
  1960. BTI_API xChar(
  1961.            BTI_SINT     iOption,
  1962.            BTI_SINT     iType,
  1963.            BTI_CHAR_PTR cCharacter )
  1964. {
  1965.    #ifdef BTI_DOS
  1966.    if (!Primitives_Loaded ())
  1967.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1968.    #endif
  1969.  
  1970.    XQLPPARMS.fcn                   = tCharFcn;
  1971.    XQLPPARMS.v.tcharData.charFcn   = iOption;
  1972.    XQLPPARMS.v.tcharData.charType  = iType;
  1973.    XQLPPARMS.v.tcharData.charValue = *(BTI_SINT *)cCharacter;
  1974.  
  1975.    callPrimitive ();
  1976.  
  1977.    *cCharacter = XQLPPARMS.v.tcharData.charValue;
  1978.    return (XQLPPARMS.stat);
  1979. }
  1980.  
  1981. /***************************************************************************
  1982.    xVersion
  1983. ***************************************************************************/
  1984. BTI_API xVersion(
  1985.            BTI_CHAR_PTR sVersion )
  1986. {
  1987.    #ifdef BTI_DOS
  1988.    if (!Primitives_Loaded ())
  1989.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  1990.    #endif
  1991.  
  1992.    XQLPPARMS.fcn                   = tVersionFcn;
  1993.    XQLPPARMS.v.tversionData.buffer = (BTI_CHAR_PTR) sVersion;
  1994.  
  1995.    callPrimitive ();
  1996.  
  1997.    return (XQLPPARMS.stat);
  1998. }
  1999.  
  2000. /***************************************************************************
  2001.    xConvert
  2002. ***************************************************************************/
  2003. BTI_API xConvert(
  2004.            BTI_SINT     iOption,
  2005.            BTI_SINT     iType,
  2006.            BTI_SIZE     tSize,
  2007.            BTI_SIZE     tDec,
  2008.            BTI_SIZE     tDSize,
  2009.            BTI_CHAR_PTR sValue,
  2010.            BTI_CHAR_PTR sRetVal,
  2011.            BTI_CHAR_PTR sMask,
  2012.            BTI_SINT     iJustify )
  2013. {
  2014.    #ifdef BTI_DOS
  2015.    if (!Primitives_Loaded ())
  2016.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  2017.    #endif
  2018.  
  2019.    XQLPPARMS.fcn                = tCnvFcn;
  2020.    XQLPPARMS.v.tcnvData.option  = iOption;
  2021.    XQLPPARMS.v.tcnvData.type    = iType;
  2022.    XQLPPARMS.v.tcnvData.size    = tSize;
  2023.    XQLPPARMS.v.tcnvData.dec     = tDec;
  2024.    XQLPPARMS.v.tcnvData.dsize   = tDSize;
  2025.    XQLPPARMS.v.tcnvData.value   = (BTI_CHAR_PTR) sValue;
  2026.    XQLPPARMS.v.tcnvData.retval  = (BTI_CHAR_PTR) sRetVal;
  2027.    XQLPPARMS.v.tcnvData.mask    = (BTI_CHAR_PTR) sMask;
  2028.    XQLPPARMS.v.tcnvData.justify = iJustify;
  2029.  
  2030.    callPrimitive ();
  2031.  
  2032.    return (XQLPPARMS.stat);
  2033. }
  2034.  
  2035. /***************************************************************************
  2036.    xValidate
  2037. ***************************************************************************/
  2038. BTI_API xValidate(
  2039.            BTI_SIZE_PTR tCount,
  2040.            BTI_CHAR_PTR sFieldName,
  2041.            BTI_SIZE     tBufLen,
  2042.            BTI_CHAR_PTR bDataBuf )
  2043. {
  2044.    #ifdef BTI_DOS
  2045.    if (!Primitives_Loaded ())
  2046.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  2047.    #endif
  2048.  
  2049.    XQLPPARMS.fcn                  = tValFcn;
  2050.    XQLPPARMS.v.tvalData.fieldname = (BTI_CHAR_PTR) sFieldName;
  2051.    XQLPPARMS.v.tvalData.count     = *tCount;
  2052.    XQLPPARMS.v.tvalData.buflen    = tBufLen;
  2053.    XQLPPARMS.v.tvalData.data      = (BTI_CHAR_PTR) bDataBuf;
  2054.  
  2055.    callPrimitive ();
  2056.  
  2057.    *tCount = (BTI_SIZE)XQLPPARMS.v.tvalData.count;
  2058.    return (XQLPPARMS.stat);
  2059. }
  2060.  
  2061. /***************************************************************************
  2062.    xMask
  2063. ***************************************************************************/
  2064. BTI_API xMask(
  2065.            BTI_SINT     iOption,
  2066.            BTI_SINT     iType,
  2067.            BTI_SIZE     tSize,
  2068.            BTI_SINT     iDec,
  2069.            BTI_SIZE_PTR tLen,
  2070.            BTI_CHAR_PTR sMask )
  2071. {
  2072.    #ifdef BTI_DOS
  2073.    if (!Primitives_Loaded ())
  2074.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  2075.    #endif
  2076.  
  2077.    XQLPPARMS.fcn                  = tMaskFcn;
  2078.    XQLPPARMS.v.tmaskData.option   = iOption;
  2079.    XQLPPARMS.v.tmaskData.type     = iType;
  2080.    XQLPPARMS.v.tmaskData.size     = tSize;
  2081.    XQLPPARMS.v.tmaskData.dec      = iDec;
  2082.    XQLPPARMS.v.tmaskData.mlen     = *tLen;
  2083.    XQLPPARMS.v.tmaskData.mask     = (BTI_CHAR_PTR) sMask;
  2084.  
  2085.    callPrimitive ();
  2086.  
  2087.    *tLen = XQLPPARMS.v.tmaskData.mlen;
  2088.  
  2089.    return (XQLPPARMS.stat);
  2090. }
  2091.  
  2092. /***************************************************************************
  2093.    xStatus
  2094. ***************************************************************************/
  2095. BTI_API xStatus(
  2096.            BTI_SINT     iCursorID,
  2097.            BTI_SINT     iOption,
  2098.            BTI_SIZE_PTR tLen,
  2099.            BTI_CHAR_PTR sStatBuf )
  2100. {
  2101.    #ifdef BTI_DOS
  2102.    if (!Primitives_Loaded ())
  2103.       return (SQL_PRIM_COMPONENT_NOT_LOADED);
  2104.    #endif
  2105.  
  2106.    XQLPPARMS.fcn                = tStatFcn;
  2107.    XQLPPARMS.cursorid           = iCursorID;
  2108.    XQLPPARMS.v.tstatData.option = iOption;
  2109.    XQLPPARMS.v.tstatData.buflen = *tLen;
  2110.    XQLPPARMS.v.tstatData.buf    = (BTI_CHAR_PTR) sStatBuf;
  2111.  
  2112.    callPrimitive ();
  2113.  
  2114.    *tLen = (BTI_SIZE)XQLPPARMS.v.tstatData.buflen;
  2115.    return (XQLPPARMS.stat);
  2116. }
  2117.  
  2118. /***************************************************************************
  2119.    PLATFORM-DEPENDENT SUPPORT FUNCTIONS
  2120. ***************************************************************************/
  2121. /***************************************************************************
  2122.    callsql
  2123. ***************************************************************************/
  2124. #ifdef BTI_DOS
  2125. BTI_API callsql(
  2126.            BTI_CHAR_PTR SQLParms )
  2127. {
  2128.    segread((struct SREGS *) &sregs);
  2129.    regs.dx = FP_OFF (SQLParms);
  2130.    sregs.ds = FP_SEG (SQLParms);
  2131.  
  2132.    int86x(SQL_INT, (union REGS *)®s, (union REGS *)®s,
  2133.           (struct SREGS *)&sregs);
  2134.  
  2135.    return(0);
  2136. }
  2137. #endif
  2138.  
  2139. #ifdef BTI_DOS_32R
  2140. BTI_API callsql(
  2141.            BTI_CHAR_PTR SQLParms )
  2142. {
  2143.    pmswParmBlock pb;
  2144.  
  2145.    *((BTI_LONG_PTR) &(pb.sign)) = *((BTI_LONG_PTR) PMSW_SIGN);
  2146.    pb.flags = 0;
  2147.    if (XQLMPARMS.XQL_ID[3] == 'P')
  2148.       pb.func = XQLP_CALL;
  2149.    else
  2150.       pb.func = XQLM_CALL;
  2151.    pb.len  = sizeof(pb);
  2152.    pb.data = SQLParms;
  2153.  
  2154.    (*_ImportedFunctions_)[PROCESS7B].functionPtr((pmswParmBlock *)SQLParms);
  2155.  
  2156.    return(0);
  2157. }
  2158. #endif
  2159.  
  2160. #ifdef BTI_DOS_32P
  2161. BTI_API callsql(
  2162.            BTI_CHAR_PTR SQLParms )
  2163. {
  2164.    /*
  2165.    ** Phar Lap DOS extender specific code
  2166.    */
  2167.    SWI_REGS       sql_regs;
  2168.    FARPTR         protectedP;
  2169.    BTI_ULONG      realPtr;
  2170.    BTI_ULONG      bufferSize;
  2171.    PARMBLOCK      *srb;
  2172.    BTI_SINT       fcn;
  2173.    BTI_SINT       stat = SS_SUCCESS;
  2174.  
  2175.    bufferSize = MaxSRBDataSize;
  2176.    srb = (PARMBLOCK *) malloc(bufferSize);
  2177.    if (!srb)
  2178.       stat = SQL_NO_HEAP_MEM_P;
  2179.    else
  2180.    {
  2181.       stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
  2182.       startOfRealPtr = realPtr;
  2183.  
  2184.       if (stat == SS_SUCCESS)
  2185.       {
  2186.          stat = SRBFormat((PARMBLOCK *) SQLParms, srb, &fcn);
  2187.  
  2188.          if (stat == SS_SUCCESS)
  2189.          {
  2190.             copyToLow(
  2191.                FP_SEL(protectedP),          /* Selector to real-mode buffer */
  2192.                FP_OFF(protectedP),            /* offset of real-mode buffer */
  2193.                srb,                                  /* send/receive buffer */
  2194.                bufferSize);                                 /* size of srb */
  2195.  
  2196.             /*
  2197.             ** Initialize registers for real-mode interrupt call.
  2198.             */
  2199.             memset(&sql_regs, 0, sizeof(sql_regs));
  2200.             sql_regs.ds  = RP_SEG(realPtr);
  2201.             sql_regs.edx = RP_OFF(realPtr);
  2202.  
  2203.             /*
  2204.             **   The _dx_real_int routine issues the 7b interrupt in real mode
  2205.             */
  2206.             _dx_real_int(SQL_INT, &sql_regs);
  2207.  
  2208.             copyFromLow(
  2209.                 srb,
  2210.                 FP_SEL(protectedP),
  2211.                 FP_OFF(protectedP),
  2212.                 bufferSize);
  2213.  
  2214.             SRBUnformat((PARMBLOCK *) SQLParms, srb, fcn);
  2215.          }
  2216.          freeRealModeBuffer(FP_SEL(protectedP));
  2217.       }
  2218.       free(srb);
  2219.    }
  2220.    if (stat != SS_SUCCESS)
  2221.       ((PARMBLOCK *) SQLParms)->stat = stat;
  2222.    return(((PARMBLOCK *)SQLParms)->stat);
  2223. }
  2224. #endif
  2225.  
  2226. #ifdef BTI_DOS_32B
  2227. BTI_API callsql(
  2228.            BTI_CHAR_PTR SQLParms )
  2229. {
  2230.    /*
  2231.    **   Call SSQL using Borland Power Pack DOS Extender
  2232.    */
  2233.    union  REGS    sql_regs;
  2234.    FARPTR         protectedP;
  2235.    BTI_ULONG      realPtr;
  2236.    BTI_ULONG      bufferSize;
  2237.    PARMBLOCK      *srb;
  2238.    BTI_SINT       fcn;
  2239.    BTI_SINT       stat = SS_SUCCESS;
  2240.    struct   REALMODEREGS
  2241.    {
  2242.       BTI_ULONG edi;
  2243.       BTI_ULONG esi;
  2244.       BTI_ULONG ebp;
  2245.       BTI_ULONG reserved;
  2246.       BTI_ULONG ebx;
  2247.       BTI_ULONG edx;
  2248.       BTI_ULONG ecx;
  2249.       BTI_ULONG eax;
  2250.       BTI_WORD  CPUflag;
  2251.       BTI_WORD  es;
  2252.       BTI_WORD  ds;
  2253.       BTI_WORD  fs;
  2254.       BTI_WORD  gs;
  2255.       BTI_WORD  ip;
  2256.       BTI_WORD  cs;
  2257.       BTI_WORD  sp;
  2258.       BTI_WORD  ss;
  2259.    } realmodeRegs;
  2260.  
  2261.    bufferSize = MaxSRBDataSize;
  2262.    srb = (PARMBLOCK *) malloc(bufferSize);
  2263.    if (!srb)
  2264.       stat = SQL_NO_HEAP_MEM_P;
  2265.    else
  2266.    {
  2267.       stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
  2268.       startOfRealPtr = realPtr;
  2269.  
  2270.       if (stat == SS_SUCCESS)
  2271.       {
  2272.          stat = SRBFormat((PARMBLOCK *) SQLParms, srb, &fcn);
  2273.  
  2274.          if (stat == SS_SUCCESS)
  2275.          {
  2276.             copyToLow(
  2277.                FP_SEL(protectedP),
  2278.                FP_OFF(protectedP),
  2279.                srb,
  2280.                bufferSize);
  2281.  
  2282.             /*
  2283.             ** Initialize registers for real-mode interrupt
  2284.             */
  2285.             sql_regs.x.eax = 0x300;
  2286.             sql_regs.h.bl  = SQL_INT;
  2287.             sql_regs.h.bh  = 0;
  2288.  
  2289.             /*
  2290.             ** CX = Number of words to copy from protected-mode to
  2291.             ** real-mode stack
  2292.             */
  2293.             sql_regs.x.ecx = 0;
  2294.  
  2295.             /*
  2296.             ** Initialize real mode segment registers for call to SSQL
  2297.             */
  2298.             memset(&realmodeRegs, 0, sizeof(struct REALMODEREGS));
  2299.  
  2300.             /*
  2301.             ** DS Register contains the segment address of parameter block
  2302.             */
  2303.             realmodeRegs.ds  = (BTI_WORD) (realPtr >> 16);
  2304.  
  2305.             /*
  2306.             ** EDX Register contains offset of parameter block
  2307.             */
  2308.             realmodeRegs.edx = (realPtr << 16);
  2309.             sql_regs.x.edi = (BTI_ULONG) &realmodeRegs;
  2310.  
  2311.             int386(0x31, &sql_regs, &sql_regs);
  2312.  
  2313.             copyFromLow(
  2314.                 srb,
  2315.                 FP_SEL(protectedP),
  2316.                 FP_OFF(protectedP),
  2317.                 bufferSize);
  2318.  
  2319.             SRBUnformat((PARMBLOCK *) SQLParms, srb, fcn);
  2320.          }
  2321.          freeRealModeBuffer(FP_SEL(protectedP));  /* Free real-mode mem */
  2322.       }
  2323.       free(srb);                    /* Free temporary send/request buffer */
  2324.    }
  2325.    if (stat)
  2326.       ((PARMBLOCK *) SQLParms)->stat = stat;
  2327.    return(((PARMBLOCK *) SQLParms)->stat);
  2328. }
  2329. #endif
  2330.  
  2331. #ifdef BTI_DOS_16B
  2332. BTI_API callsql(
  2333.            BTI_CHAR_PTR SQLParms )
  2334. {
  2335.    /*
  2336.    **   Call SSQL using Borland Power Pack DOS Extender
  2337.    */
  2338.    union REGS sql_regs;
  2339.    FARPTR protectedP;
  2340.    BTI_ULONG realPtr;
  2341.    BTI_ULONG bufferSize;
  2342.    PARMBLOCK *srb;
  2343.    BTI_SINT fcn;
  2344.    BTI_SINT stat = SS_SUCCESS;
  2345.    struct REALMODEREGS
  2346.    {
  2347.       BTI_ULONG edi;
  2348.       BTI_ULONG esi;
  2349.       BTI_ULONG ebp;
  2350.       BTI_ULONG reserved;
  2351.       BTI_ULONG ebx;
  2352.       BTI_ULONG edx;
  2353.       BTI_ULONG ecx;
  2354.       BTI_ULONG eax;
  2355.       BTI_WORD  CPUflag;
  2356.       BTI_WORD  es;
  2357.       BTI_WORD  ds;
  2358.       BTI_WORD  fs;
  2359.       BTI_WORD  gs;
  2360.       BTI_WORD  ip;
  2361.       BTI_WORD  cs;
  2362.       BTI_WORD  sp;
  2363.       BTI_WORD  ss;
  2364.    } realmodeRegs, *realmodeRegsP = &realmodeRegs;
  2365.  
  2366.    bufferSize = MaxSRBDataSize;
  2367.    srb = (PARMBLOCK *)malloc(bufferSize);
  2368.  
  2369.    if (!srb)
  2370.       stat = SQL_NO_HEAP_MEM_P;
  2371.    else
  2372.    {
  2373.       stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
  2374.  
  2375.       startOfRealPtr = realPtr;
  2376.  
  2377.       if (stat == SS_SUCCESS)
  2378.       {
  2379.          stat = SRBFormat((PARMBLOCK *)SQLParms, srb, &fcn);
  2380.  
  2381.          if (stat == SS_SUCCESS)
  2382.          {
  2383.             _fmemcpy((BTI_VOID_PTR)protectedP, (BTI_VOID_PTR)srb, bufferSize);
  2384.  
  2385.             /* Initialize registers for real-mode interrupt */
  2386.             sql_regs.x.ax = 0x300;
  2387.             sql_regs.h.bl = SQL_INT;
  2388.             sql_regs.h.bh = 0;
  2389.             sql_regs.x.cx = 0;
  2390.             sql_regs.x.di = FP_OFF(realmodeRegsP);
  2391.             segread((struct SREGS *)&sregs);
  2392.             sregs.es = FP_SEG(realmodeRegsP);
  2393.             memset(&realmodeRegs, 0, sizeof(struct REALMODEREGS));
  2394.             realmodeRegs.ds = FP_SEG((BTI_WORD_PTR)realPtr);
  2395.             realmodeRegs.edx = FP_OFF((BTI_WORD_PTR)realPtr);
  2396.  
  2397.             int86x(0x31, (union REGS *)&sql_regs, (union REGS *)&sql_regs,
  2398.                    (struct SREGS *)&sregs);
  2399.  
  2400.             _fmemcpy((BTI_VOID_PTR)srb, (BTI_VOID_PTR)protectedP, bufferSize);
  2401.  
  2402.             SRBUnformat((PARMBLOCK *)SQLParms, srb, fcn);
  2403.          }
  2404.          freeRealModeBuffer(FP_SEG(protectedP));      /* Free real-mode mem */
  2405.       }
  2406.       free(srb);                      /* Free temporary send/request buffer */
  2407.    }
  2408.    if (stat)
  2409.       ((PARMBLOCK *)SQLParms)->stat = stat;
  2410.    return(((PARMBLOCK *)SQLParms)->stat);
  2411. }
  2412. #endif
  2413.  
  2414. /***************************************************************************
  2415.    callPrimitive
  2416. ***************************************************************************/
  2417. #if defined(BTI_DOS)     || defined(BTI_DOS_32R) ||\
  2418.     defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  2419. BTI_API callPrimitive(
  2420.            void )
  2421. {
  2422.    /*
  2423.    **   Initialize signature for Relational Primitive call
  2424.    */
  2425.    *((BTI_LONG_PTR) &(XQLPPARMS.XQL_ID)) = XQLP_SIG;
  2426.    XQLPPARMS.sessionid  = SQL_SessionID;     /* Initialize the Session ID */
  2427.  
  2428.    callsql((BTI_CHAR_PTR) &XQLPPARMS);
  2429.  
  2430.    return(0);
  2431. }
  2432. #endif
  2433.  
  2434. /***************************************************************************
  2435.    callSQLFunction
  2436. ***************************************************************************/
  2437. #if defined(BTI_DOS)     || defined(BTI_DOS_32R) || \
  2438.     defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  2439. BTI_API callSQLFunction(
  2440.            void )
  2441. {
  2442.    /*
  2443.    **   Initialize signature for SQL-level function call
  2444.    */
  2445.    *((BTI_LONG_PTR) &(XQLMPARMS.XQL_ID)) = XQLM_SIG;
  2446.    XQLMPARMS.sessionid  = SQL_SessionID;     /* Initialize the Session ID */
  2447.  
  2448.    callsql((BTI_CHAR_PTR)&XQLMPARMS);
  2449.  
  2450.    return(0);
  2451. }
  2452. #endif
  2453.  
  2454. /***************************************************************************
  2455.    sql_loaded
  2456. ***************************************************************************/
  2457. #ifdef BTI_DOS
  2458. BTI_API sql_loaded(
  2459.            void )
  2460. {
  2461.    BTI_SINT  btrstat;
  2462.  
  2463.    SQLCODE = SQL_COMPONENT_NOT_LOADED;
  2464.    XQLMPARMS.stat = XQLMPARMS.fcn  = -1;
  2465.  
  2466.    segread((struct SREGS *) &sregs);
  2467.    regs.ax = 0x3500 + SQL_INT;
  2468.  
  2469.    int86x(0x21, (union REGS *)®s, (union REGS *)®s,
  2470.           (struct SREGS *)&sregs);
  2471.  
  2472.    if (regs.bx == SQL_OFFSET)
  2473.    {
  2474.       XQLMPARMS.v.bxData.btrop = -1;
  2475.       XQLMPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
  2476.  
  2477.       callSQLFunction ();
  2478.  
  2479.       if (XQLMPARMS.stat == SQL_INVALID_FUNCTIONCODE)
  2480.          SQLCODE = 0;
  2481.    }
  2482.    return (SQLCODE == 0);
  2483. }
  2484. #endif
  2485.  
  2486. #ifdef BTI_DOS_32P
  2487. BTI_API sql_loaded(
  2488.            void )
  2489. {
  2490.    BTI_SINT              btrstat;
  2491.    BTI_ULONG             sqlAddress;
  2492.  
  2493.    SQLCODE = SQL_COMPONENT_NOT_LOADED;
  2494.    XQLMPARMS.stat = XQLMPARMS.fcn  = -1;
  2495.    /*
  2496.    **   The _dx_rmiv_get routine returns the real-mode interrupt
  2497.    **   vector for interupt 7b
  2498.    */
  2499.    _dx_rmiv_get(SQL_INT, &sqlAddress);
  2500.  
  2501.    if (((BTI_WORD) (sqlAddress & 0xFFFF)) == SQL_OFFSET)
  2502.    {
  2503.       XQLMPARMS.v.bxData.btrop = -1;
  2504.       XQLMPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
  2505.  
  2506.       callSQLFunction ();
  2507.  
  2508.       if (XQLMPARMS.stat == SQL_INVALID_FUNCTIONCODE)
  2509.          SQLCODE = 0;
  2510.    }
  2511.    return (SQLCODE == 0);
  2512. }
  2513. #endif
  2514.  
  2515. #if defined(BTI_DOS_32B)
  2516. BTI_API sql_loaded(
  2517.            void )
  2518. {
  2519.    BTI_SINT              stat;
  2520.    union REGS            inRegs, outRegs;
  2521.    BTI_SINT              btrstat;
  2522.  
  2523.    SQLCODE = SQL_COMPONENT_NOT_LOADED;
  2524.    XQLMPARMS.stat = XQLMPARMS.fcn  = -1;
  2525.  
  2526.    inRegs.x.eax = 0x200;
  2527.    inRegs.x.ebx = SQL_INT;
  2528.  
  2529.    int386(0x31, &inRegs, &outRegs);
  2530.  
  2531.    if (((BTI_WORD) (outRegs.x.edx & 0xFFFF)) == SQL_OFFSET)
  2532.    {
  2533.       XQLMPARMS.v.bxData.btrop = -1;
  2534.       XQLMPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
  2535.  
  2536.       callSQLFunction ();
  2537.  
  2538.       if (XQLMPARMS.stat == SQL_INVALID_FUNCTIONCODE)
  2539.          SQLCODE = 0;
  2540.    }
  2541.    return (SQLCODE == 0);
  2542. }
  2543. #endif
  2544.  
  2545. #if defined(BTI_DOS_16B)
  2546. BTI_API sql_loaded(
  2547.            void )
  2548. {
  2549.    BTI_SINT              stat;
  2550.    union REGS            inRegs, outRegs;
  2551.    BTI_SINT              btrstat;
  2552.  
  2553.    SQLCODE = SQL_COMPONENT_NOT_LOADED;
  2554.    XQLMPARMS.stat = XQLMPARMS.fcn  = -1;
  2555.  
  2556.    inRegs.x.ax = 0x200;
  2557.    inRegs.x.bx = SQL_INT;
  2558.  
  2559.    int86(0x31, &inRegs, &outRegs);
  2560.  
  2561.    if (outRegs.x.dx == SQL_OFFSET)
  2562.    {
  2563.       XQLMPARMS.v.bxData.btrop = -1;
  2564.       XQLMPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
  2565.  
  2566.       callSQLFunction();
  2567.  
  2568.       if (XQLMPARMS.stat == SQL_INVALID_FUNCTIONCODE)
  2569.          SQLCODE = 0;
  2570.    }
  2571.    return(SQLCODE == 0);
  2572. }
  2573. #endif
  2574.  
  2575. /***************************************************************************
  2576.    Primitives_Loaded
  2577. ***************************************************************************/
  2578. #ifdef BTI_DOS
  2579. BTI_API Primitives_Loaded(
  2580.            void )
  2581. {
  2582.    BTI_INT stat = 0;
  2583.    BTI_INT btrstat;
  2584.  
  2585.    XQLPPARMS.stat = XQLPPARMS.fcn  = -1;
  2586.  
  2587.    segread((struct SREGS *)&sregs);
  2588.    regs.ax = 0x3500 + SQL_INT;
  2589.  
  2590.    int86x(0x21, (union REGS *)®s, (union REGS *)®s,
  2591.       (struct SREGS *)&sregs);
  2592.  
  2593.    if (regs.bx == SQL_OFFSET)
  2594.    {
  2595.       XQLPPARMS.v.bxData.btrop = -1;
  2596.       XQLPPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
  2597.  
  2598.       callPrimitive ();
  2599.  
  2600.       if (XQLPPARMS.stat == SQL_INVALID_PRIMITIVE_FUNCTION ||
  2601.          XQLPPARMS.stat == SQL_INVALID_FUNCTIONCODE)
  2602.          stat = 1;
  2603.    }
  2604.    return (stat);
  2605. }
  2606. #endif
  2607.  
  2608. #if defined(BTI_DOS_32P)
  2609. BTI_API Primitives_Loaded(
  2610.            void )
  2611. {
  2612.    BTI_INT stat = 0;
  2613.    BTI_INT btrstat;
  2614.    BTI_ULONG sqlAddress;
  2615.  
  2616.    XQLPPARMS.stat = XQLPPARMS.fcn  = -1;
  2617.  
  2618.    /*
  2619.    **   The _dx_rmiv_get routine returns the real-mode interrupt
  2620.    **   vector for interupt 7b
  2621.    */
  2622.    _dx_rmiv_get(SQL_INT, &sqlAddress);
  2623.  
  2624.    if (((BTI_WORD) (sqlAddress & 0xFFFF)) == SQL_OFFSET)
  2625.    {
  2626.       XQLPPARMS.v.bxData.btrop = -1;
  2627.       XQLPPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
  2628.  
  2629.       callPrimitive ();
  2630.       if (XQLPPARMS.stat == SQL_INVALID_PRIMITIVE_FUNCTION  ||
  2631.            XQLPPARMS.stat == SQL_INVALID_FUNCTIONCODE)
  2632.          stat = 1;
  2633.    }
  2634.    return (stat);
  2635. }
  2636. #endif
  2637.  
  2638. #if defined(BTI_DOS_32B)
  2639. BTI_API Primitives_Loaded(
  2640.            void )
  2641. {
  2642.    BTI_INT stat = SS_SUCCESS;
  2643.    BTI_INT btrstat;
  2644.    union REGS inRegs, outRegs;
  2645.  
  2646.    XQLPPARMS.stat = XQLPPARMS.fcn  = -1;
  2647.  
  2648.    inRegs.x.eax = 0x200;
  2649.    inRegs.x.ebx = SQL_INT;
  2650.  
  2651.    int386(0x31, &inRegs, &outRegs);
  2652.  
  2653.    if (((BTI_WORD) (outRegs.x.edx & 0xFFFF)) == SQL_OFFSET)
  2654.    {
  2655.       XQLPPARMS.v.bxData.btrop = -1;
  2656.       XQLPPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
  2657.  
  2658.       callPrimitive ();
  2659.  
  2660.       if (XQLPPARMS.stat == SQL_INVALID_PRIMITIVE_FUNCTION ||
  2661.            XQLPPARMS.stat == SQL_INVALID_FUNCTIONCODE)
  2662.          stat = 1;
  2663.    }
  2664.    return (stat);
  2665. }
  2666. #endif
  2667.  
  2668. #if defined(BTI_DOS_16B)
  2669. BTI_API Primitives_Loaded(
  2670.            void )
  2671. {
  2672.    BTI_INT stat = SS_SUCCESS;
  2673.    BTI_INT btrstat;
  2674.    union REGS inRegs, outRegs;
  2675.  
  2676.    XQLPPARMS.stat = XQLPPARMS.fcn  = -1;
  2677.  
  2678.    inRegs.x.ax = 0x200;
  2679.    inRegs.x.bx = SQL_INT;
  2680.  
  2681.    int86(0x31, &inRegs, &outRegs);
  2682.  
  2683.    if (outRegs.x.dx == SQL_OFFSET)
  2684.    {
  2685.       XQLPPARMS.v.bxData.btrop = -1;
  2686.       XQLPPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
  2687.  
  2688.       callPrimitive();
  2689.  
  2690.       if (XQLPPARMS.stat == SQL_INVALID_PRIMITIVE_FUNCTION ||
  2691.           XQLPPARMS.stat == SQL_INVALID_FUNCTIONCODE)
  2692.          stat = 1;
  2693.    }
  2694.    return(stat);
  2695. }
  2696. #endif
  2697.  
  2698. /***************************************************************************
  2699.    CallPMSW  (real mode)
  2700. ***************************************************************************/
  2701. #if defined(BTI_DOS)
  2702. BTI_API CallPMSW(
  2703.            pmswParmBlock *pb )
  2704. {
  2705.    BTI_SINT     stat = 0;
  2706.    union REGS   regs;
  2707.    struct SREGS sregs;
  2708.  
  2709.    segread(&sregs);
  2710.  
  2711.    /*
  2712.    **   Check to see if PMSwitch is loaded.
  2713.    */
  2714.    regs.x.ax = 0x3500 + SQL_INT;
  2715.    int86x(0x21, ®s, ®s, &sregs);
  2716.    if (regs.x.bx != SQL_OFFSET)
  2717.        stat = SQL_COMPONENT_NOT_LOADED;
  2718.  
  2719.    if (stat == 0)
  2720.    {
  2721.        /*
  2722.        **   Make the call to PMSwitch.
  2723.        */
  2724.        /* parameter block is expected to be in DX */
  2725.        regs.x.dx = FP_OFF(pb);
  2726.        sregs.ds = FP_SEG(pb);
  2727.  
  2728.        int86x(SQL_INT, ®s, ®s, &sregs);
  2729.    } /* end if */
  2730.  
  2731.    return(stat);
  2732. }
  2733. #endif
  2734.  
  2735. /***************************************************************************
  2736.    CallPMSW  (protected mode with Rational & SSQLSTUB.EXE)
  2737. ***************************************************************************/
  2738. #if defined(BTI_DOS_32R)
  2739. BTI_API CallPMSW(
  2740.            pmswParmBlock *pb )
  2741. {
  2742.  
  2743.    (*_ImportedFunctions_)[ PROCESS7B ].functionPtr(pb);
  2744.    return 0;
  2745. }
  2746. #endif
  2747.  
  2748. /***************************************************************************
  2749.    CallPMSW  (Phar Lap DOS Extender)
  2750. ***************************************************************************/
  2751. #if defined(BTI_DOS_32P)
  2752. BTI_API CallPMSW(
  2753.            pmswParmBlock *pb )
  2754. {
  2755.    BTI_SINT       stat = 0;
  2756.    BTI_ULONG      sqlAddress;
  2757.    SWI_REGS       sql_regs;
  2758.    FARPTR         protectedP;
  2759.    BTI_ULONG      realPtr;
  2760.    BTI_ULONG      bufferSize;
  2761.    BTI_CHAR_PTR   srb;
  2762.    BTI_SINT       fcn;
  2763.  
  2764.    /*
  2765.    **   The _dx_rmiv_get routine returns the real-mode interrupt
  2766.    **   vector for interupt 7b
  2767.    */
  2768.    _dx_rmiv_get(SQL_INT, &sqlAddress);
  2769.  
  2770.    /*
  2771.    **   Check to see if PMSwitch is loaded.
  2772.    */
  2773.    if (((BTI_WORD) (sqlAddress & 0xFFFF)) != SQL_OFFSET)
  2774.        stat = SQL_COMPONENT_NOT_LOADED;
  2775.    else
  2776.    {
  2777.       /*
  2778.       **   Make the call to PMSwitch.
  2779.       */
  2780.  
  2781.       bufferSize = MaxSRBDataSize;
  2782.       srb = (BTI_CHAR_PTR) malloc(bufferSize);
  2783.       if (!srb)
  2784.       {
  2785.          stat = SQL_NO_HEAP_MEM_P;
  2786.       }
  2787.       else
  2788.       {
  2789.          stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
  2790.          startOfRealPtr  = realPtr + sizeof(pmswParmBlock);
  2791.  
  2792.          if (stat == SS_SUCCESS)
  2793.          {
  2794.                       /* Copy the pmswParmBlock structure to the srb buffer */
  2795.             memcpy(
  2796.                srb,
  2797.                pb,
  2798.                sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
  2799.  
  2800.  
  2801.             /*
  2802.             ** Save real-mode pointer to the parameter block in the data
  2803.             ** pointer of the pmswParmBlock structure.  Must save a real-
  2804.             ** mode address here because the entire srb buffer will be
  2805.             ** passed to the real-mode interrupt 7B handler.
  2806.             */
  2807.             *((BTI_ULONG *) &((pmswParmBlock *) srb)->data) = realPtr +
  2808.                                                       sizeof(pmswParmBlock);
  2809.  
  2810.             /*
  2811.             ** Call SRBFormat() to initialize the SSQL parameter block
  2812.             ** structure.
  2813.             */
  2814.             stat = SRBFormat(
  2815.                       (PARMBLOCK *) pb->data,
  2816.                       (PARMBLOCK *) &srb[sizeof(pmswParmBlock)],
  2817.                       &fcn);
  2818.  
  2819.  
  2820.             if (stat == SS_SUCCESS)
  2821.             {
  2822.                copyToLow(         /* Copy data to DOS real memory location */
  2823.                   FP_SEL(protectedP),
  2824.                   FP_OFF(protectedP),
  2825.                   srb,
  2826.                   bufferSize);
  2827.  
  2828.                memset(&sql_regs, 0, sizeof(sql_regs));
  2829.                sql_regs.ds  = RP_SEG(realPtr);
  2830.                sql_regs.edx = RP_OFF(realPtr);
  2831.  
  2832.                /*
  2833.                **   The _dx_real_int routine issues the 7b interrupt in real
  2834.                **   mode
  2835.                */
  2836.                _dx_real_int(SQL_INT, &sql_regs);
  2837.  
  2838.                    /* Copy data from DOS real memory back to protected mode */
  2839.                copyFromLow(
  2840.                   srb,
  2841.                   FP_SEL(protectedP),
  2842.                   FP_OFF(protectedP),
  2843.                   bufferSize);
  2844.  
  2845.                SRBUnformat(
  2846.                   (PARMBLOCK *) pb->data,
  2847.                   (PARMBLOCK *) &srb[sizeof(pmswParmBlock)],
  2848.                   fcn);
  2849.  
  2850.                memcpy(
  2851.                   pb,
  2852.                   srb,
  2853.                   sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
  2854.             }
  2855.             freeRealModeBuffer(FP_SEL(protectedP));
  2856.          }
  2857.          free(srb);
  2858.       }
  2859.    } /* end if */
  2860.  
  2861.    return(stat);
  2862. }
  2863. #endif
  2864.  
  2865. /***************************************************************************
  2866.    CallPMSW  (Borland Power Pack DOS Extender)
  2867. ***************************************************************************/
  2868. #if defined(BTI_DOS_32B)
  2869. BTI_API CallPMSW(
  2870.            pmswParmBlock *pb )
  2871. {
  2872.    union REGS     inRegs, outRegs;
  2873.    BTI_SINT       stat = SS_SUCCESS;
  2874.    union  REGS    sql_regs;
  2875.    FARPTR         protectedP;
  2876.    BTI_ULONG      realPtr;
  2877.    BTI_ULONG      bufferSize;
  2878.    BTI_CHAR_PTR   srb;
  2879.    BTI_SINT       fcn;
  2880.    struct   REALMODEREGS
  2881.    {
  2882.       BTI_ULONG edi;
  2883.       BTI_ULONG esi;
  2884.       BTI_ULONG ebp;
  2885.       BTI_ULONG reserved;
  2886.       BTI_ULONG ebx;
  2887.       BTI_ULONG edx;
  2888.       BTI_ULONG ecx;
  2889.       BTI_ULONG eax;
  2890.       BTI_WORD  CPUflag;
  2891.       BTI_WORD  es;
  2892.       BTI_WORD  ds;
  2893.       BTI_WORD  fs;
  2894.       BTI_WORD  gs;
  2895.       BTI_WORD  ip;
  2896.       BTI_WORD  cs;
  2897.       BTI_WORD  sp;
  2898.       BTI_WORD  ss;
  2899.    } realmodeRegs;
  2900.  
  2901.    inRegs.x.eax = 0x200;
  2902.    inRegs.x.ebx = SQL_INT;
  2903.  
  2904.    int386(0x31, &inRegs, &outRegs);
  2905.  
  2906.    if ((BTI_WORD) (outRegs.x.edx & 0xFFFF) != SQL_OFFSET)
  2907.        stat = SQL_COMPONENT_NOT_LOADED;
  2908.    else
  2909.    {
  2910.       bufferSize = MaxSRBDataSize;
  2911.       srb = malloc(bufferSize);
  2912.       if (!srb)
  2913.          stat = SQL_NO_HEAP_MEM_P;
  2914.       else
  2915.       {
  2916.          stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
  2917.          startOfRealPtr = realPtr + sizeof(pmswParmBlock);
  2918.  
  2919.          if (stat == SS_SUCCESS)
  2920.          {
  2921.                       /* Copy the pmswParmBlock structure to the srb buffer */
  2922.             memcpy(
  2923.                srb,
  2924.                pb,
  2925.                sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
  2926.  
  2927.             /*
  2928.             ** Save real-mode pointer to the parameter block in the data
  2929.             ** pointer of the pmswParmBlock structure.  Must save a real-
  2930.             ** mode address here because the entire srb buffer will be
  2931.             ** passed to the real-mode interrupt 7B handler.
  2932.             */
  2933.             *((BTI_ULONG *) &((pmswParmBlock *) srb)->data) = realPtr +
  2934.                                                       sizeof(pmswParmBlock);
  2935.             /*
  2936.             ** Call SRBFormat() to initialize the SSQL parameter block
  2937.             ** structure.
  2938.             */
  2939.             stat = SRBFormat(
  2940.                       (PARMBLOCK *) pb->data,
  2941.                       (PARMBLOCK *) &srb[sizeof(pmswParmBlock)],
  2942.                       &fcn);
  2943.  
  2944.             if (stat == SS_SUCCESS)
  2945.             {
  2946.                copyToLow(         /* Copy data to DOS real memory location */
  2947.                   FP_SEL(protectedP),
  2948.                   FP_OFF(protectedP),
  2949.                   srb,
  2950.                   bufferSize);     /* bufferSize ??? */
  2951.  
  2952.                sql_regs.x.eax = 0x300;
  2953.                sql_regs.h.bl  = SQL_INT;
  2954.                sql_regs.h.bh  = 0;
  2955.                /*
  2956.                ** CX = Number of words to copy from protected-mode to
  2957.                ** real-mode stack
  2958.                */
  2959.                sql_regs.x.ecx = 0;
  2960.  
  2961.                /*
  2962.                ** Initialize real mode segment registers for call to SSQL
  2963.                */
  2964.                memset(&realmodeRegs, 0, sizeof(struct REALMODEREGS));
  2965.  
  2966.                /*
  2967.                ** DS Register contains the segment address of parameter block
  2968.                */
  2969.                realmodeRegs.ds  = (BTI_WORD) (realPtr >> 16);
  2970.  
  2971.                /*
  2972.                ** EDX Register contains offset of parameter block
  2973.                */
  2974.                realmodeRegs.edx = (realPtr << 16);
  2975.                sql_regs.x.edi = (BTI_ULONG) &realmodeRegs;
  2976.  
  2977.                int386(0x31, &sql_regs, &sql_regs);     /* real-mode int 7b */
  2978.  
  2979.                copyFromLow(     /* Copy data back to protected mode buffer */
  2980.                    srb,
  2981.                    FP_SEL(protectedP),
  2982.                    FP_OFF(protectedP),
  2983.                    bufferSize);
  2984.  
  2985.                SRBUnformat(
  2986.                   (PARMBLOCK *) pb->data,
  2987.                   (PARMBLOCK *) &srb[sizeof(pmswParmBlock)],
  2988.                   fcn);
  2989.  
  2990.                memcpy(
  2991.                   pb,
  2992.                   srb,
  2993.                   sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
  2994.             }
  2995.             freeRealModeBuffer(FP_SEL(protectedP));
  2996.          }
  2997.          free(srb);
  2998.       }
  2999.    }
  3000.    return(stat);
  3001. }
  3002. #endif
  3003.  
  3004. #if defined(BTI_DOS_16B)
  3005. BTI_API CallPMSW(
  3006.            pmswParmBlock *pb )
  3007. {
  3008.    union REGS inRegs, outRegs;
  3009.    BTI_SINT stat = SS_SUCCESS;
  3010.    union REGS sql_regs;
  3011.    FARPTR protectedP;
  3012.    BTI_ULONG realPtr;
  3013.    BTI_ULONG bufferSize;
  3014.    BTI_CHAR_PTR srb;
  3015.    BTI_SINT fcn;
  3016.    struct REALMODEREGS
  3017.    {
  3018.       BTI_ULONG edi;
  3019.       BTI_ULONG esi;
  3020.       BTI_ULONG ebp;
  3021.       BTI_ULONG reserved;
  3022.       BTI_ULONG ebx;
  3023.       BTI_ULONG edx;
  3024.       BTI_ULONG ecx;
  3025.       BTI_ULONG eax;
  3026.       BTI_WORD  CPUflag;
  3027.       BTI_WORD  es;
  3028.       BTI_WORD  ds;
  3029.       BTI_WORD  fs;
  3030.       BTI_WORD  gs;
  3031.       BTI_WORD  ip;
  3032.       BTI_WORD  cs;
  3033.       BTI_WORD  sp;
  3034.       BTI_WORD  ss;
  3035.    } realmodeRegs, *realmodeRegsP = &realmodeRegs;
  3036.  
  3037.    inRegs.x.ax = 0x200;
  3038.    inRegs.x.bx = SQL_INT;
  3039.  
  3040.    int86(0x31, &inRegs, &outRegs);
  3041.  
  3042.    if (outRegs.x.dx != SQL_OFFSET)
  3043.        stat = SQL_COMPONENT_NOT_LOADED;
  3044.    else
  3045.    {
  3046.       bufferSize = MaxSRBDataSize;
  3047.       srb = malloc(bufferSize);
  3048.  
  3049.       if (!srb)
  3050.          stat = SQL_NO_HEAP_MEM_P;
  3051.       else
  3052.       {
  3053.          stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
  3054.  
  3055.          startOfRealPtr = realPtr + sizeof(pmswParmBlock);
  3056.  
  3057.          if (stat == SS_SUCCESS)
  3058.          {
  3059.             /* Copy the pmswParmBlock structure to the srb buffer */
  3060.             memcpy(srb, pb, sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
  3061.  
  3062.             /*
  3063.             ** Save real-mode pointer to the parameter block in the data
  3064.             ** pointer of the pmswParmBlock structure.  Must save a real-
  3065.             ** mode address here because the entire srb buffer will be
  3066.             ** passed to the real-mode interrupt 7B handler.
  3067.             */
  3068.             *((BTI_ULONG *)&((pmswParmBlock *)srb)->data) = realPtr +
  3069.                                                       sizeof(pmswParmBlock);
  3070.  
  3071.             /* Initialize the SSQL parameter block structure */
  3072.             stat = SRBFormat((PARMBLOCK *)pb->data,
  3073.                              (PARMBLOCK *)&srb[sizeof(pmswParmBlock)], &fcn);
  3074.  
  3075.             if (stat == SS_SUCCESS)
  3076.             {
  3077.                /* Copy data to DOS real memory location */
  3078.                _fmemcpy((BTI_VOID_PTR)protectedP, (BTI_VOID_PTR)srb,
  3079.                         bufferSize);
  3080.  
  3081.                sql_regs.x.ax = 0x300;
  3082.                sql_regs.h.bl = SQL_INT;
  3083.                sql_regs.h.bh = 0;
  3084.                sql_regs.x.cx = 0;
  3085.                sql_regs.x.di = FP_OFF(realmodeRegsP);
  3086.                segread((struct SREGS *)&sregs);
  3087.                sregs.es = FP_SEG(realmodeRegsP);
  3088.                memset(&realmodeRegs, 0, sizeof(struct REALMODEREGS));
  3089.                realmodeRegs.ds = FP_SEG((BTI_WORD_PTR)realPtr);
  3090.                realmodeRegs.edx = FP_OFF((BTI_WORD_PTR)realPtr);
  3091.  
  3092.                int86x(0x31, (union REGS *)&sql_regs, (union REGS *)&sql_regs,
  3093.                       (struct SREGS *)&sregs);
  3094.  
  3095.                /* Copy data back to protected mode buffer */
  3096.                _fmemcpy((BTI_VOID_PTR)srb, (BTI_VOID_PTR)protectedP,
  3097.                         bufferSize);
  3098.  
  3099.                SRBUnformat((PARMBLOCK *)pb->data,
  3100.                            (PARMBLOCK *)&srb[sizeof(pmswParmBlock)], fcn);
  3101.  
  3102.                memcpy(pb, srb, sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
  3103.             }
  3104.             freeRealModeBuffer(FP_SEG(protectedP));
  3105.          }
  3106.          free(srb);
  3107.       }
  3108.    }
  3109.    return(stat);
  3110. }
  3111. #endif
  3112.  
  3113. /***************************************************************************
  3114.    callxqlm
  3115. ***************************************************************************/
  3116. #ifdef BTI_NLM
  3117. BTI_SINT callxqlm(
  3118.             void )
  3119. {
  3120.    BTI_SINT stat;
  3121.  
  3122.    *((BTI_LONG_PTR) &(XQLMPARMS.XQL_ID)) = XQLM_SIG;
  3123.    XQLMPARMS.sessionid  = SQL_SessionID;
  3124.    XQLMPARMS.stat       = NSAgentID;
  3125.  
  3126.    stat = XQLEntry(&XQLMPARMS);
  3127.  
  3128.    if (stat)
  3129.       XQLMPARMS.stat = stat;
  3130.    return 0;
  3131. }
  3132. #endif
  3133.  
  3134. /***************************************************************************
  3135.    callxqlp
  3136. ***************************************************************************/
  3137. #ifdef BTI_NLM
  3138. BTI_VOID callxqlp(
  3139.             void )
  3140. {
  3141.    BTI_SINT stat;
  3142.  
  3143.    *((BTI_LONG_PTR) &(XQLPPARMS.XQL_ID)) = XQLP_SIG;
  3144.    XQLPPARMS.sessionid  = SQL_SessionID;
  3145.    XQLPPARMS.stat       = NSAgentID;
  3146.  
  3147.    stat = XQLEntry(&XQLPPARMS);
  3148.  
  3149.    if (stat)
  3150.       XQLPPARMS.stat = stat;
  3151. }
  3152. #endif
  3153.  
  3154. /***************************************************************************
  3155.    getRealModeBuffer
  3156. ***************************************************************************/
  3157. #if defined(BTI_DOS_32P)
  3158. BTI_SINT getRealModeBuffer(
  3159.             FARPTR    *protectedP,
  3160.             BTI_ULONG *realAddr,
  3161.             BTI_ULONG  requestedSize )
  3162. {
  3163.    BTI_SINT  stat;                                    /* Return status code */
  3164.    BTI_ULONG bufferSize;
  3165.  
  3166.    /*
  3167.    ** Get Information about the DOS Data Buffer
  3168.    **
  3169.    ** The _dx_dos_buf_get function returns real and protected-mode pointers
  3170.    ** to the buffer used to buffer data on MS-DOS and BIOS system calls.  The
  3171.    ** size of the buffer is returned in the size parameter.  Note: need to
  3172.    ** make this call each time because address of the MS_DOS buffer changes
  3173.    ** when anyone calls Load for Debug(_dx_dbg_ld) or the Set DOS Data Buffer
  3174.    ** Size(_dx_dosbuf_set).
  3175.    */
  3176.    _dx_dosbuf_get((FARPTR *) protectedP, realAddr, &bufferSize);
  3177.  
  3178.    if (bufferSize < requestedSize)
  3179.       stat = SQL_BUFFER_TOO_SHORT;
  3180.    else
  3181.       stat = SS_SUCCESS;
  3182.  
  3183.    return stat;
  3184. }
  3185. #endif
  3186.  
  3187. #if defined(BTI_DOS_32B)
  3188. BTI_SINT getRealModeBuffer(
  3189.             FARPTR    *protectedP,
  3190.             BTI_ULONG *realAddr,
  3191.             BTI_ULONG  requestedSize )
  3192. {
  3193.    BTI_SINT allocStatus;
  3194.    union REGS inRegs, outRegs;
  3195.  
  3196.    /*
  3197.    ** Allocate DOS Memory
  3198.    ** Interrupt 31h, function 100h
  3199.    ** Note: The DPMI server must support version 0.9 or later of the DPMI
  3200.    **       specification to support this this function.  An error code
  3201.    **       will be returned in the AX register and returned to caller
  3202.    **       as B_DATALENGTH_ERROR.
  3203.    **
  3204.    ** AX = 100h
  3205.    ** BX = Number of 16-byte paragraphs to allocate
  3206.    **
  3207.    ** Returns:
  3208.    **
  3209.    ** if carry flag is clear
  3210.    **    AX = real mode segment base address of allocated block
  3211.    **    DX = selector for allocated block
  3212.    **
  3213.    ** if carry flag is set
  3214.    **    AX = error code
  3215.    **
  3216.    */
  3217.    inRegs.x.eax = 0x100;
  3218.    inRegs.x.ebx = (requestedSize + 15) / 16;        /* Number of paragraphs */
  3219.  
  3220.    int386(0x31, &inRegs, &outRegs);
  3221.  
  3222.    if (outRegs.x.cflag)
  3223.       allocStatus = SQL_BUFFER_TOO_SHORT;
  3224.    else
  3225.    {
  3226.       *realAddr = (outRegs.x.eax << 16) & 0xFFFF0000;
  3227.       FP_SET(*protectedP, 0, (BTI_WORD) outRegs.x.edx);
  3228.       allocStatus = SS_SUCCESS;
  3229.    }
  3230.  
  3231.    return allocStatus;
  3232. }
  3233. #endif
  3234.  
  3235. #if defined(BTI_DOS_16B)
  3236. BTI_SINT getRealModeBuffer(
  3237.             FARPTR    *protectedP,
  3238.             BTI_ULONG *realAddr,
  3239.             BTI_ULONG  requestedSize )
  3240. {
  3241.    BTI_SINT allocStatus;
  3242.    union REGS inRegs, outRegs;
  3243.  
  3244.    /*
  3245.    ** Allocate DOS Memory
  3246.    ** Interrupt 31h, function 100h
  3247.    ** Note: The DPMI server must support version 0.9 or later of the DPMI
  3248.    **       specification to support this this function.  An error code
  3249.    **       will be returned in the AX register and returned to caller
  3250.    **       as B_DATALENGTH_ERROR.
  3251.    **
  3252.    ** AX = 100h
  3253.    ** BX = Number of 16-byte paragraphs to allocate
  3254.    **
  3255.    ** Returns:
  3256.    **
  3257.    ** if carry flag is clear
  3258.    **    AX = real mode segment base address of allocated block
  3259.    **    DX = selector for allocated block
  3260.    **
  3261.    ** if carry flag is set
  3262.    **    AX = error code
  3263.    **
  3264.    */
  3265.    inRegs.x.ax = 0x100;                        /* allocate DOS memory block */
  3266.    inRegs.x.bx = (requestedSize + 15) / 16;         /* Number of paragraphs */
  3267.  
  3268.    int86(0x31, &inRegs, &outRegs);
  3269.  
  3270.    if (outRegs.x.cflag)
  3271.       allocStatus = SQL_BUFFER_TOO_SHORT;
  3272.    else
  3273.    {
  3274.       *realAddr = MK_FP(outRegs.x.ax, 0);
  3275.       *protectedP = MK_FP(outRegs.x.dx, 0);
  3276.       allocStatus = SS_SUCCESS;
  3277.    }
  3278.  
  3279.    return(allocStatus);
  3280. }
  3281. #endif
  3282.  
  3283. /***************************************************************************
  3284.    freeRealModeBuffer
  3285. ***************************************************************************/
  3286. #if defined(BTI_DOS_32P)
  3287. static BTI_VOID freeRealModeBuffer(
  3288.                    BTI_WORD sel )
  3289. {
  3290.    /*
  3291.    ** Phar Lap specific code
  3292.    */
  3293.  
  3294.    /* Nothing to do! */
  3295. }
  3296. #endif
  3297.  
  3298. #if defined(BTI_DOS_32B)
  3299. static BTI_VOID freeRealModeBuffer(
  3300.                 BTI_WORD sel )
  3301. {
  3302.    union REGS inRegs, outRegs;
  3303.  
  3304.    inRegs.x.edx = sel;                              /* Selector to be freed */
  3305.    inRegs.x.eax = 0x101;
  3306.  
  3307.    int386(0x31, &inRegs, &outRegs);                       /* free selector */
  3308. }
  3309. #endif
  3310.  
  3311. #if defined(BTI_DOS_16B)
  3312. static BTI_VOID freeRealModeBuffer(
  3313.                    BTI_WORD sel )
  3314. {
  3315.    union REGS inRegs, outRegs;
  3316.  
  3317.    inRegs.x.dx = sel;                               /* Selector to be freed */
  3318.    inRegs.x.ax = 0x101;
  3319.  
  3320.    int86(0x31, &inRegs, &outRegs);
  3321. }
  3322. #endif
  3323.  
  3324. /*
  3325. *****************************************************************************
  3326. **  SRBFormat
  3327. **
  3328. **  Prototype:
  3329. **
  3330. **      BTI_SINT SRBFormat(PARMBLOCK *from, PARMBLOCK *srb, BTI_SINT *fcn)
  3331. **
  3332. **
  3333. **  Description:
  3334. **
  3335. **      SRBFormat() formats a parameter block (PARMBLOCK structure) into
  3336. **      a buffer for transmittal to the Scalable SQL engine.
  3337. **
  3338. **  Preconditions:
  3339. **
  3340. **      None.
  3341. **
  3342. **  Parameters:
  3343. **
  3344. **      *from:          Input parameter block.
  3345. **        <input>
  3346. **
  3347. **      *srb:           Formatted output parameter block
  3348. **        <output>
  3349. **
  3350. **      *fcn:           Returns the sequenced function number that SRBUnformat
  3351. **        <output>      can use to plug back into the PARMBLOCK when calling
  3352. **                      unfixparms().
  3353. **
  3354. **  Return value:
  3355. **
  3356. **      None.
  3357. **
  3358. **  Globals:
  3359. **
  3360. **      None.
  3361. **
  3362. **  Called Functions:
  3363. **
  3364. **      fixParms()
  3365. **
  3366. **  Comments:
  3367. **
  3368. **      None.
  3369. **
  3370. *****************************************************************************
  3371. */
  3372. #if defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
  3373. BTI_SINT SRBFormat(
  3374.             PARMBLOCK *from,
  3375.             PARMBLOCK *srb,
  3376.             BTI_SINT *fcn )
  3377. {
  3378.     BTI_SINT  stat = SS_SUCCESS;
  3379.     PARMBLOCK *to;
  3380.  
  3381.     to = srb;
  3382.  
  3383.     stat = fixParms(from, to);
  3384.  
  3385.     /* grab sequenced function so SRBUnformat can reset it */
  3386.     *fcn = to->fcn;
  3387.     /* restore unsequenced function since the engine does this itself */
  3388.     to->fcn = from->fcn;
  3389.  
  3390.     return(stat);
  3391. }
  3392. #endif
  3393.  
  3394. /*
  3395. *****************************************************************************
  3396. **  SRBUnformat
  3397. **
  3398. **  Description:
  3399. **      SRBUnformat() takes a send/request buffer, extracts the parameter
  3400. **      block and reformats it for use locally.
  3401. **
  3402. **  Parameters:
  3403. **      *to:            Contains reformatted parameter block on output.
  3404. **        <output>
  3405. **
  3406. **      *srb:           Contains the return buffer from SSQL.
  3407. **        <input>
  3408. **
  3409. **      fcn:            Contains the sequenced function code from SRBFormat()
  3410. **        <input>
  3411. **
  3412. **  Return value:
  3413. **      None.
  3414. *****************************************************************************
  3415. */
  3416. #if defined(BTI_DOS_32B) || defined(BTI_DOS_32P) || defined(BTI_DOS_16B)
  3417. BTI_SINT SRBUnformat(
  3418.             PARMBLOCK *to,
  3419.             PARMBLOCK *srb,
  3420.             BTI_SINT fcn )
  3421. {
  3422.     PARMBLOCK *from;
  3423.     BTI_SINT  stat;
  3424.  
  3425.     from = srb;
  3426.     from->fcn = fcn;                   /* sequenced function from SRBFormat */
  3427.  
  3428.     stat = unfixParms(from, to);
  3429.  
  3430.     return(stat);
  3431. }
  3432. #endif
  3433.  
  3434. #ifdef __cplusplus
  3435. }
  3436. #endif
  3437.