- 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>
234 lines
8.2 KiB
C++
234 lines
8.2 KiB
C++
// BDE - (C) Copyright 1995 by Borland International
|
|
|
|
// Upsize.C
|
|
#include "snipit.h"
|
|
|
|
static const char szUPTblName[] = "customer";
|
|
static const char szUPTblType[] = szPARADOX;
|
|
static const char szSVTblName[] = "SrvrCustomer";
|
|
|
|
//=====================================================================
|
|
// Function:
|
|
// UpSize();
|
|
//
|
|
// Description:
|
|
// This example shows how to copy a local table to an SQL server.
|
|
// This is done using the DbiBatchMove function.
|
|
//
|
|
// The example will request that the user supply a server name
|
|
// and password, and will then proceed to copy the "Customer"
|
|
// Paradox table (and its primary index) to the table.
|
|
//
|
|
// WARNING:
|
|
// You must have write access to your server in order for this
|
|
// example to work.
|
|
//=====================================================================
|
|
void
|
|
UpSize (void)
|
|
{
|
|
hDBIDb hDb; // Handle to the server database
|
|
hDBICur hCur; // Server cursor handle
|
|
hDBIDb hDbPX; // Handle to the Paradox database
|
|
hDBICur hCurPX; // Paradox cursor handle
|
|
DBIResult rslt; // Return value of a given function call.
|
|
UINT16 iLen; // Length of the returned property
|
|
CURProps TblProps; // Table properties
|
|
pIDXDesc pIdxDesc = NULL; // Index pointer
|
|
UINT16 i=0; // Index counter
|
|
CHAR szIndex[DBIMAXNAMELEN]; // Temporary index name
|
|
UINT16 iIndexNum = 1; // Index number on the server table
|
|
|
|
BATTblDesc BatTblDesc = {
|
|
NULL,
|
|
"",
|
|
"",
|
|
{ NULL },
|
|
{ NULL }
|
|
};
|
|
|
|
Screen("*** Copying a local table to an SQL Server ***\r\n");
|
|
|
|
BREAK_IN_DEBUGGER();
|
|
|
|
Screen(" Initializing IDAPI...");
|
|
if (InitAndConnect2(&hDb) != DBIERR_NONE)
|
|
{
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Get the type of the server.
|
|
rslt = DbiGetProp((hDBIObj)hDb, dbDATABASETYPE,
|
|
(pCHAR)BatTblDesc.szTblType, sizeof(DBINAME), &iLen);
|
|
ChkRslt(rslt, "Get Prop");
|
|
|
|
if (! strcmp(BatTblDesc.szTblType, "STANDARD"))
|
|
{
|
|
Screen(" This example only works on remote SQL databases");
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Open a standard database for the local table.
|
|
rslt = DbiOpenDatabase(NULL, NULL, dbiREADWRITE, dbiOPENSHARED,
|
|
NULL, 0, NULL, NULL, &hDbPX);
|
|
if (ChkRslt(rslt, "OpenDatabase") != DBIERR_NONE)
|
|
{
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
Screen(" Setting the database directory for the standard database...");
|
|
rslt = DbiSetDirectory(hDbPX, (pCHAR) szTblDirectory);
|
|
ChkRslt(rslt, "SetDirectory");
|
|
|
|
Screen(" Open the %s %s table which will be copied to the\r\n"
|
|
" %s server...", szUPTblName, szUPTblType,
|
|
BatTblDesc.szTblType);
|
|
|
|
rslt = DbiOpenTable(hDbPX, (pCHAR) szUPTblName, (pCHAR) szUPTblType,
|
|
NULL, NULL, 0, dbiREADWRITE, dbiOPENSHARED,
|
|
xltFIELD, FALSE, NULL, &hCurPX);
|
|
if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
|
|
{
|
|
DbiCloseDatabase(&hDbPX);
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
rslt = DbiSetToBegin(hCurPX);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
|
|
Screen("\r\n Copying the %s table to the server...",
|
|
szUPTblName);
|
|
|
|
BatTblDesc.hDb = hDb;
|
|
strcpy(BatTblDesc.szTblName, (pCHAR)szSVTblName);
|
|
|
|
rslt = DbiBatchMove(NULL, hCurPX, &BatTblDesc, NULL, batCOPY, NULL,
|
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
|
NULL, NULL, NULL, NULL, TRUE, TRUE,
|
|
NULL, TRUE);
|
|
if(ChkRslt(rslt, "Batch Move") != DBIERR_NONE)
|
|
{
|
|
rslt = DbiCloseCursor(&hCurPX);
|
|
ChkRslt(rslt, "CloseCur");
|
|
DbiCloseDatabase(&hDbPX);
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
Screen(" Open the %s %s table...", szSVTblName, BatTblDesc.szTblType);
|
|
rslt = DbiOpenTable(hDb, (pCHAR) szSVTblName,
|
|
(pCHAR)BatTblDesc.szTblType, NULL, NULL, 0,
|
|
dbiREADWRITE, dbiOPENEXCL, xltFIELD, FALSE, NULL,
|
|
&hCur);
|
|
if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
|
|
{
|
|
rslt = DbiDeleteTable(hDb,(pCHAR) szSVTblName,
|
|
(pCHAR)BatTblDesc.szTblType);
|
|
ChkRslt(rslt, "DeleteTable");
|
|
rslt = DbiCloseCursor(&hCurPX);
|
|
ChkRslt(rslt, "CloseCur");
|
|
DbiCloseDatabase(&hDbPX);
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Allocate a buffer for the index descriptors.
|
|
rslt = DbiGetCursorProps(hCurPX, &TblProps);
|
|
ChkRslt(rslt, "GetCursorProps");
|
|
|
|
pIdxDesc = (pIDXDesc)malloc(TblProps.iIndexes * sizeof(IDXDesc));
|
|
if ((pIdxDesc == NULL) && (TblProps.iIndexes != 0))
|
|
{
|
|
rslt = DbiCloseCursor(&hCur);
|
|
ChkRslt(rslt, "CloseCur");
|
|
rslt = DbiDeleteTable(hDb,(pCHAR) szSVTblName,
|
|
(pCHAR)BatTblDesc.szTblType);
|
|
ChkRslt(rslt, "DeleteTable");
|
|
rslt = DbiCloseCursor(&hCurPX);
|
|
ChkRslt(rslt, "CloseCur");
|
|
DbiCloseDatabase(&hDbPX);
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Check if there are indexes on the table.
|
|
if (TblProps.iIndexes != 0)
|
|
{
|
|
rslt = DbiGetIndexDescs(hCurPX, pIdxDesc);
|
|
ChkRslt(rslt, "Get Index Descs");
|
|
}
|
|
|
|
Screen(" Add the Unique indexes found in the original table to "
|
|
"the %s table...", szSVTblName);
|
|
|
|
for ( i = 0; i < TblProps.iIndexes; i++)
|
|
{
|
|
// Only add the index if it is unique - such as a Paradox primary
|
|
// index or certain dBASE indexes.
|
|
if (pIdxDesc[i].bUnique == TRUE)
|
|
{
|
|
// Initialize index descriptor.
|
|
pIdxDesc[i].bPrimary = FALSE;
|
|
pIdxDesc[i].bUnique = TRUE;
|
|
pIdxDesc[i].bDescending = FALSE;
|
|
pIdxDesc[i].bMaintained = TRUE;
|
|
pIdxDesc[i].bSubset = FALSE;
|
|
pIdxDesc[i].bExpIdx = FALSE;
|
|
pIdxDesc[i].iBlockSize = 0;
|
|
pIdxDesc[i].iRestrNum = 0;
|
|
pIdxDesc[i].iIndexId = iIndexNum;
|
|
strcpy(pIdxDesc[i].szTagName, "");
|
|
memset(szIndex, 0, DBIMAXNAMELEN);
|
|
wsprintf(szIndex, "Index%u",iIndexNum);
|
|
strcpy(pIdxDesc[i].szName, szIndex);
|
|
|
|
rslt = DbiAddIndex(hDb, hCur, (pCHAR)szSVTblName,
|
|
(pCHAR)BatTblDesc.szTblType, &pIdxDesc[i],
|
|
NULL);
|
|
ChkRslt(rslt, "Add Index");
|
|
iIndexNum++;
|
|
}
|
|
}
|
|
|
|
memset(&TblProps, 0, sizeof(CURProps));
|
|
rslt = DbiGetCursorProps(hCur, &TblProps);
|
|
ChkRslt(rslt, "GetCursorProps");
|
|
|
|
rslt = DbiSetToBegin(hCur);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
|
|
Screen("\r\n Displaying the first 10 records of the %s %s table...",
|
|
szSVTblName, BatTblDesc.szTblType);
|
|
DisplayTable(hCur, 10);
|
|
|
|
Screen("\r\n Close the %s table...", szUPTblName);
|
|
rslt = DbiCloseCursor(&hCurPX);
|
|
ChkRslt(rslt, "CloseCur");
|
|
|
|
Screen(" Close the %s table...", szSVTblName);
|
|
rslt = DbiCloseCursor(&hCur);
|
|
ChkRslt(rslt, "CloseCur");
|
|
|
|
Screen(" Delete the %s table...", szSVTblName);
|
|
rslt = DbiDeleteTable(hDb,(pCHAR) szSVTblName,
|
|
(pCHAR)BatTblDesc.szTblType);
|
|
ChkRslt(rslt, "DeleteTable");
|
|
|
|
Screen(" Close the databases and exit IDAPI...");
|
|
DbiCloseDatabase(&hDbPX);
|
|
CloseDbAndExit(&hDb);
|
|
|
|
free(pIdxDesc);
|
|
|
|
Screen("\r\n*** End of Example ***");
|
|
}
|