home *** CD-ROM | disk | FTP | other *** search
- /* */
- /* WatCom C interface to the Btrieve Record Manager */
- /* */
-
-
- typedef unsigned short int INT;
- #define SINT short
- #define BTR_ERR 20 /* record manager not started */
- #define BTR_INT 0x7B /* Btrieve interrupt vector */
- #define BTR_OFFSET 0x33 /* Btrieve offset within segment */
- #define VARIABLE_ID 0x6176 /* id for variable length records - 'va' */
-
-
- SINT BTRV (SINT operation,
- char *posBlock,
- char *dataBuf,
- INT *dataLen,
- char *keyBuf,
- SINT keyNum
- )
-
- {
- struct REGVAL { SINT AX, BX, CX, DX, SI, DI, CY; } regs;
-
- struct SEGREG { SINT ES, CS, SS, DS; } sregs;
-
- struct BTRIEVE_PARMS /* structure passed to Btrieve Record Manager */
- {
- char far *bufAddress; /* callers data buffer Address */
- INT bufLength; /* length of data buffer */
- char far *curAddress; /* user position block Address */
- char far *fcbAddress; /* Address of disk FCB */
- INT function; /* requested function */
- char far *keyAddress; /* Address of user's key buffer */
- char keyLength; /* length of user's key buffer */
- char keyNumber; /* key of reference for request */
- INT far *statAddress; /* Address of status word */
- INT xfaceID; /* language identifier */
- } xData;
-
- INT stat = 0; /* status of Btrieve call */
-
- /* */
- /* Check to see that the Btrieve Record Manager has been started. */
- /* */
-
- regs.AX = 0x3500 + BTR_INT;
- int86x (0x21, ®s, ®s, &sregs);
- if (regs.BX != BTR_OFFSET)
- return (BTR_ERR);
-
- /* Read segment registers and initialize segment part of addresses to */
- /* user's data segment. */
- /* */
-
- segread (&sregs);
-
- /* */
- /* Move user parameters to xData, the block where Btrieve expects them.*/
- /* */
-
- xData.function = operation;
- xData.statAddress = &stat;
- xData.fcbAddress = posBlock;
- xData.curAddress = posBlock + 38;
- xData.bufAddress = dataBuf;
- xData.bufLength = *dataLen;
- xData.keyAddress = keyBuf;
- xData.keyLength = 255; /* use max since we don't know */
- xData.keyNumber = keyNum;
- xData.xfaceID = VARIABLE_ID;
-
- /* */
- /* Make call to the Btrieve Record Manager. */
- /* */
-
- regs.DX = (INT) &xData; /* parameter block is expected to be in DX */
- sregs.DS = sregs.SS;
- int86x (BTR_INT, ®s, ®s, &sregs);
-
- *dataLen = xData.bufLength;
- return (stat); /* return status */
- }
-