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

  1. /*********************************************************************
  2. **
  3. **                    BENGINE.CPP
  4. **
  5. ** Implement functions of the BEngine class.
  6. **
  7. *********************************************************************/
  8.  
  9. // DBF - (C) Copyright 1994 by Borland International
  10.  
  11. #include "kdbf.h"
  12. #pragma hdrstop
  13.  
  14. // Constructor. Makes a C++ BEngine object without opening IDAPI
  15.  
  16. BEngine::BEngine()
  17. {
  18.     isOpen = FALSE;
  19.     engineType = pxLocal;
  20.     lastError = DBIERR_NONE;
  21.     engdef *eo = 0;
  22.  
  23.     try
  24.     {
  25.         eo = new engdef;           // See the INTSTRCT.H file.
  26.  
  27.         eo->engenv.engineType   = pxLocal;
  28.         eo->engenv.tabCrtMode   = px50Fmt;
  29.         eo->engenv.dosShare     = pxLocalShare;
  30.         eo->engenv.tabLckMode   = px40Lck;
  31.         eo->engenv.tblMaxSize   = 2048;
  32.         eo->handleCnt           = 0;
  33.         eo->compIdxCnt          = 0;
  34.         engobj = (void *) eo;
  35.     }
  36.     catch(xalloc)
  37.     {
  38.         lastError = DBIERR_NOMEMORY;
  39.         return;
  40.     }
  41. }
  42.  
  43. //  This constructor makes a BEngine object and actually opens the
  44. //  Paradox engine in the requested mode.
  45.  
  46. BEngine::BEngine(BEngineType eType)
  47. {
  48.     isOpen = FALSE;
  49.     engdef *eo = 0;
  50.  
  51.     try
  52.     {
  53.         eo = new engdef;          // See the INTSTRCT.H file.
  54.     }
  55.     catch(xalloc)
  56.     {
  57.         lastError = DBIERR_NOMEMORY;
  58.         return;
  59.     }
  60.     eo->engenv.engineType       = eType;
  61.     eo->engenv.tabCrtMode       = px50Fmt;
  62.     eo->engenv.dosShare         = pxLocalShare;
  63.     eo->engenv.tabLckMode       = px40Lck;
  64.     eo->engenv.winShare         = pxShared;
  65.     eo->engenv.tblMaxSize       = 2048;
  66.     eo->engenv.netNamePath[0]   = eo->engenv.userName[0]
  67.                                 = eo->engenv.clientName[0]
  68.                                 = 0;
  69.     eo->handleCnt               = 0;
  70.     eo->compIdxCnt              = 0;
  71.     engobj = (void *) eo;
  72.     switch (eType)
  73.     {
  74.         case pxWin:             
  75. #ifdef WINDOWS
  76.             engineType = pxWin;
  77.             if ((lastError = DbiInit(NULL)) != DBIERR_NONE)
  78.             {
  79.                 return;
  80.             }
  81.             break;
  82. #else
  83.             lastError = PXERR_INVENGINETYPE;
  84.             return;
  85. #endif 
  86.         case pxNet:
  87. #ifdef WINDOWS
  88.             lastError = PXERR_INVENGINETYPE;
  89.             return;
  90. #else
  91.             lastError = DBIERR_NOTSUPPORTED;
  92.             return;
  93. #endif
  94.         case pxLocal:
  95. #ifdef WINDOWS
  96.             lastError = PXERR_INVENGINETYPE;
  97.             return;
  98. #else
  99.             lastError = DBIERR_NOTSUPPORTED;
  100.             return;
  101.         #endif
  102.     default:
  103.       lastError = PXERR_INVENGINETYPE;
  104.       return;
  105.   }
  106.   isOpen = TRUE;
  107.   lastError = DbiDebugLayerOptions(DEBUGON | OUTPUTTOFILE, "DBF.DBG");
  108. }
  109.  
  110.  
  111. // Make an engine object and open it based on the specified 
  112. // environment.  
  113. BEngine::BEngine(const BEnv& env)
  114. {
  115.     lastError = DBIERR_NONE;
  116.     isOpen = FALSE;
  117.     engdef *eo = 0;
  118.  
  119.     try
  120.     {
  121.         eo = new engdef;          // See the INTSTRCT.H file.
  122.     }
  123.     catch(xalloc)
  124.     {
  125.         lastError = DBIERR_NOMEMORY;
  126.         return;
  127.     }
  128.     eo->handleCnt = 0;
  129.     eo->compIdxCnt = 0;
  130.     engobj = (void *) eo;
  131.     engineType = env.engineType;
  132.     setDefaults(env);
  133.     open();
  134. }
  135.  
  136. // Destructor; Closes IDAPI if it's open.
  137.  
  138. BEngine::~BEngine()
  139. {
  140.     close();
  141.     engdef *eo  = (engdef *)engobj;
  142.     if (eo)
  143.     {
  144.         // Reset pointers in any dependent database objects.
  145.         for (int i=0; i < eo->handleCnt; i++)
  146.         {
  147.             if (eo->dbList[i])
  148.             {
  149.                 ((dbdef *)eo->dbList[i]->dbobj)->engH = 0;
  150.             }
  151.         }
  152.         if (eo->handleCnt)
  153.         {
  154.             delete [] eo->dbList;
  155.             eo->dbList = 0;
  156.         }
  157.  
  158.         delete eo;
  159.         eo = 0;
  160.     }
  161. }
  162.  
  163. // Set default values for the Engine's resource parameters.
  164.  
  165. Retcode BEngine::setDefaults(const BEnv &env)
  166. {
  167.     BEnv &senv = ((engdef *) engobj)->engenv;
  168.  
  169.     senv = env;
  170.  
  171.     lastError = DBIERR_NONE;
  172.  
  173.     return lastError;
  174. }
  175.  
  176. // Open the engine based on a previously set environment.
  177. // The engine is opened in Local, Network or Windows mode
  178. // based on the value of engineType.
  179.  
  180. Retcode BEngine::open(void)
  181. {
  182.     BEnv &senv = ((engdef *) engobj)->engenv;
  183.  
  184.     if (isOpen)
  185.     {
  186.         return (lastError = PXERR_ENGINEOPEN);
  187.     }
  188.  
  189.     switch (senv.engineType)
  190.     {
  191.         case pxWin:
  192. #ifdef WINDOWS
  193.             if ((lastError = DbiInit(NULL)) != DBIERR_NONE)
  194.             {
  195.                 return lastError;
  196.             }
  197.             break;
  198. #else
  199.             return (lastError = PXERR_INVENGINETYPE);
  200. #endif
  201.         case pxNet:
  202. #ifdef WINDOWS
  203.             return (lastError = PXERR_INVENGINETYPE);
  204. #else
  205.             lastError = DBIERR_NOTSUPPORTED;
  206.             return lastError;
  207. #endif
  208.         case pxLocal:
  209. #ifdef WINDOWS
  210.             return (lastError = PXERR_INVENGINETYPE);
  211. #else
  212.             if ((lastError = DbiInit(NULL)) != DBIERR_NONE)
  213.             {
  214.                 return lastError;
  215.             }
  216.             break;
  217. #endif
  218.         default:
  219.             return (lastError = PXERR_INVENGINETYPE);
  220.     }
  221.  
  222.     isOpen = TRUE;
  223.     DbiDebugLayerOptions(DEBUGON | OUTPUTTOFILE, "DBF.DBG");
  224.     setTblCreateMode(senv.tabCrtMode);
  225.     return (lastError = DBIERR_NONE);
  226. }
  227.  
  228. // Shut down the currently open engine and close all databases.
  229.  
  230. Retcode BEngine::close(void)
  231. {
  232.     // Close all open databases.
  233.  
  234.     engdef *eo = (engdef *) engobj;
  235.     for (int i=0; i < eo->handleCnt; i++)
  236.     {
  237.         if (eo->dbList[i]  && eo->dbList[i]->isOpen)
  238.         {
  239.             if ((lastError = eo->dbList[i]->close())   // Close database.
  240.                 != DBIERR_NONE)
  241.             {
  242.                 return (lastError);
  243.             }
  244.         }
  245.     }
  246.     for (i = 0; i < eo->compIdxCnt; i++) // Delete compound key
  247.     {                          // map information.
  248.         delete eo->keymap[i].tableName;
  249.         eo->keymap[i].tableName = 0;
  250.         delete [] eo->keymap[i].fieldArray;
  251.         eo->keymap[i].fieldArray = 0;
  252.     }
  253.     if (eo->compIdxCnt)
  254.     {
  255.         delete [] eo->keymap;
  256.         eo->keymap = 0;
  257.     }
  258.     eo->compIdxCnt = 0;
  259.     if (isOpen)
  260.     {
  261.         DbiDebugLayerOptions(0, NULL);
  262.         if ((lastError = DbiExit()) != DBIERR_NONE)
  263.         {
  264.             return lastError;
  265.         }
  266.     }
  267.     else
  268.     {
  269.         lastError = PXERR_ENGINENOTOPEN;
  270.     }
  271.     isOpen = FALSE;
  272.     return lastError;
  273. }
  274.  
  275. // Get the current values for various engine parameters.
  276.  
  277. void BEngine::getDefaults(BEnv &env) const
  278. {
  279.     env = ((engdef *)engobj)->engenv;
  280. }
  281.  
  282. // Enable or Disable the internal hardware error handler.
  283.  
  284. #pragma argsused
  285. Retcode BEngine::setHWHandler(BOOL ehEnable)
  286. {
  287.     lastError = DBIERR_NOTSUPPORTED;
  288.     return lastError;
  289. }
  290.  
  291. // Add a password
  292.  
  293. Retcode BEngine::addPassword(char *password)
  294. {
  295.     if (!isOpen)
  296.     {
  297.         return (lastError = PXERR_ENGINENOTOPEN);
  298.     }
  299.     lastError = DbiAddPassword(password);
  300.     return lastError;
  301. }
  302.  
  303. // Set the maximum size of tables you can create.
  304.  
  305. Retcode BEngine::setMaxTblSize(int maxSize)
  306. {
  307.     if (!isOpen)
  308.     {
  309.         return (lastError = PXERR_ENGINENOTOPEN);
  310.     }
  311.     ((engdef *)engobj)->engenv.tblMaxSize = maxSize;
  312.     lastError = DBIERR_NONE;
  313.     return lastError;
  314. }
  315.  
  316. // Choose the table format
  317. Retcode BEngine::setTblCreateMode(PXTabCrtMode crtMode)
  318. {
  319.     if (!isOpen)
  320.     {
  321.         return (lastError = PXERR_ENGINENOTOPEN);
  322.     }
  323.  
  324.     ((engdef *)engobj)->engenv.tabCrtMode = crtMode;
  325.     lastError = DBIERR_NONE;
  326.     return lastError;
  327. }  
  328.  
  329. // Remove a previously entered password.
  330. Retcode BEngine::deletePassword(char *password)
  331. {
  332.     if (!isOpen)
  333.     {
  334.         return (lastError = PXERR_ENGINENOTOPEN);
  335.     }
  336.     lastError = DbiDropPassword(password);
  337.     return lastError;
  338. }
  339.  
  340. // Get the error message corresponding to an error.  
  341.  
  342. char far *BEngine::getErrorMessage(int errnbr)
  343. {
  344.     return (PXOopErrMsg(errnbr));
  345. }
  346.  
  347. Retcode BEngine::getErrorContext(INT16 context, char far *message)
  348. {
  349.     if (!isOpen)
  350.     {
  351.         lastError = PXERR_ENGINENOTOPEN;
  352.         return 0;
  353.     }
  354.     lastError = DbiGetErrorContext(context, message);
  355.     
  356.     return lastError;
  357. }
  358.  
  359. Retcode BEngine::getErrorEntry(UINT16 entry, UINT32 &nativeCode,
  360.                                char far *message)
  361. {
  362.     if (!isOpen)
  363.     {
  364.         lastError = PXERR_ENGINENOTOPEN;
  365.         return 0;
  366.     }
  367.     lastError = DbiGetErrorEntry(entry, &nativeCode, message);
  368.     
  369.     return lastError;
  370. }
  371.  
  372. Retcode BEngine::GetErrorInfo(DBIErrInfo &errorInfo)
  373. {
  374.     if (!isOpen)
  375.     {
  376.         lastError = PXERR_ENGINENOTOPEN;
  377.         return 0;
  378.     }
  379.  
  380.     lastError = DbiGetErrorInfo(TRUE, &errorInfo);
  381.  
  382.     return lastError;
  383. }
  384.  
  385.  
  386. // Return the name of the user in a shared environment.
  387. char *BEngine::getUsername(void)
  388. {
  389.     if (!isOpen)
  390.     {
  391.         lastError = PXERR_ENGINENOTOPEN;
  392.         return NULL;
  393.     }
  394.     engdef *eo = (engdef *) engobj;
  395.     if ((lastError = DbiGetNetUserName(eo->engenv.userName)) == DBIERR_NONE)
  396.     {
  397.         return eo->engenv.userName;
  398.     }
  399.     else
  400.     {
  401.         return 0;
  402.     }
  403. }
  404.  
  405. // Note - sessions are not fully integrated into the KDBF. Make certain to
  406. //        explicitly close any child objects associated with the session
  407. //        before closing a given session.
  408.  
  409. hDBISes BEngine::getHandle(void)
  410. {
  411.     hDBISes temp;
  412.  
  413.     getCurrSession(temp);
  414.  
  415.     return temp;
  416. }
  417.  
  418. Retcode BEngine::startSession(hDBISes &sessionHandle, const char *netFile)
  419. {
  420.     if (!isOpen)
  421.     {
  422.         lastError = PXERR_ENGINENOTOPEN;
  423.         return lastError;
  424.     }
  425.  
  426.     lastError = DbiStartSession(NULL, &sessionHandle, (pCHAR)netFile);
  427.  
  428.     return lastError;
  429. }
  430.  
  431. Retcode BEngine::getCurrSession(hDBISes &sessionHandle)
  432. {
  433.     if (!isOpen)
  434.     {
  435.         lastError = PXERR_ENGINENOTOPEN;
  436.         return lastError;
  437.     }
  438.  
  439.     lastError = DbiGetCurrSession(&sessionHandle);
  440.  
  441.     return lastError;
  442. }
  443.  
  444. Retcode BEngine::setCurrSession(hDBISes &sessionHandle)
  445. {
  446.     if (!isOpen)
  447.     {
  448.         lastError = PXERR_ENGINENOTOPEN;
  449.         return lastError;
  450.     }
  451.  
  452.     lastError = DbiSetCurrSession(sessionHandle);
  453.  
  454.     return lastError;
  455. }
  456.  
  457. Retcode BEngine::closeSession(hDBISes &sessionHandle)
  458. {
  459.     if (!isOpen)
  460.     {
  461.         lastError = PXERR_ENGINENOTOPEN;
  462.         return lastError;
  463.     }
  464.  
  465.     lastError = DbiCloseSession(sessionHandle);
  466.  
  467.     return lastError;
  468. }
  469.  
  470. Retcode BEngine::getSessionInfo(SESInfo &sessionInfo)
  471. {
  472.     if (!isOpen)
  473.     {
  474.         lastError = PXERR_ENGINENOTOPEN;
  475.         return lastError;
  476.     }
  477.  
  478.     lastError = DbiGetSesInfo(&sessionInfo);
  479.  
  480.     return lastError;
  481. }
  482.  
  483. Retcode BEngine::setPrivateDir(const char *Directory)
  484. {
  485.     if (!isOpen)
  486.     {
  487.         lastError = PXERR_ENGINENOTOPEN;
  488.         return lastError;
  489.     }
  490.  
  491.     lastError = DbiSetPrivateDir((pCHAR)Directory);
  492.  
  493.     return lastError;
  494. }
  495.  
  496. // Get the private directory
  497.  
  498. Retcode BEngine::getPrivateDir(char *Directory)
  499. {
  500.     SESInfo sesInfo;
  501.     
  502.     if (!isOpen)
  503.     {
  504.         lastError = PXERR_ENGINENOTOPEN;
  505.         return lastError;
  506.     }
  507.  
  508.     lastError = DbiGetSesInfo(&sesInfo);
  509.  
  510.     if (lastError == DBIERR_NONE)
  511.     {
  512.         strcpy(Directory, sesInfo.szPrivDir);
  513.     }
  514.  
  515.     return lastError;
  516. }
  517.  
  518. Retcode BEngine::getSysVersion(UINT16 &version, UINT16 &interfaceLevel,
  519.                                DATE &versionDate, TIME &versionTime)
  520. {
  521.     SYSVersion sysVersion;
  522.  
  523.     if (!isOpen)
  524.     {
  525.         lastError = PXERR_ENGINENOTOPEN;
  526.         return lastError;
  527.     }
  528.  
  529.     lastError = DbiGetSysVersion(&sysVersion);
  530.  
  531.     version = sysVersion.iVersion;
  532.     interfaceLevel = sysVersion.iIntfLevel;
  533.     versionDate = sysVersion.dateVer;
  534.     versionTime = sysVersion.timeVer;
  535.  
  536.     return lastError;
  537. }
  538.  
  539. Retcode BEngine::getSysConfig(BOOL   &localShare,
  540.                               UINT16 &netProtocol,
  541.                               BOOL   &netShare,
  542.                               CHAR   *netType,
  543.                               CHAR   *userName,
  544.                               CHAR   *iniFile,
  545.                               CHAR   *langDriver)
  546. {
  547.     SYSConfig configInfo;
  548.  
  549.     if (!isOpen)
  550.     {
  551.         lastError = PXERR_ENGINENOTOPEN;
  552.         return lastError;
  553.     }
  554.  
  555.     lastError = DbiGetSysConfig(&configInfo);
  556.  
  557.     localShare  = configInfo.bLocalShare;
  558.     netProtocol = configInfo.iNetProtocol;
  559.     netShare    = configInfo.bNetShare;
  560.     strcpy(netType, configInfo.szNetType);
  561.     strcpy(userName, configInfo.szUserName);
  562.     strcpy(iniFile, configInfo.szIniFile);
  563.     strcpy(langDriver, configInfo.szLangDriver);
  564.  
  565.     return lastError;
  566. }
  567.  
  568. Retcode BEngine::getClientInfo(CHAR   *name,
  569.                                UINT16 &sessions,
  570.                                CHAR   *workingDirectory,
  571.                                CHAR   *language)
  572. {
  573.     CLIENTInfo clientInfo;
  574.  
  575.     if (!isOpen)
  576.     {
  577.         lastError = PXERR_ENGINENOTOPEN;
  578.         return lastError;
  579.     }
  580.  
  581.     lastError = DbiGetClientInfo(&clientInfo);
  582.  
  583.     strcpy(name, clientInfo.szName);
  584.     sessions = clientInfo.iSessions;
  585.     strcpy(workingDirectory, clientInfo.szWorkDir);
  586.     strcpy(language, clientInfo.szLang);
  587.  
  588.     return lastError;
  589. }
  590.  
  591. Retcode BEngine::getSysInfo(UINT16 &bufferSpace,
  592.                             UINT16 &heapSpace,
  593.                             UINT16 &drivers,
  594.                             UINT16 &clients,
  595.                             UINT16 &sessions,
  596.                             UINT16 &databases,
  597.                             UINT16 &cursors)
  598. {
  599.     SYSInfo sysInfo;
  600.  
  601.     if (!isOpen)
  602.     {
  603.         lastError = PXERR_ENGINENOTOPEN;
  604.         return lastError;
  605.     }
  606.  
  607.     lastError = DbiGetSysInfo(&sysInfo);
  608.  
  609.     bufferSpace = sysInfo.iBufferSpace;
  610.     heapSpace   = sysInfo.iHeapSpace;
  611.     drivers     = sysInfo.iDrivers;
  612.     clients     = sysInfo.iClients;
  613.     sessions    = sysInfo.iSessions;
  614.     databases   = sysInfo.iDatabases;
  615.     cursors     = sysInfo.iCursors;
  616.  
  617.     return lastError;
  618. }
  619.  
  620. Retcode BEngine::openDriverList(BListCursor<DRVType> &driverList)
  621. {
  622.     TABLEHANDLE tabH;
  623.  
  624.     if (!isOpen)
  625.     {
  626.         return (lastError = PXERR_ENGINENOTOPEN);
  627.     }
  628.  
  629.     lastError = DbiOpenDriverList(&tabH);
  630.     if (lastError != DBIERR_NONE)
  631.     {
  632.         return lastError;
  633.     }
  634.  
  635.     lastError = driverList.attach(tabH);
  636.  
  637.     return lastError;
  638. }
  639.  
  640. Retcode BEngine::openDatabaseList(BListCursor<DBDesc> &databaseList)
  641. {
  642.     TABLEHANDLE tabH;
  643.  
  644.     if (!isOpen)
  645.     {
  646.         return (lastError = PXERR_ENGINENOTOPEN);
  647.     }
  648.  
  649.     lastError = DbiOpenDatabaseList(&tabH);
  650.     if (lastError != DBIERR_NONE)
  651.     {
  652.         return lastError;
  653.     }
  654.  
  655.     lastError = databaseList.attach(tabH);
  656.  
  657.     return lastError;
  658. }
  659.  
  660. Retcode BEngine::openTableTypesList(BListCursor<TBLType> &tableTypesList,
  661.                                     const char *driver)
  662. {
  663.     TABLEHANDLE tabH;
  664.  
  665.     if (!isOpen)
  666.     {
  667.         return (lastError = PXERR_ENGINENOTOPEN);
  668.     }
  669.  
  670.     lastError = DbiOpenTableTypesList((pCHAR)driver, &tabH);
  671.     if (lastError != DBIERR_NONE)
  672.     {
  673.         return lastError;
  674.     }
  675.  
  676.     lastError = tableTypesList.attach(tabH);
  677.  
  678.     return lastError;
  679. }
  680.  
  681. Retcode BEngine::openFieldTypesList(BListCursor<FLDType> &fieldTypesList,
  682.                                     const char *driver,
  683.                                     const char *tableType)
  684. {
  685.     TABLEHANDLE tabH;
  686.  
  687.     if (!isOpen)
  688.     {
  689.         return (lastError = PXERR_ENGINENOTOPEN);
  690.     }
  691.  
  692.     lastError = DbiOpenFieldTypesList((pCHAR)driver, (pCHAR)tableType, &tabH);
  693.     if (lastError != DBIERR_NONE)
  694.     {
  695.         return lastError;
  696.     }
  697.  
  698.     lastError = fieldTypesList.attach(tabH);
  699.  
  700.     return lastError;
  701. }
  702.  
  703. Retcode BEngine::openIndexTypesList(BListCursor<IDXType> &indexTypesList,
  704.                                     const char *driver)
  705. {
  706.     TABLEHANDLE tabH;
  707.  
  708.     if (!isOpen)
  709.     {
  710.         return (lastError = PXERR_ENGINENOTOPEN);
  711.     }
  712.  
  713.     lastError = DbiOpenIndexTypesList((pCHAR)driver, &tabH);
  714.     if (lastError != DBIERR_NONE)
  715.     {
  716.         return lastError;
  717.     }
  718.  
  719.     lastError = indexTypesList.attach(tabH);
  720.  
  721.     return lastError;
  722. }
  723.  
  724. Retcode BEngine::openLanguageDriverList(BListCursor<LDDesc> &languageDriverList)
  725. {
  726.     TABLEHANDLE tabH;
  727.  
  728.     if (!isOpen)
  729.     {
  730.         return (lastError = PXERR_ENGINENOTOPEN);
  731.     }
  732.  
  733.     lastError = DbiOpenLdList(&tabH);
  734.     if (lastError != DBIERR_NONE)
  735.     {
  736.         return lastError;
  737.     }
  738.  
  739.     lastError = languageDriverList.attach(tabH);
  740.  
  741.     return lastError;
  742. }
  743.  
  744. Retcode BEngine::openUserList(BListCursor<USERDesc> &userList)
  745. {
  746.     TABLEHANDLE tabH;
  747.  
  748.     if (!isOpen)
  749.     {
  750.         return (lastError = PXERR_ENGINENOTOPEN);
  751.     }
  752.  
  753.     lastError = DbiOpenUserList(&tabH);
  754.     if (lastError != DBIERR_NONE)
  755.     {
  756.         return lastError;
  757.     }
  758.  
  759.     lastError = userList.attach(tabH);
  760.  
  761.     return lastError;
  762. }
  763.  
  764. Retcode BEngine::openCfgInfoList(BListCursor<CFGDesc> &cfgList,
  765.                                  const char *cfgPath,
  766.                                  hDBICfg cfgH,
  767.                                  DBIOpenMode openMode,
  768.                                  CFGMode cfgMode)
  769. {
  770.     TABLEHANDLE tabH;
  771.  
  772.     if (!isOpen)
  773.     {
  774.         return (lastError = PXERR_ENGINENOTOPEN);
  775.     }
  776.  
  777.     lastError = DbiOpenCfgInfoList(cfgH, openMode, cfgMode, (pCHAR)cfgPath,
  778.                                    &tabH);
  779.     if (lastError != DBIERR_NONE)
  780.     {
  781.         return lastError;
  782.     }
  783.  
  784.     lastError = cfgList.attach(tabH);
  785.  
  786.     return lastError;
  787. }
  788.  
  789. Retcode BEngine::useIdleTime(void)
  790. {
  791.     if (!isOpen)
  792.     {
  793.         return (lastError = PXERR_ENGINENOTOPEN);
  794.     }
  795.  
  796.     lastError = DbiUseIdleTime();
  797.  
  798.     return lastError;
  799. }
  800.  
  801. Retcode BEngine::registerCallBack(CBType callBackType, UINT32 clientData,
  802.                                   UINT16 callBackBufferLength,
  803.                                   pVOID callBackBuffer,
  804.                                   pfDBICallBack callBackFunction)
  805. {
  806.     if (!isOpen)
  807.     {
  808.         return (lastError = PXERR_ENGINENOTOPEN);
  809.     }
  810.  
  811.     lastError = DbiRegisterCallBack(NULL, callBackType, clientData,
  812.                                     callBackBufferLength, callBackBuffer,
  813.                                     callBackFunction);
  814.  
  815.     return lastError;
  816. }
  817.  
  818. Retcode BEngine::getCallBack(CBType callBackType, UINT32 &clientData,
  819.                              UINT16 &callBackBufferLength,
  820.                              ppVOID callBackBuffer,
  821.                              ppfDBICallBack callBackFunction)
  822. {
  823.     if (!isOpen)
  824.     {
  825.         return (lastError = PXERR_ENGINENOTOPEN);
  826.     }
  827.  
  828.     lastError = DbiGetCallBack(NULL, callBackType, &clientData,
  829.                                &callBackBufferLength, callBackBuffer,
  830.                                callBackFunction);
  831.  
  832.     return lastError;
  833. }
  834.  
  835. char * BEngine::nameOf() const
  836. {
  837.   return ("BEngine");
  838. }
  839.  
  840. void BEngine::printOn(ostream& os)
  841. {
  842.   os << nameOf() << "{ Engine Type = " << (int) engineType
  843.      << ", Open Status = " << (int) isOpen << "}\n";
  844. }
  845.  
  846. static void makeEngInst()
  847. {
  848.     BListCursor<USERDesc> bListUserDesc;
  849.     BListCursor<LDDesc> bListLdDesc;
  850.     BListCursor<IDXType> bListIdxType;
  851.     BListCursor<FLDType> bListFldType;
  852.     BListCursor<TBLType> bListTblType;
  853.     BListCursor<DBDesc> bListDbDesc;
  854.     BListCursor<DRVType> bListDrvType;
  855.     BListCursor<CFGDesc> bListCfgDesc;
  856. }
  857.