- 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>
188 lines
6.3 KiB
C++
188 lines
6.3 KiB
C++
// BDE - (C) Copyright 1995 by Borland International
|
|
|
|
// Callback.C
|
|
#include "snipit.h"
|
|
|
|
static const DBIPATH szTblName = "CUST2";
|
|
static const char szTblType[] = szDBASE;
|
|
pCHAR CallBackData2;
|
|
|
|
CBRType DBIFN _export CallBackFunc2(CBType ecbType, UINT32 iClientData,
|
|
pVOID pCbInfo);
|
|
|
|
//=====================================================================
|
|
// Function:
|
|
// InputReqCallback();
|
|
//
|
|
// Description:
|
|
// This example shows how to access a dBASE table which is missing
|
|
// it's .MDX file. This is accomplished with the use of the
|
|
// cbINPUTREQ callback. Note that this method can also be used
|
|
// to access FOX and CLIPPER tables.
|
|
//=====================================================================
|
|
void InputReqCallback(void)
|
|
{
|
|
hDBIDb hDb; // Handle to the database
|
|
hDBICur hCur; // Handle to the table
|
|
UINT16 uNumOfRecs = 5; // No. of records to display
|
|
CBInputDesc CbInfo; // Variable which is used within
|
|
// the callback
|
|
DBIResult rslt; // Return value from IDAPI
|
|
// functions
|
|
|
|
Screen("*** Open Table CallBack Example ***\r\n");
|
|
|
|
BREAK_IN_DEBUGGER();
|
|
|
|
Screen(" Initializing IDAPI...");
|
|
if (InitAndConnect(&hDb) != DBIERR_NONE)
|
|
{
|
|
Screen("*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
Screen(" Setting the database directory...");
|
|
rslt = DbiSetDirectory(hDb, (pCHAR) szTblDirectory);
|
|
ChkRslt(rslt, "SetDirectory");
|
|
|
|
Screen(" ERROR expected opening the %s table: \r\n"
|
|
" 'Index does not exist'...", szTblName);
|
|
rslt = DbiOpenTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType,
|
|
NULL, NULL, 0, dbiREADONLY, dbiOPENSHARED,
|
|
xltFIELD, FALSE, NULL, &hCur);
|
|
ChkRslt(rslt, "OpenTable");
|
|
|
|
if (hCur)
|
|
{
|
|
Screen(" Display the %s table...", szTblName);
|
|
DisplayTable(hCur, uNumOfRecs);
|
|
|
|
Screen("\r\n Close the %s table...", szTblName);
|
|
DbiCloseCursor(&hCur);
|
|
}
|
|
|
|
// Allocate enough space for the data passed to the callback function.
|
|
CallBackData2 = (pCHAR)malloc(100 * sizeof(CHAR));
|
|
if (CallBackData2 == NULL)
|
|
{
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Register the callback.
|
|
rslt = DbiRegisterCallBack(NULL, cbINPUTREQ, (UINT32) CallBackData2,
|
|
sizeof(CBInputDesc), &CbInfo, CallBackFunc2);
|
|
if(ChkRslt(rslt, "RegisterCallback") != DBIERR_NONE)
|
|
{
|
|
free(CallBackData2);
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
Screen("\r\n Open the %s table...", szTblName);
|
|
rslt = DbiOpenTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType,
|
|
NULL, NULL, 0, dbiREADONLY, dbiOPENSHARED,
|
|
xltFIELD, FALSE, NULL, &hCur);
|
|
ChkRslt(rslt, "OpenTable");
|
|
|
|
if (hCur)
|
|
{
|
|
Screen(" Display the Table...");
|
|
DisplayTable(hCur, uNumOfRecs);
|
|
|
|
Screen("\r\n Close the %s table...", szTblName);
|
|
rslt = DbiCloseCursor(&hCur);
|
|
ChkRslt(rslt, "CloseCursor");
|
|
}
|
|
|
|
// Unregister the callback by passing in NULL for the function.
|
|
rslt = DbiRegisterCallBack(NULL, cbINPUTREQ, NULL, 0, NULL, NULL);
|
|
if (ChkRslt(rslt, "RegisterCallBack") != DBIERR_NONE)
|
|
{
|
|
free(CallBackData2);
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
free(CallBackData2);
|
|
|
|
Screen("\r\n Close the database and exit IDAPI...");
|
|
CloseDbAndExit(&hDb);
|
|
|
|
Screen("\r\n*** End of Example ***");
|
|
}
|
|
|
|
//======================================================================
|
|
// Name: CallBackFunc2(ecbType, iClientData, pCbInfo)
|
|
//
|
|
// Input: ecbType - Callback type
|
|
// iClientData - Pointer to client information that is passed into
|
|
// the callback function
|
|
// pCbInfo - The callback structure that holds the information
|
|
// about the current state
|
|
//
|
|
// Return: The action that should be taken
|
|
//
|
|
// Description:
|
|
// This function will be called from the BDE during the process
|
|
// of opening the table.
|
|
//======================================================================
|
|
CBRType DBIFN
|
|
CallBackFunc2 (CBType ecbType, UINT32 iClientData, pVOID pCbInfo)
|
|
{
|
|
CBInputDesc *eCBInputDesc; // Variable to contain passed-in
|
|
// information
|
|
int i;
|
|
|
|
// Set to stop an unused variable warning.
|
|
iClientData = iClientData;
|
|
|
|
switch (ecbType)
|
|
{
|
|
// In case this is a restructure progress callback, display the
|
|
// information.
|
|
case cbINPUTREQ:
|
|
|
|
eCBInputDesc = (CBInputDesc far *)pCbInfo;
|
|
|
|
Screen("\r\n ### In the Callback function...\r\n");
|
|
|
|
Screen(" ### %s", eCBInputDesc->szMsg);
|
|
Screen("\r\n Options are:");
|
|
for (i = 0; i < eCBInputDesc->iCount; i++)
|
|
{
|
|
Screen(" ### %s: %s",
|
|
eCBInputDesc->acbEntry[i].szKeyWord,
|
|
eCBInputDesc->acbEntry[i].szHelp);
|
|
}
|
|
|
|
Screen(" ### Default: %s",
|
|
eCBInputDesc->acbEntry[eCBInputDesc->iSelection].szKeyWord);
|
|
|
|
if (eCBInputDesc->eCbInputId == cbiMDXMISSING)
|
|
{
|
|
i = 0;
|
|
while (i < eCBInputDesc->iCount)
|
|
{
|
|
if (!strcmp(eCBInputDesc->acbEntry[i].szKeyWord,
|
|
"Open Read Only"))
|
|
{
|
|
Screen("\r\n ### Open the table read only...\r\n");
|
|
eCBInputDesc->iSelection = i + 1;
|
|
eCBInputDesc->bSave = FALSE;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
default:
|
|
Screen("### In the callback function");
|
|
}
|
|
|
|
return cbrCHKINPUT;
|
|
}
|