- BORLAND/: Borland C++ 4.52 (chosen over 4.5 by byte-match: CODE/RP/CW32.LIB
is identical to 4.52's install lib). BCC32/TLINK32/TLIB/MAKE run natively on
Win11; CODE/BT/OPT.MAK is the shipped BTL4OPT.EXE's exact flag recipe
(extender = Borland PowerPack DPMI32, not Phar Lap TNT).
- restoration/source410/: the literal 1995-form reconstruction of the missing
BT game source (never mixed into CODE/). Round 1-3 state:
* 6 of 10 surviving original TUs COMPILE CLEAN under the period toolchain
(BTMSSN, BTCNSL, BTSCNRL, BTTEAM, BTL4MODE, BTL4ARND) - first builds
since 1996.
* BT_L4/BTL4APP.CPP pilot reconstruction: 12/12 functions, Fail() lands on
its binary-recorded line 400 exactly.
* BT/BTCNSL.HPP: console wire IDs recovered from the binary's ctors
(Killed=9, Damaged=10, ScoreUpdate=13, DeathWithoutHonor=15 [T1];
TeamScore=12 flagged [T4]).
* MUNGA/: 8 engine-header backfills back-dated from the BT412 WinTesla tree
(VDATA numbering decomp-verified; AUDREND's OpenAL-era virtual removed -
the period compiler is the drift detector).
* Tooling: backdate.py (WinTesla->1995 header transform), compile410.sh
(per-TU verification sweep under authentic OPT.MAK flags).
* README: corrected roadmap - MECH.HPP is the capstone grown with the mech
TU reconstructions; BTREG.CPP green = the header-family milestone.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
201 lines
7.5 KiB
C++
201 lines
7.5 KiB
C++
// BDE - (C) Copyright 1995 by Borland International
|
|
|
|
// FiltComp.c
|
|
#include "snipit.h"
|
|
|
|
static const char szTblName[] = "customer";
|
|
static const char szTblType[] = szPARADOX;
|
|
|
|
//==============================================================
|
|
// Function:
|
|
// FiltComp();
|
|
//
|
|
// Description:
|
|
// This example shows how to use filters to limit the
|
|
// result set of a table. Specifically, this example
|
|
// does a comparison of the first N digits of a character
|
|
// field. Filters perform a function similar to that of
|
|
// ranges, but more powerful operations are supported.
|
|
//==============================================================
|
|
void
|
|
FiltComp (void)
|
|
{
|
|
hDBIDb hDb; // Handle to the database.
|
|
hDBICur hCur; // Handle to the table.
|
|
pBYTE pcanExpr; // Structure containing
|
|
// filter info.
|
|
hDBIFilter hFilter; // Filter handle.
|
|
UINT16 uSizeNodes; // Size of the nodes in the
|
|
// tree.
|
|
UINT16 uSizeCanExpr; // Size of the header
|
|
// information.
|
|
UINT16 uSizeLiterals; // Size of the literals.
|
|
UINT16 uTotalSize; // Total size of the filter
|
|
// expression.
|
|
UINT32 uNumRecs = 10; // Number of records to
|
|
// display.
|
|
CANExpr canExp; // Contains the header
|
|
// information.
|
|
UINT16 Nodes[] = // Nodes of the filter
|
|
// tree.
|
|
{
|
|
// Offset 0
|
|
nodeCOMPARE, // canCompare.nodeClass
|
|
canEQ, // canCompare.canOp
|
|
1, // canCompare.bCaseInsensitive
|
|
5, // canCompare.iParialLen (0 if
|
|
// full length)
|
|
12, // canBinary.iOperand1
|
|
20, // canBinary.iOperand2
|
|
// Offsets in the Nodes array
|
|
|
|
// Offset 12
|
|
nodeFIELD, // canField.nodeClass
|
|
canFIELD, // canField.canOp
|
|
2, // canField.iFieldNum
|
|
0, // canField.iNameOffset: szField
|
|
// is the literal at offset 0
|
|
|
|
// Offset 20
|
|
nodeCONST, // canConst.nodeClass
|
|
canCONST, // canConst.canOp
|
|
fldZSTRING, // canConst.iType
|
|
6, // canConst.iSize
|
|
5 // canConst.iOffset: szConst is
|
|
// the literal at offset
|
|
// strlen(szField) + 1
|
|
};
|
|
|
|
// Name of the field for the third node of the tree.
|
|
CHAR szField[] = "NAME";
|
|
// Value of the constant for the second node of the tree.
|
|
CHAR szConst[] = "OCEAN";
|
|
// Return value from IDAPI functions.
|
|
DBIResult rslt;
|
|
|
|
Screen("*** Compare Filter Example ***\r\n");
|
|
|
|
BREAK_IN_DEBUGGER();
|
|
|
|
Screen(" Initializing IDAPI...");
|
|
if (InitAndConnect(&hDb) != DBIERR_NONE)
|
|
{
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
Screen(" Setting the database directory...");
|
|
rslt = DbiSetDirectory(hDb, (pCHAR) szTblDirectory);
|
|
ChkRslt(rslt, "SetDirectory");
|
|
|
|
Screen(" Open the %s table...", szTblName);
|
|
rslt = DbiOpenTable(hDb, (pCHAR) szTblName,
|
|
(pCHAR) szTblType, NULL, NULL, 0,
|
|
dbiREADWRITE, dbiOPENSHARED, xltFIELD,
|
|
FALSE, NULL, &hCur);
|
|
if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
|
|
{
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Go to the beginning of the table
|
|
rslt = DbiSetToBegin(hCur);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
|
|
Screen("\r\n Display the %s table...", szTblName);
|
|
DisplayTable(hCur, uNumRecs);
|
|
|
|
uSizeNodes = sizeof(Nodes); // Size of the nodes.
|
|
// Size of the literals.
|
|
uSizeLiterals = strlen(szField) + 1 + strlen(szConst) + 1;
|
|
// Size of the header information.
|
|
uSizeCanExpr = sizeof(CANExpr);
|
|
// Total size of the filter.
|
|
uTotalSize = uSizeCanExpr + uSizeNodes + uSizeLiterals;
|
|
|
|
// Initialize the header information
|
|
canExp.iVer = 1; // Version.
|
|
canExp.iTotalSize = uTotalSize; // Total size of the
|
|
// filter.
|
|
canExp.iNodes = 3; // Number of nodes.
|
|
canExp.iNodeStart = uSizeCanExpr; // The offset in the
|
|
// buffer where the
|
|
// expression nodes
|
|
// start.
|
|
|
|
// The offset in the buffer where the literals start.
|
|
canExp.iLiteralStart = uSizeCanExpr + uSizeNodes;
|
|
// Allocate space for the filter expression.
|
|
pcanExpr = (pBYTE)malloc(uTotalSize * sizeof(BYTE));
|
|
if (pcanExpr == NULL)
|
|
{
|
|
Screen(" Could not allocate memory...");
|
|
DbiCloseCursor(&hCur);
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Initialize the filter expression.
|
|
memmove(pcanExpr, &canExp, uSizeCanExpr);
|
|
memmove(&pcanExpr[uSizeCanExpr], Nodes, uSizeNodes);
|
|
|
|
memmove(&pcanExpr[uSizeCanExpr + uSizeNodes],
|
|
szField, strlen(szField) + 1); // First litteral
|
|
memmove(&pcanExpr[uSizeCanExpr + uSizeNodes +
|
|
strlen(szField) + 1],
|
|
szConst, strlen(szConst) + 1); // Second litteral
|
|
|
|
rslt = DbiSetToBegin(hCur);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
|
|
Screen("\r\n Add a filter to the %s table which will"
|
|
" limit the records\r\n which are displayed"
|
|
" to those whose %s field starts with '%s'...",
|
|
szTblName, szField, szConst);
|
|
rslt = DbiAddFilter(hCur, 0L, 1, FALSE, (pCANExpr)pcanExpr,
|
|
NULL, &hFilter);
|
|
if (ChkRslt(rslt, "AddFilter") != DBIERR_NONE)
|
|
{
|
|
rslt = DbiCloseCursor(&hCur);
|
|
ChkRslt(rslt, "CloseCursor");
|
|
free(pcanExpr);
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Activate the filter.
|
|
Screen(" Activate the filter on the %s table...",
|
|
szTblName);
|
|
rslt = DbiActivateFilter(hCur, hFilter);
|
|
ChkRslt(rslt, "ActivateFilter");
|
|
|
|
rslt = DbiSetToBegin(hCur);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
|
|
Screen("\r\n Display the %s table with the filter"
|
|
" set...", szTblName);
|
|
DisplayTable(hCur, uNumRecs);
|
|
|
|
Screen("\r\n Deactivate the filter...");
|
|
rslt = DbiDeactivateFilter(hCur, hFilter);
|
|
ChkRslt(rslt, "DeactivateFilter");
|
|
|
|
Screen("\r\n Drop the filter...");
|
|
rslt = DbiDropFilter(hCur, hFilter);
|
|
ChkRslt(rslt, "DropFilter");
|
|
|
|
rslt = DbiCloseCursor(&hCur);
|
|
ChkRslt(rslt, "CloseCursor");
|
|
|
|
free(pcanExpr);
|
|
|
|
Screen(" Close the database and exit IDAPI...");
|
|
CloseDbAndExit(&hDb);
|
|
|
|
Screen("\r\n*** End of Example ***");
|
|
}
|