Files
TeslaRel410/BORLAND/BDE/EXAMPLES/SNIPIT/DBIO.C
T
CydandClaude Fable 5 63312e07f9 source410: literal 4.10 source reconstruction + BC++ 4.52 fleet toolchain archived
- 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>
2026-07-19 07:33:26 -05:00

130 lines
4.3 KiB
C++

// BDE - (C) Copyright 1995 by Borland International
// dbio.c
#include "snipit.h"
#define iNUMDB 5
//=====================================================================
// Function:
// DatabaseIOSample();
//
// Description:
// This example shows how to open a number of databases and get
// information about those databases.
//=====================================================================
void
DatabaseIOSample (void)
{
DBIResult rslt; // Value returned from IDAPI functions
hDBIDb hDb[iNUMDB]; // Array of handles to databases
hDBICur hCur; // Handle to the table
DBIPATH szDir; // String to hold the directory
CHAR szMessage[20]; // String to hold messages
// (expected size <20)
UINT16 iOpenedDatabases; // Count of the opened databases
UINT16 iLoop; // Loop variable
DBDesc DbDesc; // Information about the databases
Screen("*** Database Manipulation Example ***\r\n");
BREAK_IN_DEBUGGER();
Screen(" Initializing IDAPI...\r\n");
rslt = DbiInit(NULL);
if (ChkRslt(rslt, "Init") != DBIERR_NONE)
{
Screen("\r\n*** End of Example ***");
return;
}
// Turn on trace information if the debug layer is anabled (DLLSWAP.EXE).
DbiDebugLayerOptions(DEBUGON | OUTPUTTOFILE, "SNIPIT.INF");
// Specify where temporary files are placed.
rslt = DbiSetPrivateDir(szPrivDirectory);
ChkRslt(rslt, "SetPrivateDir");
// Open up to iNUMDB databases.
for (iOpenedDatabases=0; iOpenedDatabases < iNUMDB; iOpenedDatabases++)
{
Screen(" Open database #%i", iOpenedDatabases + 1);
rslt = DbiOpenDatabase("", 0, dbiREADWRITE, dbiOPENSHARED,
NULL, NULL, NULL, NULL,
&hDb[iOpenedDatabases]);
if (rslt != DBIERR_NONE)
{
// Know how to deal with running out of database handles.
if (rslt == DBIERR_DBLIMIT)
{
break;
}
ChkRslt(rslt, "OpenDatabase");
DbiDebugLayerOptions(0, NULL);
rslt = DbiExit();
ChkRslt(rslt, "Exit");
Screen("\r\n*** End of Example ***");
return;
}
}
Screen("\r\n Get the default directory for the first database...");
rslt = DbiGetDirectory(hDb[0], FALSE, szDir);
ChkRslt(rslt, "GetDirectory");
Screen(" The working directory: %s", szDir);
Screen(" Change the directory which the first database uses...");
rslt = DbiSetDirectory(hDb[0], (pCHAR) szTblDirectory);
ChkRslt(rslt, "SetDirectory");
// Display information about the available databases.
// Note that this example reads the data from the schema table
// directly into a structure defined in IDAPI.H. This should
// only be done with schema tables.
rslt = DbiOpenDatabaseList(&hCur);
if (ChkRslt(rslt, "OpenDatabaseList") == DBIERR_NONE)
{
Screen("\r\n Display information about the available databases:");
while ((rslt = DbiGetNextRecord(hCur, dbiNOLOCK, (pBYTE)&DbDesc,
NULL)) == DBIERR_NONE)
{
Screen("\r\n Logical Name: %s", DbDesc.szName);
Screen(" Description: %s", DbDesc.szText);
Screen(" Physical name/path: %s", DbDesc.szPhyName);
Screen(" Database type: %s", DbDesc.szDbType);
}
// Trap for unexpected errors.
if (rslt != DBIERR_EOF)
{
ChkRslt(rslt, "GetNextRecord");
}
}
// Place an empty line in the output edit control.
Screen("");
// Clean up and return.
for (iLoop = 0; iLoop < iOpenedDatabases; iLoop++)
{
Screen(" Close database #%i", iLoop + 1);
wsprintf(szMessage, "CloseDatabase #%i", iLoop + 1);
rslt = DbiCloseDatabase(&hDb[iLoop]);
ChkRslt(rslt, szMessage);
}
// Turn off trace information.
DbiDebugLayerOptions(0, NULL);
Screen("\r\n Clean up IDAPI");
rslt = DbiExit();
ChkRslt(rslt, "Exit");
Screen("\r\n*** End of Example ***");
}