- 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>
323 lines
12 KiB
C++
323 lines
12 KiB
C++
// BDE - (C) Copyright 1995 by Borland International
|
|
|
|
// secdesc.c
|
|
#include "snipit.h"
|
|
|
|
static DBIResult AddRecord(hDBICur hCur, DFLOAT fStatus, DFLOAT fOrder,
|
|
CHAR *szDateSent, CHAR *szDateDelivered);
|
|
|
|
static const char szTblName[] = "SecDesc";
|
|
static const char szTblType[] = szPARADOX;
|
|
|
|
// Field descriptor used in creating a table.
|
|
static SNIPFAR FLDDesc fldDesc[] = {
|
|
{ // Field 1 - AUTOINC
|
|
1, // Field number
|
|
"Status ID", // Field name
|
|
fldFLOAT, // Field type
|
|
fldUNKNOWN, // Field subtype
|
|
0, // Field size
|
|
0, // Decimal places ( 0 )
|
|
// computed
|
|
0, // Offset in record ( 0 )
|
|
0, // Length in bytes ( 0 )
|
|
0, // For NULL bits ( 0 )
|
|
fldvNOCHECKS, // Validity checks ( 0 )
|
|
fldrREADWRITE // Rights
|
|
},
|
|
{ // Field 2 - ALPHA
|
|
2, "Order No", fldFLOAT, fldUNKNOWN,
|
|
0, 0, 0, 0, 0,
|
|
fldvNOCHECKS, fldrREADWRITE
|
|
},
|
|
{ // Field 4 - DATE
|
|
3, "Date Sent", fldDATE, fldUNKNOWN,
|
|
0, 0, 0, 0, 0, fldvNOCHECKS, fldrREADWRITE
|
|
},
|
|
{ // Field 4 - DATE
|
|
4, "Date Received", fldDATE, fldUNKNOWN,
|
|
0, 0, 0, 0, 0, fldvNOCHECKS, fldrREADWRITE
|
|
}
|
|
}; // Array of field descriptors.
|
|
|
|
// The number of fields in the table.
|
|
static const UINT16 uNumFields = sizeof(fldDesc) / sizeof(fldDesc[0]);
|
|
|
|
static SNIPFAR SECDesc secDesc[] = {
|
|
{
|
|
1, // Number to identify descriptor
|
|
prvREADONLY, // Table privileges
|
|
NOFAMRIGHTS, // Family rights
|
|
"test", // Password
|
|
{ prvNONE, prvREADONLY, prvREADONLY, prvREADONLY } // Field Level Priviledges
|
|
}
|
|
};
|
|
|
|
// Define the operation on the table: add the security descriptor to the
|
|
// table.
|
|
static CROpType crOpType[] = { crADD };
|
|
|
|
// The number of security descriptors in the table.
|
|
static const UINT16 uNumDescs = sizeof(secDesc) / sizeof(secDesc[0]);
|
|
|
|
//=====================================================================
|
|
// Function:
|
|
// SecDesc();
|
|
//
|
|
// Desccription:
|
|
// This function shows how to use auxiliary passwords with a
|
|
// Paradox table.
|
|
//=====================================================================
|
|
void
|
|
SecDesc (void)
|
|
{
|
|
DBIResult rslt; // Return value from IDAPI functions
|
|
hDBIDb hDb; // Handle to the database
|
|
hDBICur hCur; // Handle to the table
|
|
CRTblDesc TblDesc; // Create table descriptor
|
|
UINT16 uDispNumRecs = 10; // Number of records to add and
|
|
// display
|
|
CHAR szPassword[] = "MyPass"; // Password for the table
|
|
|
|
Screen("*** Security Descriptor 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(" Initializing the table descriptor...");
|
|
memset((void *)&TblDesc, 0, sizeof(CRTblDesc));
|
|
lstrcpy(TblDesc.szTblName, szTblName);
|
|
lstrcpy(TblDesc.szTblType, szTblType);
|
|
TblDesc.iFldCount = uNumFields;
|
|
TblDesc.pfldDesc = fldDesc;
|
|
TblDesc.bProtected = TRUE;
|
|
strcpy(TblDesc.szPassword, szPassword);
|
|
TblDesc.iSecRecCount = uNumDescs;
|
|
TblDesc.pecrSecOp = crOpType;
|
|
TblDesc.psecDesc = (SECDesc *)secDesc;
|
|
|
|
// Add the master password to the session. This is needed
|
|
// before the create in case the table needs to be overwritten.
|
|
// The master password is also required in order to open the table.
|
|
rslt = DbiAddPassword(szPassword);
|
|
ChkRslt(rslt, "AddPassword");
|
|
|
|
Screen(" Creating the %s table...", szTblName);
|
|
rslt = DbiCreateTable(hDb, TRUE, &TblDesc);
|
|
if (ChkRslt(rslt, "CreateTable") != DBIERR_NONE)
|
|
{
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
Screen(" Open the %s table with the master password...",
|
|
szTblName);
|
|
rslt = DbiOpenTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType,
|
|
NULL, NULL, 0, dbiREADWRITE, dbiOPENSHARED,
|
|
xltFIELD, FALSE, NULL, &hCur);
|
|
if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
|
|
{
|
|
rslt = DbiDeleteTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType);
|
|
ChkRslt(rslt, "DeleteTable");
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
Screen("\r\n Add five records to the table...");
|
|
AddRecord(hCur, 1, 1004, "07/28/1994", "08/12/1994");
|
|
AddRecord(hCur, 2, 1005, "08/02/1994", "08/12/1994");
|
|
AddRecord(hCur, 3, 1006, "08/04/1994", "08/12/1994");
|
|
AddRecord(hCur, 4, 1007, "09/28/1994", "11/12/1994");
|
|
AddRecord(hCur, 5, 1008, "10/28/1994", "11/12/1994");
|
|
|
|
Screen("\r\n Close the table...");
|
|
rslt = DbiCloseCursor(&hCur);
|
|
ChkRslt(rslt, "CloseCursor");
|
|
|
|
// Remove the master password from the session.
|
|
rslt = DbiDropPassword(szPassword);
|
|
ChkRslt(rslt, "DropPassword");
|
|
|
|
// Add the auxiliary password to the session.
|
|
rslt = DbiAddPassword("test");
|
|
ChkRslt(rslt, "AddPassword");
|
|
|
|
// Open the table.
|
|
// Note that the table has to be opened read-only as the
|
|
// security descriptor only supports read operations.
|
|
Screen("\r\n Open the %s table with the auxiliary password...",
|
|
szTblName);
|
|
rslt = DbiOpenTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType,
|
|
NULL, NULL, 0, dbiREADONLY, dbiOPENSHARED,
|
|
xltFIELD, FALSE, NULL, &hCur);
|
|
if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
|
|
{
|
|
rslt = DbiDeleteTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType);
|
|
ChkRslt(rslt, "DeleteTable");
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Go to the beginning of the table.
|
|
rslt = DbiSetToBegin(hCur);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
|
|
Screen(" Display the \"%s\" table...", szTblName);
|
|
Screen(" Notice that the \"Status ID\" field is blank:"
|
|
" the auxiliary password does\r\n not have access to"
|
|
" the \"Status ID\" field");
|
|
DisplayTable(hCur, uDispNumRecs);
|
|
|
|
Screen("\r\n Close the table...");
|
|
rslt = DbiCloseCursor(&hCur);
|
|
ChkRslt(rslt, "CloseCursor");
|
|
|
|
Screen(" Need to add the master password in order to delete"
|
|
" the table.\r\n The auxiliary password does not have"
|
|
" sufficient rights");
|
|
rslt = DbiAddPassword(szPassword);
|
|
ChkRslt(rslt, "AddPassword");
|
|
|
|
Screen(" Deleting the table...");
|
|
rslt = DbiDeleteTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType);
|
|
ChkRslt(rslt, "DeleteTable");
|
|
|
|
Screen(" Close the database and exit IDAPI...");
|
|
CloseDbAndExit(&hDb);
|
|
|
|
Screen("\r\n*** End of Example ***");
|
|
}
|
|
|
|
//=====================================================================
|
|
// Function:
|
|
// AddRecord(hCur, fStatus, fOrder, *DateOrdered, *DateDelivered)
|
|
//
|
|
// Input: hCur - Cursor to the table
|
|
// fStatus - Value to write to the Status ID field
|
|
// fOrder - Value to write to the Order ID field
|
|
// DateSent - Value to write to the Date Sent field
|
|
// DateDelivered - Value to write to the Date Received field
|
|
//
|
|
// Return: Success of the function
|
|
//
|
|
// Description:
|
|
// This function is used to add a record to the table.
|
|
//=====================================================================
|
|
DBIResult
|
|
AddRecord (hDBICur hCur, DFLOAT fStatus, DFLOAT fOrder, CHAR *szDateSent,
|
|
CHAR *szDateDelivered)
|
|
{
|
|
DBIResult rslt; // Return value from IDAPI functions
|
|
pBYTE pRecBuf; // Record buffer
|
|
CURProps TblProps; // The properties of the table
|
|
UINT16 uMonth; // Contains the month portion of the
|
|
// date
|
|
UINT16 uDay; // Contains the day portion of the
|
|
// date
|
|
INT16 iYear; // Contains the year portion of the
|
|
// date
|
|
CHAR szDate[30]; // Pointer to be allocated from the
|
|
// heap
|
|
CHAR *pszTemp; // Temporary string used in parsing
|
|
// the date
|
|
DBIDATE Date; // Date structure, used in
|
|
// DbiPutField
|
|
|
|
// Allocate a record buffer.
|
|
rslt = DbiGetCursorProps(hCur, &TblProps);
|
|
ChkRslt(rslt, "GetCursorProps");
|
|
|
|
pRecBuf = (pBYTE) malloc(TblProps.iRecBufSize * sizeof(pBYTE));
|
|
if (pRecBuf == NULL)
|
|
{
|
|
Screen(" Error - Out of memory!");
|
|
return DBIERR_NOMEMORY;
|
|
}
|
|
|
|
// Make sure we're starting with a clean record buffer.
|
|
rslt = DbiInitRecord(hCur, pRecBuf);
|
|
ChkRslt(rslt, "InitRecord");
|
|
|
|
// Add the Status ID to the record buffer.
|
|
rslt = DbiPutField(hCur, 1, pRecBuf, (pBYTE) &fStatus);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Add the Order ID to the record buffer.
|
|
rslt = DbiPutField(hCur, 2, pRecBuf, (pBYTE) &fOrder);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
strcpy(szDate, szDateSent);
|
|
pszTemp = strtok(szDate, "/");
|
|
if (pszTemp)
|
|
{
|
|
uMonth = atoi(pszTemp); // uMonth set to 0 if invalid date.
|
|
pszTemp = strtok(NULL, "/");
|
|
if (pszTemp)
|
|
{
|
|
uDay = atoi(pszTemp); // uDay set to 0 if invalid date.
|
|
pszTemp = strtok(NULL, "/");
|
|
if (pszTemp)
|
|
{
|
|
iYear = atoi(pszTemp); // iYear set to 0 if
|
|
// invalid date.
|
|
}
|
|
}
|
|
}
|
|
|
|
// Encode the date.
|
|
rslt = DbiDateEncode(uMonth, uDay, iYear, &Date);
|
|
ChkRslt(rslt, "DateEncode");
|
|
|
|
// Put the data into the record buffer.
|
|
rslt = DbiPutField(hCur, 3, pRecBuf, (pBYTE) &Date);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Need to convert the string to a Date structure.
|
|
strcpy(szDate, szDateDelivered);
|
|
pszTemp = strtok(szDate, "/");
|
|
if (pszTemp)
|
|
{
|
|
uMonth = atoi(pszTemp); // uMonth set to 0 if invalid date.
|
|
pszTemp = strtok(NULL, "/");
|
|
if (pszTemp)
|
|
{
|
|
uDay = atoi(pszTemp); // uDay set to 0 if invalid date.
|
|
pszTemp = strtok(NULL, "/");
|
|
if (pszTemp)
|
|
{
|
|
iYear = atoi(pszTemp); // iYear set to 0 if
|
|
// invalid date.
|
|
}
|
|
}
|
|
}
|
|
|
|
// Encode the date.
|
|
rslt = DbiDateEncode(uMonth, uDay, iYear, &Date);
|
|
ChkRslt(rslt, "DateEncode");
|
|
|
|
// Put the data into the record buffer.
|
|
rslt = DbiPutField(hCur, 4, pRecBuf, (pBYTE) &Date);
|
|
ChkRslt(rslt,"PutField");
|
|
|
|
// Insert the record into the table.
|
|
rslt = DbiInsertRecord(hCur, dbiNOLOCK, pRecBuf);
|
|
ChkRslt(rslt, "InsertRecord");
|
|
|
|
free(pRecBuf);
|
|
|
|
return rslt;
|
|
}
|