home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / kdbf / envdef.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  15.5 KB  |  415 lines

  1. /***********************************************************************
  2. **                            ENVDEF.H
  3. ** This file contains structure, type and error definitions used 
  4. ** throughout the object layer. 
  5. **
  6. ***********************************************************************/
  7.  
  8. // DBF - (C) Copyright 1994 by Borland International
  9.       
  10. #if !defined( ENVDEF_H )
  11. #define ENVDEF_H
  12. #ifdef WINDOWS
  13. #include <windows.h>
  14. #endif
  15. #include <idapi.h>
  16. #include <string.h>
  17. #include <new.h>
  18. #include <except.h>
  19. #include "compat.h"
  20.  
  21. #ifdef _MSC_VER
  22.   #define _CLASSTYPE
  23. #endif
  24.  
  25. // Global defines. 
  26.  
  27. #define MAXNAMELEN      DBIMAXNAMELEN        // Name limit for tables, fields, etc.)
  28. #define MAXPATHLEN      DBIMAXPATHLEN        // Length of DOS path.
  29.  
  30. // Engine type for Paradox -- Local, Network or Windows.
  31.  
  32. enum BEngineType {pxLocal=1, pxNet=2, pxWin=3};
  33.  
  34. // File Share mode for the DOS Paradox Engine (local or network).
  35.  
  36. // NetShare to share only network files; LocalShare to share lock local 
  37. // and network files; with NoShare, neither local or network files 
  38. // will be shared. 
  39.  
  40. enum PXDosShare {pxLocalShare=0, pxNetShare, pxNoShare}; 
  41.  
  42. // Lock mode for the Windows Paradox Engine; With SingleClient,
  43. // no locking. 
  44.  
  45. enum PXWinShare {pxShared=0, pxSingleClient=1, pxExclusive=2};
  46.  
  47.  
  48. // Sort order for the Paradox Engine;  
  49.  
  50. enum PXSortOrder {pxAscii=1,pxIntl,pxNorDan,pxNorDan4,pxSwedFin}; 
  51.  
  52. enum PXTabCrtMode {px35Fmt=3,px40Fmt=4,px50Fmt=5};
  53.                                                             
  54. // Table lock mode for the Paradox Engine.
  55.  
  56. enum PXTblLckMode {px40Lck=0,px35Lck=1};
  57.  
  58. // Modes for creating a new index on a table.
  59.  
  60. enum PXKeyCrtMode {pxPrimary=0, pxSecondary, pxIncSecondary};
  61.  
  62. // Modes for Paradox locks.
  63.  
  64. enum PXLockMode {pxFL=1, pxWL, pxPWL, pxPFL};
  65.  
  66. // Modes for Paradox searches.
  67.  
  68. enum PXSearchMode {pxSearchFirst=keySEARCHEQ, pxGreater=keySEARCHGT,
  69.                    pxClosestRecord=keySEARCHGEQ, pxSearchNext=3};
  70.  
  71. // Modes for BLOB open.
  72.  
  73. enum PXBlobOpenMode {pxBlobRead = 0, pxBlobWrite};
  74.  
  75. // Values for a cursor's status.  
  76.  
  77. enum PXCursorStatus {atRecord = 0, atBegin, atEnd, atCrack}; 
  78.  
  79. // Environment structure for specifying engine's parameters.   
  80.  
  81. class _CLASSTYPE BEnv { 
  82. public:
  83.   BEngineType   engineType;
  84.   int           bufSize;
  85.   int           maxTables;
  86.   int           maxRecBufs;
  87.   int           maxLocks;
  88.   int           maxFiles;
  89.   PXSortOrder   sortOrder;
  90.   PXTabCrtMode  tabCrtMode;
  91.  
  92.   // Fields relevant for Engine operation in network mode.
  93.  
  94.   PXDosShare    dosShare;
  95.   char          netNamePath[MAXPATHLEN+1];
  96.   char          userName[MAXNAMELEN+1];
  97.   PXTblLckMode  tabLckMode;
  98.  
  99.   // Fields relevant for the Windows Paradox Engine.
  100.  
  101.   PXWinShare    winShare;
  102.   char          clientName[MAXNAMELEN+1];
  103.   DBIPATH       workingDirectory;
  104.   DBIPATH       initializationFile;
  105.   char          language[MAXNAMELEN+1];
  106.  
  107. // IDAPI
  108.   INT16         tblMaxSize;
  109.   char          reserved[18];       // Reserved for future use.
  110.  
  111.   BEnv() { memset(this,0,sizeof(BEnv)); }    // initialize to zeros 
  112.   
  113.   };
  114.                   
  115.  
  116. // Error code returned by most functions.
  117.  
  118. typedef DBIResult Retcode;
  119.  
  120. typedef unsigned    FIELDNUMBER;            // Field number; 1 .. N
  121. typedef hDBICur     TABLEHANDLE;            // Table handle
  122. typedef hDBIDb      DATABASEHANDLE;         // Handle to a database
  123. typedef UINT32      LOCKHANDLE;             // Lock handle
  124. typedef INT32       RECORDNUMBER;           // Record number; 1 .. N
  125. typedef pBYTE       RECORDHANDLE;           // Record handle
  126. typedef int         BLOBHANDLE;             // BLOB handle
  127. typedef pBYTE       BOOKMARK;               // Handle to a bookmark
  128.  
  129. // Field Description Structure.
  130.  
  131. enum PXFieldType
  132.     {
  133.     fldUnknown = 0, fldChar, fldDate, fldBlob, fldBool, fldShort, fldLong,
  134.     fldDouble, fldBcd, fldCharIdapi, fldTime, fldTimeStamp, fldUInt16,
  135.     fldUInt32, fldFloatIEEE, fldVarBytes, fldLockInfo
  136.     };
  137.  
  138. enum PXFieldSubtype
  139.     {
  140.     fldstNone = 0, fldstPassword = 1, fldstMoney=21, fldstMemo=22,
  141.     fldstBinary=23,  fldstFmtMemo=24, fldstOleObj=25, fldstGraphic=26,
  142.     fldstDBSoleObj=27, fldstTypedBinary=28
  143.     };
  144.     
  145. typedef struct {
  146.   FIELDNUMBER    fldNum;                // Field number (1..n).
  147.   char           fldName[MAXNAMELEN+1]; // Null-terminated field name.
  148.   PXFieldType    fldType;               // Field type.
  149.   PXFieldSubtype fldSubtype;            // Field Subtype.
  150.   int            fldLen;                // Field Length; for BLOBs;
  151.                                         // the header length.
  152.   char           reserved[20];          // For future use.
  153.   } FieldDesc;
  154.  
  155.  
  156. // A custom record's field and map definition structure. Used in custom
  157. // record subclasses of BRecord.    
  158.  
  159. typedef struct 
  160.   { 
  161.   int           useCnt;      // Number of instances using this descriptor.          
  162.   int           fieldCnt;    // Count of fields in the custom record.
  163.   FieldDesc     far *desc;   // Descriptor array for custom record's fields 
  164.   FIELDNUMBER  *tblFldNbr;   // Array maps custom record field numbers 
  165.                              // to table's fields. Elements that don't  
  166.                              // have a corresponding table field must 
  167.                              // be set to 0.                                                                               
  168.   } CRFldMapdef; 
  169.  
  170.  
  171. // Default Date structure.
  172. typedef struct  {
  173.   int     year;   
  174.   char    month;  
  175.   char    day;
  176. } BDate;
  177.  
  178. typedef struct  {
  179.   UINT16  hour;
  180.   UINT16  minute;
  181.   UINT16  milSec;
  182. } BTime; 
  183.  
  184. typedef struct  {
  185.   BDate BDay;
  186.   BTime BHour;
  187. } BTimeStamp;
  188.  
  189. typedef struct {
  190.   UINT16    valChkCount;
  191.   pCROpType cropType;
  192.   pVCHKDesc vchkDesc;
  193.   } ValidityDesc;
  194.  
  195. typedef struct {
  196.   UINT16    rintCount;
  197.   pCROpType cropType;
  198.   pRINTDesc rintDesc;
  199.   } RefDesc;
  200.  
  201.  
  202. // the _CLASSTYPE macro is Borland C++ specific. It ensures
  203. // proper declaration of the DBF classes for use in a DLL.
  204. // For Microsoft C++, it is #defined to nothing at the top
  205. // of this header file.
  206.  
  207. class _CLASSTYPE BDbObject;
  208. class _CLASSTYPE BEngine;
  209. class _CLASSTYPE BDatabase;
  210. class _CLASSTYPE BCursor;
  211. class _CLASSTYPE BRecord;
  212. class _CLASSTYPE BStatement;
  213.  
  214. // The following error definitions are copied from PXENGINE.H. They
  215. // are included here so that the Database Framework programmer does 
  216. // not have to include PXENGINE.H. 
  217.  
  218. #ifndef PXSUCCESS
  219. #define PXSUCCESS DBIERR_NONE 
  220.  
  221. // initialization errors
  222.  
  223. #define PXERR_NOTINITERR        DBIERR_NOTINITIALIZED    // Engine not initialized
  224. #define PXERR_ALREADYINIT       DBIERR_MULTIPLEINIT    // Engine already initialized
  225. #define PXERR_NOTLOGGEDIN       98   // Could not login on network (to PARADOX.NET)
  226. #define PXERR_NONETINIT        107   // Engine not initialized with PXNetInit
  227. #define PXERR_NETMULTIPLE       DBIERR_NETMULTIPLE    // multiple PARADOX.NET files
  228. #define PXERR_CANTSHAREPDOXNET 134   // can't lock PARADOX.NET -- is SHARE.EXE loaded?
  229. #define PXERR_WINDOWSREALMODE  135   // can't run Engine in Windows real mode
  230.  
  231.  
  232. // hardware related errors
  233.  
  234. #define PXERR_DRIVENOTREADY     1    // Drive not ready
  235. #define PXERR_DISKWRITEPRO      124  // Disk is write protected
  236. #define PXERR_GENERALFAILURE    126  // General hardware error
  237.  
  238.  
  239. // directory reg error codes
  240.  
  241. #define PXERR_DIRNOTFOUND       DBIERR_INVALIDDIR   // Directory not found
  242. #define PXERR_DIRBUSY           DBIERR_DIRBUSY   // Sharing violation
  243. #define PXERR_DIRLOCKED         DBIERR_DIRLOCKED   // Sharing violation
  244. #define PXERR_DIRNOACCESS       DBIERR_DIRNOACCESS   // No access to directory
  245. #define PXERR_DIRNOTPRIVATE     DBIERR_DIRNOTPRIVATE    // Single user, but directory is shared
  246.  
  247.  
  248. // file oriented errors
  249.  
  250. #define PXERR_FILEBUSY          DBIERR_FILEBUSY    // File is busy
  251. #define PXERR_FILELOCKED        DBIERR_LOCKED    // File is locked
  252. #define PXERR_FILENOTFOUND      DBIERR_NOSUCHTABLE    // Could not find file
  253.  
  254.  
  255. // table oriented errors
  256.  
  257. #define PXERR_TABLEBUSY        DBIERR_FILEBUSY    // Table is busy
  258. #define PXERR_TABLELOCKED      DBIERR_LOCKED   // Table is locked
  259. #define PXERR_TABLENOTFOUND    DBIERR_NOSUCHTABLE   // Table was not found
  260. #define PXERR_TABLEOPEN        DBIERR_TABLEOPEN    // Unable to perform operation on open table
  261. #define PXERR_TABLEINDEXED     DBIERR_NOTINDEXED   // Table is indexed
  262. #define PXERR_TABLENOTINDEXED  DBIERR_NOTINDEXED     // Table is not indexed
  263. #define PXERR_TABLEEMPTY       DBIERR_INVALIDTABLE    // Operation on empty table
  264. #define PXERR_TABLEWRITEPRO    DBIERR_TABLEREADONLY   // Table is write protected
  265. #define PXERR_TABLEPRE40       DBIERR_BADFORMAT    // Feature not available for pre Paradox 4.0 tables
  266.  
  267. #define PXERR_TABLECORRUPTED   DBIERR_FILECORRUPT   // Table is corrupted
  268. #define PXERR_TABLEFULL        DBIERR_TABLEFULL  // Table is full
  269. #define PXERR_TABLESQL         DBIERR_TABLESQL   // Table is SQL replica
  270. #define PXERR_INSUFRIGHTS      DBIERR_NOTSUFFTABLERIGHTS    // Insufficient password rights
  271. #define PXERR_CANTUPGRADE       92   // Table too old to upgrade, or
  272.                                      // existing table header too small.
  273. #define PXERR_LOCKTIMEOUT      DBIERR_LOCKTIMEOUT  // Timed out trying to achieve a lock.
  274.  
  275.  
  276. // index oriented errors
  277.  
  278. #define PXERR_XCORRUPTED        DBIERR_INDEXCORRUPT     // Primary index is corrupted
  279. #define PXERR_XOUTOFDATE        DBIERR_INDEXOUTOFDATE     // Primary index is out of date
  280. #define PXERR_XSORTVERSION      DBIERR_DIFFSORTORDER   // Sort for index different from table
  281.  
  282. #define PXERR_SXCORRUPTED       DBIERR_INDEXCORRUPT   // Secondary index is corrupted
  283. #define PXERR_SXOUTOFDATE       DBIERR_INDEXOUTOFDATE    // Secondary index is out of date
  284. #define PXERR_SXNOTFOUND        DBIERR_NOSUCHINDEX  // Secondary index was not found
  285. #define PXERR_SXOPEN            DBIERR_INDEXOPEN    // Not used-here for backwards compatability
  286. #define PXERR_SXCANTUPDATE      136                 // Can't update table open on non-maintained secondary
  287.  
  288. #define PXERR_RECTOOBIG         DBIERR_RECTOOBIG   // Record too big for index
  289.  
  290.  
  291. // record oriented errors
  292.  
  293. #define PXERR_RECDELETED       DBIERR_RECDELETED   // Another user deleted record
  294. #define PXERR_RECLOCKED        DBIERR_ALREADYLOCKED   // Record is locked
  295. #define PXERR_RECNOTFOUND      DBIERR_RECNOTFOUND   // Record was not found
  296. #define PXERR_KEYVIOL          DBIERR_KEYVIOL   // Key violation
  297.  
  298. #define PXERR_ENDOFTABLE       DBIERR_EOF   // End of table
  299. #define PXERR_STARTOFTABLE     DBIERR_BOF   // Start of table
  300.  
  301.  
  302. // errors specific for Windows Engine DLL
  303.  
  304. #define PXERR_TOOMANYCLIENTS        DBIERR_CLIENTSLIMIT
  305.     // Check mapping
  306. #define PXERR_EXCEEDSCONFIGLIMITS   DBIERR_INVALIDCFGPARAM
  307. #define PXERR_CANTREMAPFILEHANDLE   DBIERR_INVALIDHNDL
  308.  
  309.  
  310. // resource errors
  311.  
  312. #define PXERR_OUTOFMEM          DBIERR_NOMEMORY   // Not enough memory to complete operation
  313. #define PXERR_OUTOFDISK         DBIERR_NODISKSPACE   // Not enough disk space to complete operation
  314. #define PXERR_OUTOFSTACK        DBIERR_NOMEMORY   // Not enough stack space to complete operation
  315. #define PXERR_OUTOFSWAPBUF      DBIERR_NOMEMORY   // Not enough swap buffer space to complete operation
  316.  
  317. #define PXERR_OUTOFFILEHANDLES  DBIERR_NOFILEHANDLES   // No more file handles available
  318. #define PXERR_OUTOFTABLEHANDLES DBIERR_CURSORLIMIT   // No more table handles available
  319. #define PXERR_OUTOFRECHANDLES   DBIERR_NOMEMORY   // No more record handles available
  320. #define PXERR_OUTOFLOCKHANDLES  DBIERR_LOCKFILELIMIT   // Too many locks on table
  321.  
  322. #define PXERR_NOMORETMPNAMES    ERRCODE_NOTEMPTBLSPACE   // No more temporary names available
  323. #define PXERR_TOOMANYPASSW      DBIERR_PASSWORDLIMIT   // Too many passwords specified
  324.  
  325.  
  326. // invalid parameters to functions
  327.  
  328. #define PXERR_TYPEMISMATCH      30   // Data type mismatch
  329. #define PXERR_OUTOFRANGE        DBIERR_OUTOFRANGE   // Argument out of range
  330. #define PXERR_INVPARAMETER      DBIERR_INVALIDPARAM   // Invalid argument
  331. #define PXERR_INVDATE           DBIERR_INVALIDDATE   // Invalid date given
  332.  
  333. #define PXERR_INVFIELDHANDLE    DBIERR_INVALIDHNDL   // Invalid field handle
  334. #define PXERR_INVRECHANDLE      DBIERR_INVALIDHNDL   // Invalid record handle
  335. #define PXERR_INVTABLEHANDLE    DBIERR_INVALIDHNDL   // Invalid table handle
  336. #define PXERR_INVLOCKHANDLE     DBIERR_INVALIDHNDL   // Invalid lock handle
  337.  
  338. #define PXERR_INVDIRNAME        DBIERR_INVALIDDIR   // Invalid directory name
  339. #define PXERR_INVFILENAME       DBIERR_INVALIDFILENAME   // Invalid file name
  340. #define PXERR_INVTABLENAME      DBIERR_INVALIDTABLENAME  // Invalid table name
  341. #define PXERR_INVFIELDNAME      DBIERR_INVALIDFIELDNAME   // Invalid field name
  342.  
  343. #define PXERR_INVLOCKCODE      106   // Invalid lock code
  344. #define PXERR_INVUNLOCK         DBIERR_UNLOCKFAILED   // Invalid unlock
  345. #define PXERR_INVSORTORDER      DBIERR_DIFFSORTORDER   // Invalid sort order table
  346. #define PXERR_INVPASSW          DBIERR_INVALIDPASSWORD   // Invalid password
  347. #define PXERR_INVNETTYPE        DBIERR_UNKNOWNNETTYPE   // Invalid net type (PXNetInit)
  348. #define PXERR_BUFTOOSMALL       DBIERR_BUFFTOOSMALL   // Buffer too small for result
  349.  
  350. #define PXERR_STRUCTDIFFER      DBIERR_DIFFERENTTABLES   // Table structures are different
  351.  
  352. #define PXERR_INVENGINESTATE    79   // Previous fatal error; cannot proceed
  353.  
  354.  
  355. // Blob error codes
  356.  
  357. #define PXERR_BLOBMODE           51     // Operation not applicable for Blob's
  358.                                         // open mode.
  359. #define PXERR_BLOBOPEN           DBIERR_BLOBOPENED     // Blob already open.
  360. #define PXERR_BLOBINVOFFSET      DBIERR_INVALIDBLOBOFFSET     // Invalid offset into Blob.
  361. #define PXERR_BLOBINVSIZE        DBIERR_INVALIDBLOBLEN     // Invalid size for Blob.
  362. #define PXERR_BLOBMODIFIED       DBIERR_BLOBMODIFIED     // Another user modified Blob.
  363. #define PXERR_BLOBCORRUPT        DBIERR_MEMOCORRUPT      // Blob file corrupted.
  364. #define PXERR_BLOBNOINDEX        DBIERR_INVALIDINDEXCREATE     // Cannot index on a Blob.
  365. #define PXERR_BLOBINVHANDLE      DBIERR_INVALIDBLOBHANDLE     // Invalid Blob handle.
  366. #define PXERR_BLOBNOSEARCH       60     // Can't search on a Blob field.
  367.  
  368.  
  369. // Locking related error codes
  370.  
  371. #define PXERR_INUSEBYPDOX35      16     // Directory is in use by Paradox 3.5
  372.                                         // or Paradox Engine 2.0
  373.  
  374. #endif 
  375.  
  376. // Database Framework function that returns the error message 
  377. // corresponding to an error number.
  378.  
  379. char far *pascal far PXOopErrMsg(Retcode errCode);
  380.  
  381. // Database Framework errors.
  382.  
  383. #define PXERR_INVENGINETYPE     400
  384. #define PXERR_ENGINEOPEN        401
  385. #define PXERR_ENGINENOTOPEN     402
  386. #define PXERR_DBALREADYOPEN     403
  387. #define PXERR_DBNOTOPEN         404
  388. #define PXERR_CURSORALREADYOPEN 405
  389. #define PXERR_CURSORNOTOPEN     406
  390. #define PXERR_RECALREADYATT     407
  391. #define PXERR_RECNOTATT         408
  392. #define PXERR_INVFIELDTYPE      409
  393. #define PXERR_INVCURRRECORD     410
  394. #define PXERR_TABLESDIFFER      411
  395. #define PXERR_INVKEYCOUNT       412  
  396. #define PXERR_NOKEYMAP          413
  397. #define PXERR_NOCLEARNULL       414 
  398. #define PXERR_DATACONV          415
  399. #define PXERR_BLOBNOTOPEN       DBIERR_BLOBNOTOPENED
  400. #define PXERR_STATEMENTOPEN     417
  401. #define PXERR_STATEMENTNOTOPEN  418
  402.  
  403. // GENERATE Utility Errors 
  404.  
  405. #define PXERR_INCOMPLETESPEC    501 
  406. #define PXERR_NOSPECFILE        502
  407. #define PXERR_INVOPTION         503
  408. #define PXERR_CANTCREATEFILE    504
  409. #define PXERR_NOLEFTPAREN       505
  410. #define PXERR_NOCOMMAORRP       506 
  411. #define PXERR_INVCHARLEN        507 
  412. #define PXERR_INVTYPEWARN       508 
  413.  
  414. #endif
  415.