home *** CD-ROM | disk | FTP | other *** search
- #if !defined(BTI_DOS) && !defined(BTI_NLM) && !defined(BTI_DOS_32R) && \
- !defined(BTI_DOS_32P) && !defined(BTI_DOS_32B) && \
- !defined(BTI_DOS_16B)
- #error Define one of the following: BTI_DOS, BTI_NLM, BTI_DOS_32R,\
- BTI_DOS_32P, BTI_DOS_32B, BTI_DOS_16B
- #endif
- /***************************************************************************
- **
- ** Copyright 1982-1997 Pervasive Software Inc. All Rights Reserved
- **
- ***************************************************************************/
- /***************************************************************************
- SQLAPI.C
- This module implements the Scalable SQL Interface for C/C++
- applications using DOS, Extended DOS (with Rational SSQLSTUB, Phar Lap
- or Borland Power Pack) and NLMs. No interface code is required for
- MS-Windows, since the functions are available from DLLs.
-
- ***************************************************************************/
- #include <stddef.h>
- #include <sqlapi.h>
- #include <sqlconst.h>
- #include <btitypes.h>
-
- #if defined(BTI_DOS) || defined(BTI_DOS_32R) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_32P) || defined(BTI_DOS_16B)
- #include <dos.h>
- #include <string.h>
- #endif
-
- #if defined(BTI_DOS_32P)
- #include <i86.h>
- #include <pharlap.h>
- #include <fixparms.h>
- #include <malloc.h>
-
- BTI_ULONG startOfRealPtr;
- #endif
-
- #if defined(BTI_DOS_32B)
- #include <stdlib.h>
- #include <fixparms.h>
- #include <malloc.h>
-
- BTI_ULONG startOfRealPtr;
-
- /***************************************************************************
- ** Define Far pointer data type (selector:offset32)
- **
- ** The Borland C 32-bit compiler does not support far pointers. For this
- ** compiler, a FARPTR is defined as a structure which has the same
- ** organization in memory as a standard 48-bit far pointer.
- **
- ** The following macros are used to get and set the selector and offset
- ** fields of far pointers, and work both for compilers that directly
- ** support far pointers and compilers that don't have far pointer support.
- ** The FP_SEL macro returns the 16-bit selector number field
- ** of a far pointer. The FP_OFF macro returns the 32-bit offset
- ** field of a far pointer. The FP_SET macro is used to construct a far
- ** pointer from a selector number and offset. It takes three arguments:
- ** the name of the far pointer to be set, an offset, and a selector number.
- ** The FP_INCR macro increments the offset field of a far pointer.
- ***************************************************************************/
- typedef struct
- {
- BTI_ULONG Off;
- BTI_WORD Sel;
- } FARPTR;
-
- #ifndef FP_SEL
- #define FP_SEL(fp) ((fp).Sel)
- #endif
-
- #ifndef FP_OFF
- #define FP_OFF(fp) ((fp).Off)
- #endif
-
- #ifndef FP_SET
- #define FP_SET(fp, off, sel) \
- {\
- (fp).Sel = (BTI_WORD) (sel);\
- (fp).Off = (BTI_ULONG) (off);\
- }
- #endif
-
- #ifndef FP_INCR
- #define FP_INCR(fp, incr) ((fp).Off += (BTI_ULONG) (incr))
- #endif
- #endif
-
- #if defined(BTI_DOS_16B)
- #include <stdlib.h>
- #include <fixparms.h>
- #include <malloc.h>
- #include <mem.h>
-
- BTI_ULONG startOfRealPtr;
-
- #define FARPTR BTI_ULONG
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /***************************************************************************
- Constants
- ***************************************************************************/
- #define INVALID_SESSION_ID -1
- #define SQL_INT 0x7B /* SQL interrupt vector */
- #define SQL_OFFSET 0x33 /* SQL offset within segment */
- #define XQLP_CALL 10
- #define XQLM_CALL 11
-
- /***************************************************************************
- PROCESS7B IS IN PMSWITCH, AND IS RESOLVED AT RUN-TIME
- ***************************************************************************/
- #if defined(BTI_DOS_32R)
- typedef struct
- {
- char *Name;
- void cdecl (*functionPtr) (pmswParmBlock *bP);
- } IMPORTS[];
- #define PROCESS7B 75
- IMPORTS * _ImportedFunctions_ = 0;
- #endif
-
- /***************************************************************************
- PLATFORM-DEPENDENT SUPPORT FUNCTIONS PROTOTYPES
- ***************************************************************************/
- #if defined(BTI_DOS) || defined(BTI_DOS_32R) || \
- defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- BTI_API callsql(BTI_CHAR_PTR SQLParms);
- BTI_API callPrimitive(BTI_VOID);
- BTI_API callSQLFunction(BTI_VOID);
- BTI_API sql_loaded(BTI_VOID);
- BTI_API Primitives_Loaded(BTI_VOID);
- BTI_API CallPMSW(pmswParmBlock *pb);
- #endif
-
- #if defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- BTI_VOID freeRealModeBuffer(BTI_WORD);
- BTI_SINT getRealModeBuffer(FARPTR *, BTI_ULONG *, BTI_ULONG);
- BTI_SINT SRBFormat(PARMBLOCK *from, PARMBLOCK *srb, BTI_SINT *fcn);
- BTI_SINT SRBUnformat(PARMBLOCK *to, PARMBLOCK *srb, BTI_SINT fcn);
- #endif
-
- #if defined(BTI_DOS_32P) || defined(BTI_DOS_32B)
- /***************************************************************************
- The following function are in assembly language: define with CDECL
- ***************************************************************************/
- extern void cdecl copyToLow(unsigned short dst_sel, unsigned dst_offset,
- void * src, unsigned int size);
- extern void cdecl copyFromLow(void * dst, unsigned short src_sel,
- unsigned src_offset, unsigned int size);
- #endif
-
- #ifdef BTI_NLM
- BTI_SINT XQLEntry(BTI_VOID *); /* This API must be imported. */
- BTI_SINT callxqlm(BTI_VOID);
- BTI_VOID callxqlp(BTI_VOID);
- #endif
-
- /***************************************************************************
- PLATFORM-DEPENDENT MACROS FOR FUNCTION NAMES
- ***************************************************************************/
- #ifdef BTI_NLM
- #define callSQLFunction callxqlm
- #define callPrimitive callxqlp
- #endif
-
- /***************************************************************************
- COMPILER DEPENDENCIES
- ***************************************************************************/
- /* Microsoft changed function and structure names in 7.x */
- #if defined _MSC_VER
- #if (_MSC_VER > 600)
- #define segread _segread
- #define int86x _int86x
- #define REGS _REGS
- #define SREGS _SREGS
- #endif
- #endif
-
- /***************************************************************************
- MACROS
- ***************************************************************************/
- #if defined(BTI_DOS) || defined(BTI_DOS_32R) || defined(BTI_DOS_16B)
- #undef FP_SEG
- #undef FP_OFF
- #define FP_SEG(fp) (*((BTI_WORD_PTR)&(fp) + 1))
- #define FP_OFF(fp) (*((BTI_WORD_PTR)&(fp)))
- #endif
-
- #if defined(BTI_DOS_16B)
- #undef MK_FP
- #define MK_FP(seg,ofs) ((BTI_ULONG)(seg)<<16 + (BTI_WORD)(ofs))
- #endif
-
- /***************************************************************************
- GLOBAL VARIABLES
- ***************************************************************************/
- BTI_SINT SQLCODE;
- BTI_SINT SQL_SessionID = INVALID_SESSION_ID;
-
- #ifdef BTI_NLM
- BTI_SINT NSAgentID = 0x4D58; /* "XM" = Default, if SetNSAgentID not called */
- #endif
-
- #if defined(BTI_DOS) || defined(BTI_DOS_16B)
- typedef struct { BTI_WORD es, cs, ss, ds; } SQL_SREGS;
- typedef struct { BTI_WORD ax, bx, cx, dx, si, di, cy, flags; } SQL_REGS;
- SQL_REGS regs;
- SQL_SREGS sregs;
- #endif
-
- #if defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- extern BTI_WORD MaxSRBDataSize;
- #endif
-
- /**************************************************************************
- PLATFORM-INDEPENDENT SESSION MANAGEMENT PRIMITIVES
- The following primitives are required by applications which
- want to use multiple SQL logins:
- xGetSessionID
- xPutSessionID
- ***************************************************************************/
- /***************************************************************************
- xGetSessionID
- ***************************************************************************/
- BTI_API xGetSessionID(BTI_SINT_PTR iSessionID)
- {
- /* assumes -1 is uninitialized SQL_SessionID */
- if (SQL_SessionID == - 1)
- return SQL_NO_DICTIONARY_ACTIVE;
- *iSessionID = SQL_SessionID;
- return (0);
- }
-
- /***************************************************************************
- xPutSessionID
- ***************************************************************************/
- BTI_API xPutSessionID(BTI_SINT iSessionID)
- {
- SQL_SessionID = iSessionID;
- return (0);
- }
-
- /**************************************************************************
- PLATFORM-SPECIFIC MISCELLANEOUS FUNCTIONS
- SetNSAgentID (NLM)
- **************************************************************************/
- /**************************************************************************
- SetNSAgentID
- **************************************************************************/
- #ifdef BTI_NLM
- BTI_VOID SetNSAgentID(BTI_CHAR_PTR newID)
- {
- NSAgentID = ((BTI_WORD)*(newID+1) << 8) + *newID;
- }
- #endif
-
- /**************************************************************************
- DATABASE NAMES APIs FOR DOS
- **************************************************************************/
- /**************************************************************************
- SQLGetCountDatabaseNames
- **************************************************************************/
- #if defined(BTI_DOS) || defined(BTI_DOS_32R) ||\
- defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- BTI_API SQLGetCountDatabaseNames(
- BTI_SIZE_PTR tCount )
- {
- BTI_SINT stat = 0;
- PARMBLOCK dbnpb;
- pmswParmBlock pb;
-
- *((BTI_LONG_PTR) &(dbnpb.XQL_ID)) = DBNM_SIG;
- dbnpb.fcn = 2;
-
- dbnpb.v.dbnGetCntData.count = *tCount;
-
- *((BTI_LONG_PTR) &(pb.sign)) = *((BTI_LONG_PTR) PMSW_SIGN);
- pb.flags = 0;
- pb.func = DBNM_FUNC;
- pb.len = sizeof(dbnpb);
- pb.data = &dbnpb;
-
- stat = CallPMSW(&pb);
-
- *tCount = (BTI_SIZE)dbnpb.v.dbnGetCntData.count;
-
- if (stat == 0)
- stat = dbnpb.stat;
-
- return(stat);
- }
-
- BTI_API SQLGetDatabaseNames(
- BTI_SIZE_PTR tBufLen, BTI_CHAR_PTR bDataBuf )
- {
- BTI_SINT stat = 0;
- PARMBLOCK dbnpb;
- pmswParmBlock pb;
-
- *((BTI_LONG_PTR) &(dbnpb.XQL_ID)) = DBNM_SIG;
- dbnpb.fcn = 4;
-
- dbnpb.v.dbnGetNameData.bufLen = *tBufLen;
- dbnpb.v.dbnGetNameData.buffer = bDataBuf;
-
- *((BTI_LONG_PTR) &(pb.sign)) = *((BTI_LONG_PTR) PMSW_SIGN);
- pb.flags = 0;
- pb.func = DBNM_FUNC;
- pb.len = sizeof(dbnpb);
- pb.data = &dbnpb;
-
- stat = CallPMSW(&pb);
-
- *tBufLen = (BTI_SIZE)dbnpb.v.dbnGetNameData.bufLen;
-
- if (stat == 0)
- stat = dbnpb.stat;
-
- return(stat);
- }
-
- BTI_API SQLUnloadDBNames(BTI_SINT iReserved)
- {
- BTI_SINT stat = 0;
- PARMBLOCK dbnpb;
- pmswParmBlock pb;
-
- iReserved = 0; /* prevent compiler warning by using 'iReserved' */
-
- *((BTI_LONG_PTR) &(dbnpb.XQL_ID)) = DBNM_SIG;
- dbnpb.fcn = 7;
-
- dbnpb.v.dbnUnloadData.reserved = 0;
-
- *((BTI_LONG_PTR) &(pb.sign)) = *((BTI_LONG_PTR) PMSW_SIGN);
- pb.flags = 0;
- pb.func = DBNM_FUNC;
- pb.len = sizeof(dbnpb);
- pb.data = &dbnpb;
-
- stat = CallPMSW(&pb);
-
- if (stat == 0)
- stat = dbnpb.stat;
-
- return(stat);
- }
- #endif
-
- /**************************************************************************
- PLATFORM-INDEPENDENT SQL-LEVEL FUNCTIONS
- XQLCursor XQLSPUtility
- XQLCompile XQLStatus
- XQLDescribe XQLStop
- XQLExec XQLSubst
- XQLFetch XQLVersion
- XQLFormat XQLConvert
- XQLFree XQLValidate
- XQLLogin XQLMask
- XQLLogout
- **************************************************************************/
- /****** SQL-Level Function Numbers *******/
- #define lLogInFcn 0
- #define lLogOutFcn 1
- #define lCursorFcn 2
- #define lCompFcn 3
- #define lFormatFcn 4
- #define lFetchFcn 5
- #define lDescribeFcn 6
- #define lSubstFcn 7
- #define lExecFcn 8
- #define lFreeFcn 9
- #define lStatFcn 10
- #define lStopFcn 11
- #define lVersFcn 12
- #define lConvFcn 13
- #define lValFcn 14
- #define lMaskFcn 15
- #define lSPUtilityFcn 16
-
- /***************************************************************************
- SQL-Level Functions Call Parameter Block
- ***************************************************************************/
- PARMBLOCK XQLMPARMS;
-
- /***************************************************************************
- XQLCompile
- ***************************************************************************/
- BTI_API XQLCompile(
- BTI_SINT iCursorID,
- BTI_SIZE_PTR tStatementLen,
- BTI_CHAR_PTR sStatement)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lCompFcn;
- XQLMPARMS.cursorid = iCursorID;
- XQLMPARMS.v.xcData.length = *tStatementLen;
- XQLMPARMS.v.xcData.statement = (BTI_CHAR_PTR) sStatement;
-
- callSQLFunction ();
-
- *tStatementLen = (BTI_SIZE)XQLMPARMS.v.xcData.length;
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLCursor
- ***************************************************************************/
- BTI_API XQLCursor(
- BTI_SINT_PTR iCursorID)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lCursorFcn;
- XQLMPARMS.cursorid = -1;
-
- callSQLFunction ();
-
- *iCursorID = XQLMPARMS.cursorid;
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLDescribe
- ***************************************************************************/
- BTI_API XQLDescribe(
- BTI_SINT iCursorID,
- BTI_SIZE tPosition,
- BTI_SINT_PTR iDataType,
- BTI_SIZE_PTR tSize,
- BTI_SIZE_PTR tDecPlaces,
- BTI_SIZE_PTR tDisplayLen,
- BTI_SIZE_PTR tNameLen,
- BTI_CHAR_PTR sName )
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lDescribeFcn;
- XQLMPARMS.cursorid = iCursorID;
- XQLMPARMS.v.xdData.position = tPosition;
- XQLMPARMS.v.xdData.namelength = *tNameLen;
- XQLMPARMS.v.xdData.namebuf = (BTI_CHAR_PTR) sName;
-
- callSQLFunction ();
-
- *iDataType = XQLMPARMS.v.xdData.datatype;
- *tSize = (BTI_SIZE)XQLMPARMS.v.xdData.datasize;
- *tDecPlaces = (BTI_SIZE)XQLMPARMS.v.xdData.deccount;
- *tDisplayLen = (BTI_SIZE)XQLMPARMS.v.xdData.dsize;
- *tNameLen = (BTI_SIZE)XQLMPARMS.v.xdData.namelength;
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLExec
- ***************************************************************************/
- BTI_API XQLExec(
- BTI_SINT iCursorID)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lExecFcn;
- XQLMPARMS.cursorid = iCursorID;
-
- callSQLFunction ();
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLFetch
- ***************************************************************************/
- BTI_API XQLFetch(
- BTI_SINT iCursorID,
- BTI_SINT iOption,
- BTI_SIZE_PTR tBufLen,
- BTI_CHAR_PTR bDataBuf,
- BTI_LONG_PTR lCount,
- BTI_SINT iASCIIFlag,
- BTI_SINT iSpacing )
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lFetchFcn;
- XQLMPARMS.cursorid = iCursorID;
- XQLMPARMS.v.xfData.datalen = *tBufLen;
- XQLMPARMS.v.xfData.operation= iOption;
- XQLMPARMS.v.xfData.databuf = (BTI_CHAR_PTR) bDataBuf;
- XQLMPARMS.v.xfData.select = *lCount;
- XQLMPARMS.v.xfData.ASCIIFlag= iASCIIFlag;
- XQLMPARMS.v.xfData.spacing = iSpacing;
-
- callSQLFunction ();
-
- *tBufLen = (BTI_SIZE)XQLMPARMS.v.xfData.datalen;
- *lCount = XQLMPARMS.v.xfData.select;
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLFormat
- ***************************************************************************/
- BTI_API XQLFormat(
- BTI_SINT iCursorID,
- BTI_SIZE tPosition,
- BTI_SIZE tMaskLen,
- BTI_CHAR_PTR sMask)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lFormatFcn;
- XQLMPARMS.cursorid = iCursorID;
- XQLMPARMS.v.xfmData.position = tPosition;
- XQLMPARMS.v.xfmData.masklen = tMaskLen;
- XQLMPARMS.v.xfmData.mask = (BTI_CHAR_PTR) sMask;
-
- callSQLFunction ();
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLFree
- ***************************************************************************/
- BTI_API XQLFree(
- BTI_SINT iCursorID)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lFreeFcn;
- XQLMPARMS.cursorid = iCursorID;
-
- callSQLFunction ();
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLLogin
- ***************************************************************************/
- BTI_API XQLLogin(
- BTI_CHAR_PTR sUser,
- BTI_CHAR_PTR sPassword,
- BTI_CHAR_PTR sDDPath,
- BTI_CHAR_PTR sDataPath,
- BTI_CHAR_PTR sReserved,
- BTI_SINT iFeaturesUsed )
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lLogInFcn;
- XQLMPARMS.cursorid = 0;
-
- #ifdef BTI_NLM
- XQLMPARMS.stat = NSAgentID;
- #endif
-
- XQLMPARMS.v.tloginData.username = (BTI_CHAR_PTR) sUser;
- XQLMPARMS.v.tloginData.pswd = (BTI_CHAR_PTR) sPassword;
- XQLMPARMS.v.tloginData.dictionary = (BTI_CHAR_PTR) sDDPath;
- XQLMPARMS.v.tloginData.filepath = (BTI_CHAR_PTR) sDataPath;
- XQLMPARMS.v.tloginData.sreserved = (BTI_CHAR_PTR) sReserved;
- XQLMPARMS.v.tloginData.iFeaturesUsed = iFeaturesUsed;
-
- callSQLFunction ();
-
- if (XQLMPARMS.stat == 0)
- SQL_SessionID = XQLMPARMS.sessionid;
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLLogout
- ***************************************************************************/
- BTI_API XQLLogout
- (void)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lLogOutFcn;
-
- callSQLFunction ();
-
- SQLCODE = XQLMPARMS.stat;
- SQL_SessionID = -1;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLStatus
- ***************************************************************************/
- BTI_API XQLStatus(
- BTI_SINT iCursorID,
- BTI_SINT iOption,
- BTI_CHAR_PTR sStatBuf)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lStatFcn;
- XQLMPARMS.cursorid = iCursorID;
- XQLMPARMS.v.xstData.option = iOption;
- XQLMPARMS.v.xstData.buf = (BTI_CHAR_PTR) sStatBuf;
-
- callSQLFunction ();
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLStop
- ***************************************************************************/
- BTI_API XQLStop
- (void)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lStopFcn;
-
- callSQLFunction ();
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLSubst
- ***************************************************************************/
- BTI_API XQLSubst(
- BTI_SINT iCursorID,
- BTI_SIZE tCount,
- BTI_SIZE tNameLen,
- BTI_CHAR_PTR sVarNames,
- BTI_SIZE tTextLen,
- BTI_CHAR_PTR sValueText)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lSubstFcn;
- XQLMPARMS.cursorid = iCursorID;
- XQLMPARMS.v.xsData.count = tCount;
- XQLMPARMS.v.xsData.nlen = tNameLen;
- XQLMPARMS.v.xsData.vname = (BTI_CHAR_PTR) sVarNames;
- XQLMPARMS.v.xsData.tlen = tTextLen;
- XQLMPARMS.v.xsData.vtext = (BTI_CHAR_PTR) sValueText;
-
- callSQLFunction ();
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLVersion
- ***************************************************************************/
- BTI_API XQLVersion(
- BTI_CHAR_PTR sVersion)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lVersFcn;
- XQLMPARMS.v.xvData.buffer = (BTI_CHAR_PTR) sVersion;
-
- callSQLFunction ();
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLConvert
- ***************************************************************************/
- BTI_API XQLConvert(
- BTI_SINT iOption,
- BTI_SINT iType,
- BTI_SIZE tSize,
- BTI_SIZE tDec,
- BTI_SIZE tdSize,
- BTI_CHAR_PTR sValue,
- BTI_CHAR_PTR sRetVal,
- BTI_CHAR_PTR sMask,
- BTI_SINT sJustify)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lConvFcn;
- XQLMPARMS.v.tcnvData.option = iOption;
- XQLMPARMS.v.tcnvData.type = iType;
- XQLMPARMS.v.tcnvData.size = tSize;
- XQLMPARMS.v.tcnvData.dec = tDec;
- XQLMPARMS.v.tcnvData.dsize = tdSize;
- XQLMPARMS.v.tcnvData.value = (BTI_CHAR_PTR) sValue;
- XQLMPARMS.v.tcnvData.retval = (BTI_CHAR_PTR) sRetVal;
- XQLMPARMS.v.tcnvData.mask = (BTI_CHAR_PTR) sMask;
- XQLMPARMS.v.tcnvData.justify = sJustify;
-
- callSQLFunction ();
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLValidate
- ***************************************************************************/
- BTI_API XQLValidate(
- BTI_SIZE_PTR tCount,
- BTI_CHAR_PTR sFieldName,
- BTI_SIZE tBufLen,
- BTI_CHAR_PTR bDataBuf )
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lValFcn;
- XQLMPARMS.v.tvalData.fieldname = (BTI_CHAR_PTR) sFieldName;
- XQLMPARMS.v.tvalData.count = *tCount;
- XQLMPARMS.v.tvalData.buflen = tBufLen;
- XQLMPARMS.v.tvalData.data = (BTI_CHAR_PTR) bDataBuf;
-
- callSQLFunction ();
-
- *tCount = (BTI_SIZE)XQLMPARMS.v.tvalData.count;
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLMask
- ***************************************************************************/
- BTI_API XQLMask(
- BTI_SINT iOption,
- BTI_SINT iType,
- BTI_SIZE tSize,
- BTI_SIZE tDec,
- BTI_SIZE_PTR tLen,
- BTI_CHAR_PTR sMask)
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lMaskFcn;
- XQLMPARMS.v.tmaskData.option = iOption;
- XQLMPARMS.v.tmaskData.type = iType;
- XQLMPARMS.v.tmaskData.size = tSize;
- XQLMPARMS.v.tmaskData.dec = tDec;
- XQLMPARMS.v.tmaskData.mlen = *tLen;
- XQLMPARMS.v.tmaskData.mask = (BTI_CHAR_PTR) sMask;
-
- callSQLFunction ();
-
- *tLen = (BTI_SIZE)XQLMPARMS.v.tmaskData.mlen;
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /***************************************************************************
- XQLSPUtility
- ***************************************************************************/
- BTI_API XQLSPUtility(
- BTI_SINT iCursorID,
- BTI_SINT iOption,
- BTI_SIZE_PTR tStatementCount,
- BTI_SIZE_PTR tStatementExec,
- BTI_SIZE_PTR tBufLen,
- BTI_CHAR_PTR bDataBuf )
- {
- #if defined(BTI_DOS) || defined(BTI_DOS_32P) || \
- defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- if (!sql_loaded ())
- return (SQLCODE);
- #endif
-
- XQLMPARMS.fcn = lSPUtilityFcn;
- XQLMPARMS.cursorid = iCursorID;
- XQLMPARMS.v.xspData.option = iOption;
- XQLMPARMS.v.xspData.stmntCnt = *tStatementCount;
- XQLMPARMS.v.xspData.stmntExec = *tStatementExec;
- XQLMPARMS.v.xspData.bufLen = *tBufLen;
- XQLMPARMS.v.xspData.statBuf = (BTI_CHAR_PTR) bDataBuf;
-
- callSQLFunction ();
-
- *tStatementCount = (BTI_SIZE)XQLMPARMS.v.xspData.stmntCnt;
- *tStatementExec = XQLMPARMS.v.xspData.stmntExec;
- *tBufLen = (BTI_SIZE)XQLMPARMS.v.xspData.bufLen;
-
- SQLCODE = XQLMPARMS.stat;
- return (XQLMPARMS.stat);
- }
-
- /**************************************************************************
- PLATFORM-INDEPENDENT HISTORICAL RELATIONAL PRIMITIVES
- The following functions will be phased out over time. They
- are included in the interface modules to support existing
- applications. New applications should not use these functions.
-
- xCompute xOrder xDD xAccess
- xDescribe xRemall xDDAttr xPassword
- xMovefld xRemove xDDModify xSecurity
- xFetch xReset xDDCreate xUser
- xField xRestrict xDDDrop xChar
- xFree xStop xDDField xVersion
- xInsert xTrans xDDFile xStatus
- xJoin xStore xDDIndex xConvert
- xLogin xRecall xDDPath xValidate
- xLogout xUpdate xDDView xMask
- xNew xUpdall
- *********************************************************************/
- /****** Relational Primitives Function Numbers *******/
- #define tLogInFcn 0
- #define tLogOutFcn 1
- #define tNewFcn 2
- #define tFreeFcn 3
- #define tMoveFldFcn 4
- #define tFieldFcn 5
- #define tDescribeFcn 6
- #define tFetchFcn 7
- #define tComputeFcn 8
- #define tOrderFcn 9
- #define tRestrictFcn 10
- #define tJoinFcn 11
- #define tInsertFcn 12
- #define tUpdateFcn 13
- #define tUpdallFcn 14
- #define tRemoveFcn 15
- #define tRemallFcn 16
- #define tResetFcn 17
- #define tTransFcn 18
- #define tStatFcn 19
- #define tDDCreFcn 20
- #define tStoreFcn 21
- #define tRecallFcn 22
- #define tStopFcn 23
- #define tDDFileFcn 24
- #define tDDFieldFcn 25
- #define tDDIndexFcn 26
- #define tDDModFcn 27
- #define tDDViewFcn 28
- #define tDDDrpFcn 29
- #define tDDPathFcn 30
- #define tDDAttrFcn 31
- #define tDDFcn 32
- #define tSecurFcn 33
- #define tUserFcn 34
- #define tAccessFcn 35
- #define tPswdFcn 36
- #define tCharFcn 37
- #define tVersionFcn 38
- #define tCnvFcn 39
- #define tValFcn 40
- #define tMaskFcn 41
-
- /***************************************************************************
- Primitive-Level Functions Parameter Block
- ***************************************************************************/
- PARMBLOCK XQLPPARMS;
-
- /***************************************************************************
- xCompute
- ***************************************************************************/
- BTI_API xCompute(
- BTI_SINT iCursorID,
- BTI_CHAR_PTR sFldName,
- BTI_SINT iFldType,
- BTI_SIZE tFldLen,
- BTI_SIZE tDecPlaces,
- BTI_SIZE_PTR tExpLen,
- BTI_CHAR_PTR sExpression )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded())
- return(SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tComputeFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tcompData.fldname = (BTI_CHAR_PTR) sFldName;
- XQLPPARMS.v.tcompData.fldtype = iFldType;
- XQLPPARMS.v.tcompData.fldsize = tFldLen;
- XQLPPARMS.v.tcompData.flddec = tDecPlaces;
- XQLPPARMS.v.tcompData.explen = *tExpLen;
- XQLPPARMS.v.tcompData.expbuf = (BTI_CHAR_PTR) sExpression;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat > 0)
- *tExpLen = (BTI_SIZE)XQLPPARMS.v.tcompData.explen;
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDescribe
- ***************************************************************************/
- BTI_API xDescribe(
- BTI_SINT iCursorID,
- BTI_SINT iOption,
- BTI_SIZE_PTR tBufLen,
- BTI_SIZE tPosition,
- BTI_SIZE_PTR tCount,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDescribeFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tdescData.option = iOption;
- XQLPPARMS.v.tdescData.desclen = *tBufLen;
- XQLPPARMS.v.tdescData.position = tPosition;
- XQLPPARMS.v.tdescData.count = *tCount;
- XQLPPARMS.v.tdescData.desclist = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- *tBufLen = (BTI_SIZE)XQLPPARMS.v.tdescData.desclen;
- *tCount = (BTI_SIZE)XQLPPARMS.v.tdescData.count;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xMovefld
- ***************************************************************************/
- BTI_API xMovefld(
- BTI_SINT iCursorID,
- BTI_SIZE tFromPosition,
- BTI_SIZE tToPosition)
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tMoveFldFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tmovData.frompos = tFromPosition;
- XQLPPARMS.v.tmovData.topos = tToPosition;
-
- callPrimitive ();
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xFetch
- ***************************************************************************/
- BTI_API xFetch(
- BTI_SINT iCursorID,
- BTI_SIZE_PTR tBufLen,
- BTI_SINT iOption,
- BTI_LONG_PTR lRecordCount,
- BTI_LONG_PTR lRejectCount,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tFetchFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tfetchData.datalen = *tBufLen;
- XQLPPARMS.v.tfetchData.option = iOption;
- XQLPPARMS.v.tfetchData.select = *lRecordCount;
- XQLPPARMS.v.tfetchData.reject = *lRejectCount;
- XQLPPARMS.v.tfetchData.databuf = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- *tBufLen = (BTI_SIZE)XQLPPARMS.v.tfetchData.datalen;
- *lRecordCount = XQLPPARMS.v.tfetchData.select;
- *lRejectCount = XQLPPARMS.v.tfetchData.reject;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xField
- ***************************************************************************/
- BTI_API xField(
- BTI_SINT iCursorID,
- BTI_SINT iOption,
- BTI_SIZE tPosition,
- BTI_SIZE_PTR tCount,
- BTI_CHAR_PTR sFldNames )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tFieldFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tfldData.option = iOption;
- XQLPPARMS.v.tfldData.position = tPosition;
- XQLPPARMS.v.tfldData.count = *tCount;
- XQLPPARMS.v.tfldData.fldlist = (BTI_CHAR_PTR) sFldNames;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat >= 0)
- *tCount = (BTI_SIZE)XQLPPARMS.v.tfldData.count;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xFree
- ***************************************************************************/
- BTI_API xFree(
- BTI_SINT iCursorID )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tFreeFcn;
- XQLPPARMS.cursorid = iCursorID;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xInsert
- ***************************************************************************/
- BTI_API xInsert(
- BTI_SINT iCursorID,
- BTI_SIZE_PTR tFileCount,
- BTI_CHAR_PTR sFileNames,
- BTI_LONG_PTR lRecordCount,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tInsertFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.teditData.filecount = *tFileCount;
- XQLPPARMS.v.teditData.filelist = (BTI_CHAR_PTR) sFileNames;
- XQLPPARMS.v.teditData.editcount = *lRecordCount;
- XQLPPARMS.v.teditData.buf = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- *lRecordCount = XQLPPARMS.v.teditData.editcount;
- *tFileCount = (BTI_SIZE)XQLPPARMS.v.teditData.filecount;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xJoin
- ***************************************************************************/
- BTI_API xJoin(
- BTI_SINT iCursorID,
- BTI_CHAR_PTR sSecFile,
- BTI_CHAR_PTR sOwner,
- BTI_SINT iOption,
- BTI_SIZE tPriFldCount,
- BTI_CHAR_PTR sPriFlds,
- BTI_SIZE tSecFldCount,
- BTI_CHAR_PTR sSecFlds)
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tJoinFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tjoinData.filename = (BTI_CHAR_PTR) sSecFile;
- XQLPPARMS.v.tjoinData.owner = (BTI_CHAR_PTR) sOwner;
- XQLPPARMS.v.tjoinData.joinType = iOption;
- XQLPPARMS.v.tjoinData.pCount = tPriFldCount;
- XQLPPARMS.v.tjoinData.pNames = (BTI_CHAR_PTR) sPriFlds;
- XQLPPARMS.v.tjoinData.sCount = tSecFldCount;
- XQLPPARMS.v.tjoinData.sNames = (BTI_CHAR_PTR) sSecFlds;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xLogin
- ***************************************************************************/
- BTI_API xLogin(
- BTI_CHAR_PTR sUser,
- BTI_CHAR_PTR sPassword,
- BTI_CHAR_PTR sDDPath,
- BTI_CHAR_PTR sDataPath,
- BTI_CHAR_PTR sReserved,
- BTI_SINT iFeaturesUsed)
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tLogInFcn;
- #ifdef BTI_NLM
- XQLPPARMS.stat = NSAgentID;
- #endif
- XQLPPARMS.cursorid = 0;
- XQLPPARMS.v.tloginData.username = (BTI_CHAR_PTR) sUser;
- XQLPPARMS.v.tloginData.pswd = (BTI_CHAR_PTR) sPassword;
- XQLPPARMS.v.tloginData.dictionary = (BTI_CHAR_PTR) sDDPath;
- XQLPPARMS.v.tloginData.filepath = (BTI_CHAR_PTR) sDataPath;
- XQLPPARMS.v.tloginData.sreserved = (BTI_CHAR_PTR) sReserved;
- XQLPPARMS.v.tloginData.iFeaturesUsed = iFeaturesUsed;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat == 0)
- SQL_SessionID = XQLPPARMS.sessionid;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xLogout
- ***************************************************************************/
- BTI_API xLogout ()
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tLogOutFcn;
-
- callPrimitive ();
-
- SQL_SessionID = -1;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xNew
- ***************************************************************************/
- BTI_API xNew(
- BTI_SINT_PTR iCursorID,
- BTI_CHAR_PTR sFileName,
- BTI_CHAR_PTR sOwner,
- BTI_SINT iOpenMode)
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tNewFcn;
- XQLPPARMS.cursorid = *iCursorID;
- XQLPPARMS.v.tnewData.filename = (BTI_CHAR_PTR) sFileName;
- XQLPPARMS.v.tnewData.owner = (BTI_CHAR_PTR) sOwner;
- XQLPPARMS.v.tnewData.openmode = iOpenMode;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat == 0)
- *iCursorID = XQLPPARMS.cursorid;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xOrder
- ***************************************************************************/
- BTI_API xOrder(
- BTI_SINT iCursorID,
- BTI_SIZE tCount,
- BTI_CHAR_PTR sOrderFld)
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tOrderFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tordData.count = tCount;
- XQLPPARMS.v.tordData.fldlist = (BTI_CHAR_PTR) sOrderFld;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xRemall
- ***************************************************************************/
- BTI_API xRemall(
- BTI_SINT iCursorID,
- BTI_SIZE_PTR tFileCount,
- BTI_CHAR_PTR sFileNames,
- BTI_SINT iOption,
- BTI_LONG_PTR lRecordCount,
- BTI_LONG_PTR lRejectCount )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tRemallFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tremallData.filecount = *tFileCount;
- XQLPPARMS.v.tremallData.filelist = (BTI_CHAR_PTR) sFileNames;
- XQLPPARMS.v.tremallData.option = iOption;
- XQLPPARMS.v.tremallData.select = *lRecordCount;
- XQLPPARMS.v.tremallData.reject = *lRejectCount;
-
- callPrimitive ();
-
- *lRecordCount = XQLPPARMS.v.tremallData.select;
- *lRejectCount = XQLPPARMS.v.tremallData.reject;
- *tFileCount = (BTI_SIZE)XQLPPARMS.v.tremallData.filecount;
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xRemove
- ***************************************************************************/
- BTI_API xRemove(
- BTI_SINT iCursorID,
- BTI_SIZE_PTR tFileCount,
- BTI_CHAR_PTR sFileNames,
- BTI_LONG_PTR lRecordCount )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tRemoveFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.teditData.filecount = *tFileCount;
- XQLPPARMS.v.teditData.filelist = (BTI_CHAR_PTR) sFileNames;
- XQLPPARMS.v.teditData.editcount = *lRecordCount;
- XQLPPARMS.v.teditData.buf = 0;
-
- callPrimitive ();
-
- *lRecordCount = XQLPPARMS.v.teditData.editcount;
- *tFileCount = (BTI_SIZE)XQLPPARMS.v.teditData.filecount;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xReset
- ***************************************************************************/
- BTI_API xReset(
- BTI_CHAR_PTR sReserved)
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tResetFcn;
- XQLPPARMS.v.tresetData.sreserved = (BTI_CHAR_PTR) sReserved;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xRestrict
- ***************************************************************************/
- BTI_API xRestrict(
- BTI_SINT iCursorID,
- BTI_SINT iOption,
- BTI_SIZE_PTR tExpLen,
- BTI_CHAR_PTR sExpression )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tRestrictFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.trestData.option = iOption;
- XQLPPARMS.v.trestData.explen = *tExpLen;
- XQLPPARMS.v.trestData.expbuf = (BTI_CHAR_PTR) sExpression;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat != 0)
- *tExpLen = (BTI_SIZE)XQLPPARMS.v.trestData.explen;
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xStop
- ***************************************************************************/
- BTI_API xStop(
- void )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tStopFcn;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xTrans
- ***************************************************************************/
- BTI_API xTrans(
- BTI_SINT iOption )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tTransFcn;
- XQLPPARMS.v.ttransData.option = iOption;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xUpdate
- ***************************************************************************/
- BTI_API xUpdate(
- BTI_SINT iCursorID,
- BTI_SIZE_PTR tFileCount,
- BTI_CHAR_PTR sFileNames,
- BTI_LONG_PTR lRecordCount,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tUpdateFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.teditData.filecount = *tFileCount;
- XQLPPARMS.v.teditData.filelist = (BTI_CHAR_PTR) sFileNames;
- XQLPPARMS.v.teditData.editcount = *lRecordCount;
- XQLPPARMS.v.teditData.buf = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- *lRecordCount = XQLPPARMS.v.teditData.editcount;
- *tFileCount = (BTI_SIZE)XQLPPARMS.v.teditData.filecount;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xStore
- ***************************************************************************/
- BTI_API xStore(
- BTI_SINT iCursorID,
- BTI_CHAR_PTR sViewName,
- BTI_SIZE tTextLen,
- BTI_CHAR_PTR sText )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tStoreFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tstoreData.StoreName = (BTI_CHAR_PTR) sViewName;
- XQLPPARMS.v.tstoreData.BufLen = tTextLen;
- XQLPPARMS.v.tstoreData.Buf = (BTI_CHAR_PTR) sText;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xRecall
- ***************************************************************************/
- BTI_API xRecall(
- BTI_SINT_PTR iCursorID,
- BTI_CHAR_PTR sViewName,
- BTI_SIZE tOwnerCount,
- BTI_CHAR_PTR sOwner,
- BTI_SINT iOpenMode,
- BTI_SIZE_PTR tTextLen,
- BTI_CHAR_PTR sText )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tRecallFcn;
- XQLPPARMS.cursorid = 0;
- XQLPPARMS.v.trecallData.RecallName = (BTI_CHAR_PTR) sViewName;
- XQLPPARMS.v.trecallData.ownernum = tOwnerCount;
- XQLPPARMS.v.trecallData.ownerlst = (BTI_CHAR_PTR) sOwner;
- XQLPPARMS.v.trecallData.openmode = iOpenMode;
- XQLPPARMS.v.trecallData.buflen = *tTextLen;
- XQLPPARMS.v.trecallData.buf = (BTI_CHAR_PTR) sText;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat == 0)
- *iCursorID = XQLPPARMS.cursorid;
- *tTextLen = (BTI_SIZE)XQLPPARMS.v.trecallData.buflen;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xUpdall
- ***************************************************************************/
- BTI_API xUpdall(
- BTI_SINT iCursorID,
- BTI_SIZE_PTR tFileCount,
- BTI_CHAR_PTR sFileNames,
- BTI_SINT iOption,
- BTI_LONG_PTR lRecordCount,
- BTI_LONG_PTR lRejectCount,
- BTI_SIZE tFldCount,
- BTI_CHAR_PTR sUpdateFld,
- BTI_CHAR_PTR sReplaceFld )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tUpdallFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tupdallData.filecount = *tFileCount;
- XQLPPARMS.v.tupdallData.filelist = (BTI_CHAR_PTR) sFileNames;
- XQLPPARMS.v.tupdallData.option = iOption;
- XQLPPARMS.v.tupdallData.select = *lRecordCount;
- XQLPPARMS.v.tupdallData.reject = *lRejectCount;
- XQLPPARMS.v.tupdallData.count = tFldCount;
- XQLPPARMS.v.tupdallData.result = (BTI_CHAR_PTR) sUpdateFld;
- XQLPPARMS.v.tupdallData.value = (BTI_CHAR_PTR) sReplaceFld;
-
- callPrimitive ();
-
- *lRecordCount = XQLPPARMS.v.tupdallData.select;
- *lRejectCount = XQLPPARMS.v.tupdallData.reject;
- *tFileCount = (BTI_SIZE)XQLPPARMS.v.tupdallData.filecount;
- return (XQLPPARMS.stat);
- }
-
- /*************** Dictionary Primitives ******************/
- /***************************************************************************
- xDD
- ***************************************************************************/
- BTI_API xDD(
- BTI_CHAR_PTR sPathName,
- BTI_SINT iOption)
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDFcn;
- XQLPPARMS.v.tddData.dirpath = (BTI_CHAR_PTR) sPathName;
- XQLPPARMS.v.tddData.function = iOption;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDDAttr
- ***************************************************************************/
- BTI_API xDDAttr(
- BTI_SINT iOption,
- BTI_CHAR_PTR sFldName,
- BTI_SINT iAttrType,
- BTI_SIZE_PTR tBufLen,
- BTI_CHAR_PTR sAttrBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDAttrFcn;
- XQLPPARMS.v.tddattrData.fcn = iOption;
- XQLPPARMS.v.tddattrData.fieldname = (BTI_CHAR_PTR) sFldName;
- XQLPPARMS.v.tddattrData.attr = iAttrType;
- XQLPPARMS.v.tddattrData.bufsize = *tBufLen;
- XQLPPARMS.v.tddattrData.attrbuf = (BTI_CHAR_PTR) sAttrBuf;
-
- callPrimitive ();
-
- *tBufLen = (BTI_SIZE)XQLPPARMS.v.tddattrData.bufsize;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDDModify
- ***************************************************************************/
- BTI_API xDDModify(
- BTI_SINT iOption,
- BTI_CHAR_PTR sFileName,
- BTI_SINT iCreate,
- BTI_CHAR_PTR sPathName,
- BTI_CHAR_PTR sOwner,
- BTI_SINT iOwnerFlag,
- BTI_SIZE tFldCount,
- BTI_CHAR_PTR bFldBuf,
- BTI_SIZE tIndxCount,
- BTI_CHAR_PTR bIndxBuf)
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDModFcn;
- XQLPPARMS.v.tmodData.option = iOption;
- XQLPPARMS.v.tmodData.filename = (BTI_CHAR_PTR) sFileName;
- XQLPPARMS.v.tmodData.create = iCreate;
- XQLPPARMS.v.tmodData.pathname = (BTI_CHAR_PTR) sPathName;
- XQLPPARMS.v.tmodData.owner = (BTI_CHAR_PTR) sOwner;
- XQLPPARMS.v.tmodData.oaccess = iOwnerFlag;
- XQLPPARMS.v.tmodData.fieldlist = (BTI_CHAR_PTR) bFldBuf;
- XQLPPARMS.v.tmodData.keylist = (BTI_CHAR_PTR) bIndxBuf;
- XQLPPARMS.v.tmodData.fldcount = tFldCount;
- XQLPPARMS.v.tmodData.kcount = tIndxCount;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDDCreate
- ***************************************************************************/
- BTI_API xDDCreate(
- BTI_SINT iOption,
- BTI_CHAR_PTR sFileName,
- BTI_SINT iCreate,
- BTI_CHAR_PTR sPathName,
- BTI_CHAR_PTR sOwner,
- BTI_SINT iOwnerFlag,
- BTI_SIZE tFldCount,
- BTI_CHAR_PTR bFldBuf,
- BTI_SIZE tIndxCount,
- BTI_CHAR_PTR bIndxBuf,
- BTI_SIZE tBufLen,
- BTI_CHAR_PTR bCreateParmsBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDCreFcn;
- XQLPPARMS.v.tcreData.option = iOption;
- XQLPPARMS.v.tcreData.filename = (BTI_CHAR_PTR) sFileName;
- XQLPPARMS.v.tcreData.create = iCreate;
- XQLPPARMS.v.tcreData.pathname = (BTI_CHAR_PTR) sPathName;
- XQLPPARMS.v.tcreData.owner = (BTI_CHAR_PTR) sOwner;
- XQLPPARMS.v.tcreData.oaccess = iOwnerFlag;
- XQLPPARMS.v.tcreData.fieldlist = (BTI_CHAR_PTR) bFldBuf;
- XQLPPARMS.v.tcreData.keylist = (BTI_CHAR_PTR) bIndxBuf;
- XQLPPARMS.v.tcreData.fldcount = tFldCount;
- XQLPPARMS.v.tcreData.kcount = tIndxCount;
- XQLPPARMS.v.tcreData.buflen = tBufLen;
- XQLPPARMS.v.tcreData.createparms = (BTI_CHAR_PTR) bCreateParmsBuf;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDDrop
- ***************************************************************************/
- BTI_API xDDDrop(
- BTI_CHAR_PTR sName,
- BTI_SINT iType,
- BTI_SINT iDelete )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDDrpFcn;
- XQLPPARMS.v.tdddropData.filename = (BTI_CHAR_PTR) sName;
- XQLPPARMS.v.tdddropData.filetype = iType;
- XQLPPARMS.v.tdddropData.deletepath = iDelete;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDDField
- ***************************************************************************/
- BTI_API xDDField(
- BTI_SINT iOption,
- BTI_SIZE_PTR tCount,
- BTI_CHAR_PTR sFldNames,
- BTI_SIZE_PTR tBufLen,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDFieldFcn;
- XQLPPARMS.v.tddfieldData.rtype = iOption;
- XQLPPARMS.v.tddfieldData.count = *tCount;
- XQLPPARMS.v.tddfieldData.buflen = *tBufLen;
- XQLPPARMS.v.tddfieldData.fieldbuf = (BTI_CHAR_PTR) sFldNames;
- XQLPPARMS.v.tddfieldData.outbuf = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat >= 0)
- {
- *tCount = XQLPPARMS.v.tddfieldData.count;
- *tBufLen = XQLPPARMS.v.tddfieldData.buflen;
- }
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDDFile
- ***************************************************************************/
- BTI_API xDDFile(
- BTI_SINT iOption,
- BTI_SIZE_PTR tCount,
- BTI_CHAR_PTR sFileNames,
- BTI_SIZE_PTR tBufLen,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDFileFcn;
- XQLPPARMS.v.tddfileData.rtype = iOption;
- XQLPPARMS.v.tddfileData.count = *tCount;
- XQLPPARMS.v.tddfileData.filebuf = (BTI_CHAR_PTR) sFileNames;
- XQLPPARMS.v.tddfileData.buflen = *tBufLen;
- XQLPPARMS.v.tddfileData.outbuf = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat >= 0)
- {
- *tCount = (BTI_SIZE)XQLPPARMS.v.tddfileData.count;
- *tBufLen = (BTI_SIZE)XQLPPARMS.v.tddfileData.buflen;
- }
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDDIndex
- ***************************************************************************/
- BTI_API xDDIndex(
- BTI_SINT iOption,
- BTI_SIZE_PTR tCount,
- BTI_CHAR_PTR sIndexName,
- BTI_SIZE_PTR tBufLen,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDIndexFcn;
- XQLPPARMS.v.tddindexData.rtype = iOption;
- XQLPPARMS.v.tddindexData.count = *tCount;
- XQLPPARMS.v.tddindexData.buflen = *tBufLen;
- XQLPPARMS.v.tddindexData.fieldbuf = (BTI_CHAR_PTR) sIndexName;
- XQLPPARMS.v.tddindexData.outbuf = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat >= 0)
- {
- *tCount = (BTI_SIZE)XQLPPARMS.v.tddindexData.count;
- *tBufLen = (BTI_SIZE)XQLPPARMS.v.tddindexData.buflen;
- }
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDDPath
- ***************************************************************************/
- BTI_API xDDPath(
- BTI_SINT iOption,
- BTI_CHAR_PTR sPathName )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDPathFcn;
- XQLPPARMS.v.tddpathData.dirtype = iOption;
- XQLPPARMS.v.tddpathData.pathname = (BTI_CHAR_PTR) sPathName;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xDDView
- ***************************************************************************/
- BTI_API xDDView(
- BTI_SIZE_PTR tCount,
- BTI_CHAR_PTR sViewName,
- BTI_SIZE_PTR tBufLen,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tDDViewFcn;
- XQLPPARMS.v.tddviewData.count = *tCount;
- XQLPPARMS.v.tddviewData.viewname = (BTI_CHAR_PTR) sViewName;
- XQLPPARMS.v.tddviewData.buflen = *tBufLen;
- XQLPPARMS.v.tddviewData.outbuf = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat >= 0)
- {
- *tCount = (BTI_SIZE)XQLPPARMS.v.tddviewData.count;
- *tBufLen = (BTI_SIZE)XQLPPARMS.v.tddviewData.buflen;
- }
- return (XQLPPARMS.stat);
- }
-
- /*************** Security Primitives ******************/
- /***************************************************************************
- xAccess
- ***************************************************************************/
- BTI_API xAccess(
- BTI_CHAR_PTR sMstrPswd,
- BTI_CHAR_PTR sUser,
- BTI_SINT iOption,
- BTI_SINT iAccRights,
- BTI_CHAR_PTR sFileName,
- BTI_SIZE_PTR tCount,
- BTI_CHAR_PTR sFldNames,
- BTI_SIZE_PTR tBufLen,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tAccessFcn;
- XQLPPARMS.v.taccessData.mpswd = (BTI_CHAR_PTR) sMstrPswd;
- XQLPPARMS.v.taccessData.username = (BTI_CHAR_PTR) sUser;
- XQLPPARMS.v.taccessData.fcn = iOption;
- XQLPPARMS.v.taccessData.rights = iAccRights;
- XQLPPARMS.v.taccessData.filename = (BTI_CHAR_PTR) sFileName;
- XQLPPARMS.v.taccessData.count = *tCount;
- XQLPPARMS.v.taccessData.name = (BTI_CHAR_PTR) sFldNames;
- XQLPPARMS.v.taccessData.buflen = *tBufLen;
- XQLPPARMS.v.taccessData.outbuf = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat == 0)
- {
- *tCount = (BTI_SIZE)XQLPPARMS.v.taccessData.count;
- *tBufLen = (BTI_SIZE)XQLPPARMS.v.taccessData.buflen;
- }
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xPassword
- ***************************************************************************/
- BTI_API xPassword(
- BTI_CHAR_PTR sUser,
- BTI_CHAR_PTR sPassword )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tPswdFcn;
- XQLPPARMS.v.tpswdData.user = (BTI_CHAR_PTR) sUser;
- XQLPPARMS.v.tpswdData.pswd = (BTI_CHAR_PTR) sPassword;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xSecurity
- ***************************************************************************/
- BTI_API xSecurity(
- BTI_CHAR_PTR sMstrPswd,
- BTI_SINT iOption )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tSecurFcn;
- XQLPPARMS.v.tsecureData.mpswd = (BTI_CHAR_PTR) sMstrPswd;
- XQLPPARMS.v.tsecureData.securityflag = iOption;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xUser
- ***************************************************************************/
- BTI_API xUser(
- BTI_CHAR_PTR sMstPswd,
- BTI_SINT iOption,
- BTI_CHAR_PTR sUser,
- BTI_CHAR_PTR sPassword,
- BTI_SINT iFlags,
- BTI_SIZE_PTR tCount,
- BTI_SIZE_PTR tBufLen,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tUserFcn;
- XQLPPARMS.v.tuserData.mpswd = (BTI_CHAR_PTR) sMstPswd;
- XQLPPARMS.v.tuserData.fcn = iOption;
- XQLPPARMS.v.tuserData.username = (BTI_CHAR_PTR) sUser;
- XQLPPARMS.v.tuserData.pswd = (BTI_CHAR_PTR) sPassword;
- XQLPPARMS.v.tuserData.grights = iFlags;
- XQLPPARMS.v.tuserData.count = *tCount;
- XQLPPARMS.v.tuserData.buflen = *tBufLen;
- XQLPPARMS.v.tuserData.userbuf = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- *tCount = (BTI_SIZE)XQLPPARMS.v.tuserData.count;
- *tBufLen = (BTI_SIZE)XQLPPARMS.v.tuserData.buflen;
- return (XQLPPARMS.stat);
- }
-
- /*************** Miscellaneous Primitives ******************/
- /***************************************************************************
- xChar
- ***************************************************************************/
- BTI_API xChar(
- BTI_SINT iOption,
- BTI_SINT iType,
- BTI_CHAR_PTR cCharacter )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tCharFcn;
- XQLPPARMS.v.tcharData.charFcn = iOption;
- XQLPPARMS.v.tcharData.charType = iType;
- XQLPPARMS.v.tcharData.charValue = *(BTI_SINT *)cCharacter;
-
- callPrimitive ();
-
- *cCharacter = XQLPPARMS.v.tcharData.charValue;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xVersion
- ***************************************************************************/
- BTI_API xVersion(
- BTI_CHAR_PTR sVersion )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tVersionFcn;
- XQLPPARMS.v.tversionData.buffer = (BTI_CHAR_PTR) sVersion;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xConvert
- ***************************************************************************/
- BTI_API xConvert(
- BTI_SINT iOption,
- BTI_SINT iType,
- BTI_SIZE tSize,
- BTI_SIZE tDec,
- BTI_SIZE tDSize,
- BTI_CHAR_PTR sValue,
- BTI_CHAR_PTR sRetVal,
- BTI_CHAR_PTR sMask,
- BTI_SINT iJustify )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tCnvFcn;
- XQLPPARMS.v.tcnvData.option = iOption;
- XQLPPARMS.v.tcnvData.type = iType;
- XQLPPARMS.v.tcnvData.size = tSize;
- XQLPPARMS.v.tcnvData.dec = tDec;
- XQLPPARMS.v.tcnvData.dsize = tDSize;
- XQLPPARMS.v.tcnvData.value = (BTI_CHAR_PTR) sValue;
- XQLPPARMS.v.tcnvData.retval = (BTI_CHAR_PTR) sRetVal;
- XQLPPARMS.v.tcnvData.mask = (BTI_CHAR_PTR) sMask;
- XQLPPARMS.v.tcnvData.justify = iJustify;
-
- callPrimitive ();
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xValidate
- ***************************************************************************/
- BTI_API xValidate(
- BTI_SIZE_PTR tCount,
- BTI_CHAR_PTR sFieldName,
- BTI_SIZE tBufLen,
- BTI_CHAR_PTR bDataBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tValFcn;
- XQLPPARMS.v.tvalData.fieldname = (BTI_CHAR_PTR) sFieldName;
- XQLPPARMS.v.tvalData.count = *tCount;
- XQLPPARMS.v.tvalData.buflen = tBufLen;
- XQLPPARMS.v.tvalData.data = (BTI_CHAR_PTR) bDataBuf;
-
- callPrimitive ();
-
- *tCount = (BTI_SIZE)XQLPPARMS.v.tvalData.count;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xMask
- ***************************************************************************/
- BTI_API xMask(
- BTI_SINT iOption,
- BTI_SINT iType,
- BTI_SIZE tSize,
- BTI_SINT iDec,
- BTI_SIZE_PTR tLen,
- BTI_CHAR_PTR sMask )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tMaskFcn;
- XQLPPARMS.v.tmaskData.option = iOption;
- XQLPPARMS.v.tmaskData.type = iType;
- XQLPPARMS.v.tmaskData.size = tSize;
- XQLPPARMS.v.tmaskData.dec = iDec;
- XQLPPARMS.v.tmaskData.mlen = *tLen;
- XQLPPARMS.v.tmaskData.mask = (BTI_CHAR_PTR) sMask;
-
- callPrimitive ();
-
- *tLen = XQLPPARMS.v.tmaskData.mlen;
-
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- xStatus
- ***************************************************************************/
- BTI_API xStatus(
- BTI_SINT iCursorID,
- BTI_SINT iOption,
- BTI_SIZE_PTR tLen,
- BTI_CHAR_PTR sStatBuf )
- {
- #ifdef BTI_DOS
- if (!Primitives_Loaded ())
- return (SQL_PRIM_COMPONENT_NOT_LOADED);
- #endif
-
- XQLPPARMS.fcn = tStatFcn;
- XQLPPARMS.cursorid = iCursorID;
- XQLPPARMS.v.tstatData.option = iOption;
- XQLPPARMS.v.tstatData.buflen = *tLen;
- XQLPPARMS.v.tstatData.buf = (BTI_CHAR_PTR) sStatBuf;
-
- callPrimitive ();
-
- *tLen = (BTI_SIZE)XQLPPARMS.v.tstatData.buflen;
- return (XQLPPARMS.stat);
- }
-
- /***************************************************************************
- PLATFORM-DEPENDENT SUPPORT FUNCTIONS
- ***************************************************************************/
- /***************************************************************************
- callsql
- ***************************************************************************/
- #ifdef BTI_DOS
- BTI_API callsql(
- BTI_CHAR_PTR SQLParms )
- {
- segread((struct SREGS *) &sregs);
- regs.dx = FP_OFF (SQLParms);
- sregs.ds = FP_SEG (SQLParms);
-
- int86x(SQL_INT, (union REGS *)®s, (union REGS *)®s,
- (struct SREGS *)&sregs);
-
- return(0);
- }
- #endif
-
- #ifdef BTI_DOS_32R
- BTI_API callsql(
- BTI_CHAR_PTR SQLParms )
- {
- pmswParmBlock pb;
-
- *((BTI_LONG_PTR) &(pb.sign)) = *((BTI_LONG_PTR) PMSW_SIGN);
- pb.flags = 0;
- if (XQLMPARMS.XQL_ID[3] == 'P')
- pb.func = XQLP_CALL;
- else
- pb.func = XQLM_CALL;
- pb.len = sizeof(pb);
- pb.data = SQLParms;
-
- (*_ImportedFunctions_)[PROCESS7B].functionPtr((pmswParmBlock *)SQLParms);
-
- return(0);
- }
- #endif
-
- #ifdef BTI_DOS_32P
- BTI_API callsql(
- BTI_CHAR_PTR SQLParms )
- {
- /*
- ** Phar Lap DOS extender specific code
- */
- SWI_REGS sql_regs;
- FARPTR protectedP;
- BTI_ULONG realPtr;
- BTI_ULONG bufferSize;
- PARMBLOCK *srb;
- BTI_SINT fcn;
- BTI_SINT stat = SS_SUCCESS;
-
- bufferSize = MaxSRBDataSize;
- srb = (PARMBLOCK *) malloc(bufferSize);
- if (!srb)
- stat = SQL_NO_HEAP_MEM_P;
- else
- {
- stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
- startOfRealPtr = realPtr;
-
- if (stat == SS_SUCCESS)
- {
- stat = SRBFormat((PARMBLOCK *) SQLParms, srb, &fcn);
-
- if (stat == SS_SUCCESS)
- {
- copyToLow(
- FP_SEL(protectedP), /* Selector to real-mode buffer */
- FP_OFF(protectedP), /* offset of real-mode buffer */
- srb, /* send/receive buffer */
- bufferSize); /* size of srb */
-
- /*
- ** Initialize registers for real-mode interrupt call.
- */
- memset(&sql_regs, 0, sizeof(sql_regs));
- sql_regs.ds = RP_SEG(realPtr);
- sql_regs.edx = RP_OFF(realPtr);
-
- /*
- ** The _dx_real_int routine issues the 7b interrupt in real mode
- */
- _dx_real_int(SQL_INT, &sql_regs);
-
- copyFromLow(
- srb,
- FP_SEL(protectedP),
- FP_OFF(protectedP),
- bufferSize);
-
- SRBUnformat((PARMBLOCK *) SQLParms, srb, fcn);
- }
- freeRealModeBuffer(FP_SEL(protectedP));
- }
- free(srb);
- }
- if (stat != SS_SUCCESS)
- ((PARMBLOCK *) SQLParms)->stat = stat;
- return(((PARMBLOCK *)SQLParms)->stat);
- }
- #endif
-
- #ifdef BTI_DOS_32B
- BTI_API callsql(
- BTI_CHAR_PTR SQLParms )
- {
- /*
- ** Call SSQL using Borland Power Pack DOS Extender
- */
- union REGS sql_regs;
- FARPTR protectedP;
- BTI_ULONG realPtr;
- BTI_ULONG bufferSize;
- PARMBLOCK *srb;
- BTI_SINT fcn;
- BTI_SINT stat = SS_SUCCESS;
- struct REALMODEREGS
- {
- BTI_ULONG edi;
- BTI_ULONG esi;
- BTI_ULONG ebp;
- BTI_ULONG reserved;
- BTI_ULONG ebx;
- BTI_ULONG edx;
- BTI_ULONG ecx;
- BTI_ULONG eax;
- BTI_WORD CPUflag;
- BTI_WORD es;
- BTI_WORD ds;
- BTI_WORD fs;
- BTI_WORD gs;
- BTI_WORD ip;
- BTI_WORD cs;
- BTI_WORD sp;
- BTI_WORD ss;
- } realmodeRegs;
-
- bufferSize = MaxSRBDataSize;
- srb = (PARMBLOCK *) malloc(bufferSize);
- if (!srb)
- stat = SQL_NO_HEAP_MEM_P;
- else
- {
- stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
- startOfRealPtr = realPtr;
-
- if (stat == SS_SUCCESS)
- {
- stat = SRBFormat((PARMBLOCK *) SQLParms, srb, &fcn);
-
- if (stat == SS_SUCCESS)
- {
- copyToLow(
- FP_SEL(protectedP),
- FP_OFF(protectedP),
- srb,
- bufferSize);
-
- /*
- ** Initialize registers for real-mode interrupt
- */
- sql_regs.x.eax = 0x300;
- sql_regs.h.bl = SQL_INT;
- sql_regs.h.bh = 0;
-
- /*
- ** CX = Number of words to copy from protected-mode to
- ** real-mode stack
- */
- sql_regs.x.ecx = 0;
-
- /*
- ** Initialize real mode segment registers for call to SSQL
- */
- memset(&realmodeRegs, 0, sizeof(struct REALMODEREGS));
-
- /*
- ** DS Register contains the segment address of parameter block
- */
- realmodeRegs.ds = (BTI_WORD) (realPtr >> 16);
-
- /*
- ** EDX Register contains offset of parameter block
- */
- realmodeRegs.edx = (realPtr << 16);
- sql_regs.x.edi = (BTI_ULONG) &realmodeRegs;
-
- int386(0x31, &sql_regs, &sql_regs);
-
- copyFromLow(
- srb,
- FP_SEL(protectedP),
- FP_OFF(protectedP),
- bufferSize);
-
- SRBUnformat((PARMBLOCK *) SQLParms, srb, fcn);
- }
- freeRealModeBuffer(FP_SEL(protectedP)); /* Free real-mode mem */
- }
- free(srb); /* Free temporary send/request buffer */
- }
- if (stat)
- ((PARMBLOCK *) SQLParms)->stat = stat;
- return(((PARMBLOCK *) SQLParms)->stat);
- }
- #endif
-
- #ifdef BTI_DOS_16B
- BTI_API callsql(
- BTI_CHAR_PTR SQLParms )
- {
- /*
- ** Call SSQL using Borland Power Pack DOS Extender
- */
- union REGS sql_regs;
- FARPTR protectedP;
- BTI_ULONG realPtr;
- BTI_ULONG bufferSize;
- PARMBLOCK *srb;
- BTI_SINT fcn;
- BTI_SINT stat = SS_SUCCESS;
- struct REALMODEREGS
- {
- BTI_ULONG edi;
- BTI_ULONG esi;
- BTI_ULONG ebp;
- BTI_ULONG reserved;
- BTI_ULONG ebx;
- BTI_ULONG edx;
- BTI_ULONG ecx;
- BTI_ULONG eax;
- BTI_WORD CPUflag;
- BTI_WORD es;
- BTI_WORD ds;
- BTI_WORD fs;
- BTI_WORD gs;
- BTI_WORD ip;
- BTI_WORD cs;
- BTI_WORD sp;
- BTI_WORD ss;
- } realmodeRegs, *realmodeRegsP = &realmodeRegs;
-
- bufferSize = MaxSRBDataSize;
- srb = (PARMBLOCK *)malloc(bufferSize);
-
- if (!srb)
- stat = SQL_NO_HEAP_MEM_P;
- else
- {
- stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
-
- startOfRealPtr = realPtr;
-
- if (stat == SS_SUCCESS)
- {
- stat = SRBFormat((PARMBLOCK *)SQLParms, srb, &fcn);
-
- if (stat == SS_SUCCESS)
- {
- _fmemcpy((BTI_VOID_PTR)protectedP, (BTI_VOID_PTR)srb, bufferSize);
-
- /* Initialize registers for real-mode interrupt */
- sql_regs.x.ax = 0x300;
- sql_regs.h.bl = SQL_INT;
- sql_regs.h.bh = 0;
- sql_regs.x.cx = 0;
- sql_regs.x.di = FP_OFF(realmodeRegsP);
- segread((struct SREGS *)&sregs);
- sregs.es = FP_SEG(realmodeRegsP);
- memset(&realmodeRegs, 0, sizeof(struct REALMODEREGS));
- realmodeRegs.ds = FP_SEG((BTI_WORD_PTR)realPtr);
- realmodeRegs.edx = FP_OFF((BTI_WORD_PTR)realPtr);
-
- int86x(0x31, (union REGS *)&sql_regs, (union REGS *)&sql_regs,
- (struct SREGS *)&sregs);
-
- _fmemcpy((BTI_VOID_PTR)srb, (BTI_VOID_PTR)protectedP, bufferSize);
-
- SRBUnformat((PARMBLOCK *)SQLParms, srb, fcn);
- }
- freeRealModeBuffer(FP_SEG(protectedP)); /* Free real-mode mem */
- }
- free(srb); /* Free temporary send/request buffer */
- }
- if (stat)
- ((PARMBLOCK *)SQLParms)->stat = stat;
- return(((PARMBLOCK *)SQLParms)->stat);
- }
- #endif
-
- /***************************************************************************
- callPrimitive
- ***************************************************************************/
- #if defined(BTI_DOS) || defined(BTI_DOS_32R) ||\
- defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- BTI_API callPrimitive(
- void )
- {
- /*
- ** Initialize signature for Relational Primitive call
- */
- *((BTI_LONG_PTR) &(XQLPPARMS.XQL_ID)) = XQLP_SIG;
- XQLPPARMS.sessionid = SQL_SessionID; /* Initialize the Session ID */
-
- callsql((BTI_CHAR_PTR) &XQLPPARMS);
-
- return(0);
- }
- #endif
-
- /***************************************************************************
- callSQLFunction
- ***************************************************************************/
- #if defined(BTI_DOS) || defined(BTI_DOS_32R) || \
- defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- BTI_API callSQLFunction(
- void )
- {
- /*
- ** Initialize signature for SQL-level function call
- */
- *((BTI_LONG_PTR) &(XQLMPARMS.XQL_ID)) = XQLM_SIG;
- XQLMPARMS.sessionid = SQL_SessionID; /* Initialize the Session ID */
-
- callsql((BTI_CHAR_PTR)&XQLMPARMS);
-
- return(0);
- }
- #endif
-
- /***************************************************************************
- sql_loaded
- ***************************************************************************/
- #ifdef BTI_DOS
- BTI_API sql_loaded(
- void )
- {
- BTI_SINT btrstat;
-
- SQLCODE = SQL_COMPONENT_NOT_LOADED;
- XQLMPARMS.stat = XQLMPARMS.fcn = -1;
-
- segread((struct SREGS *) &sregs);
- regs.ax = 0x3500 + SQL_INT;
-
- int86x(0x21, (union REGS *)®s, (union REGS *)®s,
- (struct SREGS *)&sregs);
-
- if (regs.bx == SQL_OFFSET)
- {
- XQLMPARMS.v.bxData.btrop = -1;
- XQLMPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
-
- callSQLFunction ();
-
- if (XQLMPARMS.stat == SQL_INVALID_FUNCTIONCODE)
- SQLCODE = 0;
- }
- return (SQLCODE == 0);
- }
- #endif
-
- #ifdef BTI_DOS_32P
- BTI_API sql_loaded(
- void )
- {
- BTI_SINT btrstat;
- BTI_ULONG sqlAddress;
-
- SQLCODE = SQL_COMPONENT_NOT_LOADED;
- XQLMPARMS.stat = XQLMPARMS.fcn = -1;
- /*
- ** The _dx_rmiv_get routine returns the real-mode interrupt
- ** vector for interupt 7b
- */
- _dx_rmiv_get(SQL_INT, &sqlAddress);
-
- if (((BTI_WORD) (sqlAddress & 0xFFFF)) == SQL_OFFSET)
- {
- XQLMPARMS.v.bxData.btrop = -1;
- XQLMPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
-
- callSQLFunction ();
-
- if (XQLMPARMS.stat == SQL_INVALID_FUNCTIONCODE)
- SQLCODE = 0;
- }
- return (SQLCODE == 0);
- }
- #endif
-
- #if defined(BTI_DOS_32B)
- BTI_API sql_loaded(
- void )
- {
- BTI_SINT stat;
- union REGS inRegs, outRegs;
- BTI_SINT btrstat;
-
- SQLCODE = SQL_COMPONENT_NOT_LOADED;
- XQLMPARMS.stat = XQLMPARMS.fcn = -1;
-
- inRegs.x.eax = 0x200;
- inRegs.x.ebx = SQL_INT;
-
- int386(0x31, &inRegs, &outRegs);
-
- if (((BTI_WORD) (outRegs.x.edx & 0xFFFF)) == SQL_OFFSET)
- {
- XQLMPARMS.v.bxData.btrop = -1;
- XQLMPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
-
- callSQLFunction ();
-
- if (XQLMPARMS.stat == SQL_INVALID_FUNCTIONCODE)
- SQLCODE = 0;
- }
- return (SQLCODE == 0);
- }
- #endif
-
- #if defined(BTI_DOS_16B)
- BTI_API sql_loaded(
- void )
- {
- BTI_SINT stat;
- union REGS inRegs, outRegs;
- BTI_SINT btrstat;
-
- SQLCODE = SQL_COMPONENT_NOT_LOADED;
- XQLMPARMS.stat = XQLMPARMS.fcn = -1;
-
- inRegs.x.ax = 0x200;
- inRegs.x.bx = SQL_INT;
-
- int86(0x31, &inRegs, &outRegs);
-
- if (outRegs.x.dx == SQL_OFFSET)
- {
- XQLMPARMS.v.bxData.btrop = -1;
- XQLMPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
-
- callSQLFunction();
-
- if (XQLMPARMS.stat == SQL_INVALID_FUNCTIONCODE)
- SQLCODE = 0;
- }
- return(SQLCODE == 0);
- }
- #endif
-
- /***************************************************************************
- Primitives_Loaded
- ***************************************************************************/
- #ifdef BTI_DOS
- BTI_API Primitives_Loaded(
- void )
- {
- BTI_INT stat = 0;
- BTI_INT btrstat;
-
- XQLPPARMS.stat = XQLPPARMS.fcn = -1;
-
- segread((struct SREGS *)&sregs);
- regs.ax = 0x3500 + SQL_INT;
-
- int86x(0x21, (union REGS *)®s, (union REGS *)®s,
- (struct SREGS *)&sregs);
-
- if (regs.bx == SQL_OFFSET)
- {
- XQLPPARMS.v.bxData.btrop = -1;
- XQLPPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat == SQL_INVALID_PRIMITIVE_FUNCTION ||
- XQLPPARMS.stat == SQL_INVALID_FUNCTIONCODE)
- stat = 1;
- }
- return (stat);
- }
- #endif
-
- #if defined(BTI_DOS_32P)
- BTI_API Primitives_Loaded(
- void )
- {
- BTI_INT stat = 0;
- BTI_INT btrstat;
- BTI_ULONG sqlAddress;
-
- XQLPPARMS.stat = XQLPPARMS.fcn = -1;
-
- /*
- ** The _dx_rmiv_get routine returns the real-mode interrupt
- ** vector for interupt 7b
- */
- _dx_rmiv_get(SQL_INT, &sqlAddress);
-
- if (((BTI_WORD) (sqlAddress & 0xFFFF)) == SQL_OFFSET)
- {
- XQLPPARMS.v.bxData.btrop = -1;
- XQLPPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
-
- callPrimitive ();
- if (XQLPPARMS.stat == SQL_INVALID_PRIMITIVE_FUNCTION ||
- XQLPPARMS.stat == SQL_INVALID_FUNCTIONCODE)
- stat = 1;
- }
- return (stat);
- }
- #endif
-
- #if defined(BTI_DOS_32B)
- BTI_API Primitives_Loaded(
- void )
- {
- BTI_INT stat = SS_SUCCESS;
- BTI_INT btrstat;
- union REGS inRegs, outRegs;
-
- XQLPPARMS.stat = XQLPPARMS.fcn = -1;
-
- inRegs.x.eax = 0x200;
- inRegs.x.ebx = SQL_INT;
-
- int386(0x31, &inRegs, &outRegs);
-
- if (((BTI_WORD) (outRegs.x.edx & 0xFFFF)) == SQL_OFFSET)
- {
- XQLPPARMS.v.bxData.btrop = -1;
- XQLPPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
-
- callPrimitive ();
-
- if (XQLPPARMS.stat == SQL_INVALID_PRIMITIVE_FUNCTION ||
- XQLPPARMS.stat == SQL_INVALID_FUNCTIONCODE)
- stat = 1;
- }
- return (stat);
- }
- #endif
-
- #if defined(BTI_DOS_16B)
- BTI_API Primitives_Loaded(
- void )
- {
- BTI_INT stat = SS_SUCCESS;
- BTI_INT btrstat;
- union REGS inRegs, outRegs;
-
- XQLPPARMS.stat = XQLPPARMS.fcn = -1;
-
- inRegs.x.ax = 0x200;
- inRegs.x.bx = SQL_INT;
-
- int86(0x31, &inRegs, &outRegs);
-
- if (outRegs.x.dx == SQL_OFFSET)
- {
- XQLPPARMS.v.bxData.btrop = -1;
- XQLPPARMS.v.bxData.btrstat = (BTI_CHAR_PTR) &btrstat;
-
- callPrimitive();
-
- if (XQLPPARMS.stat == SQL_INVALID_PRIMITIVE_FUNCTION ||
- XQLPPARMS.stat == SQL_INVALID_FUNCTIONCODE)
- stat = 1;
- }
- return(stat);
- }
- #endif
-
- /***************************************************************************
- CallPMSW (real mode)
- ***************************************************************************/
- #if defined(BTI_DOS)
- BTI_API CallPMSW(
- pmswParmBlock *pb )
- {
- BTI_SINT stat = 0;
- union REGS regs;
- struct SREGS sregs;
-
- segread(&sregs);
-
- /*
- ** Check to see if PMSwitch is loaded.
- */
- regs.x.ax = 0x3500 + SQL_INT;
- int86x(0x21, ®s, ®s, &sregs);
- if (regs.x.bx != SQL_OFFSET)
- stat = SQL_COMPONENT_NOT_LOADED;
-
- if (stat == 0)
- {
- /*
- ** Make the call to PMSwitch.
- */
- /* parameter block is expected to be in DX */
- regs.x.dx = FP_OFF(pb);
- sregs.ds = FP_SEG(pb);
-
- int86x(SQL_INT, ®s, ®s, &sregs);
- } /* end if */
-
- return(stat);
- }
- #endif
-
- /***************************************************************************
- CallPMSW (protected mode with Rational & SSQLSTUB.EXE)
- ***************************************************************************/
- #if defined(BTI_DOS_32R)
- BTI_API CallPMSW(
- pmswParmBlock *pb )
- {
-
- (*_ImportedFunctions_)[ PROCESS7B ].functionPtr(pb);
- return 0;
- }
- #endif
-
- /***************************************************************************
- CallPMSW (Phar Lap DOS Extender)
- ***************************************************************************/
- #if defined(BTI_DOS_32P)
- BTI_API CallPMSW(
- pmswParmBlock *pb )
- {
- BTI_SINT stat = 0;
- BTI_ULONG sqlAddress;
- SWI_REGS sql_regs;
- FARPTR protectedP;
- BTI_ULONG realPtr;
- BTI_ULONG bufferSize;
- BTI_CHAR_PTR srb;
- BTI_SINT fcn;
-
- /*
- ** The _dx_rmiv_get routine returns the real-mode interrupt
- ** vector for interupt 7b
- */
- _dx_rmiv_get(SQL_INT, &sqlAddress);
-
- /*
- ** Check to see if PMSwitch is loaded.
- */
- if (((BTI_WORD) (sqlAddress & 0xFFFF)) != SQL_OFFSET)
- stat = SQL_COMPONENT_NOT_LOADED;
- else
- {
- /*
- ** Make the call to PMSwitch.
- */
-
- bufferSize = MaxSRBDataSize;
- srb = (BTI_CHAR_PTR) malloc(bufferSize);
- if (!srb)
- {
- stat = SQL_NO_HEAP_MEM_P;
- }
- else
- {
- stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
- startOfRealPtr = realPtr + sizeof(pmswParmBlock);
-
- if (stat == SS_SUCCESS)
- {
- /* Copy the pmswParmBlock structure to the srb buffer */
- memcpy(
- srb,
- pb,
- sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
-
-
- /*
- ** Save real-mode pointer to the parameter block in the data
- ** pointer of the pmswParmBlock structure. Must save a real-
- ** mode address here because the entire srb buffer will be
- ** passed to the real-mode interrupt 7B handler.
- */
- *((BTI_ULONG *) &((pmswParmBlock *) srb)->data) = realPtr +
- sizeof(pmswParmBlock);
-
- /*
- ** Call SRBFormat() to initialize the SSQL parameter block
- ** structure.
- */
- stat = SRBFormat(
- (PARMBLOCK *) pb->data,
- (PARMBLOCK *) &srb[sizeof(pmswParmBlock)],
- &fcn);
-
-
- if (stat == SS_SUCCESS)
- {
- copyToLow( /* Copy data to DOS real memory location */
- FP_SEL(protectedP),
- FP_OFF(protectedP),
- srb,
- bufferSize);
-
- memset(&sql_regs, 0, sizeof(sql_regs));
- sql_regs.ds = RP_SEG(realPtr);
- sql_regs.edx = RP_OFF(realPtr);
-
- /*
- ** The _dx_real_int routine issues the 7b interrupt in real
- ** mode
- */
- _dx_real_int(SQL_INT, &sql_regs);
-
- /* Copy data from DOS real memory back to protected mode */
- copyFromLow(
- srb,
- FP_SEL(protectedP),
- FP_OFF(protectedP),
- bufferSize);
-
- SRBUnformat(
- (PARMBLOCK *) pb->data,
- (PARMBLOCK *) &srb[sizeof(pmswParmBlock)],
- fcn);
-
- memcpy(
- pb,
- srb,
- sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
- }
- freeRealModeBuffer(FP_SEL(protectedP));
- }
- free(srb);
- }
- } /* end if */
-
- return(stat);
- }
- #endif
-
- /***************************************************************************
- CallPMSW (Borland Power Pack DOS Extender)
- ***************************************************************************/
- #if defined(BTI_DOS_32B)
- BTI_API CallPMSW(
- pmswParmBlock *pb )
- {
- union REGS inRegs, outRegs;
- BTI_SINT stat = SS_SUCCESS;
- union REGS sql_regs;
- FARPTR protectedP;
- BTI_ULONG realPtr;
- BTI_ULONG bufferSize;
- BTI_CHAR_PTR srb;
- BTI_SINT fcn;
- struct REALMODEREGS
- {
- BTI_ULONG edi;
- BTI_ULONG esi;
- BTI_ULONG ebp;
- BTI_ULONG reserved;
- BTI_ULONG ebx;
- BTI_ULONG edx;
- BTI_ULONG ecx;
- BTI_ULONG eax;
- BTI_WORD CPUflag;
- BTI_WORD es;
- BTI_WORD ds;
- BTI_WORD fs;
- BTI_WORD gs;
- BTI_WORD ip;
- BTI_WORD cs;
- BTI_WORD sp;
- BTI_WORD ss;
- } realmodeRegs;
-
- inRegs.x.eax = 0x200;
- inRegs.x.ebx = SQL_INT;
-
- int386(0x31, &inRegs, &outRegs);
-
- if ((BTI_WORD) (outRegs.x.edx & 0xFFFF) != SQL_OFFSET)
- stat = SQL_COMPONENT_NOT_LOADED;
- else
- {
- bufferSize = MaxSRBDataSize;
- srb = malloc(bufferSize);
- if (!srb)
- stat = SQL_NO_HEAP_MEM_P;
- else
- {
- stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
- startOfRealPtr = realPtr + sizeof(pmswParmBlock);
-
- if (stat == SS_SUCCESS)
- {
- /* Copy the pmswParmBlock structure to the srb buffer */
- memcpy(
- srb,
- pb,
- sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
-
- /*
- ** Save real-mode pointer to the parameter block in the data
- ** pointer of the pmswParmBlock structure. Must save a real-
- ** mode address here because the entire srb buffer will be
- ** passed to the real-mode interrupt 7B handler.
- */
- *((BTI_ULONG *) &((pmswParmBlock *) srb)->data) = realPtr +
- sizeof(pmswParmBlock);
- /*
- ** Call SRBFormat() to initialize the SSQL parameter block
- ** structure.
- */
- stat = SRBFormat(
- (PARMBLOCK *) pb->data,
- (PARMBLOCK *) &srb[sizeof(pmswParmBlock)],
- &fcn);
-
- if (stat == SS_SUCCESS)
- {
- copyToLow( /* Copy data to DOS real memory location */
- FP_SEL(protectedP),
- FP_OFF(protectedP),
- srb,
- bufferSize); /* bufferSize ??? */
-
- sql_regs.x.eax = 0x300;
- sql_regs.h.bl = SQL_INT;
- sql_regs.h.bh = 0;
- /*
- ** CX = Number of words to copy from protected-mode to
- ** real-mode stack
- */
- sql_regs.x.ecx = 0;
-
- /*
- ** Initialize real mode segment registers for call to SSQL
- */
- memset(&realmodeRegs, 0, sizeof(struct REALMODEREGS));
-
- /*
- ** DS Register contains the segment address of parameter block
- */
- realmodeRegs.ds = (BTI_WORD) (realPtr >> 16);
-
- /*
- ** EDX Register contains offset of parameter block
- */
- realmodeRegs.edx = (realPtr << 16);
- sql_regs.x.edi = (BTI_ULONG) &realmodeRegs;
-
- int386(0x31, &sql_regs, &sql_regs); /* real-mode int 7b */
-
- copyFromLow( /* Copy data back to protected mode buffer */
- srb,
- FP_SEL(protectedP),
- FP_OFF(protectedP),
- bufferSize);
-
- SRBUnformat(
- (PARMBLOCK *) pb->data,
- (PARMBLOCK *) &srb[sizeof(pmswParmBlock)],
- fcn);
-
- memcpy(
- pb,
- srb,
- sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
- }
- freeRealModeBuffer(FP_SEL(protectedP));
- }
- free(srb);
- }
- }
- return(stat);
- }
- #endif
-
- #if defined(BTI_DOS_16B)
- BTI_API CallPMSW(
- pmswParmBlock *pb )
- {
- union REGS inRegs, outRegs;
- BTI_SINT stat = SS_SUCCESS;
- union REGS sql_regs;
- FARPTR protectedP;
- BTI_ULONG realPtr;
- BTI_ULONG bufferSize;
- BTI_CHAR_PTR srb;
- BTI_SINT fcn;
- struct REALMODEREGS
- {
- BTI_ULONG edi;
- BTI_ULONG esi;
- BTI_ULONG ebp;
- BTI_ULONG reserved;
- BTI_ULONG ebx;
- BTI_ULONG edx;
- BTI_ULONG ecx;
- BTI_ULONG eax;
- BTI_WORD CPUflag;
- BTI_WORD es;
- BTI_WORD ds;
- BTI_WORD fs;
- BTI_WORD gs;
- BTI_WORD ip;
- BTI_WORD cs;
- BTI_WORD sp;
- BTI_WORD ss;
- } realmodeRegs, *realmodeRegsP = &realmodeRegs;
-
- inRegs.x.ax = 0x200;
- inRegs.x.bx = SQL_INT;
-
- int86(0x31, &inRegs, &outRegs);
-
- if (outRegs.x.dx != SQL_OFFSET)
- stat = SQL_COMPONENT_NOT_LOADED;
- else
- {
- bufferSize = MaxSRBDataSize;
- srb = malloc(bufferSize);
-
- if (!srb)
- stat = SQL_NO_HEAP_MEM_P;
- else
- {
- stat = getRealModeBuffer(&protectedP, &realPtr, bufferSize);
-
- startOfRealPtr = realPtr + sizeof(pmswParmBlock);
-
- if (stat == SS_SUCCESS)
- {
- /* Copy the pmswParmBlock structure to the srb buffer */
- memcpy(srb, pb, sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
-
- /*
- ** Save real-mode pointer to the parameter block in the data
- ** pointer of the pmswParmBlock structure. Must save a real-
- ** mode address here because the entire srb buffer will be
- ** passed to the real-mode interrupt 7B handler.
- */
- *((BTI_ULONG *)&((pmswParmBlock *)srb)->data) = realPtr +
- sizeof(pmswParmBlock);
-
- /* Initialize the SSQL parameter block structure */
- stat = SRBFormat((PARMBLOCK *)pb->data,
- (PARMBLOCK *)&srb[sizeof(pmswParmBlock)], &fcn);
-
- if (stat == SS_SUCCESS)
- {
- /* Copy data to DOS real memory location */
- _fmemcpy((BTI_VOID_PTR)protectedP, (BTI_VOID_PTR)srb,
- bufferSize);
-
- sql_regs.x.ax = 0x300;
- sql_regs.h.bl = SQL_INT;
- sql_regs.h.bh = 0;
- sql_regs.x.cx = 0;
- sql_regs.x.di = FP_OFF(realmodeRegsP);
- segread((struct SREGS *)&sregs);
- sregs.es = FP_SEG(realmodeRegsP);
- memset(&realmodeRegs, 0, sizeof(struct REALMODEREGS));
- realmodeRegs.ds = FP_SEG((BTI_WORD_PTR)realPtr);
- realmodeRegs.edx = FP_OFF((BTI_WORD_PTR)realPtr);
-
- int86x(0x31, (union REGS *)&sql_regs, (union REGS *)&sql_regs,
- (struct SREGS *)&sregs);
-
- /* Copy data back to protected mode buffer */
- _fmemcpy((BTI_VOID_PTR)srb, (BTI_VOID_PTR)protectedP,
- bufferSize);
-
- SRBUnformat((PARMBLOCK *)pb->data,
- (PARMBLOCK *)&srb[sizeof(pmswParmBlock)], fcn);
-
- memcpy(pb, srb, sizeof(pmswParmBlock) - sizeof(BTI_VOID_PTR));
- }
- freeRealModeBuffer(FP_SEG(protectedP));
- }
- free(srb);
- }
- }
- return(stat);
- }
- #endif
-
- /***************************************************************************
- callxqlm
- ***************************************************************************/
- #ifdef BTI_NLM
- BTI_SINT callxqlm(
- void )
- {
- BTI_SINT stat;
-
- *((BTI_LONG_PTR) &(XQLMPARMS.XQL_ID)) = XQLM_SIG;
- XQLMPARMS.sessionid = SQL_SessionID;
- XQLMPARMS.stat = NSAgentID;
-
- stat = XQLEntry(&XQLMPARMS);
-
- if (stat)
- XQLMPARMS.stat = stat;
- return 0;
- }
- #endif
-
- /***************************************************************************
- callxqlp
- ***************************************************************************/
- #ifdef BTI_NLM
- BTI_VOID callxqlp(
- void )
- {
- BTI_SINT stat;
-
- *((BTI_LONG_PTR) &(XQLPPARMS.XQL_ID)) = XQLP_SIG;
- XQLPPARMS.sessionid = SQL_SessionID;
- XQLPPARMS.stat = NSAgentID;
-
- stat = XQLEntry(&XQLPPARMS);
-
- if (stat)
- XQLPPARMS.stat = stat;
- }
- #endif
-
- /***************************************************************************
- getRealModeBuffer
- ***************************************************************************/
- #if defined(BTI_DOS_32P)
- BTI_SINT getRealModeBuffer(
- FARPTR *protectedP,
- BTI_ULONG *realAddr,
- BTI_ULONG requestedSize )
- {
- BTI_SINT stat; /* Return status code */
- BTI_ULONG bufferSize;
-
- /*
- ** Get Information about the DOS Data Buffer
- **
- ** The _dx_dos_buf_get function returns real and protected-mode pointers
- ** to the buffer used to buffer data on MS-DOS and BIOS system calls. The
- ** size of the buffer is returned in the size parameter. Note: need to
- ** make this call each time because address of the MS_DOS buffer changes
- ** when anyone calls Load for Debug(_dx_dbg_ld) or the Set DOS Data Buffer
- ** Size(_dx_dosbuf_set).
- */
- _dx_dosbuf_get((FARPTR *) protectedP, realAddr, &bufferSize);
-
- if (bufferSize < requestedSize)
- stat = SQL_BUFFER_TOO_SHORT;
- else
- stat = SS_SUCCESS;
-
- return stat;
- }
- #endif
-
- #if defined(BTI_DOS_32B)
- BTI_SINT getRealModeBuffer(
- FARPTR *protectedP,
- BTI_ULONG *realAddr,
- BTI_ULONG requestedSize )
- {
- BTI_SINT allocStatus;
- union REGS inRegs, outRegs;
-
- /*
- ** Allocate DOS Memory
- ** Interrupt 31h, function 100h
- ** Note: The DPMI server must support version 0.9 or later of the DPMI
- ** specification to support this this function. An error code
- ** will be returned in the AX register and returned to caller
- ** as B_DATALENGTH_ERROR.
- **
- ** AX = 100h
- ** BX = Number of 16-byte paragraphs to allocate
- **
- ** Returns:
- **
- ** if carry flag is clear
- ** AX = real mode segment base address of allocated block
- ** DX = selector for allocated block
- **
- ** if carry flag is set
- ** AX = error code
- **
- */
- inRegs.x.eax = 0x100;
- inRegs.x.ebx = (requestedSize + 15) / 16; /* Number of paragraphs */
-
- int386(0x31, &inRegs, &outRegs);
-
- if (outRegs.x.cflag)
- allocStatus = SQL_BUFFER_TOO_SHORT;
- else
- {
- *realAddr = (outRegs.x.eax << 16) & 0xFFFF0000;
- FP_SET(*protectedP, 0, (BTI_WORD) outRegs.x.edx);
- allocStatus = SS_SUCCESS;
- }
-
- return allocStatus;
- }
- #endif
-
- #if defined(BTI_DOS_16B)
- BTI_SINT getRealModeBuffer(
- FARPTR *protectedP,
- BTI_ULONG *realAddr,
- BTI_ULONG requestedSize )
- {
- BTI_SINT allocStatus;
- union REGS inRegs, outRegs;
-
- /*
- ** Allocate DOS Memory
- ** Interrupt 31h, function 100h
- ** Note: The DPMI server must support version 0.9 or later of the DPMI
- ** specification to support this this function. An error code
- ** will be returned in the AX register and returned to caller
- ** as B_DATALENGTH_ERROR.
- **
- ** AX = 100h
- ** BX = Number of 16-byte paragraphs to allocate
- **
- ** Returns:
- **
- ** if carry flag is clear
- ** AX = real mode segment base address of allocated block
- ** DX = selector for allocated block
- **
- ** if carry flag is set
- ** AX = error code
- **
- */
- inRegs.x.ax = 0x100; /* allocate DOS memory block */
- inRegs.x.bx = (requestedSize + 15) / 16; /* Number of paragraphs */
-
- int86(0x31, &inRegs, &outRegs);
-
- if (outRegs.x.cflag)
- allocStatus = SQL_BUFFER_TOO_SHORT;
- else
- {
- *realAddr = MK_FP(outRegs.x.ax, 0);
- *protectedP = MK_FP(outRegs.x.dx, 0);
- allocStatus = SS_SUCCESS;
- }
-
- return(allocStatus);
- }
- #endif
-
- /***************************************************************************
- freeRealModeBuffer
- ***************************************************************************/
- #if defined(BTI_DOS_32P)
- static BTI_VOID freeRealModeBuffer(
- BTI_WORD sel )
- {
- /*
- ** Phar Lap specific code
- */
-
- /* Nothing to do! */
- }
- #endif
-
- #if defined(BTI_DOS_32B)
- static BTI_VOID freeRealModeBuffer(
- BTI_WORD sel )
- {
- union REGS inRegs, outRegs;
-
- inRegs.x.edx = sel; /* Selector to be freed */
- inRegs.x.eax = 0x101;
-
- int386(0x31, &inRegs, &outRegs); /* free selector */
- }
- #endif
-
- #if defined(BTI_DOS_16B)
- static BTI_VOID freeRealModeBuffer(
- BTI_WORD sel )
- {
- union REGS inRegs, outRegs;
-
- inRegs.x.dx = sel; /* Selector to be freed */
- inRegs.x.ax = 0x101;
-
- int86(0x31, &inRegs, &outRegs);
- }
- #endif
-
- /*
- *****************************************************************************
- ** SRBFormat
- **
- ** Prototype:
- **
- ** BTI_SINT SRBFormat(PARMBLOCK *from, PARMBLOCK *srb, BTI_SINT *fcn)
- **
- **
- ** Description:
- **
- ** SRBFormat() formats a parameter block (PARMBLOCK structure) into
- ** a buffer for transmittal to the Scalable SQL engine.
- **
- ** Preconditions:
- **
- ** None.
- **
- ** Parameters:
- **
- ** *from: Input parameter block.
- ** <input>
- **
- ** *srb: Formatted output parameter block
- ** <output>
- **
- ** *fcn: Returns the sequenced function number that SRBUnformat
- ** <output> can use to plug back into the PARMBLOCK when calling
- ** unfixparms().
- **
- ** Return value:
- **
- ** None.
- **
- ** Globals:
- **
- ** None.
- **
- ** Called Functions:
- **
- ** fixParms()
- **
- ** Comments:
- **
- ** None.
- **
- *****************************************************************************
- */
- #if defined(BTI_DOS_32P) || defined(BTI_DOS_32B) || defined(BTI_DOS_16B)
- BTI_SINT SRBFormat(
- PARMBLOCK *from,
- PARMBLOCK *srb,
- BTI_SINT *fcn )
- {
- BTI_SINT stat = SS_SUCCESS;
- PARMBLOCK *to;
-
- to = srb;
-
- stat = fixParms(from, to);
-
- /* grab sequenced function so SRBUnformat can reset it */
- *fcn = to->fcn;
- /* restore unsequenced function since the engine does this itself */
- to->fcn = from->fcn;
-
- return(stat);
- }
- #endif
-
- /*
- *****************************************************************************
- ** SRBUnformat
- **
- ** Description:
- ** SRBUnformat() takes a send/request buffer, extracts the parameter
- ** block and reformats it for use locally.
- **
- ** Parameters:
- ** *to: Contains reformatted parameter block on output.
- ** <output>
- **
- ** *srb: Contains the return buffer from SSQL.
- ** <input>
- **
- ** fcn: Contains the sequenced function code from SRBFormat()
- ** <input>
- **
- ** Return value:
- ** None.
- *****************************************************************************
- */
- #if defined(BTI_DOS_32B) || defined(BTI_DOS_32P) || defined(BTI_DOS_16B)
- BTI_SINT SRBUnformat(
- PARMBLOCK *to,
- PARMBLOCK *srb,
- BTI_SINT fcn )
- {
- PARMBLOCK *from;
- BTI_SINT stat;
-
- from = srb;
- from->fcn = fcn; /* sequenced function from SRBFormat */
-
- stat = unfixParms(from, to);
-
- return(stat);
- }
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-