Changeset 2c813bc in tol


Ignore:
Timestamp:
Jun 3, 2013, 7:15:57 PM (13 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
27e16c6
Parents:
e4e21ee
Message:

refs #1692, implement the user functions GetDBMSName, GetDBMSVersion & GetDataBaseName

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@5901 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol/btol/bdb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/bdb/bdspool.cpp

    re4e21ee r2c813bc  
    332332
    333333  contens_ = dbClose(alias);
     334}
     335
     336//--------------------------------------------------------------------
     337DeclareContensClass(BText, BTxtTemporary, BTxtGetDBMSName);
     338DefExtOpr(1, BTxtGetDBMSName, "GetDBMSName", 1, 1, "Real", "(Real void)",
     339          I2("Return the name of the DBMS for the active connection",
     340             "Retorna el nombre del gestor para la conexión activa"),
     341          BOperClassify::BayesDataBase_);
     342//--------------------------------------------------------------------
     343void BTxtGetDBMSName::CalcContens()
     344//--------------------------------------------------------------------
     345{
     346  char buffer[256];
     347
     348  if (!dbGetDBMSName(buffer, 255))
     349    {
     350    buffer[0] = '\0';
     351    }
     352  contens_ = buffer;
     353}
     354
     355//--------------------------------------------------------------------
     356DeclareContensClass(BText, BTxtTemporary, BTxtGetDBMSVersion);
     357DefExtOpr(1, BTxtGetDBMSVersion, "GetDBMSVersion", 1, 1, "Real", "(Real void)",
     358          I2("Return the version of the DBMS for the active connection",
     359             "Retorna la versión del gestor para la conexión activa"),
     360          BOperClassify::BayesDataBase_);
     361//--------------------------------------------------------------------
     362void BTxtGetDBMSVersion::CalcContens()
     363//--------------------------------------------------------------------
     364{
     365  char buffer[256];
     366
     367  if (!dbGetDBMSVersion(buffer, 255))
     368    {
     369    buffer[0] = '\0';
     370    }
     371  contens_ = buffer;
     372}
     373
     374//--------------------------------------------------------------------
     375DeclareContensClass(BText, BTxtTemporary, BTxtGetDataBaseName);
     376DefExtOpr(1, BTxtGetDataBaseName, "GetDataBaseName", 1, 1, "Real", "(Real void)",
     377          I2("Return name of the data base for the active connection",
     378             "Retorna el nombre de la base de datos para la conexión activa"),
     379          BOperClassify::BayesDataBase_);
     380//--------------------------------------------------------------------
     381void BTxtGetDataBaseName::CalcContens()
     382//--------------------------------------------------------------------
     383{
     384  char buffer[256];
     385
     386  if (!dbGetDataBaseName(buffer, 255))
     387    {
     388    buffer[0] = '\0';
     389    }
     390  contens_ = buffer;
    334391}
    335392
  • tol/btol/bdb/dbtol.cpp

    re4e21ee r2c813bc  
    8585typedef void* (*dbOpen_fpt)(void**);
    8686typedef int (*dbClose_fpt)(void*);
     87typedef int (*dbGetDBMSName_fpt)(void*, char *, size_t);
     88typedef int (*dbGetDBMSVersion_fpt)(void*, char *, size_t);
     89typedef int (*dbGetDataBaseName_fpt)(void*, char *, size_t);
    8790typedef int (*dbOpenQuery_fpt)(void *, const char *);
    8891typedef int (*dbExecQuery_fpt)(void *, const char *);
    … …  
    108111  dbOpen_fpt dbOpen_fp;
    109112  dbClose_fpt dbClose_fp;
     113  dbGetDBMSName_fpt dbGetDBMSName_fp;
     114  dbGetDBMSVersion_fpt dbGetDBMSVersion_fp;
     115  dbGetDataBaseName_fpt dbGetDataBaseName_fp;
    110116  dbOpenQuery_fpt dbOpenQuery_fp;
    111117  dbExecQuery_fpt dbExecQuery_fp;
    … …  
    189195  FUNCTION_LOAD_DECLARATION(Open);
    190196  FUNCTION_LOAD_DECLARATION(Close);
     197  FUNCTION_LOAD_DECLARATION(GetDBMSName);
     198  FUNCTION_LOAD_DECLARATION(GetDBMSVersion);
     199  FUNCTION_LOAD_DECLARATION(GetDataBaseName);
    191200  FUNCTION_LOAD_DECLARATION(OpenQuery);
    192201  FUNCTION_LOAD_DECLARATION(ExecQuery);
    … …  
    461470#endif
    462471  return rc;
     472}
     473
     474int dbGetDBMSName(char *dbms, size_t size)
     475{
     476  if(!active_db_) {
     477    Error(I2("There is no database connection.\n",
     478             "No existe una conexión activa a BB.DD.\n"));
     479    return 0;
     480  }
     481  DBM_hdl *dbm_hdl = NULL;
     482
     483  dbm_hdl = dbm_handlers_[active_db_->hdl_idx];
     484  return dbm_hdl->dbGetDBMSName_fp(active_db_->dbd, dbms, size);
     485}
     486
     487int dbGetDBMSVersion(char *version, size_t size)
     488{
     489  if(!active_db_) {
     490    Error(I2("There is no database connection.\n",
     491             "No existe una conexión activa a BB.DD.\n"));
     492    return 0;
     493  }
     494  DBM_hdl *dbm_hdl = NULL;
     495
     496  dbm_hdl = dbm_handlers_[active_db_->hdl_idx];
     497  return dbm_hdl->dbGetDBMSVersion_fp(active_db_->dbd, version, size);
     498}
     499
     500int dbGetDataBaseName(char *database, size_t size)
     501{
     502  if(!active_db_) {
     503    Error(I2("There is no database connection.\n",
     504             "No existe una conexión activa a BB.DD.\n"));
     505    return 0;
     506  }
     507  DBM_hdl *dbm_hdl = NULL;
     508
     509  dbm_hdl = dbm_handlers_[active_db_->hdl_idx];
     510  return dbm_hdl->dbGetDataBaseName_fp(active_db_->dbd, database, size);
    463511}
    464512
  • tol/btol/bdb/tol_bdspool.h

    re4e21ee r2c813bc  
    2323#define TOL_BDSPOOL_H 1
    2424
     25#include <stdlib.h>
     26
    2527class BSet;
    2628class BList;
    … …  
    4143extern int dbOpenDirect(const char* alias, const char *user, const char *pwd, BSet * dbset=0);
    4244extern int dbClose(const char *alias);
     45extern int dbGetDBMSName(char *dbms, size_t size);
     46extern int dbGetDBMSVersion(char *version, size_t size);
     47extern int dbGetDataBaseName(char *database, size_t size);
    4348extern int dbActivate(const char *alias);
    4449extern BList *dbGetOpened(const char *dbtype);
    … …  
    6267                       unsigned short& second,
    6368                       unsigned short& msecond);
     69extern int dbGetDBMSName(char *dbmsName, size_t size);
     70extern int dbGetDBMSVersion(char *dbmsVersion, size_t size);
     71extern int dbGetDataBaseName(char *database, size_t size);
    6472
    6573#endif // TOL_BDSPOOL_H
Note: See TracChangeset for help on using the changeset viewer.