1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

1) Fix bug on strange sprintf

2) Fix bug on bad sprintf
3) Fix bug on cast from pointer to int

4) Begin implementing the "info" tables.
Already existing were the ODBC sata source table and the
WMI column info table.

A common way to handle them will permit to develop many
other such tables. Implemented:

The ODBC column info table.

Modified:
ha_connect.cc  (4)
odbconn.cpp    (4)
tabodbc.h      (4)
tabodbc.cpp    (4)
tabsys.h       (3)
rcmsg.c        (4)
tabfmt.cpp     (2)
tabtbl.cpp     (1)
resource.h     (4)
mycat.h        (4)
This commit is contained in:
Olivier Bertrand
2013-02-08 03:27:12 +01:00
102 changed files with 63512 additions and 63516 deletions

View File

@@ -39,11 +39,27 @@ add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT )
#
IF(UNIX)
if(WITH_WARNINGS)
add_definitions(-Wall -Wfatal-errors -Wextra)
add_definitions(-Wall -Wfatal-errors -Wextra -Wmissing-declarations)
message(STATUS "CONNECT: GCC: All warnings enabled")
else()
add_definitions(--no-warnings)
message(STATUS "CONNECT: GCC: All warnings disabled")
add_definitions(-Wall -Wfatal-errors -Wmissing-declarations)
add_definitions(-Wno-write-strings)
add_definitions(-Wno-unused-variable)
add_definitions(-Wno-unused-but-set-variable)
add_definitions(-Wno-unused-value)
add_definitions(-Wno-unused-function)
add_definitions(-Wno-parentheses)
add_definitions(-Wno-missing-declarations)
add_definitions(-Wno-int-to-pointer-cast)
add_definitions(-Wno-narrowing)
# This switch is for pure C only:
# add_definitions(-Wno-implicit-function-declaration)
# These switches are for C++ only
# add_definitions(-Wno-reorder)
# add_definitions(-Wno-delete-non-virtual-dtor)
message(STATUS "CONNECT: GCC: Some warnings disabled")
endif(WITH_WARNINGS)
add_definitions( -DUNIX -DLINUX -DUBUNTU )

View File

@@ -1,57 +1,57 @@
/**************** Block H Declares Source Code File (.H) ***************/
/* Name: BLOCK.H Version 2.0 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998 */
/* */
/* This file contains the BLOCK pure virtual class definition. */
/*---------------------------------------------------------------------*/
/* Note: one of the main purpose of this base class is to take care */
/* of the very specific way Plug handles memory allocation. */
/* Instead of allocating small chunks of storage via new or malloc */
/* Plug works in its private memory pool in which it does the sub- */
/* allocation using the function PlugSubAlloc. These are never freed */
/* separately but when a transaction is terminated, the entire pool */
/* is set to empty, resulting in a very fast and efficient allocate */
/* process, no garbage collection problem, and an automatic recovery */
/* procedure (via LongJump) when the memory is exhausted. */
/* For this to work new must be given two parameters, first the */
/* global pointer of the Plug application, and an optional pointer to */
/* the memory pool to use, defaulting to NULL meaning using the Plug */
/* standard default memory pool, example: */
/* tabp = new(g) XTAB("EMPLOYEE"); */
/* allocates a XTAB class object in the standard Plug memory pool. */
/***********************************************************************/
#if !defined(BLOCK_DEFINED)
#define BLOCK_DEFINED
#if defined(WIN32) && !defined(NOEX)
#define DllExport __declspec( dllexport )
#else // !WIN32
#define DllExport
#endif // !WIN32
/***********************************************************************/
/* Definition of class BLOCK with its method function new. */
/***********************************************************************/
typedef class BLOCK *PBLOCK;
class DllExport BLOCK {
public:
void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
#ifdef DEBTRACE
if (debug != NULL)
htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
#endif
return (PlugSubAlloc(g, p, size));
} // end of new
virtual void Print(PGLOBAL, FILE *, uint) {} // Produce file desc
virtual void Print(PGLOBAL, char *, uint) {} // Produce string desc
#if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, PGLOBAL, void *) {}
#endif
}; // end of class BLOCK
#endif // !BLOCK_DEFINED
/**************** Block H Declares Source Code File (.H) ***************/
/* Name: BLOCK.H Version 2.0 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998 */
/* */
/* This file contains the BLOCK pure virtual class definition. */
/*---------------------------------------------------------------------*/
/* Note: one of the main purpose of this base class is to take care */
/* of the very specific way Plug handles memory allocation. */
/* Instead of allocating small chunks of storage via new or malloc */
/* Plug works in its private memory pool in which it does the sub- */
/* allocation using the function PlugSubAlloc. These are never freed */
/* separately but when a transaction is terminated, the entire pool */
/* is set to empty, resulting in a very fast and efficient allocate */
/* process, no garbage collection problem, and an automatic recovery */
/* procedure (via LongJump) when the memory is exhausted. */
/* For this to work new must be given two parameters, first the */
/* global pointer of the Plug application, and an optional pointer to */
/* the memory pool to use, defaulting to NULL meaning using the Plug */
/* standard default memory pool, example: */
/* tabp = new(g) XTAB("EMPLOYEE"); */
/* allocates a XTAB class object in the standard Plug memory pool. */
/***********************************************************************/
#if !defined(BLOCK_DEFINED)
#define BLOCK_DEFINED
#if defined(WIN32) && !defined(NOEX)
#define DllExport __declspec( dllexport )
#else // !WIN32
#define DllExport
#endif // !WIN32
/***********************************************************************/
/* Definition of class BLOCK with its method function new. */
/***********************************************************************/
typedef class BLOCK *PBLOCK;
class DllExport BLOCK {
public:
void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
#ifdef DEBTRACE
if (debug != NULL)
htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
#endif
return (PlugSubAlloc(g, p, size));
} // end of new
virtual void Print(PGLOBAL, FILE *, uint) {} // Produce file desc
virtual void Print(PGLOBAL, char *, uint) {} // Produce string desc
#if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, PGLOBAL, void *) {}
#endif
}; // end of class BLOCK
#endif // !BLOCK_DEFINED

View File

@@ -1,150 +1,127 @@
/*************** Catalog H Declares Source Code File (.H) **************/
/* Name: CATALOG.H Version 3.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */
/* */
/* This file contains the CATALOG PlugDB classes definitions. */
/***********************************************************************/
#ifndef __CATALOG__H
#define __CATALOG__H
#include "block.h"
/***********************************************************************/
/* Defines the length of a buffer to contain entire table section. */
/***********************************************************************/
#define PLG_MAX_PATH 144 /* Must be the same across systems */
#define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */
#if !defined(WIN32)
/**************************************************************************/
/* Defines specific to Windows and ODBC. */
/**************************************************************************/
#define SQL_CHAR 1
#define SQL_NUMERIC 2
#define SQL_DECIMAL 3
#define SQL_INTEGER 4
#define SQL_SMALLINT 5
#define SQL_FLOAT 6
#define SQL_REAL 7
#define SQL_DOUBLE 8
#define SQL_TIMESTAMP 11
#define SQL_VARCHAR 12
#define SQL_NULLABLE_UNKNOWN 2
#define SQL_ALL_EXCEPT_LIKE 2
#define SQL_SEARCHABLE 3
#define SQL_ALL_TYPES 0
#define SQL_TABLE_STAT 0
#define SQL_BEST_ROWID 1
#define SQL_PC_NOT_PSEUDO 1
#define SQL_PC_PSEUDO 2
#define SQL_SCOPE_CURROW 0
#endif // !WIN32
//typedef class INDEXDEF *PIXDEF;
/***********************************************************************/
/* Defines the structure used to enumerate tables or views. */
/***********************************************************************/
typedef struct _curtab {
PRELDEF CurTdb;
char *Curp;
char *Tabpat;
bool Ispat;
bool NoView;
int Nt;
char *Type[16];
} CURTAB, *PCURTAB;
/***********************************************************************/
/* Defines the structure used to get column catalog info. */
/***********************************************************************/
typedef struct _colinfo {
char *Name;
int Type;
int Offset;
int Length;
int Key;
int Prec;
int Opt;
char *Remark;
char *Datefmt;
char *Fieldfmt;
ushort Flags; // Used by MariaDB CONNECT handlers
} COLINFO, *PCOLINFO;
/***********************************************************************/
/* CATALOG: base class for catalog classes. */
/***********************************************************************/
class DllExport CATALOG {
friend class RELDEF;
friend class TABDEF;
friend class DIRDEF;
friend class OEMDEF;
public:
CATALOG(void); // Constructor
// Implementation
void *GetDescp(void) {return Descp;}
PRELDEF GetTo_Desc(void) {return To_Desc;}
//PSZ GetDescFile(void) {return DescFile;}
int GetCblen(void) {return Cblen;}
bool GetDefHuge(void) {return DefHuge;}
void SetDefHuge(bool b) {DefHuge = b;}
bool GetSepIndex(void) {return SepIndex;}
void SetSepIndex(bool b) {SepIndex = b;}
char *GetCbuf(void) {return Cbuf;}
char *GetDataPath(void) {return (char*)DataPath;}
// Methods
virtual void Reset(void) {}
virtual void SetDataPath(PGLOBAL g, const char *path) {}
virtual bool GetBoolCatInfo(LPCSTR name, PSZ what, bool bdef) {return bdef;}
virtual bool SetIntCatInfo(LPCSTR name, PSZ what, int ival) {return false;}
virtual int GetIntCatInfo(LPCSTR name, PSZ what, int idef) {return idef;}
virtual int GetSizeCatInfo(LPCSTR name, PSZ what, PSZ sdef) {return 0;}
virtual int GetCharCatInfo(LPCSTR name, PSZ what, PSZ sdef, char *buf, int size)
{strncpy(buf, sdef, size); return size;}
virtual char *GetStringCatInfo(PGLOBAL g, PSZ name, PSZ what, PSZ sdef)
{return sdef;}
virtual int GetColCatInfo(PGLOBAL g, PTABDEF defp) {return -1;}
virtual bool GetIndexInfo(PGLOBAL g, PTABDEF defp) {return true;}
virtual bool CheckName(PGLOBAL g, char *name) {return true;}
virtual bool ClearName(PGLOBAL g, PSZ name) {return true;}
virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;}
virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am,
PRELDEF *prp = NULL) {return NULL;}
virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;}
virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;}
virtual bool TestCond(PGLOBAL g, const char *name, const char *type) {return true;}
virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;}
virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, MODE mode = MODE_READ) {return NULL;}
virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {}
virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer,
int maxbuf, int info[]) {}
virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer,
int maxbuf, int info[]) {}
virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname,
char *buffer, int maxbuf, int info[]) {return NULL;}
virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;}
virtual void ClearDB(PGLOBAL g) {}
protected:
virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;}
virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
// Members
PRELDEF To_Desc; /* To chain of relation desc. */
void *Descp; /* To DB description area */
//AREADEF DescArea; /* Table desc. area size */
char *Cbuf; /* Buffer used for col section */
int Cblen; /* Length of suballoc. buffer */
CURTAB Ctb; /* Used to enumerate tables */
bool DefHuge; /* true: tables default to huge */
bool SepIndex; /* true: separate index files */
//char DescFile[_MAX_PATH]; /* DB description filename */
LPCSTR DataPath; /* Is the Path of DB data dir */
}; // end of class CATALOG
#endif // __CATALOG__H
/*************** Catalog H Declares Source Code File (.H) **************/
/* Name: CATALOG.H Version 3.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */
/* */
/* This file contains the CATALOG PlugDB classes definitions. */
/***********************************************************************/
#ifndef __CATALOG__H
#define __CATALOG__H
#include "block.h"
/***********************************************************************/
/* Defines the length of a buffer to contain entire table section. */
/***********************************************************************/
#define PLG_MAX_PATH 144 /* Must be the same across systems */
#define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */
//typedef class INDEXDEF *PIXDEF;
/***********************************************************************/
/* Defines the structure used to enumerate tables or views. */
/***********************************************************************/
typedef struct _curtab {
PRELDEF CurTdb;
char *Curp;
char *Tabpat;
bool Ispat;
bool NoView;
int Nt;
char *Type[16];
} CURTAB, *PCURTAB;
/***********************************************************************/
/* Defines the structure used to get column catalog info. */
/***********************************************************************/
typedef struct _colinfo {
char *Name;
int Type;
int Offset;
int Length;
int Key;
int Prec;
int Opt;
char *Remark;
char *Datefmt;
char *Fieldfmt;
ushort Flags; // Used by MariaDB CONNECT handlers
} COLINFO, *PCOLINFO;
/***********************************************************************/
/* CATALOG: base class for catalog classes. */
/***********************************************************************/
class DllExport CATALOG {
friend class RELDEF;
friend class TABDEF;
friend class DIRDEF;
friend class OEMDEF;
public:
CATALOG(void); // Constructor
virtual ~CATALOG() { } // Make -Wdelete-non-virtual-dtor happy
// Implementation
void *GetDescp(void) {return Descp;}
PRELDEF GetTo_Desc(void) {return To_Desc;}
//PSZ GetDescFile(void) {return DescFile;}
int GetCblen(void) {return Cblen;}
bool GetDefHuge(void) {return DefHuge;}
void SetDefHuge(bool b) {DefHuge = b;}
bool GetSepIndex(void) {return SepIndex;}
void SetSepIndex(bool b) {SepIndex = b;}
char *GetCbuf(void) {return Cbuf;}
char *GetDataPath(void) {return (char*)DataPath;}
// Methods
virtual void Reset(void) {}
virtual void SetDataPath(PGLOBAL g, const char *path) {}
virtual bool GetBoolCatInfo(LPCSTR name, PSZ what, bool bdef) {return bdef;}
virtual bool SetIntCatInfo(LPCSTR name, PSZ what, int ival) {return false;}
virtual int GetIntCatInfo(LPCSTR name, PSZ what, int idef) {return idef;}
virtual int GetSizeCatInfo(LPCSTR name, PSZ what, PSZ sdef) {return 0;}
virtual int GetCharCatInfo(LPCSTR name, PSZ what, PSZ sdef, char *buf, int size)
{strncpy(buf, sdef, size); return size;}
virtual char *GetStringCatInfo(PGLOBAL g, PSZ name, PSZ what, PSZ sdef)
{return sdef;}
virtual int GetColCatInfo(PGLOBAL g, PTABDEF defp) {return -1;}
virtual bool GetIndexInfo(PGLOBAL g, PTABDEF defp) {return true;}
virtual bool CheckName(PGLOBAL g, char *name) {return true;}
virtual bool ClearName(PGLOBAL g, PSZ name) {return true;}
virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;}
virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am,
PRELDEF *prp = NULL) {return NULL;}
virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;}
virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;}
virtual bool TestCond(PGLOBAL g, const char *name, const char *type) {return true;}
virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;}
virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, MODE mode = MODE_READ) {return NULL;}
virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {}
virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer,
int maxbuf, int info[]) {}
virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer,
int maxbuf, int info[]) {}
virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname,
char *buffer, int maxbuf, int info[]) {return NULL;}
virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;}
virtual void ClearDB(PGLOBAL g) {}
protected:
virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;}
virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
// Members
PRELDEF To_Desc; /* To chain of relation desc. */
void *Descp; /* To DB description area */
//AREADEF DescArea; /* Table desc. area size */
char *Cbuf; /* Buffer used for col section */
int Cblen; /* Length of suballoc. buffer */
CURTAB Ctb; /* Used to enumerate tables */
bool DefHuge; /* true: tables default to huge */
bool SepIndex; /* true: separate index files */
//char DescFile[_MAX_PATH]; /* DB description filename */
LPCSTR DataPath; /* Is the Path of DB data dir */
}; // end of class CATALOG
#endif // __CATALOG__H

View File

@@ -1,42 +1,42 @@
/************** PlgDBSem H Declares Source Code File (.H) **************/
/* Name: CHKLVL.H Version 1.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2009 */
/* */
/* This file contains the definition of the checking level constants. */
/***********************************************************************/
#if !defined(_CHKLVL_DEFINED_)
#define _CHKLVL_DEFINED_
/***********************************************************************/
/* Following definitions are used to indicate the level of checking. */
/***********************************************************************/
enum CHKLVL {CHK_NO = 0x00, /* No checking */
CHK_TYPE = 0x01, /* Check types for Insert/Update */
CHK_UPDATE = 0x02, /* Two pass checking of Update */
CHK_DELETE = 0x04, /* Indexed checking of Delete */
CHK_JOIN = 0x08, /* Check types joining tables */
CHK_OPT = 0x10, /* Automatic optimize on changes */
CHK_MANY = 0x20, /* Check many-to-many joins */
CHK_ALL = 0x3F, /* All of the above */
CHK_STD = 0x1E, /* Standard level of checking */
CHK_MAXRES = 0x40, /* Prevent Maxres recalculation */
CHK_ONLY = 0x100}; /* Just check, no action (NIY) */
/***********************************************************************/
/* Following definitions are used to indicate the execution mode. */
/***********************************************************************/
enum XMOD {XMOD_EXECUTE = 0, /* DOS execution mode */
XMOD_PREPARE = 1, /* Prepare mode */
XMOD_TEST = 2, /* Test mode */
XMOD_CONVERT = 3}; /* HQL conversion mode */
/***********************************************************************/
/* Following definitions indicate the use of a temporay file. */
/***********************************************************************/
enum USETEMP {TMP_AUTO = 0, /* Best choice */
TMP_NO = 1, /* Never */
TMP_YES = 2, /* Always */
TMP_FORCE = 3}; /* Forced for MAP tables */
#endif // _CHKLVL_DEFINED_
/************** PlgDBSem H Declares Source Code File (.H) **************/
/* Name: CHKLVL.H Version 1.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2009 */
/* */
/* This file contains the definition of the checking level constants. */
/***********************************************************************/
#if !defined(_CHKLVL_DEFINED_)
#define _CHKLVL_DEFINED_
/***********************************************************************/
/* Following definitions are used to indicate the level of checking. */
/***********************************************************************/
enum CHKLVL {CHK_NO = 0x00, /* No checking */
CHK_TYPE = 0x01, /* Check types for Insert/Update */
CHK_UPDATE = 0x02, /* Two pass checking of Update */
CHK_DELETE = 0x04, /* Indexed checking of Delete */
CHK_JOIN = 0x08, /* Check types joining tables */
CHK_OPT = 0x10, /* Automatic optimize on changes */
CHK_MANY = 0x20, /* Check many-to-many joins */
CHK_ALL = 0x3F, /* All of the above */
CHK_STD = 0x1E, /* Standard level of checking */
CHK_MAXRES = 0x40, /* Prevent Maxres recalculation */
CHK_ONLY = 0x100}; /* Just check, no action (NIY) */
/***********************************************************************/
/* Following definitions are used to indicate the execution mode. */
/***********************************************************************/
enum XMOD {XMOD_EXECUTE = 0, /* DOS execution mode */
XMOD_PREPARE = 1, /* Prepare mode */
XMOD_TEST = 2, /* Test mode */
XMOD_CONVERT = 3}; /* HQL conversion mode */
/***********************************************************************/
/* Following definitions indicate the use of a temporay file. */
/***********************************************************************/
enum USETEMP {TMP_AUTO = 0, /* Best choice */
TMP_NO = 1, /* Never */
TMP_YES = 2, /* Always */
TMP_FORCE = 3}; /* Forced for MAP tables */
#endif // _CHKLVL_DEFINED_

View File

@@ -1,379 +1,379 @@
/************* Colblk C++ Functions Source Code File (.CPP) ************/
/* Name: COLBLK.CPP Version 1.9 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* This file contains the COLBLK class functions. */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
/***********************************************************************/
/* Include required application header files */
/* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "tabcol.h"
#include "colblk.h"
#include "xindex.h"
#include "xtable.h"
/***********************************************************************/
/* COLBLK protected constructor. */
/***********************************************************************/
COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
{
Next = NULL;
Index = i;
//Number = 0;
ColUse = 0;
if ((Cdp = cdp)) {
Name = cdp->Name;
Format = cdp->F;
Opt = cdp->Opt;
Long = cdp->Long;
Buf_Type = cdp->Buf_Type;
ColUse |= cdp->Flags; // Used by CONNECT
} else {
Name = NULL;
memset(&Format, 0, sizeof(FORMAT));
Opt = 0;
Long = 0;
Buf_Type = TYPE_ERROR;
} // endif cdp
To_Tdb = tdbp;
Status = BUF_NO;
//Value = NULL; done in XOBJECT constructor
To_Kcol = NULL;
} // end of COLBLK constructor
/***********************************************************************/
/* COLBLK constructor used for copying columns. */
/* tdbp is the pointer to the new table descriptor. */
/***********************************************************************/
COLBLK::COLBLK(PCOL col1, PTDB tdbp)
{
PCOL colp;
// Copy the old column block to the new one
*this = *col1;
Next = NULL;
//To_Orig = col1;
To_Tdb = tdbp;
#ifdef DEBTRACE
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
#endif
if (tdbp)
// Attach the new column to the table block
if (!tdbp->GetColumns())
tdbp->SetColumns(this);
else {
for (colp = tdbp->GetColumns(); colp->Next; colp = colp->Next) ;
colp->Next = this;
} // endelse
} // end of COLBLK copy constructor
/***********************************************************************/
/* Reset the column descriptor to non evaluated yet. */
/***********************************************************************/
void COLBLK::Reset(void)
{
Status &= ~BUF_READ;
} // end of Reset
/***********************************************************************/
/* Compare: compares itself to an (expression) object and returns */
/* true if it is equivalent. */
/***********************************************************************/
bool COLBLK::Compare(PXOB xp)
{
return (this == xp);
} // end of Compare
/***********************************************************************/
/* SetFormat: function used to set SELECT output format. */
/***********************************************************************/
bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
{
fmt = Format;
#ifdef DEBTRACE
htrc("COLBLK: %p format=%c(%d,%d)\n",
this, *fmt.Type, fmt.Length, fmt.Prec);
#endif
return false;
} // end of SetFormat
/***********************************************************************/
/* CheckColumn: a column descriptor is found, say it by returning 1. */
/***********************************************************************/
int COLBLK::CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &p, int &ag)
{
return 1;
} // end of CheckColumn
/***********************************************************************/
/* Eval: get the column value from the last read record or from a */
/* matching Index column if there is one. */
/***********************************************************************/
bool COLBLK::Eval(PGLOBAL g)
{
#ifdef DEBTRACE
htrc("Col Eval: %s status=%.4X\n", Name, Status);
#endif
if (!GetStatus(BUF_READ)) {
// if (To_Tdb->IsNull())
// Value->Reset();
if (To_Kcol)
To_Kcol->FillValue(Value);
else
ReadColumn(g);
AddStatus(BUF_READ);
} // endif
return false;
} // end of Eval
/***********************************************************************/
/* CheckSort: */
/* Used to check that a table is involved in the sort list items. */
/***********************************************************************/
bool COLBLK::CheckSort(PTDB tdbp)
{
return (tdbp == To_Tdb);
} // end of CheckSort
/***********************************************************************/
/* MarkCol: see PlugMarkCol for column references to mark. */
/***********************************************************************/
void COLBLK::MarkCol(ushort bits)
{
ColUse |= bits;
#ifdef DEBTRACE
htrc(" column R%d.%s marked as %04X\n",
To_Tdb->GetTdb_No(), Name, ColUse);
#endif
} // end of MarkCol
/***********************************************************************/
/* InitValue: prepare a column block for read operation. */
/* Now we use Format.Length for the len parameter to avoid strings */
/* to be truncated when converting from string to coded string. */
/* Added in version 1.5 is the arguments GetPrecision() and Domain */
/* in calling AllocateValue. Domain is used for TYPE_TOKEN only, */
/* but why was GetPrecision() not specified ? To be checked. */
/***********************************************************************/
bool COLBLK::InitValue(PGLOBAL g)
{
if (Value)
return false; // Already done
// Allocate a Value object
if (!(Value = AllocateValue(g, Buf_Type, Format.Length,
GetPrecision(), GetDomain(),
(To_Tdb) ? To_Tdb->GetCat() : NULL)))
return true;
Status = BUF_READY;
#ifdef DEBTRACE
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
this, Buf_Type, Value, ColUse, Status);
#endif
return false;
} // end of InitValue
/***********************************************************************/
/* SetBuffer: prepare a column block for write operation. */
/***********************************************************************/
bool COLBLK::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
{
sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer");
return true;
} // end of SetBuffer
/***********************************************************************/
/* GetLength: returns an evaluation of the column string length. */
/***********************************************************************/
int COLBLK::GetLengthEx(void)
{
return Long;
} // end of GetLengthEx
/***********************************************************************/
/* ReadColumn: what this routine does is to access the last line */
/* read from the corresponding table, extract from it the field */
/* corresponding to this column and convert it to buffer type. */
/***********************************************************************/
void COLBLK::ReadColumn(PGLOBAL g)
{
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
} // end of ReadColumn
/***********************************************************************/
/* WriteColumn: what this routine does is to access the last line */
/* read from the corresponding table, and rewrite the field */
/* corresponding to this column from the column buffer and type. */
/***********************************************************************/
void COLBLK::WriteColumn(PGLOBAL g)
{
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
} // end of WriteColumn
/***********************************************************************/
/* Make file output of a column descriptor block. */
/***********************************************************************/
void COLBLK::Print(PGLOBAL g, FILE *f, uint n)
{
char m[64];
int i;
PCOL colp;
memset(m, ' ', n); // Make margin string
m[n] = '\0';
for (colp = To_Tdb->GetColumns(), i = 1; colp; colp = colp->Next, i++)
if (colp == this)
break;
fprintf(f, "%sR%dC%d type=%d F=%.2s(%d,%d)", m, To_Tdb->GetTdb_No(),
i, GetAmType(), Format.Type, Format.Length, Format.Prec);
fprintf(f,
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n",
ColUse, Status, Buf_Type, Value, Name);
} // end of Print
/***********************************************************************/
/* Make string output of a column descriptor block. */
/***********************************************************************/
void COLBLK::Print(PGLOBAL g, char *ps, uint z)
{
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name);
} // end of Print
/***********************************************************************/
/* SPCBLK constructor. */
/***********************************************************************/
SPCBLK::SPCBLK(PCOLUMN cp)
: COLBLK((PCOLDEF)NULL, cp->GetTo_Table()->GetTo_Tdb(), 0)
{
Name = (char*)cp->GetName();
Long = 0;
Buf_Type = TYPE_ERROR;
} // end of SPCBLK constructor
/***********************************************************************/
/* WriteColumn: what this routine does is to access the last line */
/* read from the corresponding table, and rewrite the field */
/* corresponding to this column from the column buffer and type. */
/***********************************************************************/
void SPCBLK::WriteColumn(PGLOBAL g)
{
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
} // end of WriteColumn
/***********************************************************************/
/* RIDBLK constructor for the ROWID special column. */
/***********************************************************************/
RIDBLK::RIDBLK(PCOLUMN cp, bool rnm) : SPCBLK(cp)
{
Long = 10;
Buf_Type = TYPE_INT;
Rnm = rnm;
*Format.Type = 'N';
Format.Length = 10;
} // end of RIDBLK constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to return the ordinal */
/* number of the current row in the table (if Rnm is true) or in the */
/* current file (if Rnm is false) the same except for multiple tables.*/
/***********************************************************************/
void RIDBLK::ReadColumn(PGLOBAL g)
{
Value->SetValue(To_Tdb->RowNumber(g, Rnm));
} // end of ReadColumn
/***********************************************************************/
/* FIDBLK constructor for the FILEID special column. */
/***********************************************************************/
FIDBLK::FIDBLK(PCOLUMN cp) : SPCBLK(cp)
{
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
Long = _MAX_PATH;
Buf_Type = TYPE_STRING;
*Format.Type = 'C';
Format.Length = Long;
#if defined(WIN32)
Format.Prec = 1; // Case insensitive
#endif // WIN32
Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() &&
To_Tdb->GetAmType() != TYPE_AM_PLG &&
To_Tdb->GetAmType() != TYPE_AM_PLM);
Fn = NULL;
} // end of FIDBLK constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to return the current */
/* file ID of the table (can change for Multiple tables). */
/***********************************************************************/
void FIDBLK::ReadColumn(PGLOBAL g)
{
if (Fn != ((PTDBASE)To_Tdb)->GetFile(g)) {
char filename[_MAX_PATH];
Fn = ((PTDBASE)To_Tdb)->GetFile(g);
PlugSetPath(filename, Fn, ((PTDBASE)To_Tdb)->GetPath());
Value->SetValue_psz(filename);
} // endif Fn
} // end of ReadColumn
/***********************************************************************/
/* TIDBLK constructor for the TABID special column. */
/***********************************************************************/
TIDBLK::TIDBLK(PCOLUMN cp) : SPCBLK(cp)
{
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
Long = 64;
Buf_Type = TYPE_STRING;
*Format.Type = 'C';
Format.Length = Long;
Format.Prec = 1; // Case insensitive
Constant = (To_Tdb->GetAmType() != TYPE_AM_PLG &&
To_Tdb->GetAmType() != TYPE_AM_PLM);
Tname = NULL;
} // end of TIDBLK constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to return the table ID. */
/***********************************************************************/
void TIDBLK::ReadColumn(PGLOBAL g)
{
if (Tname == NULL) {
Tname = (char*)To_Tdb->GetName();
Value->SetValue_psz(Tname);
} // endif Tname
} // end of ReadColumn
/************* Colblk C++ Functions Source Code File (.CPP) ************/
/* Name: COLBLK.CPP Version 1.9 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* This file contains the COLBLK class functions. */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
/***********************************************************************/
/* Include required application header files */
/* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "tabcol.h"
#include "colblk.h"
#include "xindex.h"
#include "xtable.h"
/***********************************************************************/
/* COLBLK protected constructor. */
/***********************************************************************/
COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
{
Next = NULL;
Index = i;
//Number = 0;
ColUse = 0;
if ((Cdp = cdp)) {
Name = cdp->Name;
Format = cdp->F;
Opt = cdp->Opt;
Long = cdp->Long;
Buf_Type = cdp->Buf_Type;
ColUse |= cdp->Flags; // Used by CONNECT
} else {
Name = NULL;
memset(&Format, 0, sizeof(FORMAT));
Opt = 0;
Long = 0;
Buf_Type = TYPE_ERROR;
} // endif cdp
To_Tdb = tdbp;
Status = BUF_NO;
//Value = NULL; done in XOBJECT constructor
To_Kcol = NULL;
} // end of COLBLK constructor
/***********************************************************************/
/* COLBLK constructor used for copying columns. */
/* tdbp is the pointer to the new table descriptor. */
/***********************************************************************/
COLBLK::COLBLK(PCOL col1, PTDB tdbp)
{
PCOL colp;
// Copy the old column block to the new one
*this = *col1;
Next = NULL;
//To_Orig = col1;
To_Tdb = tdbp;
#ifdef DEBTRACE
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
#endif
if (tdbp)
// Attach the new column to the table block
if (!tdbp->GetColumns())
tdbp->SetColumns(this);
else {
for (colp = tdbp->GetColumns(); colp->Next; colp = colp->Next) ;
colp->Next = this;
} // endelse
} // end of COLBLK copy constructor
/***********************************************************************/
/* Reset the column descriptor to non evaluated yet. */
/***********************************************************************/
void COLBLK::Reset(void)
{
Status &= ~BUF_READ;
} // end of Reset
/***********************************************************************/
/* Compare: compares itself to an (expression) object and returns */
/* true if it is equivalent. */
/***********************************************************************/
bool COLBLK::Compare(PXOB xp)
{
return (this == xp);
} // end of Compare
/***********************************************************************/
/* SetFormat: function used to set SELECT output format. */
/***********************************************************************/
bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
{
fmt = Format;
#ifdef DEBTRACE
htrc("COLBLK: %p format=%c(%d,%d)\n",
this, *fmt.Type, fmt.Length, fmt.Prec);
#endif
return false;
} // end of SetFormat
/***********************************************************************/
/* CheckColumn: a column descriptor is found, say it by returning 1. */
/***********************************************************************/
int COLBLK::CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &p, int &ag)
{
return 1;
} // end of CheckColumn
/***********************************************************************/
/* Eval: get the column value from the last read record or from a */
/* matching Index column if there is one. */
/***********************************************************************/
bool COLBLK::Eval(PGLOBAL g)
{
#ifdef DEBTRACE
htrc("Col Eval: %s status=%.4X\n", Name, Status);
#endif
if (!GetStatus(BUF_READ)) {
// if (To_Tdb->IsNull())
// Value->Reset();
if (To_Kcol)
To_Kcol->FillValue(Value);
else
ReadColumn(g);
AddStatus(BUF_READ);
} // endif
return false;
} // end of Eval
/***********************************************************************/
/* CheckSort: */
/* Used to check that a table is involved in the sort list items. */
/***********************************************************************/
bool COLBLK::CheckSort(PTDB tdbp)
{
return (tdbp == To_Tdb);
} // end of CheckSort
/***********************************************************************/
/* MarkCol: see PlugMarkCol for column references to mark. */
/***********************************************************************/
void COLBLK::MarkCol(ushort bits)
{
ColUse |= bits;
#ifdef DEBTRACE
htrc(" column R%d.%s marked as %04X\n",
To_Tdb->GetTdb_No(), Name, ColUse);
#endif
} // end of MarkCol
/***********************************************************************/
/* InitValue: prepare a column block for read operation. */
/* Now we use Format.Length for the len parameter to avoid strings */
/* to be truncated when converting from string to coded string. */
/* Added in version 1.5 is the arguments GetPrecision() and Domain */
/* in calling AllocateValue. Domain is used for TYPE_TOKEN only, */
/* but why was GetPrecision() not specified ? To be checked. */
/***********************************************************************/
bool COLBLK::InitValue(PGLOBAL g)
{
if (Value)
return false; // Already done
// Allocate a Value object
if (!(Value = AllocateValue(g, Buf_Type, Format.Length,
GetPrecision(), GetDomain(),
(To_Tdb) ? To_Tdb->GetCat() : NULL)))
return true;
Status = BUF_READY;
#ifdef DEBTRACE
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
this, Buf_Type, Value, ColUse, Status);
#endif
return false;
} // end of InitValue
/***********************************************************************/
/* SetBuffer: prepare a column block for write operation. */
/***********************************************************************/
bool COLBLK::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
{
sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer");
return true;
} // end of SetBuffer
/***********************************************************************/
/* GetLength: returns an evaluation of the column string length. */
/***********************************************************************/
int COLBLK::GetLengthEx(void)
{
return Long;
} // end of GetLengthEx
/***********************************************************************/
/* ReadColumn: what this routine does is to access the last line */
/* read from the corresponding table, extract from it the field */
/* corresponding to this column and convert it to buffer type. */
/***********************************************************************/
void COLBLK::ReadColumn(PGLOBAL g)
{
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
} // end of ReadColumn
/***********************************************************************/
/* WriteColumn: what this routine does is to access the last line */
/* read from the corresponding table, and rewrite the field */
/* corresponding to this column from the column buffer and type. */
/***********************************************************************/
void COLBLK::WriteColumn(PGLOBAL g)
{
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
} // end of WriteColumn
/***********************************************************************/
/* Make file output of a column descriptor block. */
/***********************************************************************/
void COLBLK::Print(PGLOBAL g, FILE *f, uint n)
{
char m[64];
int i;
PCOL colp;
memset(m, ' ', n); // Make margin string
m[n] = '\0';
for (colp = To_Tdb->GetColumns(), i = 1; colp; colp = colp->Next, i++)
if (colp == this)
break;
fprintf(f, "%sR%dC%d type=%d F=%.2s(%d,%d)", m, To_Tdb->GetTdb_No(),
i, GetAmType(), Format.Type, Format.Length, Format.Prec);
fprintf(f,
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n",
ColUse, Status, Buf_Type, Value, Name);
} // end of Print
/***********************************************************************/
/* Make string output of a column descriptor block. */
/***********************************************************************/
void COLBLK::Print(PGLOBAL g, char *ps, uint z)
{
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name);
} // end of Print
/***********************************************************************/
/* SPCBLK constructor. */
/***********************************************************************/
SPCBLK::SPCBLK(PCOLUMN cp)
: COLBLK((PCOLDEF)NULL, cp->GetTo_Table()->GetTo_Tdb(), 0)
{
Name = (char*)cp->GetName();
Long = 0;
Buf_Type = TYPE_ERROR;
} // end of SPCBLK constructor
/***********************************************************************/
/* WriteColumn: what this routine does is to access the last line */
/* read from the corresponding table, and rewrite the field */
/* corresponding to this column from the column buffer and type. */
/***********************************************************************/
void SPCBLK::WriteColumn(PGLOBAL g)
{
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
} // end of WriteColumn
/***********************************************************************/
/* RIDBLK constructor for the ROWID special column. */
/***********************************************************************/
RIDBLK::RIDBLK(PCOLUMN cp, bool rnm) : SPCBLK(cp)
{
Long = 10;
Buf_Type = TYPE_INT;
Rnm = rnm;
*Format.Type = 'N';
Format.Length = 10;
} // end of RIDBLK constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to return the ordinal */
/* number of the current row in the table (if Rnm is true) or in the */
/* current file (if Rnm is false) the same except for multiple tables.*/
/***********************************************************************/
void RIDBLK::ReadColumn(PGLOBAL g)
{
Value->SetValue(To_Tdb->RowNumber(g, Rnm));
} // end of ReadColumn
/***********************************************************************/
/* FIDBLK constructor for the FILEID special column. */
/***********************************************************************/
FIDBLK::FIDBLK(PCOLUMN cp) : SPCBLK(cp)
{
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
Long = _MAX_PATH;
Buf_Type = TYPE_STRING;
*Format.Type = 'C';
Format.Length = Long;
#if defined(WIN32)
Format.Prec = 1; // Case insensitive
#endif // WIN32
Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() &&
To_Tdb->GetAmType() != TYPE_AM_PLG &&
To_Tdb->GetAmType() != TYPE_AM_PLM);
Fn = NULL;
} // end of FIDBLK constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to return the current */
/* file ID of the table (can change for Multiple tables). */
/***********************************************************************/
void FIDBLK::ReadColumn(PGLOBAL g)
{
if (Fn != ((PTDBASE)To_Tdb)->GetFile(g)) {
char filename[_MAX_PATH];
Fn = ((PTDBASE)To_Tdb)->GetFile(g);
PlugSetPath(filename, Fn, ((PTDBASE)To_Tdb)->GetPath());
Value->SetValue_psz(filename);
} // endif Fn
} // end of ReadColumn
/***********************************************************************/
/* TIDBLK constructor for the TABID special column. */
/***********************************************************************/
TIDBLK::TIDBLK(PCOLUMN cp) : SPCBLK(cp)
{
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
Long = 64;
Buf_Type = TYPE_STRING;
*Format.Type = 'C';
Format.Length = Long;
Format.Prec = 1; // Case insensitive
Constant = (To_Tdb->GetAmType() != TYPE_AM_PLG &&
To_Tdb->GetAmType() != TYPE_AM_PLM);
Tname = NULL;
} // end of TIDBLK constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to return the table ID. */
/***********************************************************************/
void TIDBLK::ReadColumn(PGLOBAL g)
{
if (Tname == NULL) {
Tname = (char*)To_Tdb->GetName();
Value->SetValue_psz(Tname);
} // endif Tname
} // end of ReadColumn

View File

@@ -1,180 +1,180 @@
/*************** Colblk H Declares Source Code File (.H) ***************/
/* Name: COLBLK.H Version 1.5 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the COLBLK and derived classes declares. */
/***********************************************************************/
#ifndef __COLBLK__H
#define __COLBLK__H
/***********************************************************************/
/* Include required application header files */
/***********************************************************************/
#include "xobject.h"
#include "reldef.h"
/***********************************************************************/
/* Class COLBLK: Base class for table column descriptors. */
/***********************************************************************/
class DllExport COLBLK : public XOBJECT {
friend class TDBPIVOT;
protected:
// Default constructors used by derived classes
COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0);
COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process
COLBLK(int n) {} // Used when changing a column class in TDBXML
public:
// Implementation
virtual int GetType(void) {return TYPE_COLBLK;}
virtual int GetResultType(void) {return Buf_Type;}
virtual int GetPrecision(void) {return Format.Prec;}
virtual int GetLength(void) {return Long;}
virtual int GetLengthEx(void);
virtual int GetAmType() {return TYPE_AM_ERROR;}
virtual void SetOk(void) {Status |= BUF_EMPTY;}
virtual PTDB GetTo_Tdb(void) {return To_Tdb;}
PCOL GetNext(void) {return Next;}
PSZ GetName(void) {return Name;}
int GetIndex(void) {return Index;}
int GetOpt(void) {return Opt;}
ushort GetColUse(void) {return ColUse;}
ushort GetColUse(ushort u) {return (ColUse & u);}
ushort GetStatus(void) {return Status;}
ushort GetStatus(ushort u) {return (Status & u);}
void SetColUse(ushort u) {ColUse = u;}
void SetStatus(ushort u) {Status = u;}
void AddColUse(ushort u) {ColUse |= u;}
void AddStatus(ushort u) {Status |= u;}
void SetNext(PCOL cp) {Next = cp;}
void SetKcol(PXCOL kcp) {To_Kcol = kcp;}
PCOLDEF GetCdp(void) {return Cdp;}
PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;}
PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;}
PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;}
// Methods
virtual void Reset(void);
virtual bool Compare(PXOB xp);
virtual bool SetFormat(PGLOBAL, FORMAT&);
virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag);
virtual bool IsSpecial(void) {return false;}
virtual int CheckSpcCol(PTDB tdbp, int n) {return 2;}
virtual bool CheckSort(PTDB tdbp);
virtual void MarkCol(ushort bits);
virtual bool Eval(PGLOBAL g);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetTo_Val(PVAL valp) {}
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
virtual bool VarSize(void) {return false;}
virtual bool IsColInside(PCOL colp) {return this == colp;}
bool InitValue(PGLOBAL g);
protected:
// Members
PCOL Next; // Next column in table
PSZ Name; // Column name
PCOLDEF Cdp; // To column definition block
PTDB To_Tdb; // Points to Table Descriptor Block
PXCOL To_Kcol; // Points to Xindex matching column
int Index; // Column number in table
int Opt; // Cluster/sort information
int Buf_Type; // Data type
int Long; // Internal length in table
FORMAT Format; // Output format
ushort ColUse; // Column usage
ushort Status; // Column read status
}; // end of class COLBLK
/***********************************************************************/
/* Class SPCBLK: Base class for special column descriptors. */
/***********************************************************************/
class SPCBLK : public COLBLK {
public:
// Constructor
SPCBLK(PCOLUMN cp);
// Implementation
virtual int GetAmType(void) = 0;
virtual bool GetRnm(void) {return false;}
// Methods
virtual bool IsSpecial(void) {return true;}
virtual void ReadColumn(PGLOBAL g) = 0;
virtual void WriteColumn(PGLOBAL g);
protected:
// Default constructor not to be used
SPCBLK(void) : COLBLK(1) {}
}; // end of class SPCBLK
/***********************************************************************/
/* Class RIDBLK: ROWID special column descriptor. */
/***********************************************************************/
class RIDBLK : public SPCBLK {
public:
// Constructor
RIDBLK(PCOLUMN cp, bool rnm);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_ROWID;}
virtual bool GetRnm(void) {return Rnm;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
bool Rnm; // False for RowID, True for RowNum
}; // end of class RIDBLK
/***********************************************************************/
/* Class FIDBLK: FILEID special column descriptor. */
/***********************************************************************/
class FIDBLK : public SPCBLK {
public:
// Constructor
FIDBLK(PCOLUMN cp);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_FILID;}
// Methods
virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 2 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g);
protected:
PSZ Fn; // The current To_File of the table
}; // end of class FIDBLK
/***********************************************************************/
/* Class TIDBLK: TABID special column descriptor. */
/***********************************************************************/
class TIDBLK : public SPCBLK {
public:
// Constructor
TIDBLK(PCOLUMN cp);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_TABID;}
// Methods
virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 3 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g);
protected:
// Default constructor not to be used
TIDBLK(void) {}
// Members
PSZ Tname; // The current table name
}; // end of class TIDBLK
#endif // __COLBLK__H
/*************** Colblk H Declares Source Code File (.H) ***************/
/* Name: COLBLK.H Version 1.5 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the COLBLK and derived classes declares. */
/***********************************************************************/
#ifndef __COLBLK__H
#define __COLBLK__H
/***********************************************************************/
/* Include required application header files */
/***********************************************************************/
#include "xobject.h"
#include "reldef.h"
/***********************************************************************/
/* Class COLBLK: Base class for table column descriptors. */
/***********************************************************************/
class DllExport COLBLK : public XOBJECT {
friend class TDBPIVOT;
protected:
// Default constructors used by derived classes
COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0);
COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process
COLBLK(int n) {} // Used when changing a column class in TDBXML
public:
// Implementation
virtual int GetType(void) {return TYPE_COLBLK;}
virtual int GetResultType(void) {return Buf_Type;}
virtual int GetPrecision(void) {return Format.Prec;}
virtual int GetLength(void) {return Long;}
virtual int GetLengthEx(void);
virtual int GetAmType() {return TYPE_AM_ERROR;}
virtual void SetOk(void) {Status |= BUF_EMPTY;}
virtual PTDB GetTo_Tdb(void) {return To_Tdb;}
PCOL GetNext(void) {return Next;}
PSZ GetName(void) {return Name;}
int GetIndex(void) {return Index;}
int GetOpt(void) {return Opt;}
ushort GetColUse(void) {return ColUse;}
ushort GetColUse(ushort u) {return (ColUse & u);}
ushort GetStatus(void) {return Status;}
ushort GetStatus(ushort u) {return (Status & u);}
void SetColUse(ushort u) {ColUse = u;}
void SetStatus(ushort u) {Status = u;}
void AddColUse(ushort u) {ColUse |= u;}
void AddStatus(ushort u) {Status |= u;}
void SetNext(PCOL cp) {Next = cp;}
void SetKcol(PXCOL kcp) {To_Kcol = kcp;}
PCOLDEF GetCdp(void) {return Cdp;}
PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;}
PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;}
PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;}
// Methods
virtual void Reset(void);
virtual bool Compare(PXOB xp);
virtual bool SetFormat(PGLOBAL, FORMAT&);
virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag);
virtual bool IsSpecial(void) {return false;}
virtual int CheckSpcCol(PTDB tdbp, int n) {return 2;}
virtual bool CheckSort(PTDB tdbp);
virtual void MarkCol(ushort bits);
virtual bool Eval(PGLOBAL g);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetTo_Val(PVAL valp) {}
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
virtual bool VarSize(void) {return false;}
virtual bool IsColInside(PCOL colp) {return this == colp;}
bool InitValue(PGLOBAL g);
protected:
// Members
PCOL Next; // Next column in table
PSZ Name; // Column name
PCOLDEF Cdp; // To column definition block
PTDB To_Tdb; // Points to Table Descriptor Block
PXCOL To_Kcol; // Points to Xindex matching column
int Index; // Column number in table
int Opt; // Cluster/sort information
int Buf_Type; // Data type
int Long; // Internal length in table
FORMAT Format; // Output format
ushort ColUse; // Column usage
ushort Status; // Column read status
}; // end of class COLBLK
/***********************************************************************/
/* Class SPCBLK: Base class for special column descriptors. */
/***********************************************************************/
class SPCBLK : public COLBLK {
public:
// Constructor
SPCBLK(PCOLUMN cp);
// Implementation
virtual int GetAmType(void) = 0;
virtual bool GetRnm(void) {return false;}
// Methods
virtual bool IsSpecial(void) {return true;}
virtual void ReadColumn(PGLOBAL g) = 0;
virtual void WriteColumn(PGLOBAL g);
protected:
// Default constructor not to be used
SPCBLK(void) : COLBLK(1) {}
}; // end of class SPCBLK
/***********************************************************************/
/* Class RIDBLK: ROWID special column descriptor. */
/***********************************************************************/
class RIDBLK : public SPCBLK {
public:
// Constructor
RIDBLK(PCOLUMN cp, bool rnm);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_ROWID;}
virtual bool GetRnm(void) {return Rnm;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
bool Rnm; // False for RowID, True for RowNum
}; // end of class RIDBLK
/***********************************************************************/
/* Class FIDBLK: FILEID special column descriptor. */
/***********************************************************************/
class FIDBLK : public SPCBLK {
public:
// Constructor
FIDBLK(PCOLUMN cp);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_FILID;}
// Methods
virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 2 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g);
protected:
PSZ Fn; // The current To_File of the table
}; // end of class FIDBLK
/***********************************************************************/
/* Class TIDBLK: TABID special column descriptor. */
/***********************************************************************/
class TIDBLK : public SPCBLK {
public:
// Constructor
TIDBLK(PCOLUMN cp);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_TABID;}
// Methods
virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 3 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g);
protected:
// Default constructor not to be used
TIDBLK(void) {}
// Members
PSZ Tname; // The current table name
}; // end of class TIDBLK
#endif // __COLBLK__H

File diff suppressed because it is too large Load Diff

View File

@@ -1,77 +1,77 @@
/* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**************** Cnt H Declares Source Code File (.H) *****************/
/* Name: CONNECT.H Version 2.4 */
/* This file contains the some based classes declares. */
/***********************************************************************/
//#include "xtable.h" // Base class declares
#include "filamtxt.h"
#include "tabdos.h"
//typedef struct _tabdesc *PTABD; // For friend setting
typedef struct _xinfo *PXF;
typedef struct _create_xinfo *PCXF;
typedef class TDBDOX *PTDBDOX;
/***********************************************************************/
/* Definition of classes XCOLCRT, XIXDEF, XKPDEF, DOXDEF, TDBDOX */
/* These classes purpose is chiefly to access protected items! */
/***********************************************************************/
class XCOLCRT: public COLCRT {
friend class ha_connect;
friend bool CntCreateTable(PGLOBAL, char *, PCXF);
public:
XCOLCRT(PSZ name) : COLCRT(name) {Nulls= -1;} // Constructor
bool HasNulls(void) {return (Nulls != 0);}
private:
int Nulls;
}; // end of class XCOLCRT
class DOXDEF: public DOSDEF {
//friend class TDBDOX;
//friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int);
}; // end of class DOXDEF
/***********************************************************************/
/* This is the DOS/UNIX Access Method base class declaration. */
/***********************************************************************/
class TDBDOX: public TDBDOS {
friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntCloseTable(PGLOBAL, PTDB);
friend int CntIndexInit(PGLOBAL, PTDB, int);
friend RCODE CntIndexRead(PGLOBAL, PTDB, OPVAL, const void*, int);
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*,
bool*, key_part_map*);
friend class ha_connect;
}; // end of class TDBDOX
class XKPDEF: public KPARTDEF {
friend class TDBDOX;
friend class ha_connect;
//friend int CntMakeIndex(PGLOBAL, const char *, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int);
public:
XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {HasNulls= false;}
void SetNulls(bool b) {HasNulls= b;}
protected:
bool HasNulls; /* Can have null values */
}; // end of class XKPDEF
RCODE CheckRecord(PGLOBAL g, PTDB tdbp, char *oldbuf, char *newbuf);
/* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**************** Cnt H Declares Source Code File (.H) *****************/
/* Name: CONNECT.H Version 2.4 */
/* This file contains the some based classes declares. */
/***********************************************************************/
//#include "xtable.h" // Base class declares
#include "filamtxt.h"
#include "tabdos.h"
//typedef struct _tabdesc *PTABD; // For friend setting
typedef struct _xinfo *PXF;
typedef struct _create_xinfo *PCXF;
typedef class TDBDOX *PTDBDOX;
/***********************************************************************/
/* Definition of classes XCOLCRT, XIXDEF, XKPDEF, DOXDEF, TDBDOX */
/* These classes purpose is chiefly to access protected items! */
/***********************************************************************/
class XCOLCRT: public COLCRT {
friend class ha_connect;
friend bool CntCreateTable(PGLOBAL, char *, PCXF);
public:
XCOLCRT(PSZ name) : COLCRT(name) {Nulls= -1;} // Constructor
bool HasNulls(void) {return (Nulls != 0);}
private:
int Nulls;
}; // end of class XCOLCRT
class DOXDEF: public DOSDEF {
//friend class TDBDOX;
//friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int);
}; // end of class DOXDEF
/***********************************************************************/
/* This is the DOS/UNIX Access Method base class declaration. */
/***********************************************************************/
class TDBDOX: public TDBDOS {
friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntCloseTable(PGLOBAL, PTDB);
friend int CntIndexInit(PGLOBAL, PTDB, int);
friend RCODE CntIndexRead(PGLOBAL, PTDB, OPVAL, const void*, int);
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*,
bool*, key_part_map*);
friend class ha_connect;
}; // end of class TDBDOX
class XKPDEF: public KPARTDEF {
friend class TDBDOX;
friend class ha_connect;
//friend int CntMakeIndex(PGLOBAL, const char *, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int);
public:
XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {HasNulls= false;}
void SetNulls(bool b) {HasNulls= b;}
protected:
bool HasNulls; /* Can have null values */
}; // end of class XKPDEF
RCODE CheckRecord(PGLOBAL g, PTDB tdbp, char *oldbuf, char *newbuf);

File diff suppressed because it is too large Load Diff

View File

@@ -1,106 +1,106 @@
/*************** Csort H Declares Source Code File (.H) ****************/
/* Name: CSORT.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */
/* */
/* This file contains the CSORT class declares (not 64-bits ready) */
/* */
/* Note on use of this class: This class is meant to be used as a */
/* base class by the calling class. This is because the comparison */
/* routine must belong to both CSORT and the calling class. */
/* This avoids to pass explicitly to it the calling "this" pointer. */
/***********************************************************************/
#if !defined(CSORT_DEFINED)
#define CSORT_DEFINED
#include <math.h> /* Required for log function */
#undef DOMAIN // Was defined in math.h
/***********************************************************************/
/* Constant and external definitions. */
/***********************************************************************/
#define THRESH 4 /* Threshold for insertion (was 4) */
#define MTHRESH 6 /* Threshold for median */
#ifdef DEBTRACE
extern FILE *debug; /* Debug file */
#endif
typedef int* const CPINT;
/***********************************************************************/
/* This is the CSORT base class declaration. */
/***********************************************************************/
class DllExport CSORT {
public:
// Constructor
CSORT(bool cns, int th = THRESH, int mth = MTHRESH);
protected:
// Implementation
/*********************************************************************/
/* qsortx/qstx are NOT conservative but use less storage space. */
/* qsortc/qstc ARE conservative but use more storage space. */
/*********************************************************************/
int Qsortx(void); /* Index quick/insert sort */
void Qstx(int *base, int *max); /* Preliminary quick sort */
int Qsortc(void); /* Conservative q/ins sort */
void Qstc(int *base, int *max); /* Preliminary quick sort */
void Istc(int *base, int *hi, int *max); /* Insertion sort routine */
public:
// Methods
int Qsort(PGLOBAL g, int n); /* Sort calling routine */
//virtual void Print(PGLOBAL g, FILE *f, uint n);
//virtual void Print(PGLOBAL g, char *ps, uint z);
#ifdef DEBTRACE
int GetNcmp(void) {return num_comp;}
#endif
protected:
// Overridable
virtual int Qcompare(int *, int *) = 0; /* Item compare routine */
#ifdef DEBTRACE
virtual void DebugSort(int ph, int n, int *base, int *mid, int *tmp);
#endif
public:
// Utility
static void SetCmpNum(void)
{for (int i = 1; i < 1000; i++) Cpn[i] = Cmpnum(i); Limit = 1000;}
protected:
static size_t Cmpnum(int n)
#if defined(AIX)
{return (n < Limit) ? Cpn[n]
: (size_t)round(1.0 + (double)n * (log2((double)n) - 1.0));}
#else // !AIX
{return (n < Limit) ? Cpn[n]
: (size_t)(1.5 + (double)n * (log((double)n)/Lg2 - 1.0));}
#endif // !AIX
// Members
static int Limit; /* Size of precalculated array */
static size_t Cpn[1000]; /* Precalculated cmpnum values */
static double Lg2; /* Precalculated log(2) value */
PGLOBAL G;
PDBUSER Dup; /* Used for progress info */
bool Cons; /* true for conservative sort */
int Thresh; /* Threshold for using qsort */
int Mthresh; /* Threshold for median find */
int Nitem; /* Number of items to sort */
MBLOCK Index; /* Index allocation block */
MBLOCK Offset; /* Offset allocation block */
CPINT &Pex; /* Reference to sort index */
CPINT &Pof; /* Reference to offset array */
int *Swix; /* Pointer on EQ/GT work area */
int Savmax; /* Saved ProgMax value */
int Savcur; /* Saved ProgCur value */
LPCSTR Savstep; /* Saved progress step */
#ifdef DEBTRACE
int num_comp; /* Number of quick sort calls */
#endif
}; // end of class CSORT
#endif // CSORT_DEFINED
/*************** Csort H Declares Source Code File (.H) ****************/
/* Name: CSORT.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */
/* */
/* This file contains the CSORT class declares (not 64-bits ready) */
/* */
/* Note on use of this class: This class is meant to be used as a */
/* base class by the calling class. This is because the comparison */
/* routine must belong to both CSORT and the calling class. */
/* This avoids to pass explicitly to it the calling "this" pointer. */
/***********************************************************************/
#if !defined(CSORT_DEFINED)
#define CSORT_DEFINED
#include <math.h> /* Required for log function */
#undef DOMAIN // Was defined in math.h
/***********************************************************************/
/* Constant and external definitions. */
/***********************************************************************/
#define THRESH 4 /* Threshold for insertion (was 4) */
#define MTHRESH 6 /* Threshold for median */
#ifdef DEBTRACE
extern FILE *debug; /* Debug file */
#endif
typedef int* const CPINT;
/***********************************************************************/
/* This is the CSORT base class declaration. */
/***********************************************************************/
class DllExport CSORT {
public:
// Constructor
CSORT(bool cns, int th = THRESH, int mth = MTHRESH);
protected:
// Implementation
/*********************************************************************/
/* qsortx/qstx are NOT conservative but use less storage space. */
/* qsortc/qstc ARE conservative but use more storage space. */
/*********************************************************************/
int Qsortx(void); /* Index quick/insert sort */
void Qstx(int *base, int *max); /* Preliminary quick sort */
int Qsortc(void); /* Conservative q/ins sort */
void Qstc(int *base, int *max); /* Preliminary quick sort */
void Istc(int *base, int *hi, int *max); /* Insertion sort routine */
public:
// Methods
int Qsort(PGLOBAL g, int n); /* Sort calling routine */
//virtual void Print(PGLOBAL g, FILE *f, uint n);
//virtual void Print(PGLOBAL g, char *ps, uint z);
#ifdef DEBTRACE
int GetNcmp(void) {return num_comp;}
#endif
protected:
// Overridable
virtual int Qcompare(int *, int *) = 0; /* Item compare routine */
#ifdef DEBTRACE
virtual void DebugSort(int ph, int n, int *base, int *mid, int *tmp);
#endif
public:
// Utility
static void SetCmpNum(void)
{for (int i = 1; i < 1000; i++) Cpn[i] = Cmpnum(i); Limit = 1000;}
protected:
static size_t Cmpnum(int n)
#if defined(AIX)
{return (n < Limit) ? Cpn[n]
: (size_t)round(1.0 + (double)n * (log2((double)n) - 1.0));}
#else // !AIX
{return (n < Limit) ? Cpn[n]
: (size_t)(1.5 + (double)n * (log((double)n)/Lg2 - 1.0));}
#endif // !AIX
// Members
static int Limit; /* Size of precalculated array */
static size_t Cpn[1000]; /* Precalculated cmpnum values */
static double Lg2; /* Precalculated log(2) value */
PGLOBAL G;
PDBUSER Dup; /* Used for progress info */
bool Cons; /* true for conservative sort */
int Thresh; /* Threshold for using qsort */
int Mthresh; /* Threshold for median find */
int Nitem; /* Number of items to sort */
MBLOCK Index; /* Index allocation block */
MBLOCK Offset; /* Offset allocation block */
CPINT &Pex; /* Reference to sort index */
CPINT &Pof; /* Reference to offset array */
int *Swix; /* Pointer on EQ/GT work area */
int Savmax; /* Saved ProgMax value */
int Savcur; /* Saved ProgCur value */
LPCSTR Savstep; /* Saved progress step */
#ifdef DEBTRACE
int num_comp; /* Number of quick sort calls */
#endif
}; // end of class CSORT
#endif // CSORT_DEFINED

File diff suppressed because it is too large Load Diff

View File

@@ -1,138 +1,138 @@
/******************************************************************/
/* Declaration of XML document processing using MS DOM */
/* Author: Olivier Bertrand 2007 - 2012 */
/******************************************************************/
#include "plgxml.h"
typedef class DOMDOC *PDOMDOC;
typedef class DOMNODE *PDOMNODE;
typedef class DOMATTR *PDOMATTR;
typedef class DOMNODELIST *PDOMLIST;
/******************************************************************/
/* XML block. Must have the same layout than FBLOCK up to Type. */
/******************************************************************/
typedef struct _xblock { /* Loaded XML file block */
struct _xblock *Next;
LPCSTR Fname; /* Point on file name */
size_t Length; /* Used to tell if read mode */
short Count; /* Nb of times file is used */
short Type; /* TYPE_FB_XML */
int Retcode; /* Return code from Load */
MSXML2::IXMLDOMDocumentPtr Docp;/* Document interface pointer */
//IXMLDOMNodeListPtr Nlist;
} XBLOCK, *PXBLOCK;
/******************************************************************/
/* Declaration of DOM document. */
/******************************************************************/
class DOMDOC : public XMLDOCUMENT {
friend class DOMNODE;
public:
// Constructor
DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp);
// Properties
virtual short GetDocType(void) {return TYPE_FB_XML;}
virtual void *GetDocPtr(void) {return Docp;}
// Methods
virtual bool Initialize(PGLOBAL g);
virtual bool ParseFile(char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver);
virtual void AddComment(PGLOBAL g, char *com);
virtual PXNODE GetRoot(PGLOBAL g);
virtual PXNODE NewRoot(PGLOBAL g, char *name);
virtual PXNODE NewPnode(PGLOBAL g, char *name);
virtual PXATTR NewPattr(PGLOBAL g);
virtual PXLIST NewPlist(PGLOBAL g);
virtual int DumpDoc(PGLOBAL g, char *ofn);
virtual void CloseDoc(PGLOBAL g, PFBLOCK xp);
virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn);
protected:
// Members
MSXML2::IXMLDOMDocumentPtr Docp;
MSXML2::IXMLDOMNodeListPtr Nlist;
HRESULT Hr;
}; // end of class DOMDOC
/******************************************************************/
/* Declaration of DOM XML node. */
/******************************************************************/
class DOMNODE : public XMLNODE {
friend class DOMDOC;
friend class DOMNODELIST;
public:
// Properties
virtual char *GetName(PGLOBAL g);
virtual int GetType(void) {return Nodep->nodeType;}
virtual PXNODE GetNext(PGLOBAL g);
virtual PXNODE GetChild(PGLOBAL g);
// Methods
virtual char *GetText(char *buf, int len);
virtual bool SetContent(PGLOBAL g, char *txtp, int len);
virtual PXNODE Clone(PGLOBAL g, PXNODE np);
virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp);
virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
virtual void AddText(PGLOBAL g, char *txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected:
// Constructor
DOMNODE(PXDOC dp, MSXML2::IXMLDOMNodePtr np);
// Members
MSXML2::IXMLDOMDocumentPtr Docp;
MSXML2::IXMLDOMNodePtr Nodep;
char Name[64];
WCHAR *Ws;
int Len;
}; // end of class DOMNODE
/******************************************************************/
/* Declaration of DOM XML node list. */
/******************************************************************/
class DOMNODELIST : public XMLNODELIST {
friend class DOMDOC;
friend class DOMNODE;
public:
// Methods
virtual int GetLength(void) {return Listp->length;}
virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np);
protected:
// Constructor
DOMNODELIST(PXDOC dp, MSXML2::IXMLDOMNodeListPtr lp);
// Members
MSXML2::IXMLDOMNodeListPtr Listp;
}; // end of class DOMNODELIST
/******************************************************************/
/* Declaration of DOM XML attribute. */
/******************************************************************/
class DOMATTR : public XMLATTRIBUTE {
friend class DOMDOC;
friend class DOMNODE;
public:
// Properties
//virtual char *GetText(void);
// Methods
virtual bool SetText(PGLOBAL g, char *txtp, int len);
protected:
// Constructor
DOMATTR(PXDOC dp, MSXML2::IXMLDOMAttributePtr ap);
// Members
MSXML2::IXMLDOMAttributePtr Atrp;
WCHAR *Ws;
int Len;
}; // end of class DOMATTR
/******************************************************************/
/* Declaration of XML document processing using MS DOM */
/* Author: Olivier Bertrand 2007 - 2012 */
/******************************************************************/
#include "plgxml.h"
typedef class DOMDOC *PDOMDOC;
typedef class DOMNODE *PDOMNODE;
typedef class DOMATTR *PDOMATTR;
typedef class DOMNODELIST *PDOMLIST;
/******************************************************************/
/* XML block. Must have the same layout than FBLOCK up to Type. */
/******************************************************************/
typedef struct _xblock { /* Loaded XML file block */
struct _xblock *Next;
LPCSTR Fname; /* Point on file name */
size_t Length; /* Used to tell if read mode */
short Count; /* Nb of times file is used */
short Type; /* TYPE_FB_XML */
int Retcode; /* Return code from Load */
MSXML2::IXMLDOMDocumentPtr Docp;/* Document interface pointer */
//IXMLDOMNodeListPtr Nlist;
} XBLOCK, *PXBLOCK;
/******************************************************************/
/* Declaration of DOM document. */
/******************************************************************/
class DOMDOC : public XMLDOCUMENT {
friend class DOMNODE;
public:
// Constructor
DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp);
// Properties
virtual short GetDocType(void) {return TYPE_FB_XML;}
virtual void *GetDocPtr(void) {return Docp;}
// Methods
virtual bool Initialize(PGLOBAL g);
virtual bool ParseFile(char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver);
virtual void AddComment(PGLOBAL g, char *com);
virtual PXNODE GetRoot(PGLOBAL g);
virtual PXNODE NewRoot(PGLOBAL g, char *name);
virtual PXNODE NewPnode(PGLOBAL g, char *name);
virtual PXATTR NewPattr(PGLOBAL g);
virtual PXLIST NewPlist(PGLOBAL g);
virtual int DumpDoc(PGLOBAL g, char *ofn);
virtual void CloseDoc(PGLOBAL g, PFBLOCK xp);
virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn);
protected:
// Members
MSXML2::IXMLDOMDocumentPtr Docp;
MSXML2::IXMLDOMNodeListPtr Nlist;
HRESULT Hr;
}; // end of class DOMDOC
/******************************************************************/
/* Declaration of DOM XML node. */
/******************************************************************/
class DOMNODE : public XMLNODE {
friend class DOMDOC;
friend class DOMNODELIST;
public:
// Properties
virtual char *GetName(PGLOBAL g);
virtual int GetType(void) {return Nodep->nodeType;}
virtual PXNODE GetNext(PGLOBAL g);
virtual PXNODE GetChild(PGLOBAL g);
// Methods
virtual char *GetText(char *buf, int len);
virtual bool SetContent(PGLOBAL g, char *txtp, int len);
virtual PXNODE Clone(PGLOBAL g, PXNODE np);
virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp);
virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
virtual void AddText(PGLOBAL g, char *txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected:
// Constructor
DOMNODE(PXDOC dp, MSXML2::IXMLDOMNodePtr np);
// Members
MSXML2::IXMLDOMDocumentPtr Docp;
MSXML2::IXMLDOMNodePtr Nodep;
char Name[64];
WCHAR *Ws;
int Len;
}; // end of class DOMNODE
/******************************************************************/
/* Declaration of DOM XML node list. */
/******************************************************************/
class DOMNODELIST : public XMLNODELIST {
friend class DOMDOC;
friend class DOMNODE;
public:
// Methods
virtual int GetLength(void) {return Listp->length;}
virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np);
protected:
// Constructor
DOMNODELIST(PXDOC dp, MSXML2::IXMLDOMNodeListPtr lp);
// Members
MSXML2::IXMLDOMNodeListPtr Listp;
}; // end of class DOMNODELIST
/******************************************************************/
/* Declaration of DOM XML attribute. */
/******************************************************************/
class DOMATTR : public XMLATTRIBUTE {
friend class DOMDOC;
friend class DOMNODE;
public:
// Properties
//virtual char *GetText(void);
// Methods
virtual bool SetText(PGLOBAL g, char *txtp, int len);
protected:
// Constructor
DOMATTR(PXDOC dp, MSXML2::IXMLDOMAttributePtr ap);
// Members
MSXML2::IXMLDOMAttributePtr Atrp;
WCHAR *Ws;
int Len;
}; // end of class DOMATTR

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,114 +1,114 @@
/*************** FilAMap H Declares Source Code File (.H) **************/
/* Name: FILAMAP.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the MAP file access method classes declares. */
/***********************************************************************/
#ifndef __FILAMAP_H
#define __FILAMAP_H
#include "block.h"
#include "filamtxt.h"
typedef class MAPFAM *PMAPFAM;
/***********************************************************************/
/* This is the variable file access method using file mapping. */
/***********************************************************************/
class DllExport MAPFAM : public TXTFAM {
public:
// Constructor
MAPFAM(PDOSDEF tdp);
MAPFAM(PMAPFAM tmfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MAP;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MAPFAM(this);}
// Methods
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g);
virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
// Members
char *Memory; // Pointer on file mapping view.
char *Mempos; // Position of next data to read
char *Fpos; // Position of last read record
char *Tpos; // Target Position for delete move
char *Spos; // Start position for delete move
char *Top; // Mark end of file mapping view
}; // end of class MAPFAM
/***********************************************************************/
/* This is the blocked file access method using file mapping. */
/***********************************************************************/
class DllExport MBKFAM : public MAPFAM {
public:
// Constructor
MBKFAM(PDOSDEF tdp);
MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {}
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MBKFAM(this);}
// Methods
virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
virtual int GetRowID(void);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g);
virtual void Rewind(void);
protected:
// No additional members
}; // end of class MBKFAM
/***********************************************************************/
/* This is the fixed file access method using file mapping. */
/***********************************************************************/
class DllExport MPXFAM : public MBKFAM {
public:
// Constructor
MPXFAM(PDOSDEF tdp);
MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {}
// Implementation
virtual int GetPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MPXFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
//virtual int GetRowID(void);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
protected:
// No additional members
}; // end of class MPXFAM
#endif // __FILAMAP_H
/*************** FilAMap H Declares Source Code File (.H) **************/
/* Name: FILAMAP.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the MAP file access method classes declares. */
/***********************************************************************/
#ifndef __FILAMAP_H
#define __FILAMAP_H
#include "block.h"
#include "filamtxt.h"
typedef class MAPFAM *PMAPFAM;
/***********************************************************************/
/* This is the variable file access method using file mapping. */
/***********************************************************************/
class DllExport MAPFAM : public TXTFAM {
public:
// Constructor
MAPFAM(PDOSDEF tdp);
MAPFAM(PMAPFAM tmfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MAP;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MAPFAM(this);}
// Methods
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g);
virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
// Members
char *Memory; // Pointer on file mapping view.
char *Mempos; // Position of next data to read
char *Fpos; // Position of last read record
char *Tpos; // Target Position for delete move
char *Spos; // Start position for delete move
char *Top; // Mark end of file mapping view
}; // end of class MAPFAM
/***********************************************************************/
/* This is the blocked file access method using file mapping. */
/***********************************************************************/
class DllExport MBKFAM : public MAPFAM {
public:
// Constructor
MBKFAM(PDOSDEF tdp);
MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {}
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MBKFAM(this);}
// Methods
virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
virtual int GetRowID(void);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g);
virtual void Rewind(void);
protected:
// No additional members
}; // end of class MBKFAM
/***********************************************************************/
/* This is the fixed file access method using file mapping. */
/***********************************************************************/
class DllExport MPXFAM : public MBKFAM {
public:
// Constructor
MPXFAM(PDOSDEF tdp);
MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {}
// Implementation
virtual int GetPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MPXFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
//virtual int GetRowID(void);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
protected:
// No additional members
}; // end of class MPXFAM
#endif // __FILAMAP_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,111 +1,111 @@
/***************** FilAmDbf H Declares Source Code File (.H) ****************/
/* Name: filamdbf.h Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the DBF file access method classes declares. */
/****************************************************************************/
#ifndef __FILAMDBF_H
#define __FILAMDBF_H
#include "filamfix.h"
#include "filamap.h"
typedef class DBFBASE *PDBF;
typedef class DBFFAM *PDBFFAM;
typedef class DBMFAM *PDBMFAM;
/****************************************************************************/
/* This is the base class for dBASE file access methods. */
/****************************************************************************/
class DllExport DBFBASE {
public:
// Constructors
DBFBASE(PDOSDEF tdp);
DBFBASE(PDBF txfp);
// Implementation
int ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath);
protected:
// Default constructor, not to be used
DBFBASE(void) {}
// Members
int Records; /* records in the file */
bool Accept; /* true if bad lines are accepted */
int Nerr; /* Number of bad records */
int Maxerr; /* Maximum number of bad records */
int ReadMode; /* 1: ALL 2: DEL 0: NOT DEL */
//PSZ Defpath; /* Default data path */
}; // end of class DBFBASE
/****************************************************************************/
/* This is the DOS/UNIX Access Method class declaration for DBase files. */
/****************************************************************************/
class DllExport DBFFAM : public FIXFAM, public DBFBASE {
public:
// Constructors
DBFFAM(PDOSDEF tdp) : FIXFAM(tdp), DBFBASE(tdp) {}
DBFFAM(PDBFFAM txfp) : FIXFAM(txfp), DBFBASE((PDBF)txfp) {}
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DBF;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DBFFAM(this);}
// Methods
virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed
virtual bool OpenTableFile(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
// Members
virtual bool CopyHeader(PGLOBAL g);
//int Records; in TXTFAM
//int Headlen; in TXTFAM
}; // end of class DBFFAM
/****************************************************************************/
/* This is the DOS/UNIX Access Method class declaration for DBase files */
/* using file mapping to access the file. */
/****************************************************************************/
class DllExport DBMFAM : public MPXFAM, public DBFBASE {
public:
// Constructors
DBMFAM(PDOSDEF tdp) : MPXFAM(tdp), DBFBASE(tdp) {}
DBMFAM(PDBMFAM txfp) : MPXFAM(txfp), DBFBASE((PDBF)txfp) {}
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DBF;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DBMFAM(this);}
virtual int GetDelRows(void);
// Methods
virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed
virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void Rewind(void);
protected:
// Members
//int Records; in TXTFAM
//int Headlen; in TXTFAM
}; // end of class DBFFAM
#endif // __FILAMDBF_H
/***************** FilAmDbf H Declares Source Code File (.H) ****************/
/* Name: filamdbf.h Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the DBF file access method classes declares. */
/****************************************************************************/
#ifndef __FILAMDBF_H
#define __FILAMDBF_H
#include "filamfix.h"
#include "filamap.h"
typedef class DBFBASE *PDBF;
typedef class DBFFAM *PDBFFAM;
typedef class DBMFAM *PDBMFAM;
/****************************************************************************/
/* This is the base class for dBASE file access methods. */
/****************************************************************************/
class DllExport DBFBASE {
public:
// Constructors
DBFBASE(PDOSDEF tdp);
DBFBASE(PDBF txfp);
// Implementation
int ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath);
protected:
// Default constructor, not to be used
DBFBASE(void) {}
// Members
int Records; /* records in the file */
bool Accept; /* true if bad lines are accepted */
int Nerr; /* Number of bad records */
int Maxerr; /* Maximum number of bad records */
int ReadMode; /* 1: ALL 2: DEL 0: NOT DEL */
//PSZ Defpath; /* Default data path */
}; // end of class DBFBASE
/****************************************************************************/
/* This is the DOS/UNIX Access Method class declaration for DBase files. */
/****************************************************************************/
class DllExport DBFFAM : public FIXFAM, public DBFBASE {
public:
// Constructors
DBFFAM(PDOSDEF tdp) : FIXFAM(tdp), DBFBASE(tdp) {}
DBFFAM(PDBFFAM txfp) : FIXFAM(txfp), DBFBASE((PDBF)txfp) {}
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DBF;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DBFFAM(this);}
// Methods
virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed
virtual bool OpenTableFile(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
// Members
virtual bool CopyHeader(PGLOBAL g);
//int Records; in TXTFAM
//int Headlen; in TXTFAM
}; // end of class DBFFAM
/****************************************************************************/
/* This is the DOS/UNIX Access Method class declaration for DBase files */
/* using file mapping to access the file. */
/****************************************************************************/
class DllExport DBMFAM : public MPXFAM, public DBFBASE {
public:
// Constructors
DBMFAM(PDOSDEF tdp) : MPXFAM(tdp), DBFBASE(tdp) {}
DBMFAM(PDBMFAM txfp) : MPXFAM(txfp), DBFBASE((PDBF)txfp) {}
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DBF;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DBMFAM(this);}
virtual int GetDelRows(void);
// Methods
virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed
virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void Rewind(void);
protected:
// Members
//int Records; in TXTFAM
//int Headlen; in TXTFAM
}; // end of class DBFFAM
#endif // __FILAMDBF_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,90 +1,90 @@
/************** FilAMFix H Declares Source Code File (.H) **************/
/* Name: FILAMFIX.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005 - 2012 */
/* */
/* This file contains the FIX file access method classes declares. */
/***********************************************************************/
#ifndef __FILAMFIX_H
#define __FILAMFIX_H
#include "filamtxt.h"
typedef class FIXFAM *PFIXFAM;
typedef class BGXFAM *PBGXFAM;
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */
/* files with fixed record format (FIX, BIN) */
/***********************************************************************/
class DllExport FIXFAM : public BLKFAM {
public:
// Constructor
FIXFAM(PDOSDEF tdp);
FIXFAM(PFIXFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FIX;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) FIXFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
protected:
virtual bool CopyHeader(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
// No additional members
}; // end of class FIXFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* that are standard files with columns starting at fixed offset */
/* This class is for fixed formatted files of more than 2 gigabytes. */
/***********************************************************************/
class BGXFAM : public FIXFAM {
public:
// Constructor
BGXFAM(PDOSDEF tdp);
BGXFAM(PBGXFAM txfp);
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BGXFAM(this);}
// Methods
//virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos
, int org = FILE_BEGIN);
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
// Members
HANDLE Hfile; // Handle(descriptor) to big file
HANDLE Tfile; // Handle(descriptor) to big temp file
//BIGINT Xpos; // Current file position
}; // end of class BGXFAM
#endif // __FILAMFIX_H
/************** FilAMFix H Declares Source Code File (.H) **************/
/* Name: FILAMFIX.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005 - 2012 */
/* */
/* This file contains the FIX file access method classes declares. */
/***********************************************************************/
#ifndef __FILAMFIX_H
#define __FILAMFIX_H
#include "filamtxt.h"
typedef class FIXFAM *PFIXFAM;
typedef class BGXFAM *PBGXFAM;
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */
/* files with fixed record format (FIX, BIN) */
/***********************************************************************/
class DllExport FIXFAM : public BLKFAM {
public:
// Constructor
FIXFAM(PDOSDEF tdp);
FIXFAM(PFIXFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FIX;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) FIXFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
protected:
virtual bool CopyHeader(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
// No additional members
}; // end of class FIXFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* that are standard files with columns starting at fixed offset */
/* This class is for fixed formatted files of more than 2 gigabytes. */
/***********************************************************************/
class BGXFAM : public FIXFAM {
public:
// Constructor
BGXFAM(PDOSDEF tdp);
BGXFAM(PBGXFAM txfp);
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BGXFAM(this);}
// Methods
//virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos
, int org = FILE_BEGIN);
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
// Members
HANDLE Hfile; // Handle(descriptor) to big file
HANDLE Tfile; // Handle(descriptor) to big temp file
//BIGINT Xpos; // Current file position
}; // end of class BGXFAM
#endif // __FILAMFIX_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,198 +1,198 @@
/************** FilAMTxt H Declares Source Code File (.H) **************/
/* Name: FILAMTXT.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the file access method classes declares. */
/***********************************************************************/
#ifndef __FILAMTXT_H
#define __FILAMTXT_H
#include "block.h"
typedef class TXTFAM *PTXF;
typedef class DOSFAM *PDOSFAM;
typedef class BLKFAM *PBLKFAM;
typedef class DOSDEF *PDOSDEF;
typedef class TDBDOS *PTDBDOS;
#define TYPE_AM_BLK (AMT)160
/***********************************************************************/
/* This is the base class for all file access method classes. */
/***********************************************************************/
class DllExport TXTFAM : public BLOCK {
friend class TDBDOS;
friend class TDBCSV;
friend class TDBFIX;
friend class TDBVCT;
friend class DOSCOL;
friend class BINCOL;
friend class VCTCOL;
public:
// Constructor
TXTFAM(PDOSDEF tdp);
TXTFAM(PTXF txfp);
// Implementation
virtual AMT GetAmType(void) = 0;
virtual int GetPos(void) = 0;
virtual int GetNextPos(void) = 0;
virtual PTXF Duplicate(PGLOBAL g) = 0;
virtual bool GetUseTemp(void) {return false;}
virtual int GetDelRows(void) {return DelRows;}
int GetCurBlk(void) {return CurBlk;}
void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;}
int GetBlock(void) {return Block;}
void SetBlkPos(int *bkp) {BlkPos = bkp;}
void SetNrec(int n) {Nrec = n;}
char *GetBuf(void) {return To_Buf;}
int GetRows(void) {return Rows;}
bool IsBlocked(void) {return Blocked;}
// Methods
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g) {return false;}
virtual void ResetBuffer(PGLOBAL g) {}
virtual int GetNerr(void) {return 0;}
virtual int GetRowID(void) = 0;
virtual bool RecordPos(PGLOBAL g) = 0;
virtual bool SetPos(PGLOBAL g, int recpos) = 0;
virtual int SkipRecord(PGLOBAL g, bool header) = 0;
virtual bool OpenTableFile(PGLOBAL g) = 0;
virtual bool DeferReading(void) {IsRead = false; return true;}
virtual int ReadBuffer(PGLOBAL g) = 0;
virtual int WriteBuffer(PGLOBAL g) = 0;
virtual int DeleteRecords(PGLOBAL g, int irc) = 0;
virtual void CloseTableFile(PGLOBAL g) = 0;
virtual void Rewind(void) = 0;
protected:
// Members
PTDBDOS Tdbp; // To table class
PSZ To_File; // Points to table file name
PFBLOCK To_Fb; // Pointer to file block
bool Placed; // true if Recpos was externally set
bool IsRead; // false for deferred reading
bool Blocked; // true if using blocked I/O
char *To_Buf; // Points to I/O buffer
void *DelBuf; // Buffer used to move lines in Delete
int *BlkPos; // To array of block positions
int BlkLen; // Current block length
int Buflen; // Buffer length
int Dbflen; // Delete buffer length
int Rows; // Number of rows read so far
int DelRows; // Number of deleted rows
int Headlen; // Number of bytes in header
int Lrecl; // Logical Record Length
int Block; // Number of blocks in table
int Last; // Number of elements of last block
int Nrec; // Number of records in buffer
int OldBlk; // Index of last read block
int CurBlk; // Index of current block
int CurNum; // Current buffer line number
int ReadBlks; // Number of blocks read (selected)
int Rbuf; // Number of lines read in buffer
int Modif; // Number of modified lines in block
int Blksize; // Size of padded blocks
int Ending; // Length of line end
bool Padded; // true if fixed size blocks are padded
bool Eof; // true if an EOF (0xA) character exists
char *CrLf; // End of line character(s)
}; // end of class TXTFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */
/* text files with variable record format (DOS, CSV, FMT) */
/***********************************************************************/
class DllExport DOSFAM : public TXTFAM {
public:
// Constructor
DOSFAM(PDOSDEF tdp);
DOSFAM(PDOSFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DOS;}
virtual bool GetUseTemp(void) {return UseTemp;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DOSFAM(this);}
// Methods
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
virtual int RenameTempFile(PGLOBAL g);
// Members
FILE *Stream; // Points to Dos file structure
FILE *T_Stream; // Points to temporary file structure
PFBLOCK To_Fbt; // Pointer to temp file block
int Fpos; // Position of last read record
int Tpos; // Target Position for delete move
int Spos; // Start position for delete move
bool UseTemp; // True to use a temporary file in Delete
bool Bin; // True to force binary mode
}; // end of class DOSFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */
/* text files with variable record format (DOS, CSV, FMT) */
/***********************************************************************/
class DllExport BLKFAM : public DOSFAM {
public:
// Constructor
BLKFAM(PDOSDEF tdp);
BLKFAM(PBLKFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_BLK;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BLKFAM(this);}
// Methods
virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
// Members
char *CurLine; // Position of current line in buffer
char *NxtLine; // Position of Next line in buffer
char *OutBuf; // Buffer to write in temporary file
bool Closing; // True when closing on Update
}; // end of class BLKFAM
#endif // __FILAMTXT_H
/************** FilAMTxt H Declares Source Code File (.H) **************/
/* Name: FILAMTXT.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the file access method classes declares. */
/***********************************************************************/
#ifndef __FILAMTXT_H
#define __FILAMTXT_H
#include "block.h"
typedef class TXTFAM *PTXF;
typedef class DOSFAM *PDOSFAM;
typedef class BLKFAM *PBLKFAM;
typedef class DOSDEF *PDOSDEF;
typedef class TDBDOS *PTDBDOS;
#define TYPE_AM_BLK (AMT)160
/***********************************************************************/
/* This is the base class for all file access method classes. */
/***********************************************************************/
class DllExport TXTFAM : public BLOCK {
friend class TDBDOS;
friend class TDBCSV;
friend class TDBFIX;
friend class TDBVCT;
friend class DOSCOL;
friend class BINCOL;
friend class VCTCOL;
public:
// Constructor
TXTFAM(PDOSDEF tdp);
TXTFAM(PTXF txfp);
// Implementation
virtual AMT GetAmType(void) = 0;
virtual int GetPos(void) = 0;
virtual int GetNextPos(void) = 0;
virtual PTXF Duplicate(PGLOBAL g) = 0;
virtual bool GetUseTemp(void) {return false;}
virtual int GetDelRows(void) {return DelRows;}
int GetCurBlk(void) {return CurBlk;}
void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;}
int GetBlock(void) {return Block;}
void SetBlkPos(int *bkp) {BlkPos = bkp;}
void SetNrec(int n) {Nrec = n;}
char *GetBuf(void) {return To_Buf;}
int GetRows(void) {return Rows;}
bool IsBlocked(void) {return Blocked;}
// Methods
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g) {return false;}
virtual void ResetBuffer(PGLOBAL g) {}
virtual int GetNerr(void) {return 0;}
virtual int GetRowID(void) = 0;
virtual bool RecordPos(PGLOBAL g) = 0;
virtual bool SetPos(PGLOBAL g, int recpos) = 0;
virtual int SkipRecord(PGLOBAL g, bool header) = 0;
virtual bool OpenTableFile(PGLOBAL g) = 0;
virtual bool DeferReading(void) {IsRead = false; return true;}
virtual int ReadBuffer(PGLOBAL g) = 0;
virtual int WriteBuffer(PGLOBAL g) = 0;
virtual int DeleteRecords(PGLOBAL g, int irc) = 0;
virtual void CloseTableFile(PGLOBAL g) = 0;
virtual void Rewind(void) = 0;
protected:
// Members
PTDBDOS Tdbp; // To table class
PSZ To_File; // Points to table file name
PFBLOCK To_Fb; // Pointer to file block
bool Placed; // true if Recpos was externally set
bool IsRead; // false for deferred reading
bool Blocked; // true if using blocked I/O
char *To_Buf; // Points to I/O buffer
void *DelBuf; // Buffer used to move lines in Delete
int *BlkPos; // To array of block positions
int BlkLen; // Current block length
int Buflen; // Buffer length
int Dbflen; // Delete buffer length
int Rows; // Number of rows read so far
int DelRows; // Number of deleted rows
int Headlen; // Number of bytes in header
int Lrecl; // Logical Record Length
int Block; // Number of blocks in table
int Last; // Number of elements of last block
int Nrec; // Number of records in buffer
int OldBlk; // Index of last read block
int CurBlk; // Index of current block
int CurNum; // Current buffer line number
int ReadBlks; // Number of blocks read (selected)
int Rbuf; // Number of lines read in buffer
int Modif; // Number of modified lines in block
int Blksize; // Size of padded blocks
int Ending; // Length of line end
bool Padded; // true if fixed size blocks are padded
bool Eof; // true if an EOF (0xA) character exists
char *CrLf; // End of line character(s)
}; // end of class TXTFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */
/* text files with variable record format (DOS, CSV, FMT) */
/***********************************************************************/
class DllExport DOSFAM : public TXTFAM {
public:
// Constructor
DOSFAM(PDOSDEF tdp);
DOSFAM(PDOSFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DOS;}
virtual bool GetUseTemp(void) {return UseTemp;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DOSFAM(this);}
// Methods
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
virtual int RenameTempFile(PGLOBAL g);
// Members
FILE *Stream; // Points to Dos file structure
FILE *T_Stream; // Points to temporary file structure
PFBLOCK To_Fbt; // Pointer to temp file block
int Fpos; // Position of last read record
int Tpos; // Target Position for delete move
int Spos; // Start position for delete move
bool UseTemp; // True to use a temporary file in Delete
bool Bin; // True to force binary mode
}; // end of class DOSFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */
/* text files with variable record format (DOS, CSV, FMT) */
/***********************************************************************/
class DllExport BLKFAM : public DOSFAM {
public:
// Constructor
BLKFAM(PDOSDEF tdp);
BLKFAM(PBLKFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_BLK;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BLKFAM(this);}
// Methods
virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
// Members
char *CurLine; // Position of current line in buffer
char *NxtLine; // Position of Next line in buffer
char *OutBuf; // Buffer to write in temporary file
bool Closing; // True when closing on Update
}; // end of class BLKFAM
#endif // __FILAMTXT_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,249 +1,249 @@
/************** FilAMVct H Declares Source Code File (.H) **************/
/* Name: FILAMVCT.H Version 1.5 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the VCT file access method classes declares. */
/***********************************************************************/
#ifndef __FILAMVCT__
#define __FILAMVCT__
#include "filamfix.h"
typedef class VCTFAM *PVCTFAM;
typedef class VCTCOL *PVCTCOL;
typedef class VCMFAM *PVCMFAM;
typedef class VECFAM *PVECFAM;
typedef class VMPFAM *PVMPFAM;
typedef class BGVFAM *PBGVFAM;
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in vector format. If MaxBlk=0, each block containing "Elements" */
/* records, values of each columns are consecutively stored (vector). */
/* Otherwise, data is arranged by column in the file and MaxBlk is */
/* used to set the maximum number of blocks. This leave some white */
/* space allowing to insert new values up to this maximum size. */
/***********************************************************************/
class DllExport VCTFAM : public FIXFAM {
friend class TDBVCT;
friend class VCTCOL;
public:
// Constructor
VCTFAM(PVCTDEF tdp);
VCTFAM(PVCTFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VCTFAM(this);}
// Methods
virtual void Reset(void);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g) {}
virtual int Cardinality(PGLOBAL g);
virtual int GetRowID(void);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected:
virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g);
bool ResetTableSize(PGLOBAL g, int block, int last);
// Members
char *NewBlock; // To block written on Insert
char *Colfn; // Pattern for column file names (VER)
char *Tempat; // Pattern for temp file names (VER)
int *Clens; // Pointer to col size array
int *Deplac; // Pointer to col start position array
bool *Isnum; // Pointer to buffer type isnum result
bool AddBlock; // True when adding new blocks on Insert
bool Split; // true: split column file vector format
int Header; // 0: no, 1: separate, 2: in data file
int MaxBlk; // Max number of blocks (True vector format)
int Bsize; // Because Nrec can be modified
int Ncol; // The number of columns;
}; // end of class VCTFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in vector format accessed using file mapping. */
/***********************************************************************/
class DllExport VCMFAM : public VCTFAM {
friend class TDBVCT;
friend class VCTCOL;
public:
// Constructor
VCMFAM(PVCTDEF tdp);
VCMFAM(PVCMFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VMP;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VCMFAM(this);}
// Methods
virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
// Members
char* Memory; // Pointer on file mapping view.
char* *Memcol; // Pointer on column start.
}; // end of class VCMFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in full vertical format. Each column is contained in a separate */
/* file whose name is the table name followed by the column number. */
/***********************************************************************/
class DllExport VECFAM : public VCTFAM {
friend class TDBVCT;
friend class VCTCOL;
public:
// Constructor
VECFAM(PVCTDEF tdp);
VECFAM(PVECFAM txfp);
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VECFAM(this);}
// Methods
virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected:
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual int RenameTempFile(PGLOBAL g);
bool OpenColumnFile(PGLOBAL g, char *opmode, int i);
// Members
FILE* *Streams; // Points to Dos file structure array
FILE* *T_Streams; // Points to temp file structure array
PFBLOCK *To_Fbs; // Pointer to file block array
PFBLOCK *T_Fbs; // Pointer to temp file block array
void* *To_Bufs; // Pointer to col val block array
bool InitUpdate; // Used to initialize updating
}; // end of class VECFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in full vertical format accessed using file mapping. */
/***********************************************************************/
class DllExport VMPFAM : public VCMFAM {
friend class TDBVCT;
friend class VCTCOL;
public:
// Constructor
VMPFAM(PVCTDEF tdp);
VMPFAM(PVMPFAM txfp);
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VMPFAM(this);}
// Methods
virtual bool AllocateBuffer(PGLOBAL g);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
protected:
bool MapColumnFile(PGLOBAL g, MODE mode, int i);
// Members
PFBLOCK *To_Fbs; // Pointer to file block array
}; // end of class VMPFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in (possibly blocked) vector format that can be larger than 2GB. */
/***********************************************************************/
class BGVFAM : public VCTFAM {
friend class VCTCOL;
public:
// Constructors
BGVFAM(PVCTDEF tdp);
BGVFAM(PBGVFAM txfp);
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BGVFAM(this);}
// Methods
virtual bool AllocateBuffer(PGLOBAL g);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected:
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false);
bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g);
// Members
HANDLE Hfile; // Handle to big file
HANDLE Tfile; // Handle to temporary file
BIGINT *BigDep; // Pointer to col start position array
}; // end of class BGVFAM
#endif // __FILAMVCT__
/************** FilAMVct H Declares Source Code File (.H) **************/
/* Name: FILAMVCT.H Version 1.5 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the VCT file access method classes declares. */
/***********************************************************************/
#ifndef __FILAMVCT__
#define __FILAMVCT__
#include "filamfix.h"
typedef class VCTFAM *PVCTFAM;
typedef class VCTCOL *PVCTCOL;
typedef class VCMFAM *PVCMFAM;
typedef class VECFAM *PVECFAM;
typedef class VMPFAM *PVMPFAM;
typedef class BGVFAM *PBGVFAM;
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in vector format. If MaxBlk=0, each block containing "Elements" */
/* records, values of each columns are consecutively stored (vector). */
/* Otherwise, data is arranged by column in the file and MaxBlk is */
/* used to set the maximum number of blocks. This leave some white */
/* space allowing to insert new values up to this maximum size. */
/***********************************************************************/
class DllExport VCTFAM : public FIXFAM {
friend class TDBVCT;
friend class VCTCOL;
public:
// Constructor
VCTFAM(PVCTDEF tdp);
VCTFAM(PVCTFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VCTFAM(this);}
// Methods
virtual void Reset(void);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g) {}
virtual int Cardinality(PGLOBAL g);
virtual int GetRowID(void);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected:
virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g);
bool ResetTableSize(PGLOBAL g, int block, int last);
// Members
char *NewBlock; // To block written on Insert
char *Colfn; // Pattern for column file names (VER)
char *Tempat; // Pattern for temp file names (VER)
int *Clens; // Pointer to col size array
int *Deplac; // Pointer to col start position array
bool *Isnum; // Pointer to buffer type isnum result
bool AddBlock; // True when adding new blocks on Insert
bool Split; // true: split column file vector format
int Header; // 0: no, 1: separate, 2: in data file
int MaxBlk; // Max number of blocks (True vector format)
int Bsize; // Because Nrec can be modified
int Ncol; // The number of columns;
}; // end of class VCTFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in vector format accessed using file mapping. */
/***********************************************************************/
class DllExport VCMFAM : public VCTFAM {
friend class TDBVCT;
friend class VCTCOL;
public:
// Constructor
VCMFAM(PVCTDEF tdp);
VCMFAM(PVCMFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VMP;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VCMFAM(this);}
// Methods
virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
// Members
char* Memory; // Pointer on file mapping view.
char* *Memcol; // Pointer on column start.
}; // end of class VCMFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in full vertical format. Each column is contained in a separate */
/* file whose name is the table name followed by the column number. */
/***********************************************************************/
class DllExport VECFAM : public VCTFAM {
friend class TDBVCT;
friend class VCTCOL;
public:
// Constructor
VECFAM(PVCTDEF tdp);
VECFAM(PVECFAM txfp);
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VECFAM(this);}
// Methods
virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected:
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual int RenameTempFile(PGLOBAL g);
bool OpenColumnFile(PGLOBAL g, char *opmode, int i);
// Members
FILE* *Streams; // Points to Dos file structure array
FILE* *T_Streams; // Points to temp file structure array
PFBLOCK *To_Fbs; // Pointer to file block array
PFBLOCK *T_Fbs; // Pointer to temp file block array
void* *To_Bufs; // Pointer to col val block array
bool InitUpdate; // Used to initialize updating
}; // end of class VECFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in full vertical format accessed using file mapping. */
/***********************************************************************/
class DllExport VMPFAM : public VCMFAM {
friend class TDBVCT;
friend class VCTCOL;
public:
// Constructor
VMPFAM(PVCTDEF tdp);
VMPFAM(PVMPFAM txfp);
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VMPFAM(this);}
// Methods
virtual bool AllocateBuffer(PGLOBAL g);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
protected:
bool MapColumnFile(PGLOBAL g, MODE mode, int i);
// Members
PFBLOCK *To_Fbs; // Pointer to file block array
}; // end of class VMPFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in (possibly blocked) vector format that can be larger than 2GB. */
/***********************************************************************/
class BGVFAM : public VCTFAM {
friend class VCTCOL;
public:
// Constructors
BGVFAM(PVCTDEF tdp);
BGVFAM(PBGVFAM txfp);
// Implementation
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BGVFAM(this);}
// Methods
virtual bool AllocateBuffer(PGLOBAL g);
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected:
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false);
bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g);
// Members
HANDLE Hfile; // Handle to big file
HANDLE Tfile; // Handle to temporary file
BIGINT *BigDep; // Pointer to col start position array
}; // end of class BGVFAM
#endif // __FILAMVCT__

File diff suppressed because it is too large Load Diff

View File

@@ -1,174 +1,174 @@
/************** FilAmZip H Declares Source Code File (.H) **************/
/* Name: FILAMZIP.H Version 1.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the GZIP access method classes declares. */
/***********************************************************************/
#ifndef __FILAMZIP_H
#define __FILAMZIP_H
#include "zlib.h"
#define TYPE_AM_ZIP (AMT)150
#define TYPE_AM_ZLIB (AMT)155
typedef class ZIPFAM *PZIPFAM;
typedef class ZBKFAM *PZBKFAM;
typedef class ZIXFAM *PZIXFAM;
typedef class ZLBFAM *PZLBFAM;
/***********************************************************************/
/* This is the access method class declaration for not optimized */
/* variable record length files compressed using the gzip library */
/* functions. File is accessed record by record (row). */
/***********************************************************************/
class DllExport ZIPFAM : public TXTFAM {
// friend class DOSCOL;
public:
// Constructor
ZIPFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;}
ZIPFAM(PZIPFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIPFAM(this);}
// Methods
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
int Zerror(PGLOBAL g); // GZ error function
// Members
gzFile Zfile; // Points to GZ file structure
z_off_t Zpos; // Uncompressed file position
}; // end of class ZIPFAM
/***********************************************************************/
/* This is the access method class declaration for optimized variable */
/* record length files compressed using the gzip library functions. */
/* The File is accessed by block (requires an opt file). */
/***********************************************************************/
class DllExport ZBKFAM : public ZIPFAM {
public:
// Constructor
ZBKFAM(PDOSDEF tdp);
ZBKFAM(PZBKFAM txfp);
// Implementation
virtual int GetPos(void);
virtual int GetNextPos(void) {return 0;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZBKFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
// Members
char *CurLine; // Position of current line in buffer
char *NxtLine; // Position of Next line in buffer
bool Closing; // True when closing on Insert
}; // end of class ZBKFAM
/***********************************************************************/
/* This is the access method class declaration for fixed record */
/* length files compressed using the gzip library functions. */
/* The file is always accessed by block. */
/***********************************************************************/
class DllExport ZIXFAM : public ZBKFAM {
public:
// Constructor
ZIXFAM(PDOSDEF tdp);
ZIXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {}
// Implementation
virtual int GetNextPos(void) {return 0;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIXFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
protected:
// No additional Members
}; // end of class ZIXFAM
#ifdef NOT_USED
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for PlugDB */
/* fixed/variable files compressed using the zlib library functions. */
/* Physically these are written and read using the same technique */
/* than blocked variable files, only the contain of each block is */
/* compressed using the deflate zlib function. The purpose of this */
/* specific format is to have a fast mechanism for direct access of */
/* records so blocked optimization is fast and direct access (joins) */
/* is allowed. Note that the block length is written ahead of each */
/* block to enable reading when optimization file is not available. */
/***********************************************************************/
class DllExport ZLBFAM : public BLKFAM {
public:
// Constructor
ZLBFAM(PDOSDEF tdp);
ZLBFAM(PZLBFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZLIB;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZLBFAM(this);}
inline void SetOptimized(bool b) {Optimized = b;}
// Methods
virtual int GetFileLength(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
bool WriteCompressedBuffer(PGLOBAL g);
int ReadCompressedBuffer(PGLOBAL g, void *rdbuf);
// Members
z_streamp Zstream; // Compression/decompression stream
Byte *Zbuffer; // Compressed block buffer
int *Zlenp; // Pointer to block length
bool Optimized; // true when opt file is available
}; // end of class ZLBFAM
#endif // NOT_USED
#endif // __FILAMZIP_H
/************** FilAmZip H Declares Source Code File (.H) **************/
/* Name: FILAMZIP.H Version 1.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the GZIP access method classes declares. */
/***********************************************************************/
#ifndef __FILAMZIP_H
#define __FILAMZIP_H
#include "zlib.h"
#define TYPE_AM_ZIP (AMT)150
#define TYPE_AM_ZLIB (AMT)155
typedef class ZIPFAM *PZIPFAM;
typedef class ZBKFAM *PZBKFAM;
typedef class ZIXFAM *PZIXFAM;
typedef class ZLBFAM *PZLBFAM;
/***********************************************************************/
/* This is the access method class declaration for not optimized */
/* variable record length files compressed using the gzip library */
/* functions. File is accessed record by record (row). */
/***********************************************************************/
class DllExport ZIPFAM : public TXTFAM {
// friend class DOSCOL;
public:
// Constructor
ZIPFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;}
ZIPFAM(PZIPFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIPFAM(this);}
// Methods
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
int Zerror(PGLOBAL g); // GZ error function
// Members
gzFile Zfile; // Points to GZ file structure
z_off_t Zpos; // Uncompressed file position
}; // end of class ZIPFAM
/***********************************************************************/
/* This is the access method class declaration for optimized variable */
/* record length files compressed using the gzip library functions. */
/* The File is accessed by block (requires an opt file). */
/***********************************************************************/
class DllExport ZBKFAM : public ZIPFAM {
public:
// Constructor
ZBKFAM(PDOSDEF tdp);
ZBKFAM(PZBKFAM txfp);
// Implementation
virtual int GetPos(void);
virtual int GetNextPos(void) {return 0;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZBKFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
// Members
char *CurLine; // Position of current line in buffer
char *NxtLine; // Position of Next line in buffer
bool Closing; // True when closing on Insert
}; // end of class ZBKFAM
/***********************************************************************/
/* This is the access method class declaration for fixed record */
/* length files compressed using the gzip library functions. */
/* The file is always accessed by block. */
/***********************************************************************/
class DllExport ZIXFAM : public ZBKFAM {
public:
// Constructor
ZIXFAM(PDOSDEF tdp);
ZIXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {}
// Implementation
virtual int GetNextPos(void) {return 0;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIXFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
protected:
// No additional Members
}; // end of class ZIXFAM
#ifdef NOT_USED
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for PlugDB */
/* fixed/variable files compressed using the zlib library functions. */
/* Physically these are written and read using the same technique */
/* than blocked variable files, only the contain of each block is */
/* compressed using the deflate zlib function. The purpose of this */
/* specific format is to have a fast mechanism for direct access of */
/* records so blocked optimization is fast and direct access (joins) */
/* is allowed. Note that the block length is written ahead of each */
/* block to enable reading when optimization file is not available. */
/***********************************************************************/
class DllExport ZLBFAM : public BLKFAM {
public:
// Constructor
ZLBFAM(PDOSDEF tdp);
ZLBFAM(PZLBFAM txfp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZLIB;}
virtual int GetPos(void);
virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZLBFAM(this);}
inline void SetOptimized(bool b) {Optimized = b;}
// Methods
virtual int GetFileLength(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
bool WriteCompressedBuffer(PGLOBAL g);
int ReadCompressedBuffer(PGLOBAL g, void *rdbuf);
// Members
z_streamp Zstream; // Compression/decompression stream
Byte *Zbuffer; // Compressed block buffer
int *Zlenp; // Pointer to block length
bool Optimized; // true when opt file is available
}; // end of class ZLBFAM
#endif // NOT_USED
#endif // __FILAMZIP_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,251 +1,250 @@
/***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright Olivier Bertrand 1993-2012 */
/***********************************************************************/
/***********************************************************************/
/* Included C-definition files common to all Plug routines */
/***********************************************************************/
#include <string.h> /* String manipulation declares */
#include <stdlib.h> /* C standard library */
#include <ctype.h> /* C language specific types */
#include <stdio.h> /* FOPEN_MAX declaration */
#include <time.h> /* time_t type declaration */
#include <setjmp.h> /* Long jump declarations */
#if defined(WIN32) && !defined(NOEX)
#define DllExport __declspec( dllexport )
#else // !WIN32
#define DllExport
#endif // !WIN32
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT)
#define XML_SUPPORT 1
#endif
#if defined(XMSG)
// Definition used to read messages from message file.
#include "msgid.h"
#define MSG(I) PlugReadMessage(NULL, MSG_##I, #I)
#define STEP(I) PlugReadMessage(g, MSG_##I, #I)
#elif defined(NEWMSG)
// Definition used to get messages from resource.
#include "msgid.h"
#define MSG(I) PlugGetMessage(NULL, MSG_##I)
#define STEP(I) PlugGetMessage(g, MSG_##I)
#else // !XMSG and !NEWMSG
// Definition used to replace messages ID's by their definition.
#include "messages.h"
#define MSG(I) MSG_##I
#define STEP(I) MSG_##I
#endif // !XMSG and !NEWMSG
#if defined(WIN32)
#define CRLF 2
#else // !WIN32
#define CRLF 1
#define BOOL my_bool
#endif // !WIN32
/***********************************************************************/
/* Miscellaneous Constants */
/***********************************************************************/
#define NO_IVAL -95684275 /* Used by GetIntegerOption */
#define VMLANG 370 /* Size of olf VM lang blocks */
#define MAX_JUMP 24 /* Maximum jump level number */
#define MAX_STR 1024 /* Maximum string length */
#define STR_SIZE 501 /* Length of char strings. */
#define STD_INPUT 0 /* Standard language input */
#define STD_OUTPUT 1 /* Standard language output */
#define ERROR_OUTPUT 2 /* Error message output */
#define DEBUG_OUTPUT 3 /* Debug info output */
#define PROMPT_OUTPUT 4 /* Prompt message output */
#define COPY_OUTPUT 5 /* Copy of language input */
#define STD_MSG 6 /* System message file */
#define DEBUG_MSG 7 /* Debug message file */
#define DUMMY 0 /* Dummy file index in Ldm block */
#define STDIN 1 /* stdin file index in Ldm block */
#define STDOUT 2 /* stdout file index in Ldm block */
#define STDERR 3 /* stderr file index in Ldm block */
#define STDEBUG 4 /* debug file index in Ldm block */
#define STDPRN 5 /* stdprn file index in Ldm block */
#define STDFREE 6 /* Free file index in Ldm block */
#define TYPE_SEM -2 /* Returned semantic function */
#define TYPE_DFONC -2 /* Indirect sem ref in FPARM */
#define TYPE_VOID -1
#define TYPE_SBPAR -1 /* Phrase reference in FPARM */
#define TYPE_SEMX 0 /* Initial semantic function type? */
#define TYPE_ERROR 0
#define TYPE_STRING 1
#define TYPE_FLOAT 2
#define TYPE_SHORT 3
#define TYPE_BIGINT 5
#define TYPE_LIST 6
#define TYPE_INT 7
#if defined(OS32)
#define SYS_STAMP "OS32"
#elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
#define SYS_STAMP "UNIX"
#elif defined(OS16)
#define SYS_STAMP "OS16"
#elif defined(DOSR)
#define SYS_STAMP "DOSR"
#elif defined(WIN)
#define SYS_STAMP "WIN1"
#elif defined(WIN32)
#define SYS_STAMP "WIN2"
#else
#define SYS_STAMP "XXXX"
#endif
#if defined(__cplusplus)
extern "C" {
#endif
/***********************************************************************/
/* Static variables */
/***********************************************************************/
#if defined(STORAGE)
char sys_stamp[4] = SYS_STAMP;
#else
extern char sys_stamp[];
#endif
/***********************************************************************/
/* File-Selection Indicators */
/***********************************************************************/
#define PAT_LOG "log"
#if defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
/*********************************************************************/
/* printf does not accept null pointer for %s target. */
/*********************************************************************/
#define SVP(S) ((S) ? S : "<null>")
#else
/*********************************************************************/
/* printf accepts null pointer for %s target. */
/*********************************************************************/
#define SVP(S) S
#endif
#if defined(STORAGE)
FILE *debug;
#else
extern FILE *debug;
#endif
/***********************************************************************/
/* General purpose type definitions. */
/***********************************************************************/
#include "os.h"
typedef uint OFFSET;
typedef char NAME[9];
typedef struct {
ushort Length;
char String[2];
} VARSTR;
#if !defined(PGLOBAL_DEFINED)
typedef struct _global *PGLOBAL;
#define PGLOBAL_DEFINED
#endif
typedef struct _globplg *PGS;
typedef struct _activity *PACTIVITY;
typedef struct _parm *PPARM;
/***********************************************************************/
/* Segment Sub-Allocation block structure declares. */
/* Next block is an implementation dependent segment suballoc save */
/* structure used to keep the suballocation system offsets and to */
/* restore them if needed. This scheme implies that no SubFree be used */
/***********************************************************************/
typedef struct { /* Plug Area SubAlloc header */
OFFSET To_Free; /* Offset of next free block */
uint FreeBlk; /* Size of remaining free memory */
} POOLHEADER, *PPOOLHEADER;
/***********************************************************************/
/* Language block. Containing all global information for the language */
/* this block is saved and retrieved with the language. Information */
/* in this block can be set and modified under Grammar editing. */
/***********************************************************************/
#if defined(BIT64)
typedef int TIME_T; /* Lang block size must not change */
#else // BIT32
typedef time_t TIME_T; /* time_t */
#endif // BIT32
typedef struct {
uint Memsize;
uint Size;
} AREADEF;
typedef struct Lang_block {
NAME LangName; /* Language name */
NAME Application; /* Application name */
} LANG, *PLANG;
/***********************************************************************/
/* Application block. It contains all global information for the */
/* current parse and execution using the corresponding language. */
/* This block is dynamically allocated and set at language init. */
/***********************************************************************/
typedef struct _activity { /* Describes activity and language */
void *Aptr; /* Points to user work area(s) */
NAME Ap_Name; /* Current application name */
} ACTIVITY;
/*---------------- UNIT ?????????? VERSION ? ----------------------*/
typedef struct _parm {
void *Value;
short Type, Domain;
PPARM Next;
} PARM;
/***********************************************************************/
/* Global Structure Block. This block contains, or points to, all */
/* information used by CONNECT tables. Passed as an argument */
/* to any routine allows it to have access to the entire information */
/* currently available for the whole set of loaded languages. */
/***********************************************************************/
typedef struct _global { /* Global structure */
void *Sarea; /* Points to work area */
uint Sarea_Size; /* Work area size */
PACTIVITY Activityp, ActivityStart;
char Message[MAX_STR];
short Trace;
int jump_level;
jmp_buf jumper[MAX_JUMP + 2];
} GLOBAL;
/***********************************************************************/
/* Exported routine declarations. */
/***********************************************************************/
#if defined(XMSG)
DllExport char *PlugReadMessage(PGLOBAL, int, char *);
#elif defined(NEWMSG)
DllExport char *PlugGetMessage(PGLOBAL, int);
#endif // XMSG || NEWMSG
#if defined(WIN32)
DllExport short GetLineLength(PGLOBAL); // Console line length
#endif // WIN32
DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization
DllExport int PlugExit(PGLOBAL); // Plug global termination
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);
DllExport LPCSTR PlugSetPath(LPSTR, LPCSTR, LPCSTR);
DllExport void *PlugAllocMem(PGLOBAL, uint);
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
DllExport void *MakePtr(void *, OFFSET);
DllExport void htrc(char const *fmt, ...);
#if defined(__cplusplus)
} // extern "C"
#endif
/*-------------------------- End of Global.H --------------------------*/
/***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright Olivier Bertrand 1993-2012 */
/***********************************************************************/
/***********************************************************************/
/* Included C-definition files common to all Plug routines */
/***********************************************************************/
#include <string.h> /* String manipulation declares */
#include <stdlib.h> /* C standard library */
#include <ctype.h> /* C language specific types */
#include <stdio.h> /* FOPEN_MAX declaration */
#include <time.h> /* time_t type declaration */
#include <setjmp.h> /* Long jump declarations */
#if defined(WIN32) && !defined(NOEX)
#define DllExport __declspec( dllexport )
#else // !WIN32
#define DllExport
#endif // !WIN32
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT)
#define XML_SUPPORT 1
#endif
#if defined(XMSG)
// Definition used to read messages from message file.
#include "msgid.h"
#define MSG(I) PlugReadMessage(NULL, MSG_##I, #I)
#define STEP(I) PlugReadMessage(g, MSG_##I, #I)
#elif defined(NEWMSG)
// Definition used to get messages from resource.
#include "msgid.h"
#define MSG(I) PlugGetMessage(NULL, MSG_##I)
#define STEP(I) PlugGetMessage(g, MSG_##I)
#else // !XMSG and !NEWMSG
// Definition used to replace messages ID's by their definition.
#include "messages.h"
#define MSG(I) MSG_##I
#define STEP(I) MSG_##I
#endif // !XMSG and !NEWMSG
#if defined(WIN32)
#define CRLF 2
#else // !WIN32
#define CRLF 1
#endif // !WIN32
/***********************************************************************/
/* Miscellaneous Constants */
/***********************************************************************/
#define NO_IVAL -95684275 /* Used by GetIntegerOption */
#define VMLANG 370 /* Size of olf VM lang blocks */
#define MAX_JUMP 24 /* Maximum jump level number */
#define MAX_STR 1024 /* Maximum string length */
#define STR_SIZE 501 /* Length of char strings. */
#define STD_INPUT 0 /* Standard language input */
#define STD_OUTPUT 1 /* Standard language output */
#define ERROR_OUTPUT 2 /* Error message output */
#define DEBUG_OUTPUT 3 /* Debug info output */
#define PROMPT_OUTPUT 4 /* Prompt message output */
#define COPY_OUTPUT 5 /* Copy of language input */
#define STD_MSG 6 /* System message file */
#define DEBUG_MSG 7 /* Debug message file */
#define DUMMY 0 /* Dummy file index in Ldm block */
#define STDIN 1 /* stdin file index in Ldm block */
#define STDOUT 2 /* stdout file index in Ldm block */
#define STDERR 3 /* stderr file index in Ldm block */
#define STDEBUG 4 /* debug file index in Ldm block */
#define STDPRN 5 /* stdprn file index in Ldm block */
#define STDFREE 6 /* Free file index in Ldm block */
#define TYPE_SEM -2 /* Returned semantic function */
#define TYPE_DFONC -2 /* Indirect sem ref in FPARM */
#define TYPE_VOID -1
#define TYPE_SBPAR -1 /* Phrase reference in FPARM */
#define TYPE_SEMX 0 /* Initial semantic function type? */
#define TYPE_ERROR 0
#define TYPE_STRING 1
#define TYPE_FLOAT 2
#define TYPE_SHORT 3
#define TYPE_BIGINT 5
#define TYPE_LIST 6
#define TYPE_INT 7
#if defined(OS32)
#define SYS_STAMP "OS32"
#elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
#define SYS_STAMP "UNIX"
#elif defined(OS16)
#define SYS_STAMP "OS16"
#elif defined(DOSR)
#define SYS_STAMP "DOSR"
#elif defined(WIN)
#define SYS_STAMP "WIN1"
#elif defined(WIN32)
#define SYS_STAMP "WIN2"
#else
#define SYS_STAMP "XXXX"
#endif
#if defined(__cplusplus)
extern "C" {
#endif
/***********************************************************************/
/* Static variables */
/***********************************************************************/
#if defined(STORAGE)
char sys_stamp[4] = SYS_STAMP;
#else
extern char sys_stamp[];
#endif
/***********************************************************************/
/* File-Selection Indicators */
/***********************************************************************/
#define PAT_LOG "log"
#if defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
/*********************************************************************/
/* printf does not accept null pointer for %s target. */
/*********************************************************************/
#define SVP(S) ((S) ? S : "<null>")
#else
/*********************************************************************/
/* printf accepts null pointer for %s target. */
/*********************************************************************/
#define SVP(S) S
#endif
#if defined(STORAGE)
FILE *debug;
#else
extern FILE *debug;
#endif
/***********************************************************************/
/* General purpose type definitions. */
/***********************************************************************/
#include "os.h"
typedef uint OFFSET;
typedef char NAME[9];
typedef struct {
ushort Length;
char String[2];
} VARSTR;
#if !defined(PGLOBAL_DEFINED)
typedef struct _global *PGLOBAL;
#define PGLOBAL_DEFINED
#endif
typedef struct _globplg *PGS;
typedef struct _activity *PACTIVITY;
typedef struct _parm *PPARM;
/***********************************************************************/
/* Segment Sub-Allocation block structure declares. */
/* Next block is an implementation dependent segment suballoc save */
/* structure used to keep the suballocation system offsets and to */
/* restore them if needed. This scheme implies that no SubFree be used */
/***********************************************************************/
typedef struct { /* Plug Area SubAlloc header */
OFFSET To_Free; /* Offset of next free block */
uint FreeBlk; /* Size of remaining free memory */
} POOLHEADER, *PPOOLHEADER;
/***********************************************************************/
/* Language block. Containing all global information for the language */
/* this block is saved and retrieved with the language. Information */
/* in this block can be set and modified under Grammar editing. */
/***********************************************************************/
#if defined(BIT64)
typedef int TIME_T; /* Lang block size must not change */
#else // BIT32
typedef time_t TIME_T; /* time_t */
#endif // BIT32
typedef struct {
uint Memsize;
uint Size;
} AREADEF;
typedef struct Lang_block {
NAME LangName; /* Language name */
NAME Application; /* Application name */
} LANG, *PLANG;
/***********************************************************************/
/* Application block. It contains all global information for the */
/* current parse and execution using the corresponding language. */
/* This block is dynamically allocated and set at language init. */
/***********************************************************************/
typedef struct _activity { /* Describes activity and language */
void *Aptr; /* Points to user work area(s) */
NAME Ap_Name; /* Current application name */
} ACTIVITY;
/*---------------- UNIT ?????????? VERSION ? ----------------------*/
typedef struct _parm {
void *Value;
short Type, Domain;
PPARM Next;
} PARM;
/***********************************************************************/
/* Global Structure Block. This block contains, or points to, all */
/* information used by CONNECT tables. Passed as an argument */
/* to any routine allows it to have access to the entire information */
/* currently available for the whole set of loaded languages. */
/***********************************************************************/
typedef struct _global { /* Global structure */
void *Sarea; /* Points to work area */
uint Sarea_Size; /* Work area size */
PACTIVITY Activityp, ActivityStart;
char Message[MAX_STR];
short Trace;
int jump_level;
jmp_buf jumper[MAX_JUMP + 2];
} GLOBAL;
/***********************************************************************/
/* Exported routine declarations. */
/***********************************************************************/
#if defined(XMSG)
DllExport char *PlugReadMessage(PGLOBAL, int, char *);
#elif defined(NEWMSG)
DllExport char *PlugGetMessage(PGLOBAL, int);
#endif // XMSG || NEWMSG
#if defined(WIN32)
DllExport short GetLineLength(PGLOBAL); // Console line length
#endif // WIN32
DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization
DllExport int PlugExit(PGLOBAL); // Plug global termination
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);
DllExport LPCSTR PlugSetPath(LPSTR, LPCSTR, LPCSTR);
DllExport void *PlugAllocMem(PGLOBAL, uint);
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
DllExport void *MakePtr(void *, OFFSET);
DllExport void htrc(char const *fmt, ...);
#if defined(__cplusplus)
} // extern "C"
#endif
/*-------------------------- End of Global.H --------------------------*/

File diff suppressed because it is too large Load Diff

View File

@@ -1,393 +1,393 @@
/* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/** @file ha_connect.h
@brief
The ha_connect engine is a prototype storage engine to access external data.
@see
/sql/handler.h and /storage/connect/ha_connect.cc
*/
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
/****************************************************************************/
/* Structures used to pass info between CONNECT and ha_connect. */
/****************************************************************************/
typedef struct _create_xinfo {
char *Type; /* Retrieved from table comment */
char *Filename; /* Set if not standard */
char *IndexFN; /* Set if not standard */
ulonglong Maxrows; /* Estimated max nb of rows */
ulong Lrecl; /* Set if not default */
ulong Elements; /* Number of lines in blocks */
bool Fixed; /* False for DOS type */
void *Pcf; /* To list of columns */
void *Pxdf; /* To list of indexes */
} CRXINFO, *PCXF;
typedef struct _xinfo {
ulonglong data_file_length; /* Length of data file */
ha_rows records; /* Records in table */
ulong mean_rec_length; /* Physical record length */
char *data_file_name; /* Physical file name */
} XINFO, *PXF;
typedef class user_connect *PCONNECT;
typedef struct ha_table_option_struct TOS, *PTOS;
typedef struct ha_field_option_struct FOS, *PFOS;
/** @brief
CONNECT_SHARE is a structure that will be shared among all open handlers.
This example implements the minimum of what you will probably need.
*/
typedef struct st_connect_share {
char *table_name;
uint table_name_length, use_count;
mysql_mutex_t mutex;
THR_LOCK lock;
#if !defined(MARIADB)
PTOS table_options;
PFOS field_options;
#endif // !MARIADB
} CONNECT_SHARE;
typedef class ha_connect *PHC;
/** @brief
Class definition for the storage engine
*/
class ha_connect: public handler
{
THR_LOCK_DATA lock; ///< MySQL lock
CONNECT_SHARE *share; ///< Shared lock info
public:
ha_connect(handlerton *hton, TABLE_SHARE *table_arg);
~ha_connect();
// CONNECT Implementation
static bool connect_init(void);
static bool connect_end(void);
char *GetStringOption(char *opname, char *sdef= NULL);
PTOS GetTableOptionStruct(TABLE *table_arg);
bool GetBooleanOption(char *opname, bool bdef);
int GetIntegerOption(char *opname);
bool SetIntegerOption(char *opname, int n);
PFOS GetFieldOptionStruct(Field *fp);
void *GetColumnOption(void *field, PCOLINFO pcf);
PIXDEF GetIndexInfo(int n);
const char *GetDBName(const char *name);
const char *GetTableName(void);
int GetColNameLen(Field *fp);
char *GetColName(Field *fp);
void AddColName(char *cp, Field *fp);
TABLE *GetTable(void) {return table;}
PCONNECT GetUser(THD *thd);
PGLOBAL GetPlug(THD *thd);
PTDB GetTDB(PGLOBAL g);
bool OpenTable(PGLOBAL g, bool del= false);
bool IsOpened(void);
int CloseTable(PGLOBAL g);
int MakeRecord(char *buf);
int ScanRecord(PGLOBAL g, uchar *buf);
int CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf);
int ReadIndexed(uchar *buf, OPVAL op, const uchar* key= NULL,
uint key_len= 0);
/** @brief
The name that will be used for display purposes.
*/
const char *table_type() const {return "CONNECT";}
/** @brief
The name of the index type that will be used for display.
Don't implement this method unless you really have indexes.
*/
const char *index_type(uint inx) { return "XPLUG"; }
/** @brief
The file extensions.
*/
const char **bas_ext() const;
/** @brief
This is a list of flags that indicate what functionality the storage engine
implements. The current table flags are documented in handler.h
*/
ulonglong table_flags() const
{
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_HAS_RECORDS |
/*HA_NO_AUTO_INCREMENT |*/ HA_NO_PREFIX_CHAR_KEYS |
#if defined(MARIADB)
HA_CAN_VIRTUAL_COLUMNS |
#endif // MARIADB
HA_NULL_IN_KEY | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE);
}
/** @brief
This is a bitmap of flags that indicates how the storage engine
implements indexes. The current index flags are documented in
handler.h. If you do not implement indexes, just return zero here.
@details
part is the key part to check. First key part is 0.
If all_parts is set, MySQL wants to know the flags for the combined
index, up to and including 'part'.
*/
ulong index_flags(uint inx, uint part, bool all_parts) const
{
return HA_READ_NEXT | HA_READ_RANGE;
}
/** @brief
unireg.cc will call max_supported_record_length(), max_supported_keys(),
max_supported_key_parts(), uint max_supported_key_length()
to make sure that the storage engine can handle the data it is about to
send. Return *real* limits of your storage engine here; MySQL will do
min(your_limits, MySQL_limits) automatically.
*/
uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
/** @brief
unireg.cc will call this to make sure that the storage engine can handle
the data it is about to send. Return *real* limits of your storage engine
here; MySQL will do min(your_limits, MySQL_limits) automatically.
@details
There is no need to implement ..._key_... methods if your engine doesn't
support indexes.
*/
uint max_supported_keys() const { return 10; }
/** @brief
unireg.cc will call this to make sure that the storage engine can handle
the data it is about to send. Return *real* limits of your storage engine
here; MySQL will do min(your_limits, MySQL_limits) automatically.
@details
There is no need to implement ..._key_... methods if your engine doesn't
support indexes.
*/
uint max_supported_key_parts() const { return 10; }
/** @brief
unireg.cc will call this to make sure that the storage engine can handle
the data it is about to send. Return *real* limits of your storage engine
here; MySQL will do min(your_limits, MySQL_limits) automatically.
@details
There is no need to implement ..._key_... methods if your engine doesn't
support indexes.
*/
uint max_supported_key_length() const { return 255; }
/** @brief
Called in test_quick_select to determine if indexes should be used.
*/
virtual double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; }
/** @brief
This method will never be called if you do not implement indexes.
*/
virtual double read_time(uint, uint, ha_rows rows)
{ return (double) rows / 20.0+1; }
/*
Everything below are methods that we implement in ha_connect.cc.
Most of these methods are not obligatory, skip them and
MySQL will treat them as not implemented
*/
virtual bool get_error_message(int error, String *buf);
/**
Push condition down to the table handler.
@param cond Condition to be pushed. The condition tree must not be
modified by the by the caller.
@return
The 'remainder' condition that caller must use to filter out records.
NULL means the handler will not return rows that do not match the
passed condition.
@note
The pushed conditions form a stack (from which one can remove the
last pushed condition using cond_pop).
The table handler filters out rows using (pushed_cond1 AND pushed_cond2
AND ... AND pushed_condN)
or less restrictive condition, depending on handler's capabilities.
handler->ha_reset() call empties the condition stack.
Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the
condition stack.
*/
virtual const COND *cond_push(const COND *cond);
PFIL CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond);
char *GetValStr(OPVAL vop, bool neg);
/**
Number of rows in table. It will only be called if
(table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0
*/
virtual ha_rows records();
/** @brief
We implement this in ha_connect.cc; it's a required method.
*/
int open(const char *name, int mode, uint test_if_locked); // required
/** @brief
We implement this in ha_connect.cc; it's a required method.
*/
int close(void); // required
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int write_row(uchar *buf);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int update_row(const uchar *old_data, uchar *new_data);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int delete_row(const uchar *buf);
// Added to the connect handler
int index_init(uint idx, bool sorted);
int index_end();
int index_read(uchar * buf, const uchar * key, uint key_len,
enum ha_rkey_function find_flag);
int index_next_same(uchar *buf, const uchar *key, uint keylen);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
//int index_read_map(uchar *buf, const uchar *key,
// key_part_map keypart_map, enum ha_rkey_function find_flag);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int index_next(uchar *buf);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
//int index_prev(uchar *buf);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int index_first(uchar *buf);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
//int index_last(uchar *buf);
/** @brief
Unlike index_init(), rnd_init() can be called two consecutive times
without rnd_end() in between (it only makes sense if scan=1). In this
case, the second call should prepare for the new table scan (e.g if
rnd_init() allocates the cursor, the second call should position the
cursor to the start of the table; no need to deallocate and allocate
it again. This is a required method.
*/
int rnd_init(bool scan); //required
int rnd_end();
int rnd_next(uchar *buf); ///< required
int rnd_pos(uchar *buf, uchar *pos); ///< required
void position(const uchar *record); ///< required
int info(uint); ///< required
int extra(enum ha_extra_function operation);
int external_lock(THD *thd, int lock_type); ///< required
int delete_all_rows(void);
ha_rows records_in_range(uint inx, key_range *min_key,
key_range *max_key);
int delete_table(const char *from);
bool pre_create(THD *thd, void *crt_info, void *alt_info);
int create(const char *name, TABLE *form,
HA_CREATE_INFO *create_info); ///< required
bool check_if_incompatible_data(HA_CREATE_INFO *info,
uint table_changes);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type); ///< required
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
protected:
char *GetListOption(char *opname, const char *oplist, char *def= NULL);
char *encode(PGLOBAL g, char *cnm);
bool add_fields(THD *thd, void *alter_info,
LEX_STRING *field_name,
enum_field_types type,
char *length, char *decimals,
uint type_modifier,
// Item *default_value, Item *on_update_value,
LEX_STRING *comment,
// char *change,
// List<String> *interval_list,
CHARSET_INFO *cs,
// uint uint_geom_type,
void *vcol_info,
engine_option_value *create_options);
// Members
static ulong num; // Tracable handler number
PCONNECT xp; // To user_connect associated class
ulong hnum; // The number of this handler
query_id_t valid_query_id; // The one when tdbp was allocated
query_id_t creat_query_id; // The one when handler was allocated
PTDB tdbp; // To table class object
PVAL sdval; // Used to convert date values
bool istable; // True for table handler
//char tname[64]; // The table name
MODE xmod; // Table mode
XINFO xinfo; // The table info structure
bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index
//bool hascond; // Too late for Delete
int indexing; // Type of indexing for CONNECT
#if !defined(MARIADB)
PTOS table_options;
PFOS field_options;
#endif // !MARIADB
THR_LOCK_DATA lock_data;
public:
TABLE_SHARE *tshp; // Used by called tables
char *data_file_name;
char *index_file_name;
uint int_table_flags; // Inherited from MyISAM
bool enable_activate_all_index; // Inherited from MyISAM
}; // end of ha_connect class definition
/* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/** @file ha_connect.h
@brief
The ha_connect engine is a prototype storage engine to access external data.
@see
/sql/handler.h and /storage/connect/ha_connect.cc
*/
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
/****************************************************************************/
/* Structures used to pass info between CONNECT and ha_connect. */
/****************************************************************************/
typedef struct _create_xinfo {
char *Type; /* Retrieved from table comment */
char *Filename; /* Set if not standard */
char *IndexFN; /* Set if not standard */
ulonglong Maxrows; /* Estimated max nb of rows */
ulong Lrecl; /* Set if not default */
ulong Elements; /* Number of lines in blocks */
bool Fixed; /* False for DOS type */
void *Pcf; /* To list of columns */
void *Pxdf; /* To list of indexes */
} CRXINFO, *PCXF;
typedef struct _xinfo {
ulonglong data_file_length; /* Length of data file */
ha_rows records; /* Records in table */
ulong mean_rec_length; /* Physical record length */
char *data_file_name; /* Physical file name */
} XINFO, *PXF;
typedef class user_connect *PCONNECT;
typedef struct ha_table_option_struct TOS, *PTOS;
typedef struct ha_field_option_struct FOS, *PFOS;
/** @brief
CONNECT_SHARE is a structure that will be shared among all open handlers.
This example implements the minimum of what you will probably need.
*/
typedef struct st_connect_share {
char *table_name;
uint table_name_length, use_count;
mysql_mutex_t mutex;
THR_LOCK lock;
#if !defined(MARIADB)
PTOS table_options;
PFOS field_options;
#endif // !MARIADB
} CONNECT_SHARE;
typedef class ha_connect *PHC;
/** @brief
Class definition for the storage engine
*/
class ha_connect: public handler
{
THR_LOCK_DATA lock; ///< MySQL lock
CONNECT_SHARE *share; ///< Shared lock info
public:
ha_connect(handlerton *hton, TABLE_SHARE *table_arg);
~ha_connect();
// CONNECT Implementation
static bool connect_init(void);
static bool connect_end(void);
char *GetStringOption(char *opname, char *sdef= NULL);
PTOS GetTableOptionStruct(TABLE *table_arg);
bool GetBooleanOption(char *opname, bool bdef);
int GetIntegerOption(char *opname);
bool SetIntegerOption(char *opname, int n);
PFOS GetFieldOptionStruct(Field *fp);
void *GetColumnOption(void *field, PCOLINFO pcf);
PIXDEF GetIndexInfo(int n);
const char *GetDBName(const char *name);
const char *GetTableName(void);
int GetColNameLen(Field *fp);
char *GetColName(Field *fp);
void AddColName(char *cp, Field *fp);
TABLE *GetTable(void) {return table;}
PCONNECT GetUser(THD *thd);
PGLOBAL GetPlug(THD *thd);
PTDB GetTDB(PGLOBAL g);
bool OpenTable(PGLOBAL g, bool del= false);
bool IsOpened(void);
int CloseTable(PGLOBAL g);
int MakeRecord(char *buf);
int ScanRecord(PGLOBAL g, uchar *buf);
int CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf);
int ReadIndexed(uchar *buf, OPVAL op, const uchar* key= NULL,
uint key_len= 0);
/** @brief
The name that will be used for display purposes.
*/
const char *table_type() const {return "CONNECT";}
/** @brief
The name of the index type that will be used for display.
Don't implement this method unless you really have indexes.
*/
const char *index_type(uint inx) { return "XPLUG"; }
/** @brief
The file extensions.
*/
const char **bas_ext() const;
/** @brief
This is a list of flags that indicate what functionality the storage engine
implements. The current table flags are documented in handler.h
*/
ulonglong table_flags() const
{
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_HAS_RECORDS |
/*HA_NO_AUTO_INCREMENT |*/ HA_NO_PREFIX_CHAR_KEYS |
#if defined(MARIADB)
HA_CAN_VIRTUAL_COLUMNS |
#endif // MARIADB
HA_NULL_IN_KEY | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE);
}
/** @brief
This is a bitmap of flags that indicates how the storage engine
implements indexes. The current index flags are documented in
handler.h. If you do not implement indexes, just return zero here.
@details
part is the key part to check. First key part is 0.
If all_parts is set, MySQL wants to know the flags for the combined
index, up to and including 'part'.
*/
ulong index_flags(uint inx, uint part, bool all_parts) const
{
return HA_READ_NEXT | HA_READ_RANGE;
}
/** @brief
unireg.cc will call max_supported_record_length(), max_supported_keys(),
max_supported_key_parts(), uint max_supported_key_length()
to make sure that the storage engine can handle the data it is about to
send. Return *real* limits of your storage engine here; MySQL will do
min(your_limits, MySQL_limits) automatically.
*/
uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
/** @brief
unireg.cc will call this to make sure that the storage engine can handle
the data it is about to send. Return *real* limits of your storage engine
here; MySQL will do min(your_limits, MySQL_limits) automatically.
@details
There is no need to implement ..._key_... methods if your engine doesn't
support indexes.
*/
uint max_supported_keys() const { return 10; }
/** @brief
unireg.cc will call this to make sure that the storage engine can handle
the data it is about to send. Return *real* limits of your storage engine
here; MySQL will do min(your_limits, MySQL_limits) automatically.
@details
There is no need to implement ..._key_... methods if your engine doesn't
support indexes.
*/
uint max_supported_key_parts() const { return 10; }
/** @brief
unireg.cc will call this to make sure that the storage engine can handle
the data it is about to send. Return *real* limits of your storage engine
here; MySQL will do min(your_limits, MySQL_limits) automatically.
@details
There is no need to implement ..._key_... methods if your engine doesn't
support indexes.
*/
uint max_supported_key_length() const { return 255; }
/** @brief
Called in test_quick_select to determine if indexes should be used.
*/
virtual double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; }
/** @brief
This method will never be called if you do not implement indexes.
*/
virtual double read_time(uint, uint, ha_rows rows)
{ return (double) rows / 20.0+1; }
/*
Everything below are methods that we implement in ha_connect.cc.
Most of these methods are not obligatory, skip them and
MySQL will treat them as not implemented
*/
virtual bool get_error_message(int error, String *buf);
/**
Push condition down to the table handler.
@param cond Condition to be pushed. The condition tree must not be
modified by the by the caller.
@return
The 'remainder' condition that caller must use to filter out records.
NULL means the handler will not return rows that do not match the
passed condition.
@note
The pushed conditions form a stack (from which one can remove the
last pushed condition using cond_pop).
The table handler filters out rows using (pushed_cond1 AND pushed_cond2
AND ... AND pushed_condN)
or less restrictive condition, depending on handler's capabilities.
handler->ha_reset() call empties the condition stack.
Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the
condition stack.
*/
virtual const COND *cond_push(const COND *cond);
PFIL CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond);
const char *GetValStr(OPVAL vop, bool neg);
/**
Number of rows in table. It will only be called if
(table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0
*/
virtual ha_rows records();
/** @brief
We implement this in ha_connect.cc; it's a required method.
*/
int open(const char *name, int mode, uint test_if_locked); // required
/** @brief
We implement this in ha_connect.cc; it's a required method.
*/
int close(void); // required
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int write_row(uchar *buf);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int update_row(const uchar *old_data, uchar *new_data);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int delete_row(const uchar *buf);
// Added to the connect handler
int index_init(uint idx, bool sorted);
int index_end();
int index_read(uchar * buf, const uchar * key, uint key_len,
enum ha_rkey_function find_flag);
int index_next_same(uchar *buf, const uchar *key, uint keylen);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
//int index_read_map(uchar *buf, const uchar *key,
// key_part_map keypart_map, enum ha_rkey_function find_flag);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int index_next(uchar *buf);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
//int index_prev(uchar *buf);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
int index_first(uchar *buf);
/** @brief
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
//int index_last(uchar *buf);
/** @brief
Unlike index_init(), rnd_init() can be called two consecutive times
without rnd_end() in between (it only makes sense if scan=1). In this
case, the second call should prepare for the new table scan (e.g if
rnd_init() allocates the cursor, the second call should position the
cursor to the start of the table; no need to deallocate and allocate
it again. This is a required method.
*/
int rnd_init(bool scan); //required
int rnd_end();
int rnd_next(uchar *buf); ///< required
int rnd_pos(uchar *buf, uchar *pos); ///< required
void position(const uchar *record); ///< required
int info(uint); ///< required
int extra(enum ha_extra_function operation);
int external_lock(THD *thd, int lock_type); ///< required
int delete_all_rows(void);
ha_rows records_in_range(uint inx, key_range *min_key,
key_range *max_key);
int delete_table(const char *from);
bool pre_create(THD *thd, void *crt_info, void *alt_info);
int create(const char *name, TABLE *form,
HA_CREATE_INFO *create_info); ///< required
bool check_if_incompatible_data(HA_CREATE_INFO *info,
uint table_changes);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type); ///< required
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
protected:
char *GetListOption(const char *opname, const char *oplist, const char *def= NULL);
char *encode(PGLOBAL g, char *cnm);
bool add_fields(THD *thd, void *alter_info,
LEX_STRING *field_name,
enum_field_types type,
char *length, char *decimals,
uint type_modifier,
// Item *default_value, Item *on_update_value,
LEX_STRING *comment,
// char *change,
// List<String> *interval_list,
CHARSET_INFO *cs,
// uint uint_geom_type,
void *vcol_info,
engine_option_value *create_options);
// Members
static ulong num; // Tracable handler number
PCONNECT xp; // To user_connect associated class
ulong hnum; // The number of this handler
query_id_t valid_query_id; // The one when tdbp was allocated
query_id_t creat_query_id; // The one when handler was allocated
PTDB tdbp; // To table class object
PVAL sdval; // Used to convert date values
bool istable; // True for table handler
//char tname[64]; // The table name
MODE xmod; // Table mode
XINFO xinfo; // The table info structure
bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index
//bool hascond; // Too late for Delete
int indexing; // Type of indexing for CONNECT
#if !defined(MARIADB)
PTOS table_options;
PFOS field_options;
#endif // !MARIADB
THR_LOCK_DATA lock_data;
public:
TABLE_SHARE *tshp; // Used by called tables
char *data_file_name;
char *index_file_name;
uint int_table_flags; // Inherited from MyISAM
bool enable_activate_all_index; // Inherited from MyISAM
}; // end of ha_connect class definition

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,144 +1,144 @@
/******************************************************************/
/* Declaration of XML document processing using libxml2 */
/* Author: Olivier Bertrand 2007-2012 */
/******************************************************************/
#include "plgxml.h"
typedef class LIBXMLDOC *PXDOC2;
typedef class XML2NODE *PNODE2;
typedef class XML2ATTR *PATTR2;
typedef class XML2NODELIST *PLIST2;
/******************************************************************/
/* XML2 block. Must have the same layout than FBLOCK up to Type. */
/******************************************************************/
typedef struct _x2block { /* Loaded XML file block */
struct _x2block *Next;
LPCSTR Fname; /* Point on file name */
size_t Length; /* Used to tell if read mode */
short Count; /* Nb of times file is used */
short Type; /* TYPE_FB_XML */
int Retcode; /* Return code from Load */
xmlDocPtr Docp; /* Document interface pointer */
// xmlXPathContextPtr Ctxp;
// xmlXPathObjectPtr Xop;
} X2BLOCK, *PX2BLOCK;
/******************************************************************/
/* Declaration of libxml2 document. */
/******************************************************************/
class LIBXMLDOC : public XMLDOCUMENT {
friend class XML2NODE;
friend class XML2ATTR;
public:
// Constructor
LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp);
// Properties
virtual short GetDocType(void) {return TYPE_FB_XML2;}
virtual void *GetDocPtr(void) {return Docp;}
// Methods
virtual bool Initialize(PGLOBAL g);
virtual bool ParseFile(char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver);
virtual void AddComment(PGLOBAL g, char *com);
virtual PXNODE GetRoot(PGLOBAL g);
virtual PXNODE NewRoot(PGLOBAL g, char *name);
virtual PXNODE NewPnode(PGLOBAL g, char *name);
virtual PXATTR NewPattr(PGLOBAL g);
virtual PXLIST NewPlist(PGLOBAL g);
virtual int DumpDoc(PGLOBAL g, char *ofn);
virtual void CloseDoc(PGLOBAL g, PFBLOCK xp);
virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn);
protected:
bool CheckDocument(FILE *of, xmlNodePtr np);
xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp);
int Decode(xmlChar *cnt, char *buf, int n);
xmlChar *Encode(PGLOBAL g, char *txt);
// Members
xmlDocPtr Docp;
xmlNodeSetPtr Nlist;
xmlXPathContextPtr Ctxp;
xmlXPathObjectPtr Xop;
char *Buf; // Temporary
}; // end of class LIBXMLDOC
/******************************************************************/
/* Declaration of libxml2 node. */
/******************************************************************/
class XML2NODE : public XMLNODE {
friend class LIBXMLDOC;
friend class XML2NODELIST;
public:
// Properties
virtual char *GetName(PGLOBAL g) {return (char*)Nodep->name;}
virtual int GetType(void);
virtual PXNODE GetNext(PGLOBAL g);
virtual PXNODE GetChild(PGLOBAL g);
// Methods
virtual char *GetText(char *buf, int len);
virtual bool SetContent(PGLOBAL g, char *txtp, int len);
virtual PXNODE Clone(PGLOBAL g, PXNODE np);
virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp);
virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
virtual void AddText(PGLOBAL g, char *txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected:
// Constructor
XML2NODE(PXDOC dp, xmlNodePtr np);
// Members
xmlDocPtr Docp;
xmlChar *Content;
xmlNodePtr Nodep;
}; // end of class XML2NODE
/******************************************************************/
/* Declaration of libxml2 node list. */
/******************************************************************/
class XML2NODELIST : public XMLNODELIST {
friend class LIBXMLDOC;
friend class XML2NODE;
public:
// Methods
virtual int GetLength(void);
virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np);
protected:
// Constructor
XML2NODELIST(PXDOC dp, xmlNodeSetPtr lp);
// Members
xmlNodeSetPtr Listp;
}; // end of class XML2NODELIST
/******************************************************************/
/* Declaration of libxml2 attribute. */
/******************************************************************/
class XML2ATTR : public XMLATTRIBUTE {
friend class LIBXMLDOC;
friend class XML2NODE;
public:
// Properties
//virtual char *GetText(void);
// Methods
virtual bool SetText(PGLOBAL g, char *txtp, int len);
protected:
// Constructor
XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np);
// Members
xmlAttrPtr Atrp;
xmlNodePtr Parent;
}; // end of class XML2ATTR
/******************************************************************/
/* Declaration of XML document processing using libxml2 */
/* Author: Olivier Bertrand 2007-2012 */
/******************************************************************/
#include "plgxml.h"
typedef class LIBXMLDOC *PXDOC2;
typedef class XML2NODE *PNODE2;
typedef class XML2ATTR *PATTR2;
typedef class XML2NODELIST *PLIST2;
/******************************************************************/
/* XML2 block. Must have the same layout than FBLOCK up to Type. */
/******************************************************************/
typedef struct _x2block { /* Loaded XML file block */
struct _x2block *Next;
LPCSTR Fname; /* Point on file name */
size_t Length; /* Used to tell if read mode */
short Count; /* Nb of times file is used */
short Type; /* TYPE_FB_XML */
int Retcode; /* Return code from Load */
xmlDocPtr Docp; /* Document interface pointer */
// xmlXPathContextPtr Ctxp;
// xmlXPathObjectPtr Xop;
} X2BLOCK, *PX2BLOCK;
/******************************************************************/
/* Declaration of libxml2 document. */
/******************************************************************/
class LIBXMLDOC : public XMLDOCUMENT {
friend class XML2NODE;
friend class XML2ATTR;
public:
// Constructor
LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp);
// Properties
virtual short GetDocType(void) {return TYPE_FB_XML2;}
virtual void *GetDocPtr(void) {return Docp;}
// Methods
virtual bool Initialize(PGLOBAL g);
virtual bool ParseFile(char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver);
virtual void AddComment(PGLOBAL g, char *com);
virtual PXNODE GetRoot(PGLOBAL g);
virtual PXNODE NewRoot(PGLOBAL g, char *name);
virtual PXNODE NewPnode(PGLOBAL g, char *name);
virtual PXATTR NewPattr(PGLOBAL g);
virtual PXLIST NewPlist(PGLOBAL g);
virtual int DumpDoc(PGLOBAL g, char *ofn);
virtual void CloseDoc(PGLOBAL g, PFBLOCK xp);
virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn);
protected:
bool CheckDocument(FILE *of, xmlNodePtr np);
xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp);
int Decode(xmlChar *cnt, char *buf, int n);
xmlChar *Encode(PGLOBAL g, char *txt);
// Members
xmlDocPtr Docp;
xmlNodeSetPtr Nlist;
xmlXPathContextPtr Ctxp;
xmlXPathObjectPtr Xop;
char *Buf; // Temporary
}; // end of class LIBXMLDOC
/******************************************************************/
/* Declaration of libxml2 node. */
/******************************************************************/
class XML2NODE : public XMLNODE {
friend class LIBXMLDOC;
friend class XML2NODELIST;
public:
// Properties
virtual char *GetName(PGLOBAL g) {return (char*)Nodep->name;}
virtual int GetType(void);
virtual PXNODE GetNext(PGLOBAL g);
virtual PXNODE GetChild(PGLOBAL g);
// Methods
virtual char *GetText(char *buf, int len);
virtual bool SetContent(PGLOBAL g, char *txtp, int len);
virtual PXNODE Clone(PGLOBAL g, PXNODE np);
virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp);
virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
virtual void AddText(PGLOBAL g, char *txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected:
// Constructor
XML2NODE(PXDOC dp, xmlNodePtr np);
// Members
xmlDocPtr Docp;
xmlChar *Content;
xmlNodePtr Nodep;
}; // end of class XML2NODE
/******************************************************************/
/* Declaration of libxml2 node list. */
/******************************************************************/
class XML2NODELIST : public XMLNODELIST {
friend class LIBXMLDOC;
friend class XML2NODE;
public:
// Methods
virtual int GetLength(void);
virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np);
protected:
// Constructor
XML2NODELIST(PXDOC dp, xmlNodeSetPtr lp);
// Members
xmlNodeSetPtr Listp;
}; // end of class XML2NODELIST
/******************************************************************/
/* Declaration of libxml2 attribute. */
/******************************************************************/
class XML2ATTR : public XMLATTRIBUTE {
friend class LIBXMLDOC;
friend class XML2NODE;
public:
// Properties
//virtual char *GetText(void);
// Methods
virtual bool SetText(PGLOBAL g, char *txtp, int len);
protected:
// Constructor
XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np);
// Members
xmlAttrPtr Atrp;
xmlNodePtr Parent;
}; // end of class XML2ATTR

View File

@@ -1,318 +1,318 @@
/***********************************************************************/
/* MACUTIL: Author Olivier Bertrand -- 2008-2012 */
/* From the article and sample code by Khalid Shaikh. */
/***********************************************************************/
#if defined(WIN32)
#include "my_global.h"
#else // !WIN32
#error This is WIN32 only DLL
#endif // !WIN32
#include "global.h"
#include "plgdbsem.h"
#include "macutil.h"
#if 0 // This is placed here just to know what are the actual values
#define MAX_ADAPTER_DESCRIPTION_LENGTH 128
#define MAX_ADAPTER_NAME_LENGTH 256
#define MAX_ADAPTER_ADDRESS_LENGTH 8
#define DEFAULT_MINIMUM_ENTITIES 32
#define MAX_HOSTNAME_LEN 128
#define MAX_DOMAIN_NAME_LEN 128
#define MAX_SCOPE_ID_LEN 256
#define BROADCAST_NODETYPE 1
#define PEER_TO_PEER_NODETYPE 2
#define MIXED_NODETYPE 4
#define HYBRID_NODETYPE 8
#define IP_ADAPTER_DDNS_ENABLED 0x01
#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x02
#define IP_ADAPTER_DHCP_ENABLED 0x04
#define IP_ADAPTER_RECEIVE_ONLY 0x08
#define IP_ADAPTER_NO_MULTICAST 0x10
#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x20
#endif // 0
/***********************************************************************/
/* Implementation of the MACINFO class. */
/***********************************************************************/
MACINFO::MACINFO(bool adap, bool fix)
{
Fip = NULL;
Piaf = NULL;
Curp = NULL;
Buflen = 0;
Fix = fix;
Adap = adap;
N = -1;
} // end of MACINFO constructor
/***********************************************************************/
/* MACINFO: Return an error message. */
/***********************************************************************/
void MACINFO::MakeErrorMsg(PGLOBAL g, DWORD drc)
{
if (drc == ERROR_BUFFER_OVERFLOW)
sprintf(g->Message,
"GetAdaptersInfo: Buffer Overflow buflen=%d nbofadap=%d",
Buflen, N);
else if (drc == ERROR_INVALID_PARAMETER)
strcpy(g->Message, "GetAdaptersInfo: Invalid parameters");
else if (drc == ERROR_NO_DATA)
strcpy(g->Message,
"No adapter information exists for the local computer");
else if (drc == ERROR_NOT_SUPPORTED)
strcpy(g->Message, "GetAdaptersInfo is not supported");
else
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(),
0, g->Message, sizeof(g->Message), NULL);
} // end of MakeErrorMsg
/***********************************************************************/
/* MAC: Get the number of found adapters. */
/***********************************************************************/
int MACINFO::GetNadap(PGLOBAL g)
{
if (N < 0) {
// Best method
if (Adap) {
DWORD drc = GetAdaptersInfo(NULL, &Buflen);
if (drc == ERROR_SUCCESS)
N = (Fix) ? 1 : 0;
else if (drc == ERROR_BUFFER_OVERFLOW)
N = Buflen / sizeof(IP_ADAPTER_INFO);
else
MakeErrorMsg(g, drc);
} else
N = (Fix) ? 1 : 0;
#if 0
// This method returns too many adapters
DWORD dw, drc = GetNumberOfInterfaces((PDWORD)&dw);
if (drc == NO_ERROR) {
N = (int)dw;
Buflen = N * sizeof(IP_ADAPTER_INFO);
} else
MakeErrorMsg(g, 0);
#endif
} // endif MaxSize
return N;
} // end of GetMaxSize
/***********************************************************************/
/* GetMacInfo: Get info for all found adapters. */
/***********************************************************************/
bool MACINFO::GetMacInfo(PGLOBAL g)
{
DWORD drc;
if (GetNadap(g) < 0)
return true;
else if (N == 0)
return false;
Piaf = (PIP_ADAPTER_INFO)PlugSubAlloc(g, NULL, Buflen);
drc = GetAdaptersInfo(Piaf, &Buflen);
if (drc == ERROR_SUCCESS) {
Curp = Piaf; // Curp is the first one
return false; // Success
} // endif drc
MakeErrorMsg(g, drc);
return true;
} // end of GetMacInfo
/***********************************************************************/
/* GetMacInfo: Get info for all found adapters. */
/***********************************************************************/
bool MACINFO::GetFixedInfo(PGLOBAL g)
{
ULONG len = (uint)sizeof(FIXED_INFO);
DWORD drc;
Fip = (FIXED_INFO*)PlugSubAlloc(g, NULL, len);
drc = GetNetworkParams(Fip, &len);
if (drc == ERROR_BUFFER_OVERFLOW) {
Fip = (FIXED_INFO*)PlugSubAlloc(g, NULL, len);
drc = GetNetworkParams(Fip, &len);
} // endif drc
if (drc != ERROR_SUCCESS) {
sprintf(g->Message, "GetNetworkParams failed. Rc=%08x\n", drc);
return true;
} // endif drc
return false;
} // end of GetFip
#if 0
#define IF_OTHER_ADAPTERTYPE 0
#define IF_ETHERNET_ADAPTERTYPE 1
#define IF_TOKEN_RING_ADAPTERTYPE 2
#define IF_FDDI_ADAPTERTYPE 3
#define IF_PPP_ADAPTERTYPE 4
#define IF_LOOPBACK_ADAPTERTYPE 5
#endif // 0
/***********************************************************************/
/* Get next MAC info. */
/***********************************************************************/
bool MACINFO::NextMac(void)
{
if (Curp)
Curp = Curp->Next;
return Curp != NULL;
} // end of NextMac
/***********************************************************************/
/* Get the next MAC address elements. */
/***********************************************************************/
bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv)
{
char *p = NULL, buf[260] = "";
unsigned int i;
int n = 0;
if (!Curp && flag >= 10) {
// Fix info row, no adapter info available
switch (flag) {
case 13:
case 14:
case 19:
case 22:
case 23:
break;
default:
p = "";
} // endswitch flag
} else switch (flag) {
// FIXED INFO
case 1: // Host Name
p = Fip->HostName;
break;
case 2: // Domain Name
p = Fip->DomainName;
break;
case 3: // DNS IPaddress
p = (Fip->CurrentDnsServer)
? (char*)&Fip->CurrentDnsServer->IpAddress
: (char*)&Fip->DnsServerList.IpAddress;
break;
case 4: // Node Type
n = (int)Fip->NodeType;
break;
case 5: // Scope ID ???
p = Fip->ScopeId;
break;
case 6: // Routing enabled
n = (int)Fip->EnableRouting;
break;
case 7: // Proxy enabled
n = (int)Fip->EnableProxy;
break;
case 8: // DNS enabled
n = (int)Fip->EnableDns;
break;
// ADAPTERS INFO
case 10: // Name
p = Curp->AdapterName;
break;
case 11: // Description
if ((p = strstr(Curp->Description, " - Packet Scheduler Miniport"))) {
strncpy(buf, Curp->Description, p - Curp->Description);
i = p - Curp->Description;
strncpy(buf, Curp->Description, i);
buf[i] = 0;
p = buf;
} else if ((p = strstr(Curp->Description,
" - Miniport d'ordonnancement de paquets"))) {
i = p - Curp->Description;
strncpy(buf, Curp->Description, i);
buf[i] = 0;
p = buf;
} else
p = Curp->Description;
break;
case 12: // MAC Address
for (p = buf, i = 0; i < Curp->AddressLength; i++) {
if (i)
strcat(p++, "-");
p += sprintf(p, "%.2X", Curp->Address[i]);
} // endfor i
p = buf;
break;
case 13: // Type
#if 0 // This is not found in the SDK
switch (Curp->Type) {
case IF_ETHERNET_ADAPTERTYPE: p = "Ethernet Adapter"; break;
case IF_TOKEN_RING_ADAPTERTYPE: p = "Token Ring Adapter"; break;
case IF_FDDI_ADAPTERTYPE: p = "FDDI Adapter"; break;
case IF_PPP_ADAPTERTYPE: p = "PPP Adapter"; break;
case IF_LOOPBACK_ADAPTERTYPE: p = "Loop Back Adapter"; break;
// case IF_SLIP_ADAPTERTYPE: p = "Generic Slip Adapter"; break;
default:
sprintf(buf, "Other Adapter, type=%d", Curp->Type);
p = buf;
} // endswitch Type
#endif // 0
n = (int)Curp->Type;
break;
case 14: // DHCP enabled
n = (int)Curp->DhcpEnabled;
break;
case 15: // IP Address
p = (Curp->CurrentIpAddress)
? (char*)&Curp->CurrentIpAddress->IpAddress
: (char*)&Curp->IpAddressList.IpAddress;
break;
case 16: // Subnet Mask
p = (Curp->CurrentIpAddress)
? (char*)&Curp->CurrentIpAddress->IpMask
: (char*)&Curp->IpAddressList.IpMask;
break;
case 17: // Gateway
p = (char*)&Curp->GatewayList.IpAddress;
break;
case 18: // DHCP Server
p = (char*)&Curp->DhcpServer.IpAddress;
break;
case 19: // Have WINS
n = (Curp->HaveWins) ? 1 : 0;
break;
case 20: // Primary WINS
p = (char*)&Curp->PrimaryWinsServer.IpAddress;
break;
case 21: // Secondary WINS
p = (char*)&Curp->SecondaryWinsServer.IpAddress;
break;
case 22: // Lease obtained
n = (int)Curp->LeaseObtained;
break;
case 23: // Lease expires
n = (int)Curp->LeaseExpires;
break;
default:
sprintf(g->Message, "Invalid flag value %d", flag);
return true;
} // endswitch flag
if (p)
strncpy((char*)v, p, lv);
else
*((int*)v) = n;
return false;
} // end of ReadColumn
/***********************************************************************/
/* MACUTIL: Author Olivier Bertrand -- 2008-2012 */
/* From the article and sample code by Khalid Shaikh. */
/***********************************************************************/
#if defined(WIN32)
#include "my_global.h"
#else // !WIN32
#error This is WIN32 only DLL
#endif // !WIN32
#include "global.h"
#include "plgdbsem.h"
#include "macutil.h"
#if 0 // This is placed here just to know what are the actual values
#define MAX_ADAPTER_DESCRIPTION_LENGTH 128
#define MAX_ADAPTER_NAME_LENGTH 256
#define MAX_ADAPTER_ADDRESS_LENGTH 8
#define DEFAULT_MINIMUM_ENTITIES 32
#define MAX_HOSTNAME_LEN 128
#define MAX_DOMAIN_NAME_LEN 128
#define MAX_SCOPE_ID_LEN 256
#define BROADCAST_NODETYPE 1
#define PEER_TO_PEER_NODETYPE 2
#define MIXED_NODETYPE 4
#define HYBRID_NODETYPE 8
#define IP_ADAPTER_DDNS_ENABLED 0x01
#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x02
#define IP_ADAPTER_DHCP_ENABLED 0x04
#define IP_ADAPTER_RECEIVE_ONLY 0x08
#define IP_ADAPTER_NO_MULTICAST 0x10
#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x20
#endif // 0
/***********************************************************************/
/* Implementation of the MACINFO class. */
/***********************************************************************/
MACINFO::MACINFO(bool adap, bool fix)
{
Fip = NULL;
Piaf = NULL;
Curp = NULL;
Buflen = 0;
Fix = fix;
Adap = adap;
N = -1;
} // end of MACINFO constructor
/***********************************************************************/
/* MACINFO: Return an error message. */
/***********************************************************************/
void MACINFO::MakeErrorMsg(PGLOBAL g, DWORD drc)
{
if (drc == ERROR_BUFFER_OVERFLOW)
sprintf(g->Message,
"GetAdaptersInfo: Buffer Overflow buflen=%d nbofadap=%d",
Buflen, N);
else if (drc == ERROR_INVALID_PARAMETER)
strcpy(g->Message, "GetAdaptersInfo: Invalid parameters");
else if (drc == ERROR_NO_DATA)
strcpy(g->Message,
"No adapter information exists for the local computer");
else if (drc == ERROR_NOT_SUPPORTED)
strcpy(g->Message, "GetAdaptersInfo is not supported");
else
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(),
0, g->Message, sizeof(g->Message), NULL);
} // end of MakeErrorMsg
/***********************************************************************/
/* MAC: Get the number of found adapters. */
/***********************************************************************/
int MACINFO::GetNadap(PGLOBAL g)
{
if (N < 0) {
// Best method
if (Adap) {
DWORD drc = GetAdaptersInfo(NULL, &Buflen);
if (drc == ERROR_SUCCESS)
N = (Fix) ? 1 : 0;
else if (drc == ERROR_BUFFER_OVERFLOW)
N = Buflen / sizeof(IP_ADAPTER_INFO);
else
MakeErrorMsg(g, drc);
} else
N = (Fix) ? 1 : 0;
#if 0
// This method returns too many adapters
DWORD dw, drc = GetNumberOfInterfaces((PDWORD)&dw);
if (drc == NO_ERROR) {
N = (int)dw;
Buflen = N * sizeof(IP_ADAPTER_INFO);
} else
MakeErrorMsg(g, 0);
#endif
} // endif MaxSize
return N;
} // end of GetMaxSize
/***********************************************************************/
/* GetMacInfo: Get info for all found adapters. */
/***********************************************************************/
bool MACINFO::GetMacInfo(PGLOBAL g)
{
DWORD drc;
if (GetNadap(g) < 0)
return true;
else if (N == 0)
return false;
Piaf = (PIP_ADAPTER_INFO)PlugSubAlloc(g, NULL, Buflen);
drc = GetAdaptersInfo(Piaf, &Buflen);
if (drc == ERROR_SUCCESS) {
Curp = Piaf; // Curp is the first one
return false; // Success
} // endif drc
MakeErrorMsg(g, drc);
return true;
} // end of GetMacInfo
/***********************************************************************/
/* GetMacInfo: Get info for all found adapters. */
/***********************************************************************/
bool MACINFO::GetFixedInfo(PGLOBAL g)
{
ULONG len = (uint)sizeof(FIXED_INFO);
DWORD drc;
Fip = (FIXED_INFO*)PlugSubAlloc(g, NULL, len);
drc = GetNetworkParams(Fip, &len);
if (drc == ERROR_BUFFER_OVERFLOW) {
Fip = (FIXED_INFO*)PlugSubAlloc(g, NULL, len);
drc = GetNetworkParams(Fip, &len);
} // endif drc
if (drc != ERROR_SUCCESS) {
sprintf(g->Message, "GetNetworkParams failed. Rc=%08x\n", drc);
return true;
} // endif drc
return false;
} // end of GetFip
#if 0
#define IF_OTHER_ADAPTERTYPE 0
#define IF_ETHERNET_ADAPTERTYPE 1
#define IF_TOKEN_RING_ADAPTERTYPE 2
#define IF_FDDI_ADAPTERTYPE 3
#define IF_PPP_ADAPTERTYPE 4
#define IF_LOOPBACK_ADAPTERTYPE 5
#endif // 0
/***********************************************************************/
/* Get next MAC info. */
/***********************************************************************/
bool MACINFO::NextMac(void)
{
if (Curp)
Curp = Curp->Next;
return Curp != NULL;
} // end of NextMac
/***********************************************************************/
/* Get the next MAC address elements. */
/***********************************************************************/
bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv)
{
char *p = NULL, buf[260] = "";
unsigned int i;
int n = 0;
if (!Curp && flag >= 10) {
// Fix info row, no adapter info available
switch (flag) {
case 13:
case 14:
case 19:
case 22:
case 23:
break;
default:
p = "";
} // endswitch flag
} else switch (flag) {
// FIXED INFO
case 1: // Host Name
p = Fip->HostName;
break;
case 2: // Domain Name
p = Fip->DomainName;
break;
case 3: // DNS IPaddress
p = (Fip->CurrentDnsServer)
? (char*)&Fip->CurrentDnsServer->IpAddress
: (char*)&Fip->DnsServerList.IpAddress;
break;
case 4: // Node Type
n = (int)Fip->NodeType;
break;
case 5: // Scope ID ???
p = Fip->ScopeId;
break;
case 6: // Routing enabled
n = (int)Fip->EnableRouting;
break;
case 7: // Proxy enabled
n = (int)Fip->EnableProxy;
break;
case 8: // DNS enabled
n = (int)Fip->EnableDns;
break;
// ADAPTERS INFO
case 10: // Name
p = Curp->AdapterName;
break;
case 11: // Description
if ((p = strstr(Curp->Description, " - Packet Scheduler Miniport"))) {
strncpy(buf, Curp->Description, p - Curp->Description);
i = p - Curp->Description;
strncpy(buf, Curp->Description, i);
buf[i] = 0;
p = buf;
} else if ((p = strstr(Curp->Description,
" - Miniport d'ordonnancement de paquets"))) {
i = p - Curp->Description;
strncpy(buf, Curp->Description, i);
buf[i] = 0;
p = buf;
} else
p = Curp->Description;
break;
case 12: // MAC Address
for (p = buf, i = 0; i < Curp->AddressLength; i++) {
if (i)
strcat(p++, "-");
p += sprintf(p, "%.2X", Curp->Address[i]);
} // endfor i
p = buf;
break;
case 13: // Type
#if 0 // This is not found in the SDK
switch (Curp->Type) {
case IF_ETHERNET_ADAPTERTYPE: p = "Ethernet Adapter"; break;
case IF_TOKEN_RING_ADAPTERTYPE: p = "Token Ring Adapter"; break;
case IF_FDDI_ADAPTERTYPE: p = "FDDI Adapter"; break;
case IF_PPP_ADAPTERTYPE: p = "PPP Adapter"; break;
case IF_LOOPBACK_ADAPTERTYPE: p = "Loop Back Adapter"; break;
// case IF_SLIP_ADAPTERTYPE: p = "Generic Slip Adapter"; break;
default:
sprintf(buf, "Other Adapter, type=%d", Curp->Type);
p = buf;
} // endswitch Type
#endif // 0
n = (int)Curp->Type;
break;
case 14: // DHCP enabled
n = (int)Curp->DhcpEnabled;
break;
case 15: // IP Address
p = (Curp->CurrentIpAddress)
? (char*)&Curp->CurrentIpAddress->IpAddress
: (char*)&Curp->IpAddressList.IpAddress;
break;
case 16: // Subnet Mask
p = (Curp->CurrentIpAddress)
? (char*)&Curp->CurrentIpAddress->IpMask
: (char*)&Curp->IpAddressList.IpMask;
break;
case 17: // Gateway
p = (char*)&Curp->GatewayList.IpAddress;
break;
case 18: // DHCP Server
p = (char*)&Curp->DhcpServer.IpAddress;
break;
case 19: // Have WINS
n = (Curp->HaveWins) ? 1 : 0;
break;
case 20: // Primary WINS
p = (char*)&Curp->PrimaryWinsServer.IpAddress;
break;
case 21: // Secondary WINS
p = (char*)&Curp->SecondaryWinsServer.IpAddress;
break;
case 22: // Lease obtained
n = (int)Curp->LeaseObtained;
break;
case 23: // Lease expires
n = (int)Curp->LeaseExpires;
break;
default:
sprintf(g->Message, "Invalid flag value %d", flag);
return true;
} // endswitch flag
if (p)
strncpy((char*)v, p, lv);
else
*((int*)v) = n;
return false;
} // end of ReadColumn

View File

@@ -1,36 +1,36 @@
// MACUTIL.H Olivier Bertrand 2008-2012
// Get Mac Addresses via GetAdaptersInfo
#if defined(WIN32)
#include <iphlpapi.h>
#else // !WIN32
#error This is WIN32 only
#endif // !WIN32
#include "block.h"
typedef class MACINFO *MACIP;
/***********************************************************************/
/* This is the class declaration for MACINFO. */
/***********************************************************************/
class DllExport MACINFO : public BLOCK {
public:
// Constructor
MACINFO(bool adap, bool fix);
// Implementation
int GetNadap(PGLOBAL g);
bool GetMacInfo(PGLOBAL g);
bool GetFixedInfo(PGLOBAL g);
void MakeErrorMsg(PGLOBAL g, DWORD drc);
bool NextMac(void);
bool GetOneInfo(PGLOBAL g, int flag, void *v, int lv);
// Members
FIXED_INFO *Fip; // Points to fixed info structure
PIP_ADAPTER_INFO Piaf; // Points on Adapter info array
PIP_ADAPTER_INFO Curp; // Points on current Adapt info
ULONG Buflen; // Buffer length
bool Fix; // true if FixedInfo is needed
bool Adap; // true if Piaf is needed
int N; // Number of adapters
}; // end of class MACINFO
// MACUTIL.H Olivier Bertrand 2008-2012
// Get Mac Addresses via GetAdaptersInfo
#if defined(WIN32)
#include <iphlpapi.h>
#else // !WIN32
#error This is WIN32 only
#endif // !WIN32
#include "block.h"
typedef class MACINFO *MACIP;
/***********************************************************************/
/* This is the class declaration for MACINFO. */
/***********************************************************************/
class DllExport MACINFO : public BLOCK {
public:
// Constructor
MACINFO(bool adap, bool fix);
// Implementation
int GetNadap(PGLOBAL g);
bool GetMacInfo(PGLOBAL g);
bool GetFixedInfo(PGLOBAL g);
void MakeErrorMsg(PGLOBAL g, DWORD drc);
bool NextMac(void);
bool GetOneInfo(PGLOBAL g, int flag, void *v, int lv);
// Members
FIXED_INFO *Fip; // Points to fixed info structure
PIP_ADAPTER_INFO Piaf; // Points on Adapter info array
PIP_ADAPTER_INFO Curp; // Points on current Adapt info
ULONG Buflen; // Buffer length
bool Fix; // true if FixedInfo is needed
bool Adap; // true if Piaf is needed
int N; // Number of adapters
}; // end of class MACINFO

View File

@@ -1,172 +1,172 @@
#include "my_global.h"
#ifdef UNIX
#include "osutil.h"
#include <errno.h>
#include <stddef.h>
#else /* WINDOWS */
//#include <windows.h>
#include "osutil.h"
#endif /* WINDOWS */
#include <stdlib.h>
#include <stdio.h>
#include "global.h"
#include "plgdbsem.h"
#include "maputil.h"
#ifdef WIN32
/***********************************************************************/
/* In Insert mode, just open the file for append. Otherwise */
/* create the mapping file object. The map handle can be released */
/* immediately because they will not be used anymore. */
/* If del is true in DELETE mode, then delete the whole file. */
/* Returns the file handle that can be used by caller. */
/***********************************************************************/
HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename,
MEMMAP *mm, MODE mode, bool del)
{
HANDLE hFile;
HANDLE hFileMap;
DWORD access, share, disposition;
memset(mm, 0, sizeof(MEMMAP));
*g->Message = '\0';
switch (mode) {
case MODE_READ:
access = GENERIC_READ;
share = FILE_SHARE_READ;
disposition = OPEN_EXISTING;
break;
case MODE_UPDATE:
case MODE_DELETE:
access = GENERIC_READ | GENERIC_WRITE;
share = 0;
disposition = (del) ? TRUNCATE_EXISTING : OPEN_EXISTING;
break;
case MODE_INSERT:
access = GENERIC_WRITE;
share = 0;
disposition = OPEN_ALWAYS;
break;
default:
sprintf(g->Message, MSG(BAD_FUNC_MODE), "CreateFileMap", mode);
return INVALID_HANDLE_VALUE;
} // endswitch
hFile = CreateFile(filename, access, share, NULL, disposition,
FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)
if (mode != MODE_INSERT) {
/*****************************************************************/
/* Create the file-mapping object. */
/*****************************************************************/
access = (mode == MODE_READ) ? PAGE_READONLY : PAGE_READWRITE;
hFileMap = CreateFileMapping(hFile, NULL, access, 0, 0, NULL);
if (!hFileMap) {
DWORD ler = GetLastError();
if (ler && ler != 1006) {
sprintf(g->Message, MSG(FILE_MAP_ERROR), filename, ler);
CloseHandle(hFile);
return INVALID_HANDLE_VALUE;
} else {
sprintf(g->Message, MSG(FILE_IS_EMPTY), filename);
return hFile;
} // endif ler
} // endif hFileMap
access = (mode == MODE_READ) ? FILE_MAP_READ : FILE_MAP_WRITE;
mm->memory = MapViewOfFile(hFileMap, access, 0, 0, 0);
// lenH is the high-order word of the file size
mm->lenL = GetFileSize(hFile, &mm->lenH);
CloseHandle(hFileMap); // Not used anymore
} else // MODE_INSERT
/*****************************************************************/
/* The starting point must be the end of file as for append. */
/*****************************************************************/
SetFilePointer(hFile, 0, NULL, FILE_END);
return hFile;
} // end of CreateFileMap
bool CloseMemMap(LPVOID memory, size_t dwSize)
{
return (memory) ? !UnmapViewOfFile(memory) : false;
} // end of CloseMemMap
#else /* UNIX */
// Code to handle Linux and Solaris
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
/***********************************************************************/
/* In Insert mode, just open the file for append. Otherwise */
/* create the mapping file object. The map handle can be released */
/* immediately because they will not be used anymore. */
/* If del is true in DELETE mode, then delete the whole file. */
/* Returns the file handle that can be used by caller. */
/***********************************************************************/
HANDLE CreateFileMap(PGLOBAL g, LPCSTR fileName,
MEMMAP *mm, MODE mode, bool del)
{
unsigned int openMode;
HANDLE fd;
size_t filesize;
struct stat st;
memset(mm, 0, sizeof(MEMMAP));
*g->Message = '\0';
switch (mode) {
case MODE_READ:
openMode = O_RDONLY;
break;
case MODE_UPDATE:
case MODE_DELETE:
openMode = (del) ? (O_RDWR | O_TRUNC) : O_RDWR;
break;
case MODE_INSERT:
openMode = (O_WRONLY | O_CREAT | O_APPEND);
break;
default:
sprintf(g->Message, MSG(BAD_FUNC_MODE), "CreateFileMap", mode);
return INVALID_HANDLE_VALUE;
} // endswitch
// Try to open the addressed file.
fd= global_open(g, MSGID_NONE, fileName, openMode);
if (fd != INVALID_HANDLE_VALUE && mode != MODE_INSERT) {
/* We must know about the size of the file. */
if (fstat(fd, &st)) {
sprintf(g->Message, MSG(FILE_MAP_ERROR), fileName, errno);
close(fd);
return INVALID_HANDLE_VALUE;
} // endif fstat
filesize = st.st_size;
// Now we are ready to load the file. If mmap() is available we try
// this first. If not available or it failed we try to load it.
mm->memory = mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, fd, 0);
mm->lenL = (mm->memory != 0) ? filesize : 0;
mm->lenH = 0;
} /* endif fd */
// mmap() call was successful. ??????????
return fd;
} // end of CreateFileMap
bool CloseMemMap(void *memory, size_t dwSize)
{
return (memory) ? ((munmap(memory, dwSize)) ? true : false) : false;
} // end of CloseMemMap
#endif // UNIX
#include "my_global.h"
#ifdef UNIX
#include "osutil.h"
#include <errno.h>
#include <stddef.h>
#else /* WINDOWS */
//#include <windows.h>
#include "osutil.h"
#endif /* WINDOWS */
#include <stdlib.h>
#include <stdio.h>
#include "global.h"
#include "plgdbsem.h"
#include "maputil.h"
#ifdef WIN32
/***********************************************************************/
/* In Insert mode, just open the file for append. Otherwise */
/* create the mapping file object. The map handle can be released */
/* immediately because they will not be used anymore. */
/* If del is true in DELETE mode, then delete the whole file. */
/* Returns the file handle that can be used by caller. */
/***********************************************************************/
HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename,
MEMMAP *mm, MODE mode, bool del)
{
HANDLE hFile;
HANDLE hFileMap;
DWORD access, share, disposition;
memset(mm, 0, sizeof(MEMMAP));
*g->Message = '\0';
switch (mode) {
case MODE_READ:
access = GENERIC_READ;
share = FILE_SHARE_READ;
disposition = OPEN_EXISTING;
break;
case MODE_UPDATE:
case MODE_DELETE:
access = GENERIC_READ | GENERIC_WRITE;
share = 0;
disposition = (del) ? TRUNCATE_EXISTING : OPEN_EXISTING;
break;
case MODE_INSERT:
access = GENERIC_WRITE;
share = 0;
disposition = OPEN_ALWAYS;
break;
default:
sprintf(g->Message, MSG(BAD_FUNC_MODE), "CreateFileMap", mode);
return INVALID_HANDLE_VALUE;
} // endswitch
hFile = CreateFile(filename, access, share, NULL, disposition,
FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)
if (mode != MODE_INSERT) {
/*****************************************************************/
/* Create the file-mapping object. */
/*****************************************************************/
access = (mode == MODE_READ) ? PAGE_READONLY : PAGE_READWRITE;
hFileMap = CreateFileMapping(hFile, NULL, access, 0, 0, NULL);
if (!hFileMap) {
DWORD ler = GetLastError();
if (ler && ler != 1006) {
sprintf(g->Message, MSG(FILE_MAP_ERROR), filename, ler);
CloseHandle(hFile);
return INVALID_HANDLE_VALUE;
} else {
sprintf(g->Message, MSG(FILE_IS_EMPTY), filename);
return hFile;
} // endif ler
} // endif hFileMap
access = (mode == MODE_READ) ? FILE_MAP_READ : FILE_MAP_WRITE;
mm->memory = MapViewOfFile(hFileMap, access, 0, 0, 0);
// lenH is the high-order word of the file size
mm->lenL = GetFileSize(hFile, &mm->lenH);
CloseHandle(hFileMap); // Not used anymore
} else // MODE_INSERT
/*****************************************************************/
/* The starting point must be the end of file as for append. */
/*****************************************************************/
SetFilePointer(hFile, 0, NULL, FILE_END);
return hFile;
} // end of CreateFileMap
bool CloseMemMap(LPVOID memory, size_t dwSize)
{
return (memory) ? !UnmapViewOfFile(memory) : false;
} // end of CloseMemMap
#else /* UNIX */
// Code to handle Linux and Solaris
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
/***********************************************************************/
/* In Insert mode, just open the file for append. Otherwise */
/* create the mapping file object. The map handle can be released */
/* immediately because they will not be used anymore. */
/* If del is true in DELETE mode, then delete the whole file. */
/* Returns the file handle that can be used by caller. */
/***********************************************************************/
HANDLE CreateFileMap(PGLOBAL g, LPCSTR fileName,
MEMMAP *mm, MODE mode, bool del)
{
unsigned int openMode;
HANDLE fd;
size_t filesize;
struct stat st;
memset(mm, 0, sizeof(MEMMAP));
*g->Message = '\0';
switch (mode) {
case MODE_READ:
openMode = O_RDONLY;
break;
case MODE_UPDATE:
case MODE_DELETE:
openMode = (del) ? (O_RDWR | O_TRUNC) : O_RDWR;
break;
case MODE_INSERT:
openMode = (O_WRONLY | O_CREAT | O_APPEND);
break;
default:
sprintf(g->Message, MSG(BAD_FUNC_MODE), "CreateFileMap", mode);
return INVALID_HANDLE_VALUE;
} // endswitch
// Try to open the addressed file.
fd= global_open(g, MSGID_NONE, fileName, openMode);
if (fd != INVALID_HANDLE_VALUE && mode != MODE_INSERT) {
/* We must know about the size of the file. */
if (fstat(fd, &st)) {
sprintf(g->Message, MSG(FILE_MAP_ERROR), fileName, errno);
close(fd);
return INVALID_HANDLE_VALUE;
} // endif fstat
filesize = st.st_size;
// Now we are ready to load the file. If mmap() is available we try
// this first. If not available or it failed we try to load it.
mm->memory = mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, fd, 0);
mm->lenL = (mm->memory != 0) ? filesize : 0;
mm->lenH = 0;
} /* endif fd */
// mmap() call was successful. ??????????
return fd;
} // end of CreateFileMap
bool CloseMemMap(void *memory, size_t dwSize)
{
return (memory) ? ((munmap(memory, dwSize)) ? true : false) : false;
} // end of CloseMemMap
#endif // UNIX

View File

@@ -1,22 +1,22 @@
#ifndef __MAPUTIL_H__
#define __MAPUTIL_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
void *memory;
DWORD lenL;
DWORD lenH;
} MEMMAP;
HANDLE CreateFileMap(PGLOBAL, LPCSTR, MEMMAP *, MODE, bool);
bool CloseMemMap(void *memory, size_t dwSize);
my_bool CloseFileHandle(HANDLE h);
#ifdef __cplusplus
}
#endif
#endif /* __MAPUTIL_H__ */
#ifndef __MAPUTIL_H__
#define __MAPUTIL_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
void *memory;
DWORD lenL;
DWORD lenH;
} MEMMAP;
HANDLE CreateFileMap(PGLOBAL, LPCSTR, MEMMAP *, MODE, bool);
bool CloseMemMap(void *memory, size_t dwSize);
my_bool CloseFileHandle(HANDLE h);
#ifdef __cplusplus
}
#endif
#endif /* __MAPUTIL_H__ */

View File

@@ -1,13 +1,13 @@
/**************************************************************************/
/* NLS messsages definition. */
/**************************************************************************/
#if defined(FRENCH)
#if defined(CPX)
#include "frmsg1.h"
#else /* not CPX */
#include "frmsg2.h"
#endif /* CPX */
#else /* not FRENCH */
#include "engmsg.h"
#endif /* FRENCH */
/* ---------------------------------------------------------------------- */
/**************************************************************************/
/* NLS messsages definition. */
/**************************************************************************/
#if defined(FRENCH)
#if defined(CPX)
#include "frmsg1.h"
#else /* not CPX */
#include "frmsg2.h"
#endif /* CPX */
#else /* not FRENCH */
#include "engmsg.h"
#endif /* FRENCH */
/* ---------------------------------------------------------------------- */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,64 +1,66 @@
/* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**************** MYCAT H Declares Source Code File (.H) ***************/
/* Name: MYCAT.H Version 2.3 */
/* */
/* This file contains the CONNECT plugin MYCAT class definitions. */
/***********************************************************************/
#ifndef __MYCAT__H
#define __MYCAT__H
#include "block.h"
#include "catalog.h"
/***********************************************************************/
/* MYCAT: class for managing the CONNECT plugin DB items. */
/***********************************************************************/
class MYCAT : public CATALOG {
public:
MYCAT(PHC hc); // Constructor
// Implementation
PHC GetHandler(void) {return Hc;}
void SetHandler(PHC hc) {Hc= hc;}
// Methods
void Reset(void);
void SetDataPath(PGLOBAL g, const char *path)
{SetPath(g, &DataPath, path);}
bool GetBoolCatInfo(LPCSTR name, PSZ what, bool bdef);
bool SetIntCatInfo(LPCSTR name, PSZ what, int ival);
int GetIntCatInfo(LPCSTR name, PSZ what, int idef);
int GetSizeCatInfo(LPCSTR name, PSZ what, PSZ sdef);
int GetCharCatInfo(LPCSTR name, PSZ what, PSZ sdef, char *buf, int size);
char *GetStringCatInfo(PGLOBAL g, PSZ name, PSZ what, PSZ sdef);
int GetColCatInfo(PGLOBAL g, PTABDEF defp);
bool GetIndexInfo(PGLOBAL g, PTABDEF defp);
bool StoreIndex(PGLOBAL g, PTABDEF defp) {return false;} // Temporary
PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR am, PRELDEF *prp = NULL);
PTDB GetTable(PGLOBAL g, PTABLE tablep, MODE mode = MODE_READ);
void ClearDB(PGLOBAL g);
protected:
PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
// Members
ha_connect *Hc; // The Connect handler
}; // end of class MYCAT
#endif __MYCAT__H
/* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**************** MYCAT H Declares Source Code File (.H) ***************/
/* Name: MYCAT.H Version 2.3 */
/* */
/* This file contains the CONNECT plugin MYCAT class definitions. */
/***********************************************************************/
#ifndef __MYCAT__H
#define __MYCAT__H
#include "block.h"
#include "catalog.h"
char GetTypeID(const char *type);
/***********************************************************************/
/* MYCAT: class for managing the CONNECT plugin DB items. */
/***********************************************************************/
class MYCAT : public CATALOG {
public:
MYCAT(PHC hc); // Constructor
// Implementation
PHC GetHandler(void) {return Hc;}
void SetHandler(PHC hc) {Hc= hc;}
// Methods
void Reset(void);
void SetDataPath(PGLOBAL g, const char *path)
{SetPath(g, &DataPath, path);}
bool GetBoolCatInfo(LPCSTR name, PSZ what, bool bdef);
bool SetIntCatInfo(LPCSTR name, PSZ what, int ival);
int GetIntCatInfo(LPCSTR name, PSZ what, int idef);
int GetSizeCatInfo(LPCSTR name, PSZ what, PSZ sdef);
int GetCharCatInfo(LPCSTR name, PSZ what, PSZ sdef, char *buf, int size);
char *GetStringCatInfo(PGLOBAL g, PSZ name, PSZ what, PSZ sdef);
int GetColCatInfo(PGLOBAL g, PTABDEF defp);
bool GetIndexInfo(PGLOBAL g, PTABDEF defp);
bool StoreIndex(PGLOBAL g, PTABDEF defp) {return false;} // Temporary
PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR am, PRELDEF *prp = NULL);
PTDB GetTable(PGLOBAL g, PTABLE tablep, MODE mode = MODE_READ);
void ClearDB(PGLOBAL g);
protected:
PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
// Members
ha_connect *Hc; // The Connect handler
}; // end of class MYCAT
#endif /* __MYCAT__H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,91 +1,92 @@
/***********************************************************************/
/* MYCONN.H Olivier Bertrand 2007-2012 */
/* */
/* This is the declaration file for the MySQL connection class and */
/* a few utility functions used to communicate with MySQL. */
/* */
/* DO NOT define DLL_EXPORT in your application so these items are */
/* declared are imported from the Myconn DLL. */
/***********************************************************************/
#if defined(WIN32)
#include <winsock.h>
#else // !WIN32
#include <sys/socket.h>
#endif // !WIN32
#include <mysql.h>
#include <errmsg.h>
#if defined(WIN32) && defined(MYCONN_EXPORTS)
#if defined(DLL_EXPORT)
#define DllItem _declspec(dllexport)
#else // !DLL_EXPORT
#define DllItem _declspec(dllimport)
#endif // !DLL_EXPORT
#else // !WIN32 || !MYCONN_EXPORTS
#define DllItem
#endif // !WIN32
//#define TYPE_AM_MYSQL (AMT)192
#define MYSQL_ENABLED 0x00000001
#define MYSQL_LOGON 0x00000002
typedef class MYSQLC *PMYC;
/***********************************************************************/
/* Exported/Imported functions. */
/***********************************************************************/
DllItem int MYSQLtoPLG(char *);
DllItem int MYSQLtoPLG(int);
DllItem enum enum_field_types PLGtoMYSQL(int, bool gdf = FALSE);
DllItem char *MyDateFmt(int);
DllItem char *MyDateFmt(char *);
/* -------------------------- MYCONN class --------------------------- */
/***********************************************************************/
/* MYSQLC exported/imported class. A MySQL connection. */
/***********************************************************************/
class DllItem MYSQLC {
friend class TDBMYSQL;
// Construction
public:
MYSQLC(void);
// Implementation
int GetRows(void) {return m_Rows;}
bool Connected(void);
// Methods
// int GetCurPos(void) {return (m_Res) ? N : 0;}
// int GetProgCur(void) {return N;}
int GetResultSize(PGLOBAL g, PSZ sql);
int Open(PGLOBAL g, PSZ host, PSZ db, PSZ user = "root",
PSZ pwd = "*", int pt = 0);
ulong GetThreadID(void);
ulong ServerVersion(void);
const char *ServerInfo(void);
int KillQuery(ulong id);
int ExecSQL(PGLOBAL g, const char *query, int *w = NULL);
int PrepareSQL(PGLOBAL g, const char *query);
int ExecStmt(PGLOBAL g);
int BindParams(PGLOBAL g, MYSQL_BIND *bind);
PQRYRES GetResult(PGLOBAL g, bool pdb = FALSE);
int Fetch(PGLOBAL g, int pos);
char *GetCharField(int i);
int GetFieldLength(int i);
void Rewind(void);
void FreeResult(void);
void Close(void);
void DiscardResults(void);
protected:
// Members
MYSQL *m_DB; // The return from MySQL connection
MYSQL_STMT *m_Stmt; // Prepared statement handle
MYSQL_RES *m_Res; // Points to MySQL Result
MYSQL_ROW m_Row; // Point to current row
int m_Rows; // The number of rows of the result
int N;
int m_Fields; // The number of result fields
}; // end of class MYSQLC
/***********************************************************************/
/* MYCONN.H Olivier Bertrand 2007-2012 */
/* */
/* This is the declaration file for the MySQL connection class and */
/* a few utility functions used to communicate with MySQL. */
/* */
/* DO NOT define DLL_EXPORT in your application so these items are */
/* declared are imported from the Myconn DLL. */
/***********************************************************************/
#if defined(WIN32)
#include <winsock.h>
#else // !WIN32
#include <sys/socket.h>
#endif // !WIN32
#include <mysql.h>
#include <errmsg.h>
#if defined(WIN32) && defined(MYCONN_EXPORTS)
#if defined(DLL_EXPORT)
#define DllItem _declspec(dllexport)
#else // !DLL_EXPORT
#define DllItem _declspec(dllimport)
#endif // !DLL_EXPORT
#else // !WIN32 || !MYCONN_EXPORTS
#define DllItem
#endif // !WIN32
//#define TYPE_AM_MYSQL (AMT)192
#define MYSQL_ENABLED 0x00000001
#define MYSQL_LOGON 0x00000002
typedef class MYSQLC *PMYC;
/***********************************************************************/
/* Exported/Imported functions. */
/***********************************************************************/
DllItem int MYSQLtoPLG(char *);
DllItem int MYSQLtoPLG(int);
DllItem enum enum_field_types PLGtoMYSQL(int, bool gdf = FALSE);
DllItem char *MyDateFmt(int);
DllItem char *MyDateFmt(char *);
/* -------------------------- MYCONN class --------------------------- */
/***********************************************************************/
/* MYSQLC exported/imported class. A MySQL connection. */
/***********************************************************************/
class DllItem MYSQLC {
friend class TDBMYSQL;
// Construction
public:
MYSQLC(void);
// Implementation
int GetRows(void) {return m_Rows;}
bool Connected(void);
// Methods
// int GetCurPos(void) {return (m_Res) ? N : 0;}
// int GetProgCur(void) {return N;}
int GetResultSize(PGLOBAL g, PSZ sql);
int Open(PGLOBAL g, const char *host, const char *db,
const char *user= "root", const char *pwd= "*",
int pt= 0);
ulong GetThreadID(void);
ulong ServerVersion(void);
const char *ServerInfo(void);
int KillQuery(ulong id);
int ExecSQL(PGLOBAL g, const char *query, int *w = NULL);
int PrepareSQL(PGLOBAL g, const char *query);
int ExecStmt(PGLOBAL g);
int BindParams(PGLOBAL g, MYSQL_BIND *bind);
PQRYRES GetResult(PGLOBAL g, bool pdb = FALSE);
int Fetch(PGLOBAL g, int pos);
char *GetCharField(int i);
int GetFieldLength(int i);
void Rewind(void);
void FreeResult(void);
void Close(void);
void DiscardResults(void);
protected:
// Members
MYSQL *m_DB; // The return from MySQL connection
MYSQL_STMT *m_Stmt; // Prepared statement handle
MYSQL_RES *m_Res; // Points to MySQL Result
MYSQL_ROW m_Row; // Point to current row
int m_Rows; // The number of rows of the result
int N;
int m_Fields; // The number of result fields
}; // end of class MYSQLC

View File

@@ -1,193 +1,193 @@
/************** MyUtil C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: MYUTIL */
/* ------------- */
/* Version 1.0 */
/* */
/* Author Olivier BERTRAND 2013 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
/* It contains utility functions to convert data types. */
/* It can optionally use the embedded MySQL library. */
/* */
/************************************************************************/
#include "my_global.h"
#include <mysql.h>
#if defined(WIN32)
//#include <windows.h>
#else // !WIN32
#include "osutil.h"
#endif // !WIN32
#include "global.h"
#include "plgdbsem.h"
//#include "value.h"
//#include "valblk.h"
#define DLL_EXPORT // Items are exported from this DLL
/************************************************************************/
/* Convert from MySQL type name to PlugDB type number */
/************************************************************************/
int MYSQLtoPLG(char *typname)
{
int type;
if (!stricmp(typname, "int") || !stricmp(typname, "mediumint") ||
!stricmp(typname, "integer"))
type = TYPE_INT;
else if (!stricmp(typname, "tinyint") || !stricmp(typname, "smallint"))
type = TYPE_SHORT;
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") ||
!stricmp(typname, "text") || !stricmp(typname, "blob"))
type = TYPE_STRING;
else if (!stricmp(typname, "double") || !stricmp(typname, "float") ||
!stricmp(typname, "real") || !stricmp(typname, "bigint") ||
!stricmp(typname, "decimal") || !stricmp(typname, "numeric"))
type = TYPE_FLOAT;
else if (!stricmp(typname, "date") || !stricmp(typname, "datetime") ||
!stricmp(typname, "time") || !stricmp(typname, "timestamp") ||
!stricmp(typname, "year"))
type = TYPE_DATE;
else if (!stricmp(typname, "bigint") || !stricmp(typname, "longlong"))
type = TYPE_BIGINT;
else
type = TYPE_ERROR;
return type;
} // end of MYSQLtoPLG
/************************************************************************/
/* Convert from PlugDB type to MySQL type number */
/************************************************************************/
enum enum_field_types PLGtoMYSQL(int type, bool gdf)
{
enum enum_field_types mytype;
switch (type) {
case TYPE_INT:
mytype = MYSQL_TYPE_LONG;
break;
case TYPE_SHORT:
mytype = MYSQL_TYPE_SHORT;
break;
case TYPE_FLOAT:
mytype = MYSQL_TYPE_DOUBLE;
break;
case TYPE_DATE:
mytype = (gdf) ? MYSQL_TYPE_DATE : MYSQL_TYPE_DATETIME;
break;
case TYPE_STRING:
mytype = MYSQL_TYPE_VARCHAR;
break;
case TYPE_BIGINT:
mytype = MYSQL_TYPE_LONGLONG;
break;
default:
mytype = MYSQL_TYPE_NULL;
} // endswitch mytype
return mytype;
} // end of PLGtoMYSQL
/************************************************************************/
/* Convert from MySQL type to PlugDB type number */
/************************************************************************/
int MYSQLtoPLG(int mytype)
{
int type;
switch (mytype) {
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
type = TYPE_SHORT;
break;
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_ENUM: // ???
type = TYPE_INT;
break;
case MYSQL_TYPE_LONGLONG:
type = TYPE_BIGINT;
break;
case MYSQL_TYPE_DECIMAL:
#if !defined(ALPHA)
case MYSQL_TYPE_NEWDECIMAL:
#endif // !ALPHA)
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
type = TYPE_FLOAT;
break;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_TIME:
type = TYPE_DATE;
break;
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
#if !defined(ALPHA)
case MYSQL_TYPE_VARCHAR:
#endif // !ALPHA)
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
type = TYPE_STRING;
break;
default:
type = TYPE_ERROR;
} // endswitch mytype
return type;
} // end of MYSQLtoPLG
/************************************************************************/
/* Returns the format corresponding to a MySQL date type. */
/************************************************************************/
char *MyDateFmt(int mytype)
{
char *fmt;
switch (mytype) {
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
fmt = "YYYY-MM-DD hh:mm:ss";
break;
case MYSQL_TYPE_DATE:
fmt = "YYYY-MM-DD";
break;
case MYSQL_TYPE_YEAR:
fmt = "YYYY";
break;
case MYSQL_TYPE_TIME:
fmt = "hh:mm:ss";
break;
default:
fmt = NULL;
} // endswitch mytype
return fmt;
} // end of MyDateFmt
/************************************************************************/
/* Returns the format corresponding to a MySQL date type. */
/************************************************************************/
char *MyDateFmt(char *typname)
{
char *fmt;
if (!stricmp(typname, "datetime") || !stricmp(typname, "timestamp"))
fmt = "YYYY-MM-DD hh:mm:ss";
else if (!stricmp(typname, "date"))
fmt = "YYYY-MM-DD";
else if (!stricmp(typname, "year"))
fmt = "YYYY";
else if (!stricmp(typname, "time"))
fmt = "hh:mm:ss";
else
fmt = NULL;
return fmt;
} // end of MyDateFmt
/************** MyUtil C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: MYUTIL */
/* ------------- */
/* Version 1.0 */
/* */
/* Author Olivier BERTRAND 2013 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
/* It contains utility functions to convert data types. */
/* It can optionally use the embedded MySQL library. */
/* */
/************************************************************************/
#include "my_global.h"
#include <mysql.h>
#if defined(WIN32)
//#include <windows.h>
#else // !WIN32
#include "osutil.h"
#endif // !WIN32
#include "global.h"
#include "plgdbsem.h"
//#include "value.h"
//#include "valblk.h"
#define DLL_EXPORT // Items are exported from this DLL
/************************************************************************/
/* Convert from MySQL type name to PlugDB type number */
/************************************************************************/
int MYSQLtoPLG(char *typname)
{
int type;
if (!stricmp(typname, "int") || !stricmp(typname, "mediumint") ||
!stricmp(typname, "integer"))
type = TYPE_INT;
else if (!stricmp(typname, "tinyint") || !stricmp(typname, "smallint"))
type = TYPE_SHORT;
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") ||
!stricmp(typname, "text") || !stricmp(typname, "blob"))
type = TYPE_STRING;
else if (!stricmp(typname, "double") || !stricmp(typname, "float") ||
!stricmp(typname, "real") || !stricmp(typname, "bigint") ||
!stricmp(typname, "decimal") || !stricmp(typname, "numeric"))
type = TYPE_FLOAT;
else if (!stricmp(typname, "date") || !stricmp(typname, "datetime") ||
!stricmp(typname, "time") || !stricmp(typname, "timestamp") ||
!stricmp(typname, "year"))
type = TYPE_DATE;
else if (!stricmp(typname, "bigint") || !stricmp(typname, "longlong"))
type = TYPE_BIGINT;
else
type = TYPE_ERROR;
return type;
} // end of MYSQLtoPLG
/************************************************************************/
/* Convert from PlugDB type to MySQL type number */
/************************************************************************/
enum enum_field_types PLGtoMYSQL(int type, bool gdf)
{
enum enum_field_types mytype;
switch (type) {
case TYPE_INT:
mytype = MYSQL_TYPE_LONG;
break;
case TYPE_SHORT:
mytype = MYSQL_TYPE_SHORT;
break;
case TYPE_FLOAT:
mytype = MYSQL_TYPE_DOUBLE;
break;
case TYPE_DATE:
mytype = (gdf) ? MYSQL_TYPE_DATE : MYSQL_TYPE_DATETIME;
break;
case TYPE_STRING:
mytype = MYSQL_TYPE_VARCHAR;
break;
case TYPE_BIGINT:
mytype = MYSQL_TYPE_LONGLONG;
break;
default:
mytype = MYSQL_TYPE_NULL;
} // endswitch mytype
return mytype;
} // end of PLGtoMYSQL
/************************************************************************/
/* Convert from MySQL type to PlugDB type number */
/************************************************************************/
int MYSQLtoPLG(int mytype)
{
int type;
switch (mytype) {
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
type = TYPE_SHORT;
break;
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_ENUM: // ???
type = TYPE_INT;
break;
case MYSQL_TYPE_LONGLONG:
type = TYPE_BIGINT;
break;
case MYSQL_TYPE_DECIMAL:
#if !defined(ALPHA)
case MYSQL_TYPE_NEWDECIMAL:
#endif // !ALPHA)
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
type = TYPE_FLOAT;
break;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_TIME:
type = TYPE_DATE;
break;
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
#if !defined(ALPHA)
case MYSQL_TYPE_VARCHAR:
#endif // !ALPHA)
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
type = TYPE_STRING;
break;
default:
type = TYPE_ERROR;
} // endswitch mytype
return type;
} // end of MYSQLtoPLG
/************************************************************************/
/* Returns the format corresponding to a MySQL date type. */
/************************************************************************/
char *MyDateFmt(int mytype)
{
char *fmt;
switch (mytype) {
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
fmt = "YYYY-MM-DD hh:mm:ss";
break;
case MYSQL_TYPE_DATE:
fmt = "YYYY-MM-DD";
break;
case MYSQL_TYPE_YEAR:
fmt = "YYYY";
break;
case MYSQL_TYPE_TIME:
fmt = "hh:mm:ss";
break;
default:
fmt = NULL;
} // endswitch mytype
return fmt;
} // end of MyDateFmt
/************************************************************************/
/* Returns the format corresponding to a MySQL date type. */
/************************************************************************/
char *MyDateFmt(char *typname)
{
char *fmt;
if (!stricmp(typname, "datetime") || !stricmp(typname, "timestamp"))
fmt = "YYYY-MM-DD hh:mm:ss";
else if (!stricmp(typname, "date"))
fmt = "YYYY-MM-DD";
else if (!stricmp(typname, "year"))
fmt = "YYYY";
else if (!stricmp(typname, "time"))
fmt = "hh:mm:ss";
else
fmt = NULL;
return fmt;
} // end of MyDateFmt

File diff suppressed because it is too large Load Diff

View File

@@ -1,185 +1,184 @@
/***********************************************************************/
/* ODBConn.h : header file for the ODBC connection classes. */
/***********************************************************************/
//nclude <windows.h> /* Windows include file */
//nclude <windowsx.h> /* Message crackers */
/***********************************************************************/
/* Included C-definition files required by the interface. */
/***********************************************************************/
#include "block.h"
/***********************************************************************/
/* ODBC interface. */
/***********************************************************************/
#include <sql.h>
#include <sqlext.h>
/***********************************************************************/
/* Constants and defines. */
/***********************************************************************/
// Miscellaneous sizing info
#define MAX_NUM_OF_MSG 10 // Max number of error messages
//efine MAX_CURRENCY 30 // Max size of Currency($) string
#define MAX_TNAME_LEN 32 // Max size of table names
//efine MAX_FNAME_LEN 256 // Max size of field names
#define MAX_STRING_INFO 256 // Max size of string from SQLGetInfo
//efine MAX_DNAME_LEN 256 // Max size of Recordset names
#define MAX_CONNECT_LEN 512 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type
#if !defined(WIN32)
typedef unsigned char *PUCHAR;
#endif // !WIN32
// Timeout and net wait defaults
#define DEFAULT_LOGIN_TIMEOUT 15 // seconds to before fail on connect
#define DEFAULT_QUERY_TIMEOUT 15 // seconds to before fail waiting for results
// Field Flags, used to indicate status of fields
//efine SQL_FIELD_FLAG_DIRTY 0x1
//efine SQL_FIELD_FLAG_NULL 0x2
// Update options flags
#define SQL_SETPOSUPDATES 0x0001
#define SQL_POSITIONEDSQL 0x0002
//efine SQL_GDBOUND 0x0004
enum CATINFO {CAT_TAB = 1, /* SQLTables */
CAT_COL = 2, /* SQLColumns */
CAT_KEY = 3, /* SQLPrimaryKeys */
CAT_STAT = 4, /* SQLStatistics */
CAT_SPC = 5}; /* SQLSpecialColumns */
/***********************************************************************/
/* This structure is used to control the catalog functions. */
/***********************************************************************/
typedef struct tagCATPARM {
CATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer
PUCHAR Tab; // Table name or pattern
PUCHAR Pat; // Table type or column pattern
SQLLEN* *Vlen; // To array of indicator values
UWORD *Status; // To status block
// For SQLStatistics
UWORD Unique; // Index type
UWORD Accuracy; // For Cardinality and Pages
// For SQLSpecialColumns
UWORD ColType;
UWORD Scope;
UWORD Nullable;
} CATPARM;
// ODBC connection to a data source
class TDBODBC;
class ODBCCOL;
class ODBConn;
/***********************************************************************/
/* Class DBX (ODBC exception). */
/***********************************************************************/
class DBX : public BLOCK {
friend class ODBConn;
// Construction (by ThrowDBX only) -- destruction
protected:
DBX(RETCODE rc);
public:
//virtual ~DBX() {}
//void operator delete(void*, PGLOBAL, void*) {};
// Implementation (use ThrowDBX to create)
RETCODE GetRC(void) {return m_RC;}
PSZ GetErrorMessage(int i)
{return (i >=0 && i < MAX_NUM_OF_MSG) ? m_ErrMsg[i]
: "No ODBC error";}
protected:
void BuildErrorMessage(ODBConn* pdb, HSTMT hstmt = SQL_NULL_HSTMT);
// Attributes
RETCODE m_RC;
PSZ m_ErrMsg[MAX_NUM_OF_MSG];
}; // end of DBX class definition
/***********************************************************************/
/* ODBConn class. */
/***********************************************************************/
class ODBConn : public BLOCK {
friend class DBX;
friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
private:
ODBConn(); // Standard (unused) constructor
public:
ODBConn(PGLOBAL g, TDBODBC *tdbp);
enum DOP { // Db Open oPtions
traceSQL = 0x0001, // Trace SQL calls
openReadOnly = 0x0002, // Open database read only
useCursorLib = 0x0004, // Use ODBC cursor lib
noOdbcDialog = 0x0008, // Don't display ODBC Connect dialog
forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog
int Open(PSZ ConnectString, DWORD Options = 0);
void Close(void);
// Attributes
public:
char GetQuoteChar(void) {return m_IDQuoteChar;}
// Database successfully opened?
bool IsOpen(void) {return m_hdbc != SQL_NULL_HDBC;}
PSZ GetStringInfo(ushort infotype);
int GetMaxValue(ushort infotype);
PSZ GetConnect(void) {return m_Connect;}
public:
// Operations
void SetLoginTimeout(DWORD sec) {m_LoginTimeout = sec;}
void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
int GetResultSize(char *sql, ODBCCOL *colp);
int ExecDirectSQL(char *sql, ODBCCOL *tocols);
int Fetch(void);
int PrepareSQL(char *sql);
bool ExecuteSQL(void);
bool BindParam(ODBCCOL *colp);
int GetCatInfo(CATPARM *cap);
bool GetDataSources(PQRYRES qrp);
public:
// Set special options
void OnSetOptions(HSTMT hstmt);
// Implementation
public:
// virtual ~ODBConn();
// ODBC operations
protected:
bool Check(RETCODE rc);
void ThrowDBX(RETCODE rc, HSTMT hstmt = SQL_NULL_HSTMT);
void ThrowDBX(PSZ msg);
void AllocConnect(DWORD dwOptions);
bool Connect(DWORD Options);
void VerifyConnect(void);
void GetConnectInfo(void);
void Free(void);
protected:
// Static members
static HENV m_henv;
static int m_nAlloc; // per-Appl reference to HENV above
// Members
PGLOBAL m_G;
TDBODBC *m_Tdb;
HDBC m_hdbc;
HSTMT m_hstmt;
DWORD m_LoginTimeout;
DWORD m_QueryTimeout;
DWORD m_UpdateOptions;
DWORD m_RowsetSize;
int m_Catver;
PSZ m_Connect;
bool m_Updatable;
char m_IDQuoteChar;
}; // end of ODBConn class definition
/***********************************************************************/
/* ODBConn.h : header file for the ODBC connection classes. */
/***********************************************************************/
//nclude <windows.h> /* Windows include file */
//nclude <windowsx.h> /* Message crackers */
/***********************************************************************/
/* Included C-definition files required by the interface. */
/***********************************************************************/
#include "block.h"
/***********************************************************************/
/* ODBC interface. */
/***********************************************************************/
#include <sql.h>
#include <sqlext.h>
/***********************************************************************/
/* Constants and defines. */
/***********************************************************************/
// Miscellaneous sizing info
#define MAX_NUM_OF_MSG 10 // Max number of error messages
//efine MAX_CURRENCY 30 // Max size of Currency($) string
#define MAX_TNAME_LEN 32 // Max size of table names
//efine MAX_FNAME_LEN 256 // Max size of field names
#define MAX_STRING_INFO 256 // Max size of string from SQLGetInfo
//efine MAX_DNAME_LEN 256 // Max size of Recordset names
#define MAX_CONNECT_LEN 512 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type
#if !defined(WIN32)
typedef unsigned char *PUCHAR;
#endif // !WIN32
// Timeout and net wait defaults
#define DEFAULT_LOGIN_TIMEOUT 15 // seconds to before fail on connect
#define DEFAULT_QUERY_TIMEOUT 15 // seconds to before fail waiting for results
// Field Flags, used to indicate status of fields
//efine SQL_FIELD_FLAG_DIRTY 0x1
//efine SQL_FIELD_FLAG_NULL 0x2
// Update options flags
#define SQL_SETPOSUPDATES 0x0001
#define SQL_POSITIONEDSQL 0x0002
//efine SQL_GDBOUND 0x0004
enum CATINFO {CAT_TAB = 1, /* SQLTables */
CAT_COL = 2, /* SQLColumns */
CAT_KEY = 3, /* SQLPrimaryKeys */
CAT_STAT = 4, /* SQLStatistics */
CAT_SPC = 5}; /* SQLSpecialColumns */
/***********************************************************************/
/* This structure is used to control the catalog functions. */
/***********************************************************************/
typedef struct tagCATPARM {
CATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer
PUCHAR Tab; // Table name or pattern
PUCHAR Pat; // Table type or column pattern
SQLLEN* *Vlen; // To array of indicator values
UWORD *Status; // To status block
// For SQLStatistics
UWORD Unique; // Index type
UWORD Accuracy; // For Cardinality and Pages
// For SQLSpecialColumns
UWORD ColType;
UWORD Scope;
UWORD Nullable;
} CATPARM;
// ODBC connection to a data source
class TDBODBC;
class ODBCCOL;
class ODBConn;
/***********************************************************************/
/* Class DBX (ODBC exception). */
/***********************************************************************/
class DBX : public BLOCK {
friend class ODBConn;
// Construction (by ThrowDBX only) -- destruction
protected:
DBX(RETCODE rc);
public:
//virtual ~DBX() {}
//void operator delete(void*, PGLOBAL, void*) {};
// Implementation (use ThrowDBX to create)
RETCODE GetRC(void) {return m_RC;}
const char *GetErrorMessage(int i)
{ return (i >=0 && i < MAX_NUM_OF_MSG) ? m_ErrMsg[i] : "No ODBC error"; }
protected:
void BuildErrorMessage(ODBConn* pdb, HSTMT hstmt = SQL_NULL_HSTMT);
// Attributes
RETCODE m_RC;
PSZ m_ErrMsg[MAX_NUM_OF_MSG];
}; // end of DBX class definition
/***********************************************************************/
/* ODBConn class. */
/***********************************************************************/
class ODBConn : public BLOCK {
friend class DBX;
friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
private:
ODBConn(); // Standard (unused) constructor
public:
ODBConn(PGLOBAL g, TDBODBC *tdbp);
enum DOP { // Db Open oPtions
traceSQL = 0x0001, // Trace SQL calls
openReadOnly = 0x0002, // Open database read only
useCursorLib = 0x0004, // Use ODBC cursor lib
noOdbcDialog = 0x0008, // Don't display ODBC Connect dialog
forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog
int Open(PSZ ConnectString, DWORD Options = 0);
void Close(void);
// Attributes
public:
char GetQuoteChar(void) {return m_IDQuoteChar;}
// Database successfully opened?
bool IsOpen(void) {return m_hdbc != SQL_NULL_HDBC;}
PSZ GetStringInfo(ushort infotype);
int GetMaxValue(ushort infotype);
PSZ GetConnect(void) {return m_Connect;}
public:
// Operations
void SetLoginTimeout(DWORD sec) {m_LoginTimeout = sec;}
void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
int GetResultSize(char *sql, ODBCCOL *colp);
int ExecDirectSQL(char *sql, ODBCCOL *tocols);
int Fetch(void);
int PrepareSQL(char *sql);
bool ExecuteSQL(void);
bool BindParam(ODBCCOL *colp);
int GetCatInfo(CATPARM *cap);
bool GetDataSources(PQRYRES qrp);
public:
// Set special options
void OnSetOptions(HSTMT hstmt);
// Implementation
public:
// virtual ~ODBConn();
// ODBC operations
protected:
bool Check(RETCODE rc);
void ThrowDBX(RETCODE rc, HSTMT hstmt = SQL_NULL_HSTMT);
void ThrowDBX(PSZ msg);
void AllocConnect(DWORD dwOptions);
bool Connect(DWORD Options);
void VerifyConnect(void);
void GetConnectInfo(void);
void Free(void);
protected:
// Static members
static HENV m_henv;
static int m_nAlloc; // per-Appl reference to HENV above
// Members
PGLOBAL m_G;
TDBODBC *m_Tdb;
HDBC m_hdbc;
HSTMT m_hstmt;
DWORD m_LoginTimeout;
DWORD m_QueryTimeout;
DWORD m_UpdateOptions;
DWORD m_RowsetSize;
int m_Catver;
PSZ m_Connect;
bool m_Updatable;
char m_IDQuoteChar;
}; // end of ODBConn class definition

View File

@@ -26,6 +26,7 @@ typedef unsigned char BYTE;
typedef char *LPSTR;
typedef char *LPTSTR;
typedef char *PSZ;
typedef long BOOL;
typedef int INT;
#if !defined(NODW)
/*
@@ -39,19 +40,15 @@ typedef unsigned long DWORD;
#undef HANDLE
typedef int HANDLE;
/* TODO-BAR: remove this */
#ifdef __cplusplus
typedef int bool;
#else
#define bool my_bool
#endif
#define _MAX_PATH PATH_MAX
#define stricmp strcasecmp
#define _stricmp strcasecmp
#define strnicmp strncasecmp
#define _strnicmp strncasecmp
#ifdef PATH_MAX
#define _MAX_PATH PATH_MAX
#else
#define _MAX_PATH 260
#endif
#define _MAX_DRIVE 3
#define _MAX_DIR 256
#define _MAX_FNAME 256

View File

@@ -1,232 +1,231 @@
#include "my_global.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "osutil.h"
#ifdef WIN32
my_bool CloseFileHandle(HANDLE h)
{
return !CloseHandle(h);
} /* end of CloseFileHandle */
#else /* UNIX */
/* code to handle Linux and Solaris */
#include <unistd.h>
#include <sys/stat.h>
//#include <ctype.h>
#include <fcntl.h>
#define DWORD int
extern FILE *debug;
/***********************************************************************/
/* Define some functions not existing in the UNIX library. */
/***********************************************************************/
PSZ strupr(PSZ p)
{
register int i;
for (i = 0; p[i]; i++)
p[i] = toupper(p[i]);
return (p);
} /* end of strupr */
PSZ strlwr(PSZ p)
{
register int i;
for (i = 0; p[i]; i++)
p[i] = tolower(p[i]);
return (p);
} /* end of strlwr */
#if defined(NOT_USED) /*&& !defined(sun) && !defined(LINUX) && !defined(AIX)*/
/***********************************************************************/
/* Define stricmp function not existing in some UNIX libraries. */
/***********************************************************************/
int stricmp(char *str1, char *str2)
{
register int i;
int n;
char c;
char *sup1 = malloc(strlen(str1) + 1);
char *sup2 = malloc(strlen(str2) + 1);
for (i = 0; c = str1[i]; i++)
sup1[i] = toupper(c);
sup1[i] = 0;
for (i = 0; c = str2[i]; i++)
sup2[i] = toupper(c);
sup2[i] = 0;
n = strcmp(sup1, sup2);
free(sup1);
free(sup2);
return (n);
} /* end of stricmp */
#endif /* sun */
/***********************************************************************/
/* Define the splitpath function not existing in the UNIX library. */
/***********************************************************************/
void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
{
LPCSTR p2, p = name;
#ifdef DEBTRACE
fprintf(debug,"SplitPath: name=%s [%s (%d)]\n",
XSTR(name), XSTR(__FILE__), __LINE__);
#endif
if (drive) *drive = '\0';
if (dir) *dir = '\0';
if (fn) *fn = '\0';
if (ft) *ft = '\0';
if ((p2 = strrchr(p, '/'))) {
p2++;
if (dir) strncat(dir, p, p2 - p);
p = p2;
} /* endif p2 */
if ((p2 = strrchr(p, '.'))) {
if (fn) strncat(fn, p, p2 - p);
if (ft) strcpy(ft, p2);
} else
if (fn) strcpy(fn, p);
#ifdef DEBTRACE
fprintf(debug,"SplitPath: name=%s drive=%s dir=%s filename=%s type=%s [%s(%d)]\n",
XSTR(name), XSTR(drive), XSTR(dir), XSTR(fn), XSTR(ft), __FILE__, __LINE__);
#endif
} /* end of _splitpath */
/***********************************************************************/
/* Define the makepath function not existing in the UNIX library. */
/***********************************************************************/
void _makepath(LPSTR name, LPCSTR drive, LPCSTR dir, LPCSTR fn, LPCSTR ft)
{
int n;
if (!name)
return;
else
*name = '\0';
if (dir && (n = strlen(dir)) > 0) {
strcpy(name, dir);
if (name[n-1] != '/')
strcat(name, "/");
} /* endif dir */
if (fn)
strcat(name, fn);
if (ft && strlen(ft)) {
if (*ft != '.')
strcat(name, ".");
strcat(name, ft);
} /* endif ft */
} /* end of _makepath */
my_bool CloseFileHandle(HANDLE h)
{
return (close(h)) ? TRUE : FALSE;
} /* end of CloseFileHandle */
void Sleep(DWORD time)
{
//FIXME: TODO
} /* end of Sleep */
int GetLastError()
{
return errno;
} /* end of GetLastError */
unsigned long _filelength(int fd)
{
struct stat st;
if (fd == -1)
return 0;
if (fstat(fd, &st) != 0)
return 0;
return st.st_size;
} /* end of _filelength */
char *_fullpath(char *absPath, const char *relPath, size_t maxLength)
{
// Fixme
char *p;
if( *relPath == '\\' || *relPath == '/' ) {
strncpy(absPath, relPath, maxLength);
} else if(*relPath == '~') {
// get the path to the home directory
// Fixme
strncpy(absPath, relPath, maxLength);
} else {
char buff[2*_MAX_PATH];
getcwd(buff, _MAX_PATH);
strcat(buff,"/");
strcat(buff, relPath);
strncpy(absPath, buff, maxLength);
} /* endif's relPath */
p = absPath;
for(; *p; p++)
if (*p == '\\')
*p = '/';
return absPath;
} /* end of _fullpath */
bool MessageBeep(uint i)
{
// Fixme
return TRUE;
} /* end of MessageBeep */
LPSTR _strerror(int errn)
{
static char buff[256];
sprintf(buff,"error: %d", errn);
return buff;
} /* end of _strerror */
int _isatty(int fileNo)
{
return isatty(fileNo);
} /* end of _isatty */
/* This function is ridiculous and should be revisited */
DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId,
DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, ...)
{
char buff[32];
int n;
//if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER)
// return 0; /* means error */
n = sprintf(buff, "Error code: %d", dwMessageId);
strncpy(lpBuffer, buff, nSize);
return min(n, nSize);
} /* end of FormatMessage */
#endif // UNIX
#include "my_global.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "osutil.h"
#ifdef WIN32
my_bool CloseFileHandle(HANDLE h)
{
return !CloseHandle(h);
} /* end of CloseFileHandle */
#else /* UNIX */
/* code to handle Linux and Solaris */
#include <unistd.h>
#include <sys/stat.h>
#include <ctype.h>
#include <fcntl.h>
extern FILE *debug;
/***********************************************************************/
/* Define some functions not existing in the UNIX library. */
/***********************************************************************/
PSZ strupr(PSZ p)
{
register int i;
for (i = 0; p[i]; i++)
p[i] = toupper(p[i]);
return (p);
} /* end of strupr */
PSZ strlwr(PSZ p)
{
register int i;
for (i = 0; p[i]; i++)
p[i] = tolower(p[i]);
return (p);
} /* end of strlwr */
#if defined(NOT_USED) /*&& !defined(sun) && !defined(LINUX) && !defined(AIX)*/
/***********************************************************************/
/* Define stricmp function not existing in some UNIX libraries. */
/***********************************************************************/
int stricmp(char *str1, char *str2)
{
register int i;
int n;
char c;
char *sup1 = malloc(strlen(str1) + 1);
char *sup2 = malloc(strlen(str2) + 1);
for (i = 0; c = str1[i]; i++)
sup1[i] = toupper(c);
sup1[i] = 0;
for (i = 0; c = str2[i]; i++)
sup2[i] = toupper(c);
sup2[i] = 0;
n = strcmp(sup1, sup2);
free(sup1);
free(sup2);
return (n);
} /* end of stricmp */
#endif /* sun */
/***********************************************************************/
/* Define the splitpath function not existing in the UNIX library. */
/***********************************************************************/
void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
{
LPCSTR p2, p = name;
#ifdef DEBTRACE
fprintf(debug,"SplitPath: name=%s [%s (%d)]\n",
XSTR(name), XSTR(__FILE__), __LINE__);
#endif
if (drive) *drive = '\0';
if (dir) *dir = '\0';
if (fn) *fn = '\0';
if (ft) *ft = '\0';
if ((p2 = strrchr(p, '/'))) {
p2++;
if (dir) strncat(dir, p, p2 - p);
p = p2;
} /* endif p2 */
if ((p2 = strrchr(p, '.'))) {
if (fn) strncat(fn, p, p2 - p);
if (ft) strcpy(ft, p2);
} else
if (fn) strcpy(fn, p);
#ifdef DEBTRACE
fprintf(debug,"SplitPath: name=%s drive=%s dir=%s filename=%s type=%s [%s(%d)]\n",
XSTR(name), XSTR(drive), XSTR(dir), XSTR(fn), XSTR(ft), __FILE__, __LINE__);
#endif
} /* end of _splitpath */
/***********************************************************************/
/* Define the makepath function not existing in the UNIX library. */
/***********************************************************************/
void _makepath(LPSTR name, LPCSTR drive, LPCSTR dir, LPCSTR fn, LPCSTR ft)
{
int n;
if (!name)
return;
else
*name = '\0';
if (dir && (n = strlen(dir)) > 0) {
strcpy(name, dir);
if (name[n-1] != '/')
strcat(name, "/");
} /* endif dir */
if (fn)
strcat(name, fn);
if (ft && strlen(ft)) {
if (*ft != '.')
strcat(name, ".");
strcat(name, ft);
} /* endif ft */
} /* end of _makepath */
my_bool CloseFileHandle(HANDLE h)
{
return (close(h)) ? TRUE : FALSE;
} /* end of CloseFileHandle */
void Sleep(DWORD time)
{
//FIXME: TODO
} /* end of Sleep */
int GetLastError()
{
return errno;
} /* end of GetLastError */
unsigned long _filelength(int fd)
{
struct stat st;
if (fd == -1)
return 0;
if (fstat(fd, &st) != 0)
return 0;
return st.st_size;
} /* end of _filelength */
char *_fullpath(char *absPath, const char *relPath, size_t maxLength)
{
// Fixme
char *p;
if( *relPath == '\\' || *relPath == '/' ) {
strncpy(absPath, relPath, maxLength);
} else if(*relPath == '~') {
// get the path to the home directory
// Fixme
strncpy(absPath, relPath, maxLength);
} else {
char buff[2*_MAX_PATH];
getcwd(buff, _MAX_PATH);
strcat(buff,"/");
strcat(buff, relPath);
strncpy(absPath, buff, maxLength);
} /* endif's relPath */
p = absPath;
for(; *p; p++)
if (*p == '\\')
*p = '/';
return absPath;
} /* end of _fullpath */
BOOL MessageBeep(uint i)
{
// Fixme
return TRUE;
} /* end of MessageBeep */
LPSTR _strerror(int errn)
{
static char buff[256];
sprintf(buff,"error: %d", errn);
return buff;
} /* end of _strerror */
int _isatty(int fileNo)
{
return isatty(fileNo);
} /* end of _isatty */
/* This function is ridiculous and should be revisited */
DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId,
DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, ...)
{
char buff[32];
int n;
//if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER)
// return 0; /* means error */
n = sprintf(buff, "Error code: %d", (int) dwMessageId);
strncpy(lpBuffer, buff, nSize);
return min(n, nSize);
} /* end of FormatMessage */
#endif // UNIX

View File

@@ -1,103 +1,99 @@
#ifndef __OSUTIL_H__
#define __OSUTIL_H__
#if defined(UNIX) || defined(UNIV_LINUX)
#include "my_global.h"
#include <errno.h>
#include <stddef.h>
#include "os.h"
#define MB_OK 0x00000000
#if defined(__cplusplus)
#if !defined(__MINMAX_DEFINED)
#define __MINMAX_DEFINED
#ifndef max
#define max(x,y) (((x)>(y))?(x):(y))
#endif
#ifndef min
#define min(x,y) (((x)<(y))?(x):(y))
#endif
#endif
#endif /* __cplusplus */
#ifdef __cplusplus
extern "C" {
#endif
int GetLastError();
void _splitpath(const char*, char*, char*, char*, char*);
void _makepath(char*, const char*, const char*, const char*, const char*);
char *_fullpath(char *absPath, const char *relPath, size_t maxLength);
bool MessageBeep(uint);
unsigned long _filelength(int fd);
int GetPrivateProfileString(
LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name
LPCTSTR lpDefault, // default string
LPTSTR lpReturnedString, // destination buffer
int nSize, // size of destination buffer
LPCTSTR lpFileName // initialization file name
);
uint GetPrivateProfileInt(
LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name
INT nDefault, // return value if key name not found
LPCTSTR lpFileName // initialization file name
);
bool WritePrivateProfileString(
LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name
LPCTSTR lpString, // string to add
LPCTSTR lpFileName // initialization file
);
int GetPrivateProfileSection(
LPCTSTR lpAppName, // section name
LPTSTR lpReturnedString, // return buffer
int nSize, // size of return buffer
LPCTSTR lpFileName // initialization file name
);
bool WritePrivateProfileSection(
LPCTSTR lpAppName, // section name
LPCTSTR lpString, // data
LPCTSTR lpFileName // file name
);
PSZ strupr(PSZ s);
PSZ strlwr(PSZ s);
typedef size_t FILEPOS;
//pedef int FILEHANDLE; // UNIX
#ifndef _MAX_PATH
#define MAX_PATH 256
#endif
#ifdef __cplusplus
}
#endif
#else /* WINDOWS */
#include <windows.h>
typedef __int64 FILEPOS;
//pedef HANDLE FILEHANDLE; // Win32
#endif /* WINDOWS */
#define XSTR(x) ((x)?(x):"<null>")
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* __OSUTIL_H__ */
#ifndef __OSUTIL_H__
#define __OSUTIL_H__
#if defined(UNIX) || defined(UNIV_LINUX)
#include "my_global.h"
#include <errno.h>
#include <stddef.h>
#include "os.h"
#define MB_OK 0x00000000
#if defined(__cplusplus)
#if !defined(__MINMAX_DEFINED)
#define __MINMAX_DEFINED
#ifndef max
#define max(x,y) (((x)>(y))?(x):(y))
#endif
#ifndef min
#define min(x,y) (((x)<(y))?(x):(y))
#endif
#endif
#endif /* __cplusplus */
#ifdef __cplusplus
extern "C" {
#endif
int GetLastError();
void _splitpath(const char*, char*, char*, char*, char*);
void _makepath(char*, const char*, const char*, const char*, const char*);
char *_fullpath(char *absPath, const char *relPath, size_t maxLength);
BOOL MessageBeep(uint);
unsigned long _filelength(int fd);
int GetPrivateProfileString(
LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name
LPCTSTR lpDefault, // default string
LPTSTR lpReturnedString, // destination buffer
int nSize, // size of destination buffer
LPCTSTR lpFileName // initialization file name
);
uint GetPrivateProfileInt(
LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name
INT nDefault, // return value if key name not found
LPCTSTR lpFileName // initialization file name
);
BOOL WritePrivateProfileString(
LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name
LPCTSTR lpString, // string to add
LPCTSTR lpFileName // initialization file
);
int GetPrivateProfileSection(
LPCTSTR lpAppName, // section name
LPTSTR lpReturnedString, // return buffer
int nSize, // size of return buffer
LPCTSTR lpFileName // initialization file name
);
BOOL WritePrivateProfileSection(
LPCTSTR lpAppName, // section name
LPCTSTR lpString, // data
LPCTSTR lpFileName // file name
);
PSZ strupr(PSZ s);
PSZ strlwr(PSZ s);
typedef size_t FILEPOS;
//pedef int FILEHANDLE; // UNIX
#ifdef __cplusplus
}
#endif
#else /* WINDOWS */
#include <windows.h>
typedef __int64 FILEPOS;
//pedef HANDLE FILEHANDLE; // Win32
#endif /* WINDOWS */
#define XSTR(x) ((x)?(x):"<null>")
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* __OSUTIL_H__ */

View File

@@ -1,218 +1,218 @@
/**************************************************************************/
/* PLGCNX.H */
/* Copyright to the author: Olivier Bertrand 2000-2012 */
/* */
/* This is the connection DLL's declares. */
/**************************************************************************/
#if !defined(_PLGCNX_H)
#define _PLGCNX_H
#define MAXMSGLEN 65512 /* Default max length of cnx message */
#define MAXERRMSG 512 /* Max length of error messages */
#define MAXMESSAGE 256 /* Max length of returned messages */
#define MAXDBNAME 128 /* Max length of DB related names */
/**************************************************************************/
/* API Function return codes. */
/**************************************************************************/
enum FNRC {RC_LICENSE = 7, /* PLGConnect prompt for license key */
RC_PASSWD = 6, /* PLGConnect prompt for User/Pwd */
RC_SUCWINFO = 5, /* Succes With Info return code */
RC_SOCKET = 4, /* RC from PLGConnect to socket DLL */
RC_PROMPT = 3, /* Intermediate prompt return */
RC_CANCEL = 2, /* Command was cancelled by user */
RC_PROGRESS = 1, /* Intermediate progress info */
RC_SUCCESS = 0, /* Successful function (must be 0) */
RC_MEMORY = -1, /* Storage allocation error */
RC_TRUNCATED = -2, /* Result has been truncated */
RC_TIMEOUT = -3, /* Connection timeout occured */
RC_TOOBIG = -4, /* Data is too big for connection */
RC_KEY = -5, /* Null ptr to key in Connect */
/* or bad key in other functions */
RC_MAXCONN = -6, /* Too many conn's for one process */
RC_MAXCLIENT = -7, /* Too many clients for one system */
RC_SYNCHRO = -8, /* Synchronization error */
RC_SERVER = -9, /* Error related to the server */
RC_MAXCOL = -10, /* Result has too many columns */
RC_LAST = -10}; /* Other error codes are < this and */
/* are system errors. */
/**************************************************************************/
/* Standard function return codes. */
/**************************************************************************/
#if !defined(RC_OK_DEFINED)
#define RC_OK_DEFINED
enum RCODE {RC_OK = 0, /* No error return code */
RC_NF = 1, /* Not found return code */
RC_EF = 2, /* End of file return code */
RC_FX = 3, /* Error return code */
RC_INFO = 4}; /* Success with info */
#endif // !RC_OK_DEFINED
/**************************************************************************/
/* Data types. */
/**************************************************************************/
enum XDBTYPE {DB_ERROR = 0, /* Unknown or wrong type */
DB_STRING = 1, /* Null terminated string */
DB_CHAR = 2, /* Character array */
DB_SHORT = 3, /* Used by some catalog functions */
DB_INT = 4, /* Long integer array */
DB_DOUBLE = 5, /* Double float array */
DB_DATE = 6}; /* Datetime value array */
/**************************************************************************/
/* Index of info values within the info int integer array. */
/**************************************************************************/
enum INFO {INDX_RC, /* Index of PlugDB return code field */
INDX_TIME, /* Index of elapsed time in millisec */
INDX_CHG, /* Index of Language or DB changed */
INDX_RSAV, /* Index of Result Set availability */
INDX_TYPE, /* Index of returned data type field */
INDX_LINE, /* Index of number of lines field */
INDX_LEN, /* Index of line length field */
INDX_SIZE, /* Index of returned data size field */
INDX_MAX}; /* Size of info array */
/**************************************************************************/
/* Internal message types. */
/**************************************************************************/
enum MSGTYP {MST_OPEN = 10, /* Code for old connecting message */
MST_COMMAND = 11, /* Code for send command message */
MST_RESULT = 12, /* Code for get result message */
MST_CLOSE = 13, /* Code for disconnecting message */
MST_PROGRESS = 14, /* Code for progress message */
MST_CANCEL = 15, /* Code for cancel message */
MST_PROCESSED = 16, /* Code for already processed msg */
MST_ERROR = 17, /* Code for get error message */
MST_CHAR = 18, /* Code for get char value message */
MST_LONG = 19, /* Code for get int value message */
MST_COLUMN = 20, /* Code for get col value message */
MST_MESSAGE = 21, /* Code for get message message */
MST_HEADER = 22, /* Code for get header message */
MST_SOCKET = 23, /* Code for socket error message */
MST_SHUTDOWN = 24, /* Code for shutdown message */
MST_SOCKPROG = 25, /* Code for socket progress message */
MST_POST = 26, /* Code for post command message */
MST_NEW_OPEN = 27, /* Code for new connecting message */
MST_PROG_NUM = 5}; /* Num of integers in progress msg */
/**************************************************************************/
/* Vendors. */
/**************************************************************************/
enum VENDOR {VDR_UNKNOWN = -2, /* Not known or not connected */
VDR_PlugDB = -1, /* PlugDB */
VDR_OTHER = 0}; /* OEM */
/**************************************************************************/
/* Attribute keys of Result Description structure (arranged by type). */
/**************************************************************************/
enum CKEYS {K_ProgMsg, K_Lang, K_ActiveDB, K_Cmax};
enum LKEYS {K_NBcol, K_NBlin, K_CurPos, K_RC, K_Result, K_Elapsed,
K_Continued, K_Maxsize, K_Lmax, K_Maxcol,
K_Maxres, K_Maxlin, K_NBparm};
enum NKEYS {K_Type, K_Length, K_Prec, K_DataLen, K_Nmax};
/**************************************************************************/
/* Result description structures. */
/**************************************************************************/
typedef struct _MsgTagAttr {
bool fSupplied;
char Attr[MAXMESSAGE];
} MTAG, *PMTAG;
typedef struct _CharTagAttr {
bool fSupplied;
char Attr[MAXDBNAME];
} CTAG, *PCTAG;
typedef struct _LongTagAttr {
bool fSupplied;
int Attr;
} LTAG, *PLTAG;
typedef struct _ColVar {
LTAG Lat[K_Nmax];
CTAG Cat;
} COLVAR, *LPCOLVAR;
typedef struct _ResDesc {
int Maxcol; /* Max number of columns */
int Colnum; /* Number of columns */
MTAG Mat; /* Message */
CTAG Cat[K_Cmax]; /* Character attributes */
LTAG Lat[K_Lmax]; /* Long int attributes */
COLVAR Col[1]; /* Column attributes */
} RDESC, *PRDESC;
/**************************************************************************/
/* Exported PlugDB client functions in Plgcnx DLL. */
/**************************************************************************/
#if !defined(CNXFUNC)
#if defined(UNIX) || defined(UNIV_LINUX)
#undef __stdcall
#define __stdcall
#endif
#if defined(NOLIB) /* Dynamic link of plgcnx.dll */
#define CNXFUNC(f) (__stdcall *f)
#else /* LIB */ /* Static link with plgcnx.lib */
#define CNXFUNC(f) __stdcall f
#endif
#endif
#if !defined(CNXKEY)
#define CNXKEY uint
#endif
#if !defined(XTRN)
#define XTRN
#endif
#ifdef NOT_USED
//#if !defined(NO_FUNC)
#ifdef __cplusplus
extern "C" {
#endif
XTRN int CNXFUNC(PLGConnect) (CNXKEY *, const char *, bool);
XTRN int CNXFUNC(PLGSendCommand) (CNXKEY, const char *, void *, int, int *);
XTRN int CNXFUNC(PLGGetResult) (CNXKEY, void *, int, int *, bool);
XTRN int CNXFUNC(PLGDisconnect) (CNXKEY);
XTRN int CNXFUNC(PLGGetErrorMsg) (CNXKEY, char *, int, int *);
XTRN bool CNXFUNC(PLGGetCharValue)(CNXKEY, char *, int, int);
XTRN bool CNXFUNC(PLGGetIntValue)(CNXKEY, int *, int);
XTRN bool CNXFUNC(PLGGetColValue) (CNXKEY, int *, int, int);
XTRN bool CNXFUNC(PLGGetMessage) (CNXKEY, char *, int);
XTRN bool CNXFUNC(PLGGetHeader) (CNXKEY, char *, int, int);
#ifdef __cplusplus
}
#endif
//#endif /* !NO_FUNC */
/**************************************************************************/
/* Convenience function Definitions */
/**************************************************************************/
#define PLGPostCommand(T,C) PLGSendCommand(T,C,NULL,0,NULL)
#if defined(FNCMAC)
#define PLGGetProgMsg(T,C,S) PLGGetCharValue(T,C,S,K_ProgMsg)
#define PLGGetLangID(T,C,S) PLGGetCharValue(T,C,S,K_Lang)
#define PLGGetActiveDB(T,C,S) PLGGetCharValue(T,C,S,K_ActiveDB)
#define PLGGetCursorPos(T,L) PLGGetIntValue(T,L,K_CurPos)
#define PLGGetResultType(T,L) PLGGetIntValue(T,L,K_Result)
#define PLGGetNBcol(T,L) PLGGetIntValue(T,L,K_NBcol)
#define PLGGetNBlin(T,L) PLGGetIntValue(T,L,K_NBlin)
#define PLGGetRetCode(T,L) PLGGetIntValue(T,L,K_RC)
#define PLGGetElapsed(T,L) PLGGetIntValue(T,L,K_Elapsed)
#define PLGGetContinued(T,L) PLGGetIntValue(T,L,K_Continued)
#define PLGGetMaxSize(T,L) PLGGetIntValue(T,L,K_Maxsize)
#define PLGGetLength(T,L,C) PLGGetColValue(T,L,K_Length,C)
#define PLGGetDataSize(T,L,C) PLGGetColValue(T,L,K_DataLen,C)
#define PLGGetDecimal(T,L,C) PLGGetColValue(T,L,K_Prec,C)
#define PLGGetType(T,L,C) PLGGetColValue(T,L,K_Type,C)
#endif /* FNCMAC */
#endif // NOT_USED
#endif /* !_PLGCNX_H */
/* ------------------------- End of Plgcnx.h ---------------------------- */
/**************************************************************************/
/* PLGCNX.H */
/* Copyright to the author: Olivier Bertrand 2000-2012 */
/* */
/* This is the connection DLL's declares. */
/**************************************************************************/
#if !defined(_PLGCNX_H)
#define _PLGCNX_H
#define MAXMSGLEN 65512 /* Default max length of cnx message */
#define MAXERRMSG 512 /* Max length of error messages */
#define MAXMESSAGE 256 /* Max length of returned messages */
#define MAXDBNAME 128 /* Max length of DB related names */
/**************************************************************************/
/* API Function return codes. */
/**************************************************************************/
enum FNRC {RC_LICENSE = 7, /* PLGConnect prompt for license key */
RC_PASSWD = 6, /* PLGConnect prompt for User/Pwd */
RC_SUCWINFO = 5, /* Succes With Info return code */
RC_SOCKET = 4, /* RC from PLGConnect to socket DLL */
RC_PROMPT = 3, /* Intermediate prompt return */
RC_CANCEL = 2, /* Command was cancelled by user */
RC_PROGRESS = 1, /* Intermediate progress info */
RC_SUCCESS = 0, /* Successful function (must be 0) */
RC_MEMORY = -1, /* Storage allocation error */
RC_TRUNCATED = -2, /* Result has been truncated */
RC_TIMEOUT = -3, /* Connection timeout occured */
RC_TOOBIG = -4, /* Data is too big for connection */
RC_KEY = -5, /* Null ptr to key in Connect */
/* or bad key in other functions */
RC_MAXCONN = -6, /* Too many conn's for one process */
RC_MAXCLIENT = -7, /* Too many clients for one system */
RC_SYNCHRO = -8, /* Synchronization error */
RC_SERVER = -9, /* Error related to the server */
RC_MAXCOL = -10, /* Result has too many columns */
RC_LAST = -10}; /* Other error codes are < this and */
/* are system errors. */
/**************************************************************************/
/* Standard function return codes. */
/**************************************************************************/
#if !defined(RC_OK_DEFINED)
#define RC_OK_DEFINED
enum RCODE {RC_OK = 0, /* No error return code */
RC_NF = 1, /* Not found return code */
RC_EF = 2, /* End of file return code */
RC_FX = 3, /* Error return code */
RC_INFO = 4}; /* Success with info */
#endif // !RC_OK_DEFINED
/**************************************************************************/
/* Data types. */
/**************************************************************************/
enum XDBTYPE {DB_ERROR = 0, /* Unknown or wrong type */
DB_STRING = 1, /* Null terminated string */
DB_CHAR = 2, /* Character array */
DB_SHORT = 3, /* Used by some catalog functions */
DB_INT = 4, /* Long integer array */
DB_DOUBLE = 5, /* Double float array */
DB_DATE = 6}; /* Datetime value array */
/**************************************************************************/
/* Index of info values within the info int integer array. */
/**************************************************************************/
enum INFO {INDX_RC, /* Index of PlugDB return code field */
INDX_TIME, /* Index of elapsed time in millisec */
INDX_CHG, /* Index of Language or DB changed */
INDX_RSAV, /* Index of Result Set availability */
INDX_TYPE, /* Index of returned data type field */
INDX_LINE, /* Index of number of lines field */
INDX_LEN, /* Index of line length field */
INDX_SIZE, /* Index of returned data size field */
INDX_MAX}; /* Size of info array */
/**************************************************************************/
/* Internal message types. */
/**************************************************************************/
enum MSGTYP {MST_OPEN = 10, /* Code for old connecting message */
MST_COMMAND = 11, /* Code for send command message */
MST_RESULT = 12, /* Code for get result message */
MST_CLOSE = 13, /* Code for disconnecting message */
MST_PROGRESS = 14, /* Code for progress message */
MST_CANCEL = 15, /* Code for cancel message */
MST_PROCESSED = 16, /* Code for already processed msg */
MST_ERROR = 17, /* Code for get error message */
MST_CHAR = 18, /* Code for get char value message */
MST_LONG = 19, /* Code for get int value message */
MST_COLUMN = 20, /* Code for get col value message */
MST_MESSAGE = 21, /* Code for get message message */
MST_HEADER = 22, /* Code for get header message */
MST_SOCKET = 23, /* Code for socket error message */
MST_SHUTDOWN = 24, /* Code for shutdown message */
MST_SOCKPROG = 25, /* Code for socket progress message */
MST_POST = 26, /* Code for post command message */
MST_NEW_OPEN = 27, /* Code for new connecting message */
MST_PROG_NUM = 5}; /* Num of integers in progress msg */
/**************************************************************************/
/* Vendors. */
/**************************************************************************/
enum VENDOR {VDR_UNKNOWN = -2, /* Not known or not connected */
VDR_PlugDB = -1, /* PlugDB */
VDR_OTHER = 0}; /* OEM */
/**************************************************************************/
/* Attribute keys of Result Description structure (arranged by type). */
/**************************************************************************/
enum CKEYS {K_ProgMsg, K_Lang, K_ActiveDB, K_Cmax};
enum LKEYS {K_NBcol, K_NBlin, K_CurPos, K_RC, K_Result, K_Elapsed,
K_Continued, K_Maxsize, K_Lmax, K_Maxcol,
K_Maxres, K_Maxlin, K_NBparm};
enum NKEYS {K_Type, K_Length, K_Prec, K_DataLen, K_Nmax};
/**************************************************************************/
/* Result description structures. */
/**************************************************************************/
typedef struct _MsgTagAttr {
bool fSupplied;
char Attr[MAXMESSAGE];
} MTAG, *PMTAG;
typedef struct _CharTagAttr {
bool fSupplied;
char Attr[MAXDBNAME];
} CTAG, *PCTAG;
typedef struct _LongTagAttr {
bool fSupplied;
int Attr;
} LTAG, *PLTAG;
typedef struct _ColVar {
LTAG Lat[K_Nmax];
CTAG Cat;
} COLVAR, *LPCOLVAR;
typedef struct _ResDesc {
int Maxcol; /* Max number of columns */
int Colnum; /* Number of columns */
MTAG Mat; /* Message */
CTAG Cat[K_Cmax]; /* Character attributes */
LTAG Lat[K_Lmax]; /* Long int attributes */
COLVAR Col[1]; /* Column attributes */
} RDESC, *PRDESC;
/**************************************************************************/
/* Exported PlugDB client functions in Plgcnx DLL. */
/**************************************************************************/
#if !defined(CNXFUNC)
#if defined(UNIX) || defined(UNIV_LINUX)
#undef __stdcall
#define __stdcall
#endif
#if defined(NOLIB) /* Dynamic link of plgcnx.dll */
#define CNXFUNC(f) (__stdcall *f)
#else /* LIB */ /* Static link with plgcnx.lib */
#define CNXFUNC(f) __stdcall f
#endif
#endif
#if !defined(CNXKEY)
#define CNXKEY uint
#endif
#if !defined(XTRN)
#define XTRN
#endif
#ifdef NOT_USED
//#if !defined(NO_FUNC)
#ifdef __cplusplus
extern "C" {
#endif
XTRN int CNXFUNC(PLGConnect) (CNXKEY *, const char *, bool);
XTRN int CNXFUNC(PLGSendCommand) (CNXKEY, const char *, void *, int, int *);
XTRN int CNXFUNC(PLGGetResult) (CNXKEY, void *, int, int *, bool);
XTRN int CNXFUNC(PLGDisconnect) (CNXKEY);
XTRN int CNXFUNC(PLGGetErrorMsg) (CNXKEY, char *, int, int *);
XTRN bool CNXFUNC(PLGGetCharValue)(CNXKEY, char *, int, int);
XTRN bool CNXFUNC(PLGGetIntValue)(CNXKEY, int *, int);
XTRN bool CNXFUNC(PLGGetColValue) (CNXKEY, int *, int, int);
XTRN bool CNXFUNC(PLGGetMessage) (CNXKEY, char *, int);
XTRN bool CNXFUNC(PLGGetHeader) (CNXKEY, char *, int, int);
#ifdef __cplusplus
}
#endif
//#endif /* !NO_FUNC */
/**************************************************************************/
/* Convenience function Definitions */
/**************************************************************************/
#define PLGPostCommand(T,C) PLGSendCommand(T,C,NULL,0,NULL)
#if defined(FNCMAC)
#define PLGGetProgMsg(T,C,S) PLGGetCharValue(T,C,S,K_ProgMsg)
#define PLGGetLangID(T,C,S) PLGGetCharValue(T,C,S,K_Lang)
#define PLGGetActiveDB(T,C,S) PLGGetCharValue(T,C,S,K_ActiveDB)
#define PLGGetCursorPos(T,L) PLGGetIntValue(T,L,K_CurPos)
#define PLGGetResultType(T,L) PLGGetIntValue(T,L,K_Result)
#define PLGGetNBcol(T,L) PLGGetIntValue(T,L,K_NBcol)
#define PLGGetNBlin(T,L) PLGGetIntValue(T,L,K_NBlin)
#define PLGGetRetCode(T,L) PLGGetIntValue(T,L,K_RC)
#define PLGGetElapsed(T,L) PLGGetIntValue(T,L,K_Elapsed)
#define PLGGetContinued(T,L) PLGGetIntValue(T,L,K_Continued)
#define PLGGetMaxSize(T,L) PLGGetIntValue(T,L,K_Maxsize)
#define PLGGetLength(T,L,C) PLGGetColValue(T,L,K_Length,C)
#define PLGGetDataSize(T,L,C) PLGGetColValue(T,L,K_DataLen,C)
#define PLGGetDecimal(T,L,C) PLGGetColValue(T,L,K_Prec,C)
#define PLGGetType(T,L,C) PLGGetColValue(T,L,K_Type,C)
#endif /* FNCMAC */
#endif // NOT_USED
#endif /* !_PLGCNX_H */
/* ------------------------- End of Plgcnx.h ---------------------------- */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,230 +1,230 @@
/***********************************************************************/
/* PLGODBC.H - This is the ODBC PlugDB driver include file. */
/***********************************************************************/
//efine WINVER 0x0300 // prevent Windows 3.1 feature usage
#include <windows.h> /* Windows include file */
#include <windowsx.h> /* Message crackers */
#include <commctrl.h>
/***********************************************************************/
/* Included C-definition files required by the interface. */
/***********************************************************************/
#include <string.h> /* String manipulation declares */
#include <stdlib.h> /* C standard library */
#include <ctype.h> /* C language specific types */
#include <stdio.h> /* FOPEN_MAX declaration */
#include <time.h> /* time_t type declaration */
/***********************************************************************/
/* ODBC interface of PlugDB driver declares. */
/***********************************************************************/
#include "podbcerr.h" /* Resource ID for PlugDB Driver */
#if !defined(WIN32)
#include "w16macro.h"
#endif
#define ODBCVER 0x0300
#include "sqltypes.h"
#include "sql.h"
#include "sqlext.h"
/***********************************************************************/
/* Definitions to be used in function prototypes. */
/* The SQL_API is to be used only for those functions exported for */
/* driver manager use. */
/* The EXPFUNC is to be used only for those functions exported but */
/* used internally, ie, dialog procs. */
/* The INTFUNC is to be used for all other functions. */
/***********************************************************************/
#if defined(WIN32)
#define INTFUNC __stdcall
#define EXPFUNC __stdcall
#else
#define INTFUNC FAR PASCAL
#define EXPFUNC __export CALLBACK
#endif
/***********************************************************************/
/* External variables. */
/***********************************************************************/
extern HINSTANCE NEAR s_hModule; // DLL handle.
#ifdef DEBTRACE
extern FILE *debug;
#endif
extern bool clearerror;
/***********************************************************************/
/* Additional values used by PlugDB for ODBC. */
/***********************************************************************/
#define RES_TYPE_PREPARE 1 /* Result from SQLPrepare */
#define RES_TYPE_CATALOG 2 /* Result from catalog funcs */
#define MAXPATHLEN _MAX_PATH /* Max path length */
#define MAXKEYLEN 16 /* Max keyword length */
#define MAXDESC 256 /* Max description length */
#define MAXDSNAME 33 /* Max data source name length */
#define MAXCRNAME 18 /* Max stmt cursor name length */
#define DEFMAXRES 6300 /* Default MaxRes value */
#define NAM_LEN 128 /* Length of col and tab names */
#define MAXRESULT 1000 /* ? */
#define MAXCOMMAND 200 /* ? */
#define RC_ERROR RC_LAST-1
#define RC_FREE 3
#if !defined(NOLIB)
#define CNXKEY uint /* C Key returned by Conn DLL */
#else
typedef struct _conninfo *PCONN;
#endif /* !NOLIB */
#if defined(DEBTRACE)
#define TRACE0(X) fprintf(debug,X);
#define TRACE1(X,A) fprintf(debug,X,A);
#define TRACE2(X,A,B) fprintf(debug,X,A,B);
#define TRACE3(X,A,B,C) fprintf(debug,X,A,B,C);
#define TRACE4(X,A,B,C,D) fprintf(debug,X,A,B,C,D);
#define TRACE5(X,A,B,C,D,E) fprintf(debug,X,A,B,C,D,E);
#define TRACE6(X,A,B,C,D,E,F) fprintf(debug,X,A,B,C,D,E,F);
#else /* !DEBTRACE*/
#define TRACE0(X)
#define TRACE1(X,A)
#define TRACE2(X,A,B)
#define TRACE3(X,A,B,C)
#define TRACE4(X,A,B,C,D)
#define TRACE5(X,A,B,C,D,E)
#define TRACE6(X,A,B,C,D,E,F)
#endif /* !DEBTRACE*/
// This definition MUST be identical to the value in plgdbsem.h
#define XMOD_PREPARE 1
/***********************************************************************/
/* ODBC.INI keywords (use extern definition in SETUP.C) */
/***********************************************************************/
extern char const *EMPTYSTR; /* Empty String */
extern char const *OPTIONON;
extern char const *OPTIONOFF;
extern char const *INI_SDEFAULT; /* Default data source name */
extern char const *ODBC_INI; /* ODBC initialization file */
extern char const *INI_KDEFL; /* Is SQL to use by default? */
extern char const *INI_KLANG; /* Application language */
extern char const *INI_KDATA; /* Data description file */
extern char const *INI_KSVR; /* PLG Server */
/************************************************************************/
/* Attribute key indexes (into an array of Attr structs, see below) */
/************************************************************************/
#define KEY_DSN 0
#define KEY_DEFL 1
#define KEY_LANG 2
#define KEY_DATA 3
#define KEY_SERVER 4
#define LAST_KEY 5 /* Number of keys in TAG's */
#define KEY_DESC 5
#define KEY_TRANSNAME 6
#define KEY_TRANSOPTION 7
#define KEY_TRANSDLL 8
#define NUMOFKEYS 9 /* Number of keys supported */
#define FOURYEARS 126230400 // Four years in seconds (1 leap)
/***********************************************************************/
/* This is used when an "out of memory" error happens, because this */
/* error recording system allocates memory when it logs an error, */
/* and it would be bad if it tried to allocate memory when it got an */
/* out of memory error. */
/***********************************************************************/
typedef enum _ERRSTAT {
errstatOK,
errstatNO_MEMORY,
} ERRSTAT;
/***********************************************************************/
/* Types */
/***********************************************************************/
typedef struct TagAttr {
bool fSupplied;
char Attr[MAXPATHLEN];
} TAG, *PTAG;
typedef struct _parscons { /* Parse constants */
int Slen; /* String length */
int Ntag; /* Number of entries in tags */
int Nlook; /* Number of entries in lookup */
char Sep; /* Separator */
} PARC, *PPARC;
/***********************************************************************/
/* Attribute string look-up table (maps keys to associated indexes) */
/***********************************************************************/
typedef struct _Look {
const char *szKey;
int iKey;
} LOOK, *PLOOK;
/***********************************************************************/
/* This is info about a single error. */
/***********************************************************************/
typedef struct _ERRBLK *PERRBLK;
typedef struct _ERRBLK {
PERRBLK Next; /* Next block in linked list of error blocks */
DWORD Native_Error; /* Native error */
DWORD Stderr; /* SQLC error code */
PSZ Message; /* Points to text of message */
} ERRBLK;
/***********************************************************************/
/* This is a header block, it records information about a list of */
/* errors (ERRBLOCK's). */
/***********************************************************************/
typedef struct _ERRINFO {
PERRBLK First; /* First block in linked list of error blocks. */
PERRBLK Last; /* Last block in above list. */
ERRSTAT Errstat; /* Status for special condition out of memory */
} ERRINFO, *PERRINFO;
/***********************************************************************/
/* Environment information. */
/***********************************************************************/
typedef struct _env {
ERRINFO Errinfo; /* Error list */
UDWORD ODBCver;
UDWORD ODBCdateformat;
} ENV, *PENV;
/***********************************************************************/
/* Classes used in the PlugDB ODBC Driver. */
/***********************************************************************/
typedef class DBC *PDBC;
typedef class STMT *PSTMT;
typedef class CURSOR *PCURSOR;
typedef class RESULT *PRESULT;
typedef class BINDDATA *PBIND;
typedef class BINDPARM *PBDPARM;
typedef class CPLGdrv *PSCDRV;
typedef class DESCRIPTOR *PDSC;
/***********************************************************************/
/* ODBC Prototypes. */
/***********************************************************************/
void PostSQLError(HENV, HDBC, HSTMT, DWORD, DWORD, PSZ);
void ClearSQLError(HENV, HDBC, HSTMT);
short LoadRcString(UWORD, LPSTR, short);
RETCODE RetcodeCopyBytes(HDBC, HSTMT, UCHAR FAR *, SWORD,
SWORD FAR *, UCHAR FAR *, SWORD, bool);
/***********************************************************************/
/* Private functions used by the driver. */
/***********************************************************************/
bool EXPFUNC FDriverConnectProc(HWND, WORD, WPARAM, LPARAM);
extern void ParseAttrString(PLOOK, PTAG, UCHAR FAR *, PPARC);
RETCODE PASCAL StringCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *,
char FAR *);
RETCODE PASCAL ShortCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *, short);
RETCODE PASCAL LongCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *, int);
RETCODE PASCAL GeneralCopy(HDBC, HSTMT, PTR, SWORD,
SWORD FAR *, PTR, SWORD);
/* --------------------- End of PLGODBC.H ---------------------------- */
/***********************************************************************/
/* PLGODBC.H - This is the ODBC PlugDB driver include file. */
/***********************************************************************/
//efine WINVER 0x0300 // prevent Windows 3.1 feature usage
#include <windows.h> /* Windows include file */
#include <windowsx.h> /* Message crackers */
#include <commctrl.h>
/***********************************************************************/
/* Included C-definition files required by the interface. */
/***********************************************************************/
#include <string.h> /* String manipulation declares */
#include <stdlib.h> /* C standard library */
#include <ctype.h> /* C language specific types */
#include <stdio.h> /* FOPEN_MAX declaration */
#include <time.h> /* time_t type declaration */
/***********************************************************************/
/* ODBC interface of PlugDB driver declares. */
/***********************************************************************/
#include "podbcerr.h" /* Resource ID for PlugDB Driver */
#if !defined(WIN32)
#include "w16macro.h"
#endif
#define ODBCVER 0x0300
#include "sqltypes.h"
#include "sql.h"
#include "sqlext.h"
/***********************************************************************/
/* Definitions to be used in function prototypes. */
/* The SQL_API is to be used only for those functions exported for */
/* driver manager use. */
/* The EXPFUNC is to be used only for those functions exported but */
/* used internally, ie, dialog procs. */
/* The INTFUNC is to be used for all other functions. */
/***********************************************************************/
#if defined(WIN32)
#define INTFUNC __stdcall
#define EXPFUNC __stdcall
#else
#define INTFUNC FAR PASCAL
#define EXPFUNC __export CALLBACK
#endif
/***********************************************************************/
/* External variables. */
/***********************************************************************/
extern HINSTANCE NEAR s_hModule; // DLL handle.
#ifdef DEBTRACE
extern FILE *debug;
#endif
extern bool clearerror;
/***********************************************************************/
/* Additional values used by PlugDB for ODBC. */
/***********************************************************************/
#define RES_TYPE_PREPARE 1 /* Result from SQLPrepare */
#define RES_TYPE_CATALOG 2 /* Result from catalog funcs */
#define MAXPATHLEN _MAX_PATH /* Max path length */
#define MAXKEYLEN 16 /* Max keyword length */
#define MAXDESC 256 /* Max description length */
#define MAXDSNAME 33 /* Max data source name length */
#define MAXCRNAME 18 /* Max stmt cursor name length */
#define DEFMAXRES 6300 /* Default MaxRes value */
#define NAM_LEN 128 /* Length of col and tab names */
#define MAXRESULT 1000 /* ? */
#define MAXCOMMAND 200 /* ? */
#define RC_ERROR RC_LAST-1
#define RC_FREE 3
#if !defined(NOLIB)
#define CNXKEY uint /* C Key returned by Conn DLL */
#else
typedef struct _conninfo *PCONN;
#endif /* !NOLIB */
#if defined(DEBTRACE)
#define TRACE0(X) fprintf(debug,X);
#define TRACE1(X,A) fprintf(debug,X,A);
#define TRACE2(X,A,B) fprintf(debug,X,A,B);
#define TRACE3(X,A,B,C) fprintf(debug,X,A,B,C);
#define TRACE4(X,A,B,C,D) fprintf(debug,X,A,B,C,D);
#define TRACE5(X,A,B,C,D,E) fprintf(debug,X,A,B,C,D,E);
#define TRACE6(X,A,B,C,D,E,F) fprintf(debug,X,A,B,C,D,E,F);
#else /* !DEBTRACE*/
#define TRACE0(X)
#define TRACE1(X,A)
#define TRACE2(X,A,B)
#define TRACE3(X,A,B,C)
#define TRACE4(X,A,B,C,D)
#define TRACE5(X,A,B,C,D,E)
#define TRACE6(X,A,B,C,D,E,F)
#endif /* !DEBTRACE*/
// This definition MUST be identical to the value in plgdbsem.h
#define XMOD_PREPARE 1
/***********************************************************************/
/* ODBC.INI keywords (use extern definition in SETUP.C) */
/***********************************************************************/
extern char const *EMPTYSTR; /* Empty String */
extern char const *OPTIONON;
extern char const *OPTIONOFF;
extern char const *INI_SDEFAULT; /* Default data source name */
extern char const *ODBC_INI; /* ODBC initialization file */
extern char const *INI_KDEFL; /* Is SQL to use by default? */
extern char const *INI_KLANG; /* Application language */
extern char const *INI_KDATA; /* Data description file */
extern char const *INI_KSVR; /* PLG Server */
/************************************************************************/
/* Attribute key indexes (into an array of Attr structs, see below) */
/************************************************************************/
#define KEY_DSN 0
#define KEY_DEFL 1
#define KEY_LANG 2
#define KEY_DATA 3
#define KEY_SERVER 4
#define LAST_KEY 5 /* Number of keys in TAG's */
#define KEY_DESC 5
#define KEY_TRANSNAME 6
#define KEY_TRANSOPTION 7
#define KEY_TRANSDLL 8
#define NUMOFKEYS 9 /* Number of keys supported */
#define FOURYEARS 126230400 // Four years in seconds (1 leap)
/***********************************************************************/
/* This is used when an "out of memory" error happens, because this */
/* error recording system allocates memory when it logs an error, */
/* and it would be bad if it tried to allocate memory when it got an */
/* out of memory error. */
/***********************************************************************/
typedef enum _ERRSTAT {
errstatOK,
errstatNO_MEMORY,
} ERRSTAT;
/***********************************************************************/
/* Types */
/***********************************************************************/
typedef struct TagAttr {
bool fSupplied;
char Attr[MAXPATHLEN];
} TAG, *PTAG;
typedef struct _parscons { /* Parse constants */
int Slen; /* String length */
int Ntag; /* Number of entries in tags */
int Nlook; /* Number of entries in lookup */
char Sep; /* Separator */
} PARC, *PPARC;
/***********************************************************************/
/* Attribute string look-up table (maps keys to associated indexes) */
/***********************************************************************/
typedef struct _Look {
const char *szKey;
int iKey;
} LOOK, *PLOOK;
/***********************************************************************/
/* This is info about a single error. */
/***********************************************************************/
typedef struct _ERRBLK *PERRBLK;
typedef struct _ERRBLK {
PERRBLK Next; /* Next block in linked list of error blocks */
DWORD Native_Error; /* Native error */
DWORD Stderr; /* SQLC error code */
PSZ Message; /* Points to text of message */
} ERRBLK;
/***********************************************************************/
/* This is a header block, it records information about a list of */
/* errors (ERRBLOCK's). */
/***********************************************************************/
typedef struct _ERRINFO {
PERRBLK First; /* First block in linked list of error blocks. */
PERRBLK Last; /* Last block in above list. */
ERRSTAT Errstat; /* Status for special condition out of memory */
} ERRINFO, *PERRINFO;
/***********************************************************************/
/* Environment information. */
/***********************************************************************/
typedef struct _env {
ERRINFO Errinfo; /* Error list */
UDWORD ODBCver;
UDWORD ODBCdateformat;
} ENV, *PENV;
/***********************************************************************/
/* Classes used in the PlugDB ODBC Driver. */
/***********************************************************************/
typedef class DBC *PDBC;
typedef class STMT *PSTMT;
typedef class CURSOR *PCURSOR;
typedef class RESULT *PRESULT;
typedef class BINDDATA *PBIND;
typedef class BINDPARM *PBDPARM;
typedef class CPLGdrv *PSCDRV;
typedef class DESCRIPTOR *PDSC;
/***********************************************************************/
/* ODBC Prototypes. */
/***********************************************************************/
void PostSQLError(HENV, HDBC, HSTMT, DWORD, DWORD, PSZ);
void ClearSQLError(HENV, HDBC, HSTMT);
short LoadRcString(UWORD, LPSTR, short);
RETCODE RetcodeCopyBytes(HDBC, HSTMT, UCHAR FAR *, SWORD,
SWORD FAR *, UCHAR FAR *, SWORD, bool);
/***********************************************************************/
/* Private functions used by the driver. */
/***********************************************************************/
bool EXPFUNC FDriverConnectProc(HWND, WORD, WPARAM, LPARAM);
extern void ParseAttrString(PLOOK, PTAG, UCHAR FAR *, PPARC);
RETCODE PASCAL StringCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *,
char FAR *);
RETCODE PASCAL ShortCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *, short);
RETCODE PASCAL LongCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *, int);
RETCODE PASCAL GeneralCopy(HDBC, HSTMT, PTR, SWORD,
SWORD FAR *, PTR, SWORD);
/* --------------------- End of PLGODBC.H ---------------------------- */

View File

@@ -1,140 +1,140 @@
/******************************************************************/
/* Implementation of XML document processing using PdbXML. */
/* Author: Olivier Bertrand 2007-2012 */
/******************************************************************/
#include "my_global.h"
#include "global.h"
#include "plgdbsem.h"
#include "block.h"
#include "plgxml.h"
#if !defined(DOMDOC_SUPPORT)
PXDOC GetDomDoc(PGLOBAL g, char *nsl, char *nsdf,
char *enc, PFBLOCK fp)
{
strcpy(g->Message, MSG(DOM_NOT_SUPP));
return NULL;
} // end of GetDomDoc
#endif // !DOMDOC_SUPPORT
#ifndef LIBXML2_SUPPORT
PXDOC GetLibxmlDoc(PGLOBAL g, char *nsl, char *nsdf,
char *enc, PFBLOCK fp)
{
strcpy(g->Message, "libxml2 not supported");
return NULL;
} // end of GetLibxmlDoc
#endif // LIBXML2_SUPPORT
/******************************************************************/
/* XMLDOCUMENT constructor. */
/******************************************************************/
XMLDOCUMENT::XMLDOCUMENT(char *nsl, char *nsdf, char *enc)
{
Namespaces = NULL;
Encoding = enc;
Nslist = nsl;
DefNs = nsdf;
} // end of XMLDOCUMENT constructor
/******************************************************************/
/* Make the namespace structure list. */
/******************************************************************/
bool XMLDOCUMENT::MakeNSlist(PGLOBAL g)
{
char *prefix, *href, *next = Nslist;
PNS nsp, *ppns = &Namespaces;
while (next) {
// Skip spaces
while ((*next) == ' ')
next++;
if ((*next) == '\0')
break;
// Find prefix
prefix = next;
next = strchr(next, '=');
if (next == NULL) {
strcpy(g->Message, MSG(BAS_NS_LIST));
return true;
} // endif next
*(next++) = '\0';
// Find href
href = next;
next = strchr(next, ' ');
if (next != NULL)
*(next++) = '\0';
// Allocate and link NS structure
nsp = (PNS)PlugSubAlloc(g, NULL, sizeof(NS));
nsp->Next = NULL;
nsp->Prefix = prefix;
nsp->Uri = href;
*ppns = nsp;
ppns = &nsp->Next;
} // endwhile next
return false;
} // end of MakeNSlist
/******************************************************************/
/* XMLNODE constructor. */
/******************************************************************/
XMLNODE::XMLNODE(PXDOC dp)
{
Doc = dp;
Next = NULL;
Children = NULL;
Buf = NULL;
Len = -1;
} // end of XMLNODE constructor
/******************************************************************/
/* Attach new node at the end of this node children list. */
/******************************************************************/
PXNODE XMLNODE::NewChild(PXNODE ncp)
{
PXNODE np, *pnp = &Children;
for (np = *pnp; np; np = np->Next)
pnp = &np->Next;
*pnp = np;
return ncp;
} // end of NewChild
/******************************************************************/
/* Delete a node from this node children list. */
/******************************************************************/
void XMLNODE::Delete(PXNODE dnp)
{
PXNODE *pnp = &Children;
for (PXNODE np = *pnp; np; np = np->Next)
if (np == dnp) {
*pnp = dnp->Next;
break;
} else
pnp = &np->Next;
} // end of Delete
/******************************************************************/
/* Store a string in Buf, enventually reallocating it. */
/******************************************************************/
char *XMLNODE::BufAlloc(PGLOBAL g, char *p, int n)
{
if (Len < n) {
Len = n;
Buf = (char*)PlugSubAlloc(g, NULL, n + 1);
} // endif Len
*Buf = '\0';
return strncat(Buf, p, n);
} // end of BufAlloc
/******************************************************************/
/* Implementation of XML document processing using PdbXML. */
/* Author: Olivier Bertrand 2007-2012 */
/******************************************************************/
#include "my_global.h"
#include "global.h"
#include "plgdbsem.h"
#include "block.h"
#include "plgxml.h"
#if !defined(DOMDOC_SUPPORT)
PXDOC GetDomDoc(PGLOBAL g, char *nsl, char *nsdf,
char *enc, PFBLOCK fp)
{
strcpy(g->Message, MSG(DOM_NOT_SUPP));
return NULL;
} // end of GetDomDoc
#endif // !DOMDOC_SUPPORT
#ifndef LIBXML2_SUPPORT
PXDOC GetLibxmlDoc(PGLOBAL g, char *nsl, char *nsdf,
char *enc, PFBLOCK fp)
{
strcpy(g->Message, "libxml2 not supported");
return NULL;
} // end of GetLibxmlDoc
#endif // LIBXML2_SUPPORT
/******************************************************************/
/* XMLDOCUMENT constructor. */
/******************************************************************/
XMLDOCUMENT::XMLDOCUMENT(char *nsl, char *nsdf, char *enc)
{
Namespaces = NULL;
Encoding = enc;
Nslist = nsl;
DefNs = nsdf;
} // end of XMLDOCUMENT constructor
/******************************************************************/
/* Make the namespace structure list. */
/******************************************************************/
bool XMLDOCUMENT::MakeNSlist(PGLOBAL g)
{
char *prefix, *href, *next = Nslist;
PNS nsp, *ppns = &Namespaces;
while (next) {
// Skip spaces
while ((*next) == ' ')
next++;
if ((*next) == '\0')
break;
// Find prefix
prefix = next;
next = strchr(next, '=');
if (next == NULL) {
strcpy(g->Message, MSG(BAS_NS_LIST));
return true;
} // endif next
*(next++) = '\0';
// Find href
href = next;
next = strchr(next, ' ');
if (next != NULL)
*(next++) = '\0';
// Allocate and link NS structure
nsp = (PNS)PlugSubAlloc(g, NULL, sizeof(NS));
nsp->Next = NULL;
nsp->Prefix = prefix;
nsp->Uri = href;
*ppns = nsp;
ppns = &nsp->Next;
} // endwhile next
return false;
} // end of MakeNSlist
/******************************************************************/
/* XMLNODE constructor. */
/******************************************************************/
XMLNODE::XMLNODE(PXDOC dp)
{
Doc = dp;
Next = NULL;
Children = NULL;
Buf = NULL;
Len = -1;
} // end of XMLNODE constructor
/******************************************************************/
/* Attach new node at the end of this node children list. */
/******************************************************************/
PXNODE XMLNODE::NewChild(PXNODE ncp)
{
PXNODE np, *pnp = &Children;
for (np = *pnp; np; np = np->Next)
pnp = &np->Next;
*pnp = np;
return ncp;
} // end of NewChild
/******************************************************************/
/* Delete a node from this node children list. */
/******************************************************************/
void XMLNODE::Delete(PXNODE dnp)
{
PXNODE *pnp = &Children;
for (PXNODE np = *pnp; np; np = np->Next)
if (np == dnp) {
*pnp = dnp->Next;
break;
} else
pnp = &np->Next;
} // end of Delete
/******************************************************************/
/* Store a string in Buf, enventually reallocating it. */
/******************************************************************/
char *XMLNODE::BufAlloc(PGLOBAL g, char *p, int n)
{
if (Len < n) {
Len = n;
Buf = (char*)PlugSubAlloc(g, NULL, n + 1);
} // endif Len
*Buf = '\0';
return strncat(Buf, p, n);
} // end of BufAlloc

View File

@@ -1,177 +1,177 @@
/******************************************************************/
/* Dual XML implementation base classes defines. */
/******************************************************************/
#if !defined(BASE_BUFFER_SIZE)
enum ElementType { // libxml2
XML_ELEMENT_NODE = 1,
XML_ATTRIBUTE_NODE = 2,
XML_TEXT_NODE = 3,
XML_CDATA_SECTION_NODE = 4,
XML_ENTITY_REF_NODE = 5,
XML_ENTITY_NODE = 6,
XML_PI_NODE = 7,
XML_COMMENT_NODE = 8,
XML_DOCUMENT_NODE = 9,
XML_DOCUMENT_TYPE_NODE = 10,
XML_DOCUMENT_FRAG_NODE = 11,
XML_NOTATION_NODE = 12,
XML_HTML_DOCUMENT_NODE = 13,
XML_DTD_NODE = 14,
XML_ELEMENT_DECL = 15,
XML_ATTRIBUTE_DECL = 16,
XML_ENTITY_DECL = 17,
XML_NAMESPACE_DECL = 18,
XML_XINCLUDE_START = 19,
XML_XINCLUDE_END = 20,
XML_DOCB_DOCUMENT_NODE = 21};
#endif // !BASE_BUFFER_SIZE
//#if !defined(NODE_TYPE_LIST)
#ifdef NOT_USED
enum NodeType { // MS DOM
NODE_ELEMENT = 1,
NODE_ATTRIBUTE = 2,
NODE_TEXT = 3,
NODE_CDATA_SECTION = 4,
NODE_ENTITY_REFERENCE = 5,
NODE_ENTITY = 6,
NODE_PROCESSING_INSTRUCTION = 7,
NODE_COMMENT = 8,
NODE_DOCUMENT = 9,
NODE_DOCUMENT_TYPE = 10,
NODE_DOCUMENT_FRAGMENT = 11,
NODE_NOTATION = 12};
#endif // !NODE_TYPE_LIST
typedef class XMLDOCUMENT *PXDOC; // Document
typedef class XMLNODE *PXNODE; // Node (Element)
typedef class XMLNODELIST *PXLIST; // Node list
typedef class XMLATTRIBUTE *PXATTR; // Attribute
typedef struct _ns {
struct _ns *Next;
char *Prefix;
char *Uri;
} NS, *PNS;
PXDOC GetLibxmlDoc(PGLOBAL g, char *nsl, char *nsdf,
char *enc, PFBLOCK fp = NULL);
PXDOC GetDomDoc(PGLOBAL g, char *nsl, char *nsdf,
char *enc, PFBLOCK fp = NULL);
/******************************************************************/
/* Declaration of XML document. */
/******************************************************************/
class XMLDOCUMENT : public BLOCK {
friend class XML2NODE;
friend class DOMNODE;
public:
// Properties
virtual short GetDocType(void) = 0;
virtual void *GetDocPtr(void) = 0;
// Methods
virtual bool Initialize(PGLOBAL) = 0;
virtual bool ParseFile(char *) = 0;
virtual bool NewDoc(PGLOBAL, char *) = 0;
virtual void AddComment(PGLOBAL, char *) = 0;
virtual PXNODE GetRoot(PGLOBAL) = 0;
virtual PXNODE NewRoot(PGLOBAL, char *) = 0;
virtual PXNODE NewPnode(PGLOBAL, char * = NULL) = 0;
virtual PXATTR NewPattr(PGLOBAL) = 0;
virtual PXLIST NewPlist(PGLOBAL) = 0;
virtual int DumpDoc(PGLOBAL, char *) = 0;
virtual void CloseDoc(PGLOBAL, PFBLOCK) = 0;
virtual PFBLOCK LinkXblock(PGLOBAL, MODE, int, char *) = 0;
protected:
// Constructor
XMLDOCUMENT(char *nsl, char *nsdf, char *enc);
// Utility
bool MakeNSlist(PGLOBAL g);
// Members
PNS Namespaces; /* To the namespaces */
char *Encoding; /* The document encoding */
char *Nslist; /* Namespace list */
char *DefNs; /* Default namespace */
}; // end of class XMLDOCUMENT
/******************************************************************/
/* Declaration of XML node. */
/******************************************************************/
class XMLNODE : public BLOCK {
public:
// Properties
virtual char *GetName(PGLOBAL) = 0;
virtual int GetType(void) = 0;
virtual PXNODE GetNext(PGLOBAL) = 0;
virtual PXNODE GetChild(PGLOBAL) = 0;
// Methods
virtual char *GetText(char *, int) = 0;
virtual bool SetContent(PGLOBAL, char *, int) = 0;
virtual PXNODE Clone(PGLOBAL, PXNODE) = 0;
virtual PXLIST GetChildElements(PGLOBAL, char * = NULL, PXLIST = NULL) = 0;
virtual PXLIST SelectNodes(PGLOBAL, char *, PXLIST = NULL) = 0;
virtual PXNODE SelectSingleNode(PGLOBAL, char *, PXNODE = NULL) = 0;
virtual PXATTR GetAttribute(PGLOBAL, char *, PXATTR = NULL) = 0;
virtual PXNODE AddChildNode(PGLOBAL, char *, PXNODE = NULL) = 0;
virtual PXATTR AddProperty(PGLOBAL, char *, PXATTR = NULL) = 0;
virtual void AddText(PGLOBAL, char *) = 0;
virtual void DeleteChild(PGLOBAL, PXNODE) = 0;
protected:
PXNODE NewChild(PXNODE ncp);
void Delete(PXNODE dnp);
char *BufAlloc(PGLOBAL g, char *p, int n);
// Constructor
XMLNODE(PXDOC dp);
// Members
PXDOC Doc;
PXNODE Next;
PXNODE Children;
char *Buf;
int Len;
}; // end of class XMLNODE
/******************************************************************/
/* Declaration of XML node list. */
/******************************************************************/
class XMLNODELIST : public BLOCK {
public:
// Properties
virtual int GetLength(void) = 0;
virtual PXNODE GetItem(PGLOBAL, int, PXNODE = NULL) = 0;
protected:
// Constructor
XMLNODELIST(PXDOC dp) {Doc = dp;}
// Members
PXDOC Doc;
}; // end of class XMLNODELIST
/******************************************************************/
/* Declaration of XML attribute. */
/******************************************************************/
class XMLATTRIBUTE : public BLOCK {
public:
// Properties
//virtual char *GetText(void) = 0;
// Methods
virtual bool SetText(PGLOBAL, char *, int) = 0;
protected:
// Constructor
XMLATTRIBUTE(PXDOC dp) {Doc = dp;}
// Members
PXDOC Doc;
}; // end of class XMLATTRIBUTE
/******************************************************************/
/* Dual XML implementation base classes defines. */
/******************************************************************/
#if !defined(BASE_BUFFER_SIZE)
enum ElementType { // libxml2
XML_ELEMENT_NODE = 1,
XML_ATTRIBUTE_NODE = 2,
XML_TEXT_NODE = 3,
XML_CDATA_SECTION_NODE = 4,
XML_ENTITY_REF_NODE = 5,
XML_ENTITY_NODE = 6,
XML_PI_NODE = 7,
XML_COMMENT_NODE = 8,
XML_DOCUMENT_NODE = 9,
XML_DOCUMENT_TYPE_NODE = 10,
XML_DOCUMENT_FRAG_NODE = 11,
XML_NOTATION_NODE = 12,
XML_HTML_DOCUMENT_NODE = 13,
XML_DTD_NODE = 14,
XML_ELEMENT_DECL = 15,
XML_ATTRIBUTE_DECL = 16,
XML_ENTITY_DECL = 17,
XML_NAMESPACE_DECL = 18,
XML_XINCLUDE_START = 19,
XML_XINCLUDE_END = 20,
XML_DOCB_DOCUMENT_NODE = 21};
#endif // !BASE_BUFFER_SIZE
//#if !defined(NODE_TYPE_LIST)
#ifdef NOT_USED
enum NodeType { // MS DOM
NODE_ELEMENT = 1,
NODE_ATTRIBUTE = 2,
NODE_TEXT = 3,
NODE_CDATA_SECTION = 4,
NODE_ENTITY_REFERENCE = 5,
NODE_ENTITY = 6,
NODE_PROCESSING_INSTRUCTION = 7,
NODE_COMMENT = 8,
NODE_DOCUMENT = 9,
NODE_DOCUMENT_TYPE = 10,
NODE_DOCUMENT_FRAGMENT = 11,
NODE_NOTATION = 12};
#endif // !NODE_TYPE_LIST
typedef class XMLDOCUMENT *PXDOC; // Document
typedef class XMLNODE *PXNODE; // Node (Element)
typedef class XMLNODELIST *PXLIST; // Node list
typedef class XMLATTRIBUTE *PXATTR; // Attribute
typedef struct _ns {
struct _ns *Next;
char *Prefix;
char *Uri;
} NS, *PNS;
PXDOC GetLibxmlDoc(PGLOBAL g, char *nsl, char *nsdf,
char *enc, PFBLOCK fp = NULL);
PXDOC GetDomDoc(PGLOBAL g, char *nsl, char *nsdf,
char *enc, PFBLOCK fp = NULL);
/******************************************************************/
/* Declaration of XML document. */
/******************************************************************/
class XMLDOCUMENT : public BLOCK {
friend class XML2NODE;
friend class DOMNODE;
public:
// Properties
virtual short GetDocType(void) = 0;
virtual void *GetDocPtr(void) = 0;
// Methods
virtual bool Initialize(PGLOBAL) = 0;
virtual bool ParseFile(char *) = 0;
virtual bool NewDoc(PGLOBAL, char *) = 0;
virtual void AddComment(PGLOBAL, char *) = 0;
virtual PXNODE GetRoot(PGLOBAL) = 0;
virtual PXNODE NewRoot(PGLOBAL, char *) = 0;
virtual PXNODE NewPnode(PGLOBAL, char * = NULL) = 0;
virtual PXATTR NewPattr(PGLOBAL) = 0;
virtual PXLIST NewPlist(PGLOBAL) = 0;
virtual int DumpDoc(PGLOBAL, char *) = 0;
virtual void CloseDoc(PGLOBAL, PFBLOCK) = 0;
virtual PFBLOCK LinkXblock(PGLOBAL, MODE, int, char *) = 0;
protected:
// Constructor
XMLDOCUMENT(char *nsl, char *nsdf, char *enc);
// Utility
bool MakeNSlist(PGLOBAL g);
// Members
PNS Namespaces; /* To the namespaces */
char *Encoding; /* The document encoding */
char *Nslist; /* Namespace list */
char *DefNs; /* Default namespace */
}; // end of class XMLDOCUMENT
/******************************************************************/
/* Declaration of XML node. */
/******************************************************************/
class XMLNODE : public BLOCK {
public:
// Properties
virtual char *GetName(PGLOBAL) = 0;
virtual int GetType(void) = 0;
virtual PXNODE GetNext(PGLOBAL) = 0;
virtual PXNODE GetChild(PGLOBAL) = 0;
// Methods
virtual char *GetText(char *, int) = 0;
virtual bool SetContent(PGLOBAL, char *, int) = 0;
virtual PXNODE Clone(PGLOBAL, PXNODE) = 0;
virtual PXLIST GetChildElements(PGLOBAL, char * = NULL, PXLIST = NULL) = 0;
virtual PXLIST SelectNodes(PGLOBAL, char *, PXLIST = NULL) = 0;
virtual PXNODE SelectSingleNode(PGLOBAL, char *, PXNODE = NULL) = 0;
virtual PXATTR GetAttribute(PGLOBAL, char *, PXATTR = NULL) = 0;
virtual PXNODE AddChildNode(PGLOBAL, char *, PXNODE = NULL) = 0;
virtual PXATTR AddProperty(PGLOBAL, char *, PXATTR = NULL) = 0;
virtual void AddText(PGLOBAL, char *) = 0;
virtual void DeleteChild(PGLOBAL, PXNODE) = 0;
protected:
PXNODE NewChild(PXNODE ncp);
void Delete(PXNODE dnp);
char *BufAlloc(PGLOBAL g, char *p, int n);
// Constructor
XMLNODE(PXDOC dp);
// Members
PXDOC Doc;
PXNODE Next;
PXNODE Children;
char *Buf;
int Len;
}; // end of class XMLNODE
/******************************************************************/
/* Declaration of XML node list. */
/******************************************************************/
class XMLNODELIST : public BLOCK {
public:
// Properties
virtual int GetLength(void) = 0;
virtual PXNODE GetItem(PGLOBAL, int, PXNODE = NULL) = 0;
protected:
// Constructor
XMLNODELIST(PXDOC dp) {Doc = dp;}
// Members
PXDOC Doc;
}; // end of class XMLNODELIST
/******************************************************************/
/* Declaration of XML attribute. */
/******************************************************************/
class XMLATTRIBUTE : public BLOCK {
public:
// Properties
//virtual char *GetText(void) = 0;
// Methods
virtual bool SetText(PGLOBAL, char *, int) = 0;
protected:
// Constructor
XMLATTRIBUTE(PXDOC dp) {Doc = dp;}
// Members
PXDOC Doc;
}; // end of class XMLATTRIBUTE

File diff suppressed because it is too large Load Diff

View File

@@ -1,61 +1,61 @@
#if !defined(PREPARSE_DEFINED)
#define PREPARSE_DEFINED
#include "checklvl.h"
/***********************************************************************/
/* Struct of variables used by the SQL pre-parsers. */
/***********************************************************************/
typedef struct _prepar {
struct _prepar *Next;
char *Debinp; // Start of input buffer
char *Endinp; // End of input buffer
char *Pluginp; // Points on current parsing position
char *Plugbuf; // Start of output buffer
char *Plugptr; // Current output position
char *Debchar; // Next/current start of command
char *Debselp; // Beginning of selection
char *Debline; // Start of current line
char *Plugpar[32]; // Parameters
int Numparms; // Number of defined parameters
int Nprms; // Number of ODBC parameters
int Lines; // Line number
int Chars; // Index of selection start in line
int Endchars; // Index of selection end in line
int Frinp, Frbuf; // 0: no, 1: free, 2: delete Debinp/Plugbuf
int Outsize; // Size of output buffer
FILE *Argfile; // File containing arguments
int Addargs; // 1 if arguments are added to the list
} PREPAR, *PPREP;
/***********************************************************************/
/* Struct of variables used by the date format pre-parser. */
/***********************************************************************/
typedef struct _datpar {
char *Format; // Points to format to decode
char *Curp; // Points to current parsing position
char *InFmt; // Start of input format
char *OutFmt; // Start of output format
int Index[8]; // Indexes of date values
int Num; // Number of values to retrieve
int Flag; // 1: Input, 2: Output, 4: no output blank
int Outsize; // Size of output buffers
} DATPAR, *PDTP;
/***********************************************************************/
/* Preparsers used by SQL language. */
/***********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
int sqlflex(PPREP pp);
int sqpflex(PPREP pp);
int fmdflex(PDTP pp);
#ifdef __cplusplus
}
#endif
#endif // PREPARSE_DEFINED
#if !defined(PREPARSE_DEFINED)
#define PREPARSE_DEFINED
#include "checklvl.h"
/***********************************************************************/
/* Struct of variables used by the SQL pre-parsers. */
/***********************************************************************/
typedef struct _prepar {
struct _prepar *Next;
char *Debinp; // Start of input buffer
char *Endinp; // End of input buffer
char *Pluginp; // Points on current parsing position
char *Plugbuf; // Start of output buffer
char *Plugptr; // Current output position
char *Debchar; // Next/current start of command
char *Debselp; // Beginning of selection
char *Debline; // Start of current line
char *Plugpar[32]; // Parameters
int Numparms; // Number of defined parameters
int Nprms; // Number of ODBC parameters
int Lines; // Line number
int Chars; // Index of selection start in line
int Endchars; // Index of selection end in line
int Frinp, Frbuf; // 0: no, 1: free, 2: delete Debinp/Plugbuf
int Outsize; // Size of output buffer
FILE *Argfile; // File containing arguments
int Addargs; // 1 if arguments are added to the list
} PREPAR, *PPREP;
/***********************************************************************/
/* Struct of variables used by the date format pre-parser. */
/***********************************************************************/
typedef struct _datpar {
char *Format; // Points to format to decode
char *Curp; // Points to current parsing position
char *InFmt; // Start of input format
char *OutFmt; // Start of output format
int Index[8]; // Indexes of date values
int Num; // Number of values to retrieve
int Flag; // 1: Input, 2: Output, 4: no output blank
int Outsize; // Size of output buffers
} DATPAR, *PDTP;
/***********************************************************************/
/* Preparsers used by SQL language. */
/***********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
int sqlflex(PPREP pp);
int sqpflex(PPREP pp);
int fmdflex(PDTP pp);
#ifdef __cplusplus
}
#endif
#endif // PREPARSE_DEFINED

View File

@@ -1,220 +1,220 @@
/**************** RCMsg C Program Source Code File (.C) ****************/
/* PROGRAM NAME: RCMSG */
/* ------------- */
/* Version 1.0 */
/* */
/* COPYRIGHT */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND: 2005 */
/* */
/* WHAT THIS PROGRAM DOES */
/* ----------------------- */
/* This program simulates LoadString for Unix and Linux. */
/* */
/***********************************************************************/
#include <stdio.h>
#include "resource.h"
char *GetMsgid(int id)
{
char *p = NULL;
switch (id) {
case IDS_00: p = "%s"; break;
#if defined(FRENCH)
case IDS_01: p = "%s: erreur d'allocation du buffer de communication de %d octets"; break;
case IDS_02: p = "%s: erreur d'allocation m<>moire tampon pour %d colonnes"; break;
case IDS_03: p = "%s: Commande sp<73>ciale invalide"; break;
case IDS_04: p = "%s: Wrong number of arguments %d"; break;
case IDS_05: p = "%s"; break;
case IDS_06: p = "%s: Commande d<>passant la taille du buffer interne (%d octets)"; break;
case IDS_07: p = "%s: Donn<6E>es (%d octets) tronqu<71>es <20> la taille du buffer"; break;
case IDS_08: p = "%s: R<>sultat d<>passant la taille du buffer interne (%d octets)"; break;
case IDS_09: p = "Erreur dans %s: %s"; break;
case IDS_10: p = "%s: erreur d'allocating m<>moire de %d octets"; break;
case IDS_11: p = "%s: mauvaise cl<63> de connexion %d"; break;
case IDS_12: p = "%s: Pas plus de %d connexions autoris<69>es pour un programme"; break;
case IDS_13: p = "%s: cl<63> de connexion invalide %d"; break;
case IDS_14: p = "SafeDB: %s rc=%d"; break;
case IDS_15: p = "Mauvaise Dll de communication appel<65>e par le moteur %s"; break;
case IDS_TAB_01: p = "Qualificateur"; break;
case IDS_TAB_02: p = "Propri<EFBFBD>taire"; break;
case IDS_TAB_03: p = "Nom"; break;
case IDS_TAB_04: p = "Type"; break;
case IDS_TAB_05: p = "Remarque"; break;
case IDS_COL_01: p = "Qualif_Table"; break;
case IDS_COL_02: p = "Prop_Tabl"; break;
case IDS_COL_03: p = "Nom_Table"; break;
case IDS_COL_04: p = "Nom_Colonne"; break;
case IDS_COL_05: p = "Type_Donn<EFBFBD>es"; break;
case IDS_COL_06: p = "Nom_Type"; break;
case IDS_COL_07: p = "Pr<EFBFBD>cision"; break;
case IDS_COL_08: p = "Longueur"; break;
case IDS_COL_09: p = "Echelle"; break;
case IDS_COL_10: p = "Base"; break;
case IDS_COL_11: p = "Nullifiable"; break;
case IDS_COL_12: p = "Remarques"; break;
case IDS_INF_01: p = "Nom_Type"; break;
case IDS_INF_02: p = "Type_Donn<EFBFBD>es"; break;
case IDS_INF_03: p = "Pr<EFBFBD>cision"; break;
case IDS_INF_04: p = "Pr<EFBFBD>fixe_Lit<EFBFBD>ral"; break;
case IDS_INF_05: p = "Suffixe_Lit<EFBFBD>ral"; break;
case IDS_INF_06: p = "Cr<EFBFBD>ation_Params"; break;
case IDS_INF_07: p = "Nullifiable"; break;
case IDS_INF_08: p = "Maj_Minuscule"; break;
case IDS_INF_09: p = "Localisable"; break;
case IDS_INF_10: p = "Valeur_Absolue"; break;
case IDS_INF_11: p = "Monnaie"; break;
case IDS_INF_12: p = "Auto_Incr<EFBFBD>ment"; break;
case IDS_INF_13: p = "Nom_Type_Local"; break;
case IDS_INF_14: p = "Echelle_Minimum"; break;
case IDS_INF_15: p = "Echelle_Maximum"; break;
case IDS_PKY_01: p = "Qualif_Table"; break;
case IDS_PKY_02: p = "Prop_Table"; break;
case IDS_PKY_03: p = "Nom_Table"; break;
case IDS_PKY_04: p = "Nom_Colonne"; break;
case IDS_PKY_05: p = "Num<EFBFBD>ro_Cl<EFBFBD>"; break;
case IDS_PKY_06: p = "Nom_Cl<EFBFBD>"; break;
case IDS_FKY_01: p = "PKTable_Qualifier"; break;
case IDS_FKY_02: p = "PKTable_Owner"; break;
case IDS_FKY_03: p = "PKTable_Name"; break;
case IDS_FKY_04: p = "PKColumn_Name"; break;
case IDS_FKY_05: p = "FKTable_Qualifier"; break;
case IDS_FKY_06: p = "FKTable_Owner"; break;
case IDS_FKY_07: p = "FKTable_Name"; break;
case IDS_FKY_08: p = "FKColumn_Name"; break;
case IDS_FKY_09: p = "Key_Seq"; break;
case IDS_FKY_10: p = "Update_Rule"; break;
case IDS_FKY_11: p = "Delete_Rule"; break;
case IDS_FKY_12: p = "FK_Name"; break;
case IDS_FKY_13: p = "PK_Name"; break;
case IDS_STA_01: p = "Table_Qualifier"; break;
case IDS_STA_02: p = "Table_Owner"; break;
case IDS_STA_03: p = "Table_Name"; break;
case IDS_STA_04: p = "Non_Unique"; break;
case IDS_STA_05: p = "Index_Qualifier"; break;
case IDS_STA_06: p = "Index_Name"; break;
case IDS_STA_07: p = "Type"; break;
case IDS_STA_08: p = "Seq_in_Index"; break;
case IDS_STA_09: p = "Column_Name"; break;
case IDS_STA_10: p = "Collation"; break;
case IDS_STA_11: p = "Cardinality"; break;
case IDS_STA_12: p = "Pages"; break;
case IDS_STA_13: p = "Filter_Condition"; break;
case IDS_SPC_01: p = "Champ"; break;
case IDS_SPC_02: p = "Nom_Colonne"; break;
case IDS_SPC_03: p = "Type_Donn<EFBFBD>es"; break;
case IDS_SPC_04: p = "Nom_Type"; break;
case IDS_SPC_05: p = "Pr<EFBFBD>cision"; break;
case IDS_SPC_06: p = "Longueur"; break;
case IDS_SPC_07: p = "Echelle"; break;
case IDS_SPC_08: p = "Pseudo_Colonne"; break;
case IDS_DSC_01: p = "Nom"; break;
case IDS_DSC_02: p = "Description"; break;
#else // English
case IDS_01: p = "%s: error allocating communication buffer of %d bytes"; break;
case IDS_02: p = "%s: error allocating parser memory for %d columns"; break;
case IDS_03: p = "%s: Invalid special command"; break;
case IDS_04: p = "%s: Wrong number of arguments %d"; break;
case IDS_05: p = "%s"; break;
case IDS_06: p = "%s: Command bigger than internal buffer of size = %d"; break;
case IDS_07: p = "%s: Data truncated to buffer size, actual length is %d bytes"; break;
case IDS_08: p = "%s: Result bigger than internal buffer of size = %d"; break;
case IDS_09: p = "Error in %s: %s"; break;
case IDS_10: p = "%s: error allocating instance memory of %d bytes"; break;
case IDS_11: p = "%s: wrong connection key value %d"; break;
case IDS_12: p = "%s: No more than %d connections allowed from one process"; break;
case IDS_13: p = "%s: invalid connection key value %d"; break;
case IDS_14: p = "SafeDB: %s rc=%d"; break;
case IDS_15: p = "Wrong communication Dll called for engine %s"; break;
case IDS_TAB_01: p = "Qualifier"; break;
case IDS_TAB_02: p = "Owner"; break;
case IDS_TAB_03: p = "Name"; break;
case IDS_TAB_04: p = "Type"; break;
case IDS_TAB_05: p = "Remark"; break;
case IDS_COL_01: p = "Table_Qualif"; break;
case IDS_COL_02: p = "Table_Owner"; break;
case IDS_COL_03: p = "Table_Name"; break;
case IDS_COL_04: p = "Column_Name"; break;
case IDS_COL_05: p = "Data_Type"; break;
case IDS_COL_06: p = "Type_Name"; break;
case IDS_COL_07: p = "Precision"; break;
case IDS_COL_08: p = "Length"; break;
case IDS_COL_09: p = "Scale"; break;
case IDS_COL_10: p = "Radix"; break;
case IDS_COL_11: p = "Nullable"; break;
case IDS_COL_12: p = "Remarks"; break;
case IDS_INF_01: p = "Type_Name"; break;
case IDS_INF_02: p = "Data_Type"; break;
case IDS_INF_03: p = "Precision"; break;
case IDS_INF_04: p = "Literal_Prefix"; break;
case IDS_INF_05: p = "Literal_Suffix"; break;
case IDS_INF_06: p = "Create_Params"; break;
case IDS_INF_07: p = "Nullable"; break;
case IDS_INF_08: p = "Case_Sensitive"; break;
case IDS_INF_09: p = "Searchable"; break;
case IDS_INF_10: p = "Unsigned_Attribute"; break;
case IDS_INF_11: p = "Money"; break;
case IDS_INF_12: p = "Auto_Increment"; break;
case IDS_INF_13: p = "Local_Type_Name"; break;
case IDS_INF_14: p = "Minimum_Scale"; break;
case IDS_INF_15: p = "Maximum_Scale"; break;
case IDS_PKY_01: p = "Table_Qualifier"; break;
case IDS_PKY_02: p = "Table_Owner"; break;
case IDS_PKY_03: p = "Table_Name"; break;
case IDS_PKY_04: p = "Column_Name"; break;
case IDS_PKY_05: p = "Key_Seq"; break;
case IDS_PKY_06: p = "Pk_Name"; break;
case IDS_FKY_01: p = "PKTable_Qualifier"; break;
case IDS_FKY_02: p = "PKTable_Owner"; break;
case IDS_FKY_03: p = "PKTable_Name"; break;
case IDS_FKY_04: p = "PKColumn_Name"; break;
case IDS_FKY_05: p = "FKTable_Qualifier"; break;
case IDS_FKY_06: p = "FKTable_Owner"; break;
case IDS_FKY_07: p = "FKTable_Name"; break;
case IDS_FKY_08: p = "FKColumn_Name"; break;
case IDS_FKY_09: p = "Key_Seq"; break;
case IDS_FKY_10: p = "Update_Rule"; break;
case IDS_FKY_11: p = "Delete_Rule"; break;
case IDS_FKY_12: p = "FK_Name"; break;
case IDS_FKY_13: p = "PK_Name"; break;
case IDS_STA_01: p = "Table_Qualifier"; break;
case IDS_STA_02: p = "Table_Owner"; break;
case IDS_STA_03: p = "Table_Name"; break;
case IDS_STA_04: p = "Non_Unique"; break;
case IDS_STA_05: p = "Index_Qualifier"; break;
case IDS_STA_06: p = "Index_Name"; break;
case IDS_STA_07: p = "Type"; break;
case IDS_STA_08: p = "Seq_in_Index"; break;
case IDS_STA_09: p = "Column_Name"; break;
case IDS_STA_10: p = "Collation"; break;
case IDS_STA_11: p = "Cardinality"; break;
case IDS_STA_12: p = "Pages"; break;
case IDS_STA_13: p = "Filter_Condition"; break;
case IDS_SPC_01: p = "Scope"; break;
case IDS_SPC_02: p = "Column_Name"; break;
case IDS_SPC_03: p = "Data_Type"; break;
case IDS_SPC_04: p = "Type_Name"; break;
case IDS_SPC_05: p = "Precision"; break;
case IDS_SPC_06: p = "Length"; break;
case IDS_SPC_07: p = "Scale"; break;
case IDS_SPC_08: p = "Pseudo_Column"; break;
case IDS_DSC_01: p = "Name"; break;
case IDS_DSC_02: p = "Description"; break;
#endif // English
} // endswitch(id)
return p;
} // end of GetMsgid
int GetRcString(int id, char *buf, int bufsize)
{
char *p = NULL, msg[32];
if (!(p = GetMsgid(id))) {
sprintf(msg, "ID=%d unknown", id);
p = msg;
} // endif p
return sprintf(buf, "%.*s", bufsize-1, p);
} // end of GetRcString
/**************** RCMsg C Program Source Code File (.C) ****************/
/* PROGRAM NAME: RCMSG */
/* ------------- */
/* Version 1.1 */
/* */
/* COPYRIGHT */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND: 2005 - 2013 */
/* */
/* WHAT THIS PROGRAM DOES */
/* ----------------------- */
/* This program simulates LoadString for Unix and Linux. */
/* */
/***********************************************************************/
#include <stdio.h>
#include "resource.h"
char *GetMsgid(int id)
{
char *p = NULL;
switch (id) {
case IDS_00: p = "%s"; break;
#if defined(FRENCH)
case IDS_01: p = "%s: erreur d'allocation du buffer de communication de %d octets"; break;
case IDS_02: p = "%s: erreur d'allocation m<>moire tampon pour %d colonnes"; break;
case IDS_03: p = "%s: Commande sp<73>ciale invalide"; break;
case IDS_04: p = "%s: Wrong number of arguments %d"; break;
case IDS_05: p = "%s"; break;
case IDS_06: p = "%s: Commande d<>passant la taille du buffer interne (%d octets)"; break;
case IDS_07: p = "%s: Donn<6E>es (%d octets) tronqu<71>es <20> la taille du buffer"; break;
case IDS_08: p = "%s: R<>sultat d<>passant la taille du buffer interne (%d octets)"; break;
case IDS_09: p = "Erreur dans %s: %s"; break;
case IDS_10: p = "%s: erreur d'allocating m<>moire de %d octets"; break;
case IDS_11: p = "%s: mauvaise cl<63> de connexion %d"; break;
case IDS_12: p = "%s: Pas plus de %d connexions autoris<69>es pour un programme"; break;
case IDS_13: p = "%s: cl<63> de connexion invalide %d"; break;
case IDS_14: p = "SafeDB: %s rc=%d"; break;
case IDS_15: p = "Mauvaise Dll de communication appel<65>e par le moteur %s"; break;
case IDS_TAB_01: p = "Qualificateur"; break;
case IDS_TAB_02: p = "Propri<EFBFBD>taire"; break;
case IDS_TAB_03: p = "Nom"; break;
case IDS_TAB_04: p = "Type"; break;
case IDS_TAB_05: p = "Remarque"; break;
case IDS_COL_01: p = "Qualif_Table"; break;
case IDS_COL_02: p = "Prop_Tabl"; break;
case IDS_COL_03: p = "Nom_Table"; break;
case IDS_COL_04: p = "Nom_Colonne"; break;
case IDS_COL_05: p = "Type_Donn<EFBFBD>es"; break;
case IDS_COL_06: p = "Nom_Type"; break;
case IDS_COL_07: p = "Pr<EFBFBD>cision"; break;
case IDS_COL_08: p = "Longueur"; break;
case IDS_COL_09: p = "Echelle"; break;
case IDS_COL_10: p = "Base"; break;
case IDS_COL_11: p = "Nullifiable"; break;
case IDS_COL_12: p = "Remarques"; break;
case IDS_INF_01: p = "Nom_Type"; break;
case IDS_INF_02: p = "Type_Donn<EFBFBD>es"; break;
case IDS_INF_03: p = "Pr<EFBFBD>cision"; break;
case IDS_INF_04: p = "Pr<EFBFBD>fixe_Lit<EFBFBD>ral"; break;
case IDS_INF_05: p = "Suffixe_Lit<EFBFBD>ral"; break;
case IDS_INF_06: p = "Cr<EFBFBD>ation_Params"; break;
case IDS_INF_07: p = "Nullifiable"; break;
case IDS_INF_08: p = "Maj_Minuscule"; break;
case IDS_INF_09: p = "Localisable"; break;
case IDS_INF_10: p = "Valeur_Absolue"; break;
case IDS_INF_11: p = "Monnaie"; break;
case IDS_INF_12: p = "Auto_Incr<EFBFBD>ment"; break;
case IDS_INF_13: p = "Nom_Type_Local"; break;
case IDS_INF_14: p = "Echelle_Minimum"; break;
case IDS_INF_15: p = "Echelle_Maximum"; break;
case IDS_PKY_01: p = "Qualif_Table"; break;
case IDS_PKY_02: p = "Prop_Table"; break;
case IDS_PKY_03: p = "Nom_Table"; break;
case IDS_PKY_04: p = "Nom_Colonne"; break;
case IDS_PKY_05: p = "Num<EFBFBD>ro_Cl<EFBFBD>"; break;
case IDS_PKY_06: p = "Nom_Cl<EFBFBD>"; break;
case IDS_FKY_01: p = "PKTable_Qualifier"; break;
case IDS_FKY_02: p = "PKTable_Owner"; break;
case IDS_FKY_03: p = "PKTable_Name"; break;
case IDS_FKY_04: p = "PKColumn_Name"; break;
case IDS_FKY_05: p = "FKTable_Qualifier"; break;
case IDS_FKY_06: p = "FKTable_Owner"; break;
case IDS_FKY_07: p = "FKTable_Name"; break;
case IDS_FKY_08: p = "FKColumn_Name"; break;
case IDS_FKY_09: p = "Key_Seq"; break;
case IDS_FKY_10: p = "Update_Rule"; break;
case IDS_FKY_11: p = "Delete_Rule"; break;
case IDS_FKY_12: p = "FK_Name"; break;
case IDS_FKY_13: p = "PK_Name"; break;
case IDS_STA_01: p = "Table_Qualifier"; break;
case IDS_STA_02: p = "Table_Owner"; break;
case IDS_STA_03: p = "Table_Name"; break;
case IDS_STA_04: p = "Non_Unique"; break;
case IDS_STA_05: p = "Index_Qualifier"; break;
case IDS_STA_06: p = "Index_Name"; break;
case IDS_STA_07: p = "Type"; break;
case IDS_STA_08: p = "Seq_in_Index"; break;
case IDS_STA_09: p = "Column_Name"; break;
case IDS_STA_10: p = "Collation"; break;
case IDS_STA_11: p = "Cardinality"; break;
case IDS_STA_12: p = "Pages"; break;
case IDS_STA_13: p = "Filter_Condition"; break;
case IDS_SPC_01: p = "Champ"; break;
case IDS_SPC_02: p = "Nom_Colonne"; break;
case IDS_SPC_03: p = "Type_Donn<EFBFBD>es"; break;
case IDS_SPC_04: p = "Nom_Type"; break;
case IDS_SPC_05: p = "Pr<EFBFBD>cision"; break;
case IDS_SPC_06: p = "Longueur"; break;
case IDS_SPC_07: p = "Echelle"; break;
case IDS_SPC_08: p = "Pseudo_Colonne"; break;
case IDS_DSC_01: p = "Nom"; break;
case IDS_DSC_02: p = "Description"; break;
#else // English
case IDS_01: p = "%s: error allocating communication buffer of %d bytes"; break;
case IDS_02: p = "%s: error allocating parser memory for %d columns"; break;
case IDS_03: p = "%s: Invalid special command"; break;
case IDS_04: p = "%s: Wrong number of arguments %d"; break;
case IDS_05: p = "%s"; break;
case IDS_06: p = "%s: Command bigger than internal buffer of size = %d"; break;
case IDS_07: p = "%s: Data truncated to buffer size, actual length is %d bytes"; break;
case IDS_08: p = "%s: Result bigger than internal buffer of size = %d"; break;
case IDS_09: p = "Error in %s: %s"; break;
case IDS_10: p = "%s: error allocating instance memory of %d bytes"; break;
case IDS_11: p = "%s: wrong connection key value %d"; break;
case IDS_12: p = "%s: No more than %d connections allowed from one process"; break;
case IDS_13: p = "%s: invalid connection key value %d"; break;
case IDS_14: p = "SafeDB: %s rc=%d"; break;
case IDS_15: p = "Wrong communication Dll called for engine %s"; break;
case IDS_TAB_01: p = "Qualifier"; break;
case IDS_TAB_02: p = "Owner"; break;
case IDS_TAB_03: p = "Name"; break;
case IDS_TAB_04: p = "Type"; break;
case IDS_TAB_05: p = "Remark"; break;
case IDS_COL_01: p = "Table_Qualif"; break;
case IDS_COL_02: p = "Table_Owner"; break;
case IDS_COL_03: p = "Table_Name"; break;
case IDS_COL_04: p = "Column_Name"; break;
case IDS_COL_05: p = "Data_Type"; break;
case IDS_COL_06: p = "Type_Name"; break;
case IDS_COL_07: p = "Precision"; break;
case IDS_COL_08: p = "Length"; break;
case IDS_COL_09: p = "Scale"; break;
case IDS_COL_10: p = "Radix"; break;
case IDS_COL_11: p = "Nullable"; break;
case IDS_COL_12: p = "Remarks"; break;
case IDS_INF_01: p = "Type_Name"; break;
case IDS_INF_02: p = "Data_Type"; break;
case IDS_INF_03: p = "Precision"; break;
case IDS_INF_04: p = "Literal_Prefix"; break;
case IDS_INF_05: p = "Literal_Suffix"; break;
case IDS_INF_06: p = "Create_Params"; break;
case IDS_INF_07: p = "Nullable"; break;
case IDS_INF_08: p = "Case_Sensitive"; break;
case IDS_INF_09: p = "Searchable"; break;
case IDS_INF_10: p = "Unsigned_Attribute"; break;
case IDS_INF_11: p = "Money"; break;
case IDS_INF_12: p = "Auto_Increment"; break;
case IDS_INF_13: p = "Local_Type_Name"; break;
case IDS_INF_14: p = "Minimum_Scale"; break;
case IDS_INF_15: p = "Maximum_Scale"; break;
case IDS_PKY_01: p = "Table_Qualifier"; break;
case IDS_PKY_02: p = "Table_Owner"; break;
case IDS_PKY_03: p = "Table_Name"; break;
case IDS_PKY_04: p = "Column_Name"; break;
case IDS_PKY_05: p = "Key_Seq"; break;
case IDS_PKY_06: p = "Pk_Name"; break;
case IDS_FKY_01: p = "PKTable_Qualifier"; break;
case IDS_FKY_02: p = "PKTable_Owner"; break;
case IDS_FKY_03: p = "PKTable_Name"; break;
case IDS_FKY_04: p = "PKColumn_Name"; break;
case IDS_FKY_05: p = "FKTable_Qualifier"; break;
case IDS_FKY_06: p = "FKTable_Owner"; break;
case IDS_FKY_07: p = "FKTable_Name"; break;
case IDS_FKY_08: p = "FKColumn_Name"; break;
case IDS_FKY_09: p = "Key_Seq"; break;
case IDS_FKY_10: p = "Update_Rule"; break;
case IDS_FKY_11: p = "Delete_Rule"; break;
case IDS_FKY_12: p = "FK_Name"; break;
case IDS_FKY_13: p = "PK_Name"; break;
case IDS_STA_01: p = "Table_Qualifier"; break;
case IDS_STA_02: p = "Table_Owner"; break;
case IDS_STA_03: p = "Table_Name"; break;
case IDS_STA_04: p = "Non_Unique"; break;
case IDS_STA_05: p = "Index_Qualifier"; break;
case IDS_STA_06: p = "Index_Name"; break;
case IDS_STA_07: p = "Type"; break;
case IDS_STA_08: p = "Seq_in_Index"; break;
case IDS_STA_09: p = "Column_Name"; break;
case IDS_STA_10: p = "Collation"; break;
case IDS_STA_11: p = "Cardinality"; break;
case IDS_STA_12: p = "Pages"; break;
case IDS_STA_13: p = "Filter_Condition"; break;
case IDS_SPC_01: p = "Scope"; break;
case IDS_SPC_02: p = "Column_Name"; break;
case IDS_SPC_03: p = "Data_Type"; break;
case IDS_SPC_04: p = "Type_Name"; break;
case IDS_SPC_05: p = "Precision"; break;
case IDS_SPC_06: p = "Length"; break;
case IDS_SPC_07: p = "Scale"; break;
case IDS_SPC_08: p = "Pseudo_Column"; break;
case IDS_DSC_01: p = "Name"; break;
case IDS_DSC_02: p = "Description"; break;
#endif // English
} // endswitch(id)
return p;
} // end of GetMsgid
int GetRcString(int id, char *buf, int bufsize)
{
char *p = NULL, msg[32];
if (!(p = GetMsgid(id))) {
sprintf(msg, "ID=%d unknown", id);
p = msg;
} // endif p
return sprintf(buf, "%.*s", bufsize-1, p);
} // end of GetRcString

View File

@@ -1,421 +1,421 @@
/************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: REFDEF */
/* ------------- */
/* Version 1.3 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2012 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
/* This program are the DB definition related routines. */
/* */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
#if defined(WIN32)
#include <sqlext.h>
#else
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
#include "osutil.h"
//#include "sqlext.h"
#endif
/***********************************************************************/
/* Include application header files */
/* */
/* global.h is header containing all global declarations. */
/* plgdbsem.h is header containing DB application declarations. */
/* catalog.h is header containing DB description declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "reldef.h"
#include "colblk.h"
#include "filamap.h"
#include "filamfix.h"
#include "filamvct.h"
#if defined(ZIP_SUPPORT)
#include "filamzip.h"
#endif // ZIP_SUPPORT
#include "tabdos.h"
#include "valblk.h"
#include "tabmul.h"
/***********************************************************************/
/* External static variables. */
/***********************************************************************/
//extern "C" char plgini[];
/* --------------------------- Class RELDEF -------------------------- */
/***********************************************************************/
/* RELDEF Constructor. */
/***********************************************************************/
RELDEF::RELDEF(void)
{
Next = NULL;
To_Cols = NULL;
Name = NULL;
Database = NULL;
Cat = NULL;
} // end of RELDEF constructor
/* --------------------------- Class TABDEF -------------------------- */
/***********************************************************************/
/* TABDEF Constructor. */
/***********************************************************************/
TABDEF::TABDEF(void)
{
Owner = NULL;
Desc = NULL;
Card = 0;
Elemt = 0;
Sort = 0;
Multiple = 0;
Degree = 0;
Pseudo = 0;
Read_Only = false;
} // end of TABDEF constructor
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
{
char buf[8];
int poff = 0;
void *memp = cat->Descp;
Name = (PSZ)PlugSubAlloc(g, memp, strlen(name) + 1);
strcpy(Name, name);
Cat = cat;
Elemt = cat->GetIntCatInfo(name, "Elements", 0);
Multiple = cat->GetIntCatInfo(name, "Multiple", 0);
Degree = cat->GetIntCatInfo(name, "Degree", 0);
cat->GetCharCatInfo(name, "ReadOnly", "No", buf, sizeof(buf));
Read_Only = (toupper(*buf) == 'Y');
// Get The column definitions
if ((poff = cat->GetColCatInfo(g, this)) < 0)
return true;
// Do the definition of AM specific fields
return DefineAM(g, am, poff);
} // end of Define
/* --------------------------- Class OEMDEF -------------------------- */
/***********************************************************************/
/* GetXdef: get the external TABDEF from OEM module. */
/***********************************************************************/
PTABDEF OEMDEF::GetXdef(PGLOBAL g)
{
typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *);
char c, getname[40] = "Get";
PTABDEF xdefp;
XGETDEF getdef = NULL;
PCATLG cat = Cat;
void *memp = cat->Descp;
#if defined(WIN32)
// Is the DLL already loaded?
if (!Hdll && !(Hdll = GetModuleHandle(Module)))
// No, load the Dll implementing the function
if (!(Hdll = LoadLibrary(Module))) {
char buf[256];
DWORD rc = GetLastError();
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
strcat(strcat(g->Message, ": "), buf);
return NULL;
} // endif hDll
// The exported name is always in uppercase
for (int i = 0; ; i++) {
c = Subtype[i];
getname[i + 3] = toupper(c);
if (!c) break;
} // endfor i
// Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname);
FreeLibrary((HMODULE)Hdll);
return NULL;
} // endif getdef
#else // !WIN32
const char *error = NULL;
// Is the library already loaded?
// if (!Hdll && !(Hdll = ???))
// Load the desired shared library
if (!(Hdll = dlopen(Module, RTLD_LAZY))) {
error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error));
return NULL;
} // endif Hdll
// The exported name is always in uppercase
for (int i = 0; ; i++) {
c = Subtype[i];
getname[i + 3] = toupper(c);
if (!c) break;
} // endfor i
// Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) {
error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error));
dlclose(Hdll);
return NULL;
} // endif getdef
#endif // !WIN32
// Just in case the external Get function does not set error messages
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);
// Get the table definition block
if (!(xdefp = getdef(g, memp)))
return NULL;
// Have the external class do its complete definition
if (!cat->Cbuf) {
// Suballocate a temporary buffer for the entire column section
cat->Cblen = cat->GetSizeCatInfo("Database", "Colsize", "8K");
cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen);
} // endif Cbuf
// Here "OEM" should be replace by a more useful value
if (xdefp->Define(g, cat, Name, "OEM"))
return NULL;
// Ok, return external block
return xdefp;
} // end of GetXdef
/***********************************************************************/
/* DeleteTableFile: Delete an OEM table file if applicable. */
/***********************************************************************/
bool OEMDEF::DeleteTableFile(PGLOBAL g)
{
if (!Pxdef)
Pxdef = GetXdef(g);
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true;
} // end of DeleteTableFile
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
void *memp = Cat->Descp;
Module = Cat->GetStringCatInfo(g, Name, "Module", "");
Subtype = Cat->GetStringCatInfo(g, Name, "Subtype", Module);
if (!*Module)
Module = Subtype;
Desc = (char*)PlugSubAlloc(g, memp, strlen(Module)
+ strlen(Subtype) + 3);
sprintf(Desc, "%s(%s)", Module, Subtype);
return false;
} // end of DefineAM
/***********************************************************************/
/* GetTable: makes a new Table Description Block. */
/***********************************************************************/
PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
{
RECFM rfm;
PTDBASE tdbp = NULL;
// If define block not here yet, get it now
if (!Pxdef && !(Pxdef = GetXdef(g)))
return NULL; // Error
/*********************************************************************/
/* Allocate a TDB of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode)))
return NULL;
else
rfm = tdbp->GetFtype();
if (rfm == RECFM_NAF)
return tdbp;
else if (rfm == RECFM_OEM) {
if (Multiple)
tdbp = new(g) TDBMUL(tdbp); // No block optimization yet
return tdbp;
} // endif OEM
/*********************************************************************/
/* The OEM table is based on a file type (currently DOS+ only) */
/*********************************************************************/
assert (rfm == RECFM_VAR || rfm == RECFM_FIX ||
rfm == RECFM_BIN || rfm == RECFM_VCT);
PTXF txfp = NULL;
PDOSDEF defp = (PDOSDEF)Pxdef;
bool map = defp->Mapped && mode != MODE_INSERT &&
!(PlgGetUser(g)->UseTemp == TMP_FORCE &&
(mode == MODE_UPDATE || mode == MODE_DELETE));
int cmpr = defp->Compressed;
/*********************************************************************/
/* Allocate table and file processing class of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (!((PTDBDOS)tdbp)->GetTxfp()) {
if (cmpr) {
#if defined(ZIP_SUPPORT)
if (cmpr == 1)
txfp = new(g) ZIPFAM(defp);
else {
strcpy(g->Message, "Compress 2 not supported yet");
// txfp = new(g) ZLBFAM(defp);
return NULL;
} // endelse
#else // !ZIP_SUPPORT
strcpy(g->Message, "Compress not supported");
return NULL;
#endif // !ZIP_SUPPORT
} else if (rfm == RECFM_VAR) {
if (map)
txfp = new(g) MAPFAM(defp);
else
txfp = new(g) DOSFAM(defp);
} else if (rfm == RECFM_FIX || rfm == RECFM_FIX) {
if (map)
txfp = new(g) MPXFAM(defp);
else
txfp = new(g) FIXFAM(defp);
} else if (rfm == RECFM_VCT) {
assert (Pxdef->GetDefType() == TYPE_AM_VCT);
if (map)
txfp = new(g) VCMFAM((PVCTDEF)defp);
else
txfp = new(g) VCTFAM((PVCTDEF)defp);
} // endif's
((PTDBDOS)tdbp)->SetTxfp(txfp);
} // endif Txfp
if (Multiple)
tdbp = new(g) TDBMUL(tdbp);
return tdbp;
} // end of GetTable
/* --------------------------- Class COLCRT -------------------------- */
/***********************************************************************/
/* COLCRT Constructors. */
/***********************************************************************/
COLCRT::COLCRT(PSZ name)
{
Next = NULL;
Name = name;
Desc = NULL;
Decode = NULL;
Fmt = NULL;
Offset = -1;
Long = -1;
//Freq = -1;
Key = -1;
Prec = -1;
Opt = -1;
DataType = '*';
} // end of COLCRT constructor for table creation
COLCRT::COLCRT(void)
{
Next = NULL;
Name = NULL;
Desc = NULL;
Decode = NULL;
Fmt = NULL;
Offset = 0;
Long = 0;
//Freq = 0;
Key = 0;
Prec = 0;
Opt = 0;
DataType = '*';
} // end of COLCRT constructor for table & view definition
/* --------------------------- Class COLDEF -------------------------- */
/***********************************************************************/
/* COLDEF Constructor. */
/***********************************************************************/
COLDEF::COLDEF(void) : COLCRT()
{
Buf_Type = TYPE_ERROR;
Clen = 0;
Poff = 0;
memset(&F, 0, sizeof(FORMAT));
Flags = 0;
} // end of COLDEF constructor
/***********************************************************************/
/* Define: initialize a column definition from a COLINFO structure. */
/***********************************************************************/
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
{
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1);
strcpy(Name, cfp->Name);
Poff = poff;
Buf_Type = cfp->Type;
if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) {
sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name);
return -1;
} // endswitch
strcpy(F.Type, GetFormatType(Buf_Type));
F.Length = cfp->Length;
F.Prec = cfp->Prec;
Offset = (cfp->Offset < 0) ? poff : cfp->Offset;
Long = cfp->Length;
Opt = cfp->Opt;
Key = cfp->Key;
//Freq = cfp->Freq;
if (cfp->Remark && *cfp->Remark) {
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1);
strcpy(Desc, cfp->Remark);
} // endif Remark
if (cfp->Datefmt) {
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1);
strcpy(Decode, cfp->Datefmt);
} // endif Datefmt
if (cfp->Fieldfmt) {
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1);
strcpy(Fmt, cfp->Fieldfmt);
} // endif Fieldfmt
Flags = cfp->Flags;
return (Flags & U_VIRTUAL) ? 0 : Long;
} // end of Define
/* ------------------------- End of RelDef --------------------------- */
/************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: REFDEF */
/* ------------- */
/* Version 1.3 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2012 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
/* This program are the DB definition related routines. */
/* */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
#if defined(WIN32)
#include <sqlext.h>
#else
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
#include "osutil.h"
//#include "sqlext.h"
#endif
/***********************************************************************/
/* Include application header files */
/* */
/* global.h is header containing all global declarations. */
/* plgdbsem.h is header containing DB application declarations. */
/* catalog.h is header containing DB description declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "reldef.h"
#include "colblk.h"
#include "filamap.h"
#include "filamfix.h"
#include "filamvct.h"
#if defined(ZIP_SUPPORT)
#include "filamzip.h"
#endif // ZIP_SUPPORT
#include "tabdos.h"
#include "valblk.h"
#include "tabmul.h"
/***********************************************************************/
/* External static variables. */
/***********************************************************************/
//extern "C" char plgini[];
/* --------------------------- Class RELDEF -------------------------- */
/***********************************************************************/
/* RELDEF Constructor. */
/***********************************************************************/
RELDEF::RELDEF(void)
{
Next = NULL;
To_Cols = NULL;
Name = NULL;
Database = NULL;
Cat = NULL;
} // end of RELDEF constructor
/* --------------------------- Class TABDEF -------------------------- */
/***********************************************************************/
/* TABDEF Constructor. */
/***********************************************************************/
TABDEF::TABDEF(void)
{
Owner = NULL;
Desc = NULL;
Card = 0;
Elemt = 0;
Sort = 0;
Multiple = 0;
Degree = 0;
Pseudo = 0;
Read_Only = false;
} // end of TABDEF constructor
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
{
char buf[8];
int poff = 0;
void *memp = cat->Descp;
Name = (PSZ)PlugSubAlloc(g, memp, strlen(name) + 1);
strcpy(Name, name);
Cat = cat;
Elemt = cat->GetIntCatInfo(name, "Elements", 0);
Multiple = cat->GetIntCatInfo(name, "Multiple", 0);
Degree = cat->GetIntCatInfo(name, "Degree", 0);
cat->GetCharCatInfo(name, "ReadOnly", "No", buf, sizeof(buf));
Read_Only = (toupper(*buf) == 'Y');
// Get The column definitions
if ((poff = cat->GetColCatInfo(g, this)) < 0)
return true;
// Do the definition of AM specific fields
return DefineAM(g, am, poff);
} // end of Define
/* --------------------------- Class OEMDEF -------------------------- */
/***********************************************************************/
/* GetXdef: get the external TABDEF from OEM module. */
/***********************************************************************/
PTABDEF OEMDEF::GetXdef(PGLOBAL g)
{
typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *);
char c, getname[40] = "Get";
PTABDEF xdefp;
XGETDEF getdef = NULL;
PCATLG cat = Cat;
void *memp = cat->Descp;
#if defined(WIN32)
// Is the DLL already loaded?
if (!Hdll && !(Hdll = GetModuleHandle(Module)))
// No, load the Dll implementing the function
if (!(Hdll = LoadLibrary(Module))) {
char buf[256];
DWORD rc = GetLastError();
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
strcat(strcat(g->Message, ": "), buf);
return NULL;
} // endif hDll
// The exported name is always in uppercase
for (int i = 0; ; i++) {
c = Subtype[i];
getname[i + 3] = toupper(c);
if (!c) break;
} // endfor i
// Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname);
FreeLibrary((HMODULE)Hdll);
return NULL;
} // endif getdef
#else // !WIN32
const char *error = NULL;
// Is the library already loaded?
// if (!Hdll && !(Hdll = ???))
// Load the desired shared library
if (!(Hdll = dlopen(Module, RTLD_LAZY))) {
error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error));
return NULL;
} // endif Hdll
// The exported name is always in uppercase
for (int i = 0; ; i++) {
c = Subtype[i];
getname[i + 3] = toupper(c);
if (!c) break;
} // endfor i
// Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) {
error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error));
dlclose(Hdll);
return NULL;
} // endif getdef
#endif // !WIN32
// Just in case the external Get function does not set error messages
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);
// Get the table definition block
if (!(xdefp = getdef(g, memp)))
return NULL;
// Have the external class do its complete definition
if (!cat->Cbuf) {
// Suballocate a temporary buffer for the entire column section
cat->Cblen = cat->GetSizeCatInfo("Database", "Colsize", "8K");
cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen);
} // endif Cbuf
// Here "OEM" should be replace by a more useful value
if (xdefp->Define(g, cat, Name, "OEM"))
return NULL;
// Ok, return external block
return xdefp;
} // end of GetXdef
/***********************************************************************/
/* DeleteTableFile: Delete an OEM table file if applicable. */
/***********************************************************************/
bool OEMDEF::DeleteTableFile(PGLOBAL g)
{
if (!Pxdef)
Pxdef = GetXdef(g);
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true;
} // end of DeleteTableFile
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
void *memp = Cat->Descp;
Module = Cat->GetStringCatInfo(g, Name, "Module", "");
Subtype = Cat->GetStringCatInfo(g, Name, "Subtype", Module);
if (!*Module)
Module = Subtype;
Desc = (char*)PlugSubAlloc(g, memp, strlen(Module)
+ strlen(Subtype) + 3);
sprintf(Desc, "%s(%s)", Module, Subtype);
return false;
} // end of DefineAM
/***********************************************************************/
/* GetTable: makes a new Table Description Block. */
/***********************************************************************/
PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
{
RECFM rfm;
PTDBASE tdbp = NULL;
// If define block not here yet, get it now
if (!Pxdef && !(Pxdef = GetXdef(g)))
return NULL; // Error
/*********************************************************************/
/* Allocate a TDB of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode)))
return NULL;
else
rfm = tdbp->GetFtype();
if (rfm == RECFM_NAF)
return tdbp;
else if (rfm == RECFM_OEM) {
if (Multiple)
tdbp = new(g) TDBMUL(tdbp); // No block optimization yet
return tdbp;
} // endif OEM
/*********************************************************************/
/* The OEM table is based on a file type (currently DOS+ only) */
/*********************************************************************/
assert (rfm == RECFM_VAR || rfm == RECFM_FIX ||
rfm == RECFM_BIN || rfm == RECFM_VCT);
PTXF txfp = NULL;
PDOSDEF defp = (PDOSDEF)Pxdef;
bool map = defp->Mapped && mode != MODE_INSERT &&
!(PlgGetUser(g)->UseTemp == TMP_FORCE &&
(mode == MODE_UPDATE || mode == MODE_DELETE));
int cmpr = defp->Compressed;
/*********************************************************************/
/* Allocate table and file processing class of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (!((PTDBDOS)tdbp)->GetTxfp()) {
if (cmpr) {
#if defined(ZIP_SUPPORT)
if (cmpr == 1)
txfp = new(g) ZIPFAM(defp);
else {
strcpy(g->Message, "Compress 2 not supported yet");
// txfp = new(g) ZLBFAM(defp);
return NULL;
} // endelse
#else // !ZIP_SUPPORT
strcpy(g->Message, "Compress not supported");
return NULL;
#endif // !ZIP_SUPPORT
} else if (rfm == RECFM_VAR) {
if (map)
txfp = new(g) MAPFAM(defp);
else
txfp = new(g) DOSFAM(defp);
} else if (rfm == RECFM_FIX || rfm == RECFM_FIX) {
if (map)
txfp = new(g) MPXFAM(defp);
else
txfp = new(g) FIXFAM(defp);
} else if (rfm == RECFM_VCT) {
assert (Pxdef->GetDefType() == TYPE_AM_VCT);
if (map)
txfp = new(g) VCMFAM((PVCTDEF)defp);
else
txfp = new(g) VCTFAM((PVCTDEF)defp);
} // endif's
((PTDBDOS)tdbp)->SetTxfp(txfp);
} // endif Txfp
if (Multiple)
tdbp = new(g) TDBMUL(tdbp);
return tdbp;
} // end of GetTable
/* --------------------------- Class COLCRT -------------------------- */
/***********************************************************************/
/* COLCRT Constructors. */
/***********************************************************************/
COLCRT::COLCRT(PSZ name)
{
Next = NULL;
Name = name;
Desc = NULL;
Decode = NULL;
Fmt = NULL;
Offset = -1;
Long = -1;
//Freq = -1;
Key = -1;
Prec = -1;
Opt = -1;
DataType = '*';
} // end of COLCRT constructor for table creation
COLCRT::COLCRT(void)
{
Next = NULL;
Name = NULL;
Desc = NULL;
Decode = NULL;
Fmt = NULL;
Offset = 0;
Long = 0;
//Freq = 0;
Key = 0;
Prec = 0;
Opt = 0;
DataType = '*';
} // end of COLCRT constructor for table & view definition
/* --------------------------- Class COLDEF -------------------------- */
/***********************************************************************/
/* COLDEF Constructor. */
/***********************************************************************/
COLDEF::COLDEF(void) : COLCRT()
{
Buf_Type = TYPE_ERROR;
Clen = 0;
Poff = 0;
memset(&F, 0, sizeof(FORMAT));
Flags = 0;
} // end of COLDEF constructor
/***********************************************************************/
/* Define: initialize a column definition from a COLINFO structure. */
/***********************************************************************/
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
{
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1);
strcpy(Name, cfp->Name);
Poff = poff;
Buf_Type = cfp->Type;
if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) {
sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name);
return -1;
} // endswitch
strcpy(F.Type, GetFormatType(Buf_Type));
F.Length = cfp->Length;
F.Prec = cfp->Prec;
Offset = (cfp->Offset < 0) ? poff : cfp->Offset;
Long = cfp->Length;
Opt = cfp->Opt;
Key = cfp->Key;
//Freq = cfp->Freq;
if (cfp->Remark && *cfp->Remark) {
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1);
strcpy(Desc, cfp->Remark);
} // endif Remark
if (cfp->Datefmt) {
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1);
strcpy(Decode, cfp->Datefmt);
} // endif Datefmt
if (cfp->Fieldfmt) {
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1);
strcpy(Fmt, cfp->Fieldfmt);
} // endif Fieldfmt
Flags = cfp->Flags;
return (Flags & U_VIRTUAL) ? 0 : Long;
} // end of Define
/* ------------------------- End of RelDef --------------------------- */

View File

@@ -1,194 +1,194 @@
/*************** RelDef H Declares Source Code File (.H) ***************/
/* Name: RELDEF.H Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2004-2012 */
/* */
/* This file contains the DEF classes definitions. */
/***********************************************************************/
#ifndef __RELDEF_H
#define __RELDEF_H
#include "block.h"
#include "catalog.h"
typedef class INDEXDEF *PIXDEF;
/***********************************************************************/
/* Table or View (relation) definition block. */
/***********************************************************************/
class DllExport RELDEF : public BLOCK { // Relation definition block
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
public:
RELDEF(void); // Constructor
// Implementation
PRELDEF GetNext(void) {return Next;}
PSZ GetName(void) {return Name;}
PSZ GetDB(void) {return (PSZ)Database;}
PCOLDEF GetCols(void) {return To_Cols;}
void SetCols(PCOLDEF pcd) {To_Cols = pcd;}
PCATLG GetCat(void) {return Cat;}
virtual const char *GetType(void) = 0;
virtual AMT GetDefType(void) = 0;
// Methods
virtual bool DeleteTableFile(PGLOBAL g) {return true;}
virtual bool Indexable(void) {return false;}
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0;
virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0;
protected:
PRELDEF Next; /* To next definition block */
PSZ Name; /* Name of the view */
LPCSTR Database; /* Table database */
PCOLDEF To_Cols; /* To a list of column desc */
PCATLG Cat; /* To DB catalog info */
}; // end of RELDEF
/***********************************************************************/
/* These classes correspond to the data base description contained in */
/* a .XDB file the A.M. DOS, FIX, CSV, MAP, BIN, VCT, PLG, ODBC, DOM. */
/***********************************************************************/
class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
public:
// Constructor
TABDEF(void); // Constructor
// Implementation
int GetDegree(void) {return Degree;}
void SetDegree(int d) {Degree = d;}
int GetElemt(void) {return Elemt;}
void SetNext(PTABDEF tdfp) {Next = tdfp;}
int GetMultiple(void) {return Multiple;}
int GetPseudo(void) {return Pseudo;}
PSZ GetPath(void)
{return (Database) ? (PSZ)Database : Cat->GetDataPath();}
bool SepIndex(void) {return Cat->GetSepIndex();}
bool IsReadOnly(void) {return Read_Only;}
virtual AMT GetDefType(void) {return TYPE_AM_TAB;}
virtual PIXDEF GetIndx(void) {return NULL;}
virtual void SetIndx(PIXDEF xp) {}
virtual bool IsHuge(void) {return false;}
// Methods
bool DropTable(PGLOBAL g, PSZ name);
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am);
virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0;
protected:
// Members
PSZ Owner; /* Table owner (for ODBC) */
PSZ Desc; /* Table description */
int Card; /* (max) number of rows in table */
int Elemt; /* Number of rows in blocks or rowset */
int Sort; /* Table already sorted ??? */
int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */
int Degree; /* Number of columns in the table */
int Pseudo; /* Bit: 1 ROWID Ok, 2 FILEID Ok */
bool Read_Only; /* true for read only tables */
}; // end of TABDEF
/***********************************************************************/
/* Externally defined OEM tables. */
/***********************************************************************/
class DllExport OEMDEF : public TABDEF { /* OEM table */
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
public:
// Constructor
OEMDEF(void) {Hdll = NULL; Pxdef = NULL; Module = Subtype = NULL;}
// Implementation
virtual const char *GetType(void) {return "OEM";}
virtual AMT GetDefType(void) {return TYPE_AM_OEM;}
// Methods
virtual bool DeleteTableFile(PGLOBAL g);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected:
PTABDEF GetXdef(PGLOBAL g);
// Members
#if defined(WIN32)
HANDLE Hdll; /* Handle to the external DLL */
#else // !WIN32
void *Hdll; /* Handle for the loaded shared library */
#endif // !WIN32
PTABDEF Pxdef; /* Pointer to the external TABDEF class */
char *Module; /* Path/Name of the DLL implenting it */
char *Subtype; /* The name of the OEM table sub type */
}; // end of OEMDEF
/***********************************************************************/
/* Column definition block used during creation. */
/***********************************************************************/
class DllExport COLCRT : public BLOCK { /* Column description block */
friend class TABDEF;
public:
COLCRT(PSZ name); // Constructor
COLCRT(void); // Constructor (for views)
// Implementation
PSZ GetName(void) {return Name;}
PSZ GetDecode(void) {return Decode;}
PSZ GetFmt(void) {return Fmt;}
int GetOpt(void) {return Opt;}
int GetLong(void) {return Long;}
int GetOffset(void) {return Offset;}
void SetOffset(int offset) {Offset = offset;}
protected:
PCOLCRT Next; /* To next block */
PSZ Name; /* Column name */
PSZ Desc; /* Column description */
PSZ Decode; /* Date format */
PSZ Fmt; /* Input format for formatted files */
int Offset; /* Offset of field within record */
int Long; /* Length of field in file record (!BIN) */
int Key; /* Key (greater than 1 if multiple) */
int Prec; /* Precision for float values */
int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */
char DataType; /* Internal data type (C, N, F, T) */
}; // end of COLCRT
/***********************************************************************/
/* Column definition block. */
/***********************************************************************/
class DllExport COLDEF : public COLCRT { /* Column description block */
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
friend class COLBLK;
friend class DBFFAM;
public:
COLDEF(void); // Constructor
// Implementation
PCOLDEF GetNext(void) {return (PCOLDEF)Next;}
void SetNext(PCOLDEF pcdf) {Next = pcdf;}
int GetLength(void) {return (int)F.Length;}
int GetClen(void) {return Clen;}
int GetType(void) {return Buf_Type;}
int GetPoff(void) {return Poff;}
int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff);
void Define(PGLOBAL g, PCOL colp);
protected:
int Buf_Type; /* Internal data type */
int Clen; /* Internal data size in chars (bytes) */
int Poff; /* Calculated offset for Packed tables */
FORMAT F; /* Output format (should be in COLCRT) */
ushort Flags; /* Used by MariaDB CONNECT handler */
}; // end of COLDEF
#endif // __RELDEF_H
/*************** RelDef H Declares Source Code File (.H) ***************/
/* Name: RELDEF.H Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2004-2012 */
/* */
/* This file contains the DEF classes definitions. */
/***********************************************************************/
#ifndef __RELDEF_H
#define __RELDEF_H
#include "block.h"
#include "catalog.h"
typedef class INDEXDEF *PIXDEF;
/***********************************************************************/
/* Table or View (relation) definition block. */
/***********************************************************************/
class DllExport RELDEF : public BLOCK { // Relation definition block
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
public:
RELDEF(void); // Constructor
// Implementation
PRELDEF GetNext(void) {return Next;}
PSZ GetName(void) {return Name;}
PSZ GetDB(void) {return (PSZ)Database;}
PCOLDEF GetCols(void) {return To_Cols;}
void SetCols(PCOLDEF pcd) {To_Cols = pcd;}
PCATLG GetCat(void) {return Cat;}
virtual const char *GetType(void) = 0;
virtual AMT GetDefType(void) = 0;
// Methods
virtual bool DeleteTableFile(PGLOBAL g) {return true;}
virtual bool Indexable(void) {return false;}
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0;
virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0;
protected:
PRELDEF Next; /* To next definition block */
PSZ Name; /* Name of the view */
LPCSTR Database; /* Table database */
PCOLDEF To_Cols; /* To a list of column desc */
PCATLG Cat; /* To DB catalog info */
}; // end of RELDEF
/***********************************************************************/
/* These classes correspond to the data base description contained in */
/* a .XDB file the A.M. DOS, FIX, CSV, MAP, BIN, VCT, PLG, ODBC, DOM. */
/***********************************************************************/
class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
public:
// Constructor
TABDEF(void); // Constructor
// Implementation
int GetDegree(void) {return Degree;}
void SetDegree(int d) {Degree = d;}
int GetElemt(void) {return Elemt;}
void SetNext(PTABDEF tdfp) {Next = tdfp;}
int GetMultiple(void) {return Multiple;}
int GetPseudo(void) {return Pseudo;}
PSZ GetPath(void)
{return (Database) ? (PSZ)Database : Cat->GetDataPath();}
bool SepIndex(void) {return Cat->GetSepIndex();}
bool IsReadOnly(void) {return Read_Only;}
virtual AMT GetDefType(void) {return TYPE_AM_TAB;}
virtual PIXDEF GetIndx(void) {return NULL;}
virtual void SetIndx(PIXDEF xp) {}
virtual bool IsHuge(void) {return false;}
// Methods
bool DropTable(PGLOBAL g, PSZ name);
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am);
virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0;
protected:
// Members
PSZ Owner; /* Table owner (for ODBC) */
PSZ Desc; /* Table description */
int Card; /* (max) number of rows in table */
int Elemt; /* Number of rows in blocks or rowset */
int Sort; /* Table already sorted ??? */
int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */
int Degree; /* Number of columns in the table */
int Pseudo; /* Bit: 1 ROWID Ok, 2 FILEID Ok */
bool Read_Only; /* true for read only tables */
}; // end of TABDEF
/***********************************************************************/
/* Externally defined OEM tables. */
/***********************************************************************/
class DllExport OEMDEF : public TABDEF { /* OEM table */
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
public:
// Constructor
OEMDEF(void) {Hdll = NULL; Pxdef = NULL; Module = Subtype = NULL;}
// Implementation
virtual const char *GetType(void) {return "OEM";}
virtual AMT GetDefType(void) {return TYPE_AM_OEM;}
// Methods
virtual bool DeleteTableFile(PGLOBAL g);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected:
PTABDEF GetXdef(PGLOBAL g);
// Members
#if defined(WIN32)
HANDLE Hdll; /* Handle to the external DLL */
#else // !WIN32
void *Hdll; /* Handle for the loaded shared library */
#endif // !WIN32
PTABDEF Pxdef; /* Pointer to the external TABDEF class */
char *Module; /* Path/Name of the DLL implenting it */
char *Subtype; /* The name of the OEM table sub type */
}; // end of OEMDEF
/***********************************************************************/
/* Column definition block used during creation. */
/***********************************************************************/
class DllExport COLCRT : public BLOCK { /* Column description block */
friend class TABDEF;
public:
COLCRT(PSZ name); // Constructor
COLCRT(void); // Constructor (for views)
// Implementation
PSZ GetName(void) {return Name;}
PSZ GetDecode(void) {return Decode;}
PSZ GetFmt(void) {return Fmt;}
int GetOpt(void) {return Opt;}
int GetLong(void) {return Long;}
int GetOffset(void) {return Offset;}
void SetOffset(int offset) {Offset = offset;}
protected:
PCOLCRT Next; /* To next block */
PSZ Name; /* Column name */
PSZ Desc; /* Column description */
PSZ Decode; /* Date format */
PSZ Fmt; /* Input format for formatted files */
int Offset; /* Offset of field within record */
int Long; /* Length of field in file record (!BIN) */
int Key; /* Key (greater than 1 if multiple) */
int Prec; /* Precision for float values */
int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */
char DataType; /* Internal data type (C, N, F, T) */
}; // end of COLCRT
/***********************************************************************/
/* Column definition block. */
/***********************************************************************/
class DllExport COLDEF : public COLCRT { /* Column description block */
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
friend class COLBLK;
friend class DBFFAM;
public:
COLDEF(void); // Constructor
// Implementation
PCOLDEF GetNext(void) {return (PCOLDEF)Next;}
void SetNext(PCOLDEF pcdf) {Next = pcdf;}
int GetLength(void) {return (int)F.Length;}
int GetClen(void) {return Clen;}
int GetType(void) {return Buf_Type;}
int GetPoff(void) {return Poff;}
int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff);
void Define(PGLOBAL g, PCOL colp);
protected:
int Buf_Type; /* Internal data type */
int Clen; /* Internal data size in chars (bytes) */
int Poff; /* Calculated offset for Packed tables */
FORMAT F; /* Output format (should be in COLCRT) */
ushort Flags; /* Used by MariaDB CONNECT handler */
}; // end of COLDEF
#endif // __RELDEF_H

View File

@@ -1,136 +1,136 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by PlgSock.rc
//
#define IDS_00 115
#define IDS_01 116
#define IDS_02 117
#define IDS_03 118
#define IDS_04 119
#define IDS_05 120
#define IDS_06 121
#define IDS_07 122
#define IDS_08 123
#define IDS_09 124
#define IDS_10 125
#define IDS_11 126
#define IDS_12 127
#define IDS_13 128
#define IDS_14 129
#define IDS_15 130
#define IDS_16 131
#define IDS_17 132
#define IDS_18 133
#define IDS_19 134
#define IDS_20 135
#define IDS_21 136
#define IDS_TABLES 143
#define IDS_TAB_01 144
#define IDS_TAB_02 145
#define IDS_TAB_03 146
#define IDS_TAB_04 147
#define IDS_TAB_05 148
#define IDS_COLUMNS 159
#define IDS_COL_01 160
#define IDS_COL_02 161
#define IDS_COL_03 162
#define IDS_COL_04 163
#define IDS_COL_05 164
#define IDS_COL_06 165
#define IDS_COL_07 166
#define IDS_COL_08 167
#define IDS_COL_09 168
#define IDS_COL_10 169
#define IDS_COL_11 170
#define IDS_COL_12 171
#define IDS_INFO 175
#define IDS_INF_01 176
#define IDS_INF_02 177
#define IDS_INF_03 178
#define IDS_INF_04 179
#define IDS_INF_05 180
#define IDS_INF_06 181
#define IDS_INF_07 182
#define IDS_INF_08 183
#define IDS_INF_09 184
#define IDS_INF_10 185
#define IDS_INF_11 186
#define IDS_INF_12 187
#define IDS_INF_13 188
#define IDS_INF_14 189
#define IDS_INF_15 190
#define IDS_PKEY 191
#define IDS_PKY_01 192
#define IDS_PKY_02 193
#define IDS_PKY_03 194
#define IDS_PKY_04 195
#define IDS_PKY_05 196
#define IDS_PKY_06 197
#define IDS_FKEY 207
#define IDS_FKY_01 208
#define IDS_FKY_02 209
#define IDS_FKY_03 210
#define IDS_FKY_04 211
#define IDS_FKY_05 212
#define IDS_FKY_06 213
#define IDS_FKY_07 214
#define IDS_FKY_08 215
#define IDS_FKY_09 216
#define IDS_FKY_10 217
#define IDS_FKY_11 218
#define IDS_FKY_12 219
#define IDS_FKY_13 220
#define IDS_STAT 223
#define IDS_STA_01 224
#define IDS_STA_02 225
#define IDS_STA_03 226
#define IDS_STA_04 227
#define IDS_STA_05 228
#define IDS_STA_06 229
#define IDS_STA_07 230
#define IDS_STA_08 231
#define IDS_STA_09 232
#define IDS_STA_10 233
#define IDS_STA_11 234
#define IDS_STA_12 235
#define IDS_STA_13 236
#define IDS_SPCOLS 1247
#define IDS_SPC_01 1248
#define IDS_SPC_02 1249
#define IDS_SPC_03 1250
#define IDS_SPC_04 1251
#define IDS_SPC_05 1252
#define IDS_SPC_06 1253
#define IDS_SPC_07 1254
#define IDS_SPC_08 1255
#define IDS_CNX 1263
#define IDS_CNX_01 1264
#define IDS_CNX_02 1265
#define IDS_CNX_03 1266
#define IDS_CNX_04 1267
#define IDS_PLGCOL 1279
#define IDS_PLG_01 1280
#define IDS_PLG_02 1281
#define IDS_PLG_03 1282
#define IDS_PLG_04 1283
#define IDS_PLG_05 1284
#define IDS_PLG_06 1285
#define IDS_PLG_07 1286
#define IDS_PLG_08 1287
#define IDS_PLG_09 1288
#define IDS_DSRC 1295
#define IDS_DSC_01 1296
#define IDS_DSC_02 1297
//#define IDS_DSC_03 1298
//#define IDS_DSC_04 1299
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 1300
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1440
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by PlgSock.rc
//
#define IDS_00 115
#define IDS_01 116
#define IDS_02 117
#define IDS_03 118
#define IDS_04 119
#define IDS_05 120
#define IDS_06 121
#define IDS_07 122
#define IDS_08 123
#define IDS_09 124
#define IDS_10 125
#define IDS_11 126
#define IDS_12 127
#define IDS_13 128
#define IDS_14 129
#define IDS_15 130
#define IDS_16 131
#define IDS_17 132
#define IDS_18 133
#define IDS_19 134
#define IDS_20 135
#define IDS_21 136
#define IDS_TABLES 143
#define IDS_TAB_01 144
#define IDS_TAB_02 145
#define IDS_TAB_03 146
#define IDS_TAB_04 147
#define IDS_TAB_05 148
#define IDS_COLUMNS 159
#define IDS_COL_01 160
#define IDS_COL_02 161
#define IDS_COL_03 162
#define IDS_COL_04 163
#define IDS_COL_05 164
#define IDS_COL_06 165
#define IDS_COL_07 166
#define IDS_COL_08 167
#define IDS_COL_09 168
#define IDS_COL_10 169
#define IDS_COL_11 170
#define IDS_COL_12 171
#define IDS_INFO 175
#define IDS_INF_01 176
#define IDS_INF_02 177
#define IDS_INF_03 178
#define IDS_INF_04 179
#define IDS_INF_05 180
#define IDS_INF_06 181
#define IDS_INF_07 182
#define IDS_INF_08 183
#define IDS_INF_09 184
#define IDS_INF_10 185
#define IDS_INF_11 186
#define IDS_INF_12 187
#define IDS_INF_13 188
#define IDS_INF_14 189
#define IDS_INF_15 190
#define IDS_PKEY 191
#define IDS_PKY_01 192
#define IDS_PKY_02 193
#define IDS_PKY_03 194
#define IDS_PKY_04 195
#define IDS_PKY_05 196
#define IDS_PKY_06 197
#define IDS_FKEY 207
#define IDS_FKY_01 208
#define IDS_FKY_02 209
#define IDS_FKY_03 210
#define IDS_FKY_04 211
#define IDS_FKY_05 212
#define IDS_FKY_06 213
#define IDS_FKY_07 214
#define IDS_FKY_08 215
#define IDS_FKY_09 216
#define IDS_FKY_10 217
#define IDS_FKY_11 218
#define IDS_FKY_12 219
#define IDS_FKY_13 220
#define IDS_STAT 223
#define IDS_STA_01 224
#define IDS_STA_02 225
#define IDS_STA_03 226
#define IDS_STA_04 227
#define IDS_STA_05 228
#define IDS_STA_06 229
#define IDS_STA_07 230
#define IDS_STA_08 231
#define IDS_STA_09 232
#define IDS_STA_10 233
#define IDS_STA_11 234
#define IDS_STA_12 235
#define IDS_STA_13 236
#define IDS_SPCOLS 1247
#define IDS_SPC_01 1248
#define IDS_SPC_02 1249
#define IDS_SPC_03 1250
#define IDS_SPC_04 1251
#define IDS_SPC_05 1252
#define IDS_SPC_06 1253
#define IDS_SPC_07 1254
#define IDS_SPC_08 1255
#define IDS_CNX 1263
#define IDS_CNX_01 1264
#define IDS_CNX_02 1265
#define IDS_CNX_03 1266
#define IDS_CNX_04 1267
#define IDS_PLGCOL 1279
#define IDS_PLG_01 1280
#define IDS_PLG_02 1281
#define IDS_PLG_03 1282
#define IDS_PLG_04 1283
#define IDS_PLG_05 1284
#define IDS_PLG_06 1285
#define IDS_PLG_07 1286
#define IDS_PLG_08 1287
#define IDS_PLG_09 1288
#define IDS_DSRC 1295
#define IDS_DSC_01 1296
#define IDS_DSC_02 1297
//#define IDS_DSC_03 1298
//#define IDS_DSC_04 1299
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 1300
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1440
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -1,170 +1,170 @@
/************* TabCol C++ Functions Source Code File (.CPP) ************/
/* Name: TABCOL.CPP Version 2.6 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* This file contains the PlugDB++ XTAB, COLUMN and XORDER methods. */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
/***********************************************************************/
/* Include required application header files */
/* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */
/* tabcol.h is header containing XTAB, and XORDER declares. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "xtable.h"
#include "tabcol.h"
/***********************************************************************/
/* XTAB public constructor (in which Correl defaults to Name). */
/***********************************************************************/
XTAB::XTAB(LPCSTR name, LPCSTR correl) : Name(name)
{
Next = NULL;
To_Tdb = NULL;
Correl = (correl) ? correl : name;
Creator = NULL;
Qualifier = NULL;
#ifdef DEBTRACE
htrc(" making new TABLE %s %s\n", Name, Correl);
#endif
} // end of XTAB constructor
/***********************************************************************/
/* XTAB public constructor as a copy of another table. */
/***********************************************************************/
XTAB::XTAB(PTABLE tp) : Name(tp->Name)
{
Next = NULL;
To_Tdb = NULL;
Correl = tp->Correl;
Creator = tp->Creator;
Qualifier = tp->Qualifier;
#ifdef DEBTRACE
htrc(" making copy TABLE %s %s\n", Name, Correl);
#endif
} // end of XTAB constructor
/***********************************************************************/
/* Link the tab2 tables to the tab1(this) table chain. */
/***********************************************************************/
PTABLE XTAB::Link(PTABLE tab2)
{
PTABLE tabp;
#ifdef DEBTRACE
htrc("Linking tables %s... to %s\n", Name, tab2->Name);
#endif
for (tabp = this; tabp->Next; tabp = tabp->Next) ;
tabp->Next = tab2;
return (this);
} /* end of Link */
/***********************************************************************/
/* Make file output of XTAB contents. */
/***********************************************************************/
void XTAB::Print(PGLOBAL g, FILE *f, uint n)
{
char m[64];
memset(m, ' ', n); /* Make margin string */
m[n] = '\0';
for (PTABLE tp = this; tp; tp = tp->Next) {
fprintf(f, "%sTABLE: %s.%s %s\n",
m, SVP(tp->Creator), tp->Name, SVP(tp->Correl));
PlugPutOut(g, f, TYPE_TDB, tp->To_Tdb, n + 2);
} /* endfor tp */
} /* end of Print */
/***********************************************************************/
/* Make string output of XTAB contents. */
/***********************************************************************/
void XTAB::Print(PGLOBAL g, char *ps, uint z)
{
char buf[128];
int i, n = (int)z - 1;
*ps = '\0';
for (PTABLE tp = this; tp && n > 0; tp = tp->Next) {
i = sprintf(buf, "TABLE: %s.%s %s To_Tdb=%p ",
SVP(tp->Creator), tp->Name, SVP(tp->Correl), tp->To_Tdb);
strncat(ps, buf, n);
n -= i;
} // endif tp
} /* end of Print */
/***********************************************************************/
/* COLUMN public constructor. */
/***********************************************************************/
COLUMN::COLUMN(LPCSTR name) : Name(name)
{
To_Table = NULL;
To_Col = NULL;
Qualifier = NULL;
#ifdef DEBTRACE
htrc(" making new COLUMN %s\n", Name);
#endif
} // end of COLUMN constructor
/***********************************************************************/
/* COLUMN SetFormat: should never be called. */
/***********************************************************************/
bool COLUMN::SetFormat(PGLOBAL g, FORMAT& fmt)
{
strcpy(g->Message, MSG(NO_FORMAT_COL));
return true;
} // end of SetFormat
/***********************************************************************/
/* Make file output of COLUMN contents. */
/***********************************************************************/
void COLUMN::Print(PGLOBAL g, FILE *f, uint n)
{
char m[64];
memset(m, ' ', n); // Make margin string
m[n] = '\0';
if (Name)
fprintf(f, "%sCOLUMN: %s.%s\n", m,
((!Qualifier) ? (PSZ)"?" : Qualifier), Name);
else // LNA
fprintf(f, "%sC%d\n", m, (!Qualifier) ? 0 : *(int *)Qualifier);
PlugPutOut(g, f, TYPE_TABLE, To_Table, n + 2);
PlugPutOut(g, f, TYPE_XOBJECT, To_Col, n + 2);
} /* end of Print */
/***********************************************************************/
/* Make string output of COLUMN contents. */
/***********************************************************************/
void COLUMN::Print(PGLOBAL g, char *ps, uint z)
{
char buf[80];
if (Name)
sprintf(buf, "COLUMN: %s.%s table=%p col=%p",
((!Qualifier) ? (PSZ)"?" : Qualifier), Name, To_Table, To_Col);
else // LNA
sprintf(buf, "C%d", (!Qualifier) ? 0 : *(int *)Qualifier);
strncpy(ps, buf, z);
ps[z - 1] = '\0';
} /* end of Print */
/************* TabCol C++ Functions Source Code File (.CPP) ************/
/* Name: TABCOL.CPP Version 2.6 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* This file contains the PlugDB++ XTAB, COLUMN and XORDER methods. */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
/***********************************************************************/
/* Include required application header files */
/* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */
/* tabcol.h is header containing XTAB, and XORDER declares. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "xtable.h"
#include "tabcol.h"
/***********************************************************************/
/* XTAB public constructor (in which Correl defaults to Name). */
/***********************************************************************/
XTAB::XTAB(LPCSTR name, LPCSTR correl) : Name(name)
{
Next = NULL;
To_Tdb = NULL;
Correl = (correl) ? correl : name;
Creator = NULL;
Qualifier = NULL;
#ifdef DEBTRACE
htrc(" making new TABLE %s %s\n", Name, Correl);
#endif
} // end of XTAB constructor
/***********************************************************************/
/* XTAB public constructor as a copy of another table. */
/***********************************************************************/
XTAB::XTAB(PTABLE tp) : Name(tp->Name)
{
Next = NULL;
To_Tdb = NULL;
Correl = tp->Correl;
Creator = tp->Creator;
Qualifier = tp->Qualifier;
#ifdef DEBTRACE
htrc(" making copy TABLE %s %s\n", Name, Correl);
#endif
} // end of XTAB constructor
/***********************************************************************/
/* Link the tab2 tables to the tab1(this) table chain. */
/***********************************************************************/
PTABLE XTAB::Link(PTABLE tab2)
{
PTABLE tabp;
#ifdef DEBTRACE
htrc("Linking tables %s... to %s\n", Name, tab2->Name);
#endif
for (tabp = this; tabp->Next; tabp = tabp->Next) ;
tabp->Next = tab2;
return (this);
} /* end of Link */
/***********************************************************************/
/* Make file output of XTAB contents. */
/***********************************************************************/
void XTAB::Print(PGLOBAL g, FILE *f, uint n)
{
char m[64];
memset(m, ' ', n); /* Make margin string */
m[n] = '\0';
for (PTABLE tp = this; tp; tp = tp->Next) {
fprintf(f, "%sTABLE: %s.%s %s\n",
m, SVP(tp->Creator), tp->Name, SVP(tp->Correl));
PlugPutOut(g, f, TYPE_TDB, tp->To_Tdb, n + 2);
} /* endfor tp */
} /* end of Print */
/***********************************************************************/
/* Make string output of XTAB contents. */
/***********************************************************************/
void XTAB::Print(PGLOBAL g, char *ps, uint z)
{
char buf[128];
int i, n = (int)z - 1;
*ps = '\0';
for (PTABLE tp = this; tp && n > 0; tp = tp->Next) {
i = sprintf(buf, "TABLE: %s.%s %s To_Tdb=%p ",
SVP(tp->Creator), tp->Name, SVP(tp->Correl), tp->To_Tdb);
strncat(ps, buf, n);
n -= i;
} // endif tp
} /* end of Print */
/***********************************************************************/
/* COLUMN public constructor. */
/***********************************************************************/
COLUMN::COLUMN(LPCSTR name) : Name(name)
{
To_Table = NULL;
To_Col = NULL;
Qualifier = NULL;
#ifdef DEBTRACE
htrc(" making new COLUMN %s\n", Name);
#endif
} // end of COLUMN constructor
/***********************************************************************/
/* COLUMN SetFormat: should never be called. */
/***********************************************************************/
bool COLUMN::SetFormat(PGLOBAL g, FORMAT& fmt)
{
strcpy(g->Message, MSG(NO_FORMAT_COL));
return true;
} // end of SetFormat
/***********************************************************************/
/* Make file output of COLUMN contents. */
/***********************************************************************/
void COLUMN::Print(PGLOBAL g, FILE *f, uint n)
{
char m[64];
memset(m, ' ', n); // Make margin string
m[n] = '\0';
if (Name)
fprintf(f, "%sCOLUMN: %s.%s\n", m,
((!Qualifier) ? (PSZ)"?" : Qualifier), Name);
else // LNA
fprintf(f, "%sC%d\n", m, (!Qualifier) ? 0 : *(int *)Qualifier);
PlugPutOut(g, f, TYPE_TABLE, To_Table, n + 2);
PlugPutOut(g, f, TYPE_XOBJECT, To_Col, n + 2);
} /* end of Print */
/***********************************************************************/
/* Make string output of COLUMN contents. */
/***********************************************************************/
void COLUMN::Print(PGLOBAL g, char *ps, uint z)
{
char buf[80];
if (Name)
sprintf(buf, "COLUMN: %s.%s table=%p col=%p",
((!Qualifier) ? (PSZ)"?" : Qualifier), Name, To_Table, To_Col);
else // LNA
sprintf(buf, "C%d", (!Qualifier) ? 0 : *(int *)Qualifier);
strncpy(ps, buf, z);
ps[z - 1] = '\0';
} /* end of Print */

View File

@@ -1,110 +1,110 @@
/*************** TabCol H Declares Source Code File (.H) ***************/
/* Name: TABCOL.H Version 2.7 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* This file contains the XTAB, COLUMN and XORDER class definitions. */
/***********************************************************************/
/***********************************************************************/
/* Include required application header files */
/* block.h is header containing Block global declarations. */
/***********************************************************************/
#include "xobject.h"
/***********************************************************************/
/* Definition of class XTAB with all its method functions. */
/***********************************************************************/
class DllExport XTAB: public BLOCK { // Table Name-Owner-Correl block.
public:
// Constructors
XTAB(LPCSTR name, LPCSTR correl = NULL);
XTAB(PTABLE tp);
// Implementation
PTABLE GetNext(void) {return Next;}
PTDB GetTo_Tdb(void) {return To_Tdb;}
LPCSTR GetName(void) {return Name;}
LPCSTR GetCorrel(void) {return Correl;}
LPCSTR GetCreator(void) {return Creator;}
LPCSTR GetQualifier(void) {return Qualifier;}
void SetTo_Tdb(PTDB tdbp) {To_Tdb = tdbp;}
void SetName(LPCSTR name) {Name = name;}
void SetCorrel(LPCSTR correl) {Correl = correl;}
void SetCreator(LPCSTR crname) {Creator = crname;}
void SetQualifier(LPCSTR qname) {Qualifier = qname;}
// Methods
PTABLE Link(PTABLE);
void Print(PGLOBAL g, FILE *f, uint n);
void Print(PGLOBAL g, char *ps, uint z);
protected:
// Members
PTABLE Next; // Points to next table in chain
PTDB To_Tdb; // Points to Table description Block
LPCSTR Name; // Table name (can be changed by LNA and PLG)
LPCSTR Correl; // Correlation name
LPCSTR Creator; // Creator name
LPCSTR Qualifier; // Qualifier name
}; // end of class XTAB
/***********************************************************************/
/* Definition of class COLUMN with all its method functions. */
/* Note: because of LNA routines, the constantness of Name was */
/* removed and constructing a COLUMN with null name was allowed. */
/* Perhaps this should be replaced by the use of a specific class. */
/***********************************************************************/
class DllExport COLUMN: public XOBJECT { // Column Name/Qualifier block.
public:
// Constructor
COLUMN(LPCSTR name);
// Implementation
virtual int GetType(void) {return TYPE_COLUMN;}
virtual int GetResultType(void) {assert(false); return TYPE_VOID;}
virtual int GetLength(void) {assert(false); return 0;}
virtual int GetLengthEx(void) {assert(false); return 0;}
virtual int GetPrecision() {assert(false); return 0;};
LPCSTR GetName(void) {return Name;}
LPCSTR GetQualifier(void) {return Qualifier;}
PTABLE GetTo_Table(void) {return To_Table;}
PCOL GetTo_Col(void) {return To_Col;}
void SetQualifier(LPCSTR qualif) {Qualifier = qualif;}
void SetTo_Table(PTABLE tablep) {To_Table = tablep;}
void SetTo_Col(PCOL colp) {To_Col = colp;}
// Methods
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
// All methods below should never be used for COLUMN's
virtual void Reset(void) {assert(false);}
virtual bool Compare(PXOB) {assert(false); return false;}
virtual bool SetFormat(PGLOBAL, FORMAT&);
virtual bool Eval(PGLOBAL) {assert(false); return true;}
virtual int CheckSpcCol(PTDB, int) {assert(false); return 2;}
virtual bool CheckSort(PTDB) {assert(false); return false;}
virtual void MarkCol(ushort) {assert(false);}
private:
// Members
PTABLE To_Table; // Point to Table Name Block
PCOL To_Col; // Points to Column Description Block
LPCSTR const Name; // Column name
LPCSTR Qualifier; // Qualifier name
}; // end of class COLUMN
/***********************************************************************/
/* Definition of class SPCCOL with all its method functions. */
/* Note: Currently the special columns are ROWID, ROWNUM, FILEID, */
/* SERVID, TABID, and CONID. */
/***********************************************************************/
class SPCCOL: public COLUMN { // Special Column Name/Qualifier block.
public:
// Constructor
SPCCOL(LPCSTR name) : COLUMN(name) {}
private:
// Members
}; // end of class SPCCOL
/*************** TabCol H Declares Source Code File (.H) ***************/
/* Name: TABCOL.H Version 2.7 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* This file contains the XTAB, COLUMN and XORDER class definitions. */
/***********************************************************************/
/***********************************************************************/
/* Include required application header files */
/* block.h is header containing Block global declarations. */
/***********************************************************************/
#include "xobject.h"
/***********************************************************************/
/* Definition of class XTAB with all its method functions. */
/***********************************************************************/
class DllExport XTAB: public BLOCK { // Table Name-Owner-Correl block.
public:
// Constructors
XTAB(LPCSTR name, LPCSTR correl = NULL);
XTAB(PTABLE tp);
// Implementation
PTABLE GetNext(void) {return Next;}
PTDB GetTo_Tdb(void) {return To_Tdb;}
LPCSTR GetName(void) {return Name;}
LPCSTR GetCorrel(void) {return Correl;}
LPCSTR GetCreator(void) {return Creator;}
LPCSTR GetQualifier(void) {return Qualifier;}
void SetTo_Tdb(PTDB tdbp) {To_Tdb = tdbp;}
void SetName(LPCSTR name) {Name = name;}
void SetCorrel(LPCSTR correl) {Correl = correl;}
void SetCreator(LPCSTR crname) {Creator = crname;}
void SetQualifier(LPCSTR qname) {Qualifier = qname;}
// Methods
PTABLE Link(PTABLE);
void Print(PGLOBAL g, FILE *f, uint n);
void Print(PGLOBAL g, char *ps, uint z);
protected:
// Members
PTABLE Next; // Points to next table in chain
PTDB To_Tdb; // Points to Table description Block
LPCSTR Name; // Table name (can be changed by LNA and PLG)
LPCSTR Correl; // Correlation name
LPCSTR Creator; // Creator name
LPCSTR Qualifier; // Qualifier name
}; // end of class XTAB
/***********************************************************************/
/* Definition of class COLUMN with all its method functions. */
/* Note: because of LNA routines, the constantness of Name was */
/* removed and constructing a COLUMN with null name was allowed. */
/* Perhaps this should be replaced by the use of a specific class. */
/***********************************************************************/
class DllExport COLUMN: public XOBJECT { // Column Name/Qualifier block.
public:
// Constructor
COLUMN(LPCSTR name);
// Implementation
virtual int GetType(void) {return TYPE_COLUMN;}
virtual int GetResultType(void) {assert(false); return TYPE_VOID;}
virtual int GetLength(void) {assert(false); return 0;}
virtual int GetLengthEx(void) {assert(false); return 0;}
virtual int GetPrecision() {assert(false); return 0;};
LPCSTR GetName(void) {return Name;}
LPCSTR GetQualifier(void) {return Qualifier;}
PTABLE GetTo_Table(void) {return To_Table;}
PCOL GetTo_Col(void) {return To_Col;}
void SetQualifier(LPCSTR qualif) {Qualifier = qualif;}
void SetTo_Table(PTABLE tablep) {To_Table = tablep;}
void SetTo_Col(PCOL colp) {To_Col = colp;}
// Methods
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
// All methods below should never be used for COLUMN's
virtual void Reset(void) {assert(false);}
virtual bool Compare(PXOB) {assert(false); return false;}
virtual bool SetFormat(PGLOBAL, FORMAT&);
virtual bool Eval(PGLOBAL) {assert(false); return true;}
virtual int CheckSpcCol(PTDB, int) {assert(false); return 2;}
virtual bool CheckSort(PTDB) {assert(false); return false;}
virtual void MarkCol(ushort) {assert(false);}
private:
// Members
PTABLE To_Table; // Point to Table Name Block
PCOL To_Col; // Points to Column Description Block
LPCSTR const Name; // Column name
LPCSTR Qualifier; // Qualifier name
}; // end of class COLUMN
/***********************************************************************/
/* Definition of class SPCCOL with all its method functions. */
/* Note: Currently the special columns are ROWID, ROWNUM, FILEID, */
/* SERVID, TABID, and CONID. */
/***********************************************************************/
class SPCCOL: public COLUMN { // Special Column Name/Qualifier block.
public:
// Constructor
SPCCOL(LPCSTR name) : COLUMN(name) {}
private:
// Members
}; // end of class SPCCOL

File diff suppressed because it is too large Load Diff

View File

@@ -1,246 +1,246 @@
/*************** TabDos H Declares Source Code File (.H) ***************/
/* Name: TABDOS.H Version 3.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */
/* */
/* This file contains the DOS classes declares. */
/***********************************************************************/
#ifndef __TABDOS_H
#define __TABDOS_H
#include "xtable.h" // Table base class declares
#include "colblk.h" // Column base class declares
#include "xindex.h"
typedef struct _tabdesc *PTABD; // For friend setting
typedef class TXTFAM *PTXF;
/***********************************************************************/
/* DOS table. */
/***********************************************************************/
class DllExport DOSDEF : public TABDEF { /* Logical table description */
friend class OEMDEF;
friend class TDBDOS;
friend class TDBFIX;
friend class TXTFAM;
friend class DBFBASE;
public:
// Constructor
DOSDEF(void);
// Implementation
virtual AMT GetDefType(void) {return TYPE_AM_DOS;}
virtual const char *GetType(void) {return "DOS";}
virtual PIXDEF GetIndx(void) {return To_Indx;}
virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;}
PSZ GetOfn(void) {return Ofn;}
void SetBlock(int block) {Block = block;}
int GetBlock(void) {return Block;}
int GetLast(void) {return Last;}
void SetLast(int last) {Last = last;}
int GetLrecl(void) {return Lrecl;}
void SetLrecl(int lrecl) {Lrecl = lrecl;}
bool GetPadded(void) {return Padded;}
bool GetEof(void) {return Eof;}
int GetBlksize(void) {return Blksize;}
int GetEnding(void) {return Ending;}
int *GetTo_Pos(void) {return To_Pos;}
virtual bool IsHuge(void) {return Huge;}
// Methods
virtual bool DeleteTableFile(PGLOBAL g);
virtual bool Indexable(void) {return Compressed != 1;}
virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
bool InvalidateIndex(PGLOBAL g);
protected:
virtual bool Erase(char *filename);
// Members
PSZ Fn; /* Path/Name of corresponding file */
PSZ Ofn; /* Base Path/Name of matching index files*/
PIXDEF To_Indx; /* To index definitions blocks */
RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */
bool Mapped; /* 0: disk file, 1: memory mapped file */
bool Padded; /* true for padded table file */
bool Huge; /* true for files larger than 2GB */
bool Accept; /* true if wrong lines are accepted (DBF)*/
bool Eof; /* true if an EOF (0xA) character exists */
int *To_Pos; /* To array of block starting positions */
int Compressed; /* 0: No, 1: gz, 2:zlib compressed file */
int Lrecl; /* Size of biggest record */
int AvgLen; /* Average size of records */
int Block; /* Number de blocks of FIX/VCT tables */
int Last; /* Number of elements of last block */
int Blksize; /* Size of padded blocks */
int Maxerr; /* Maximum number of bad records (DBF) */
int ReadMode; /* Specific to DBF */
int Ending; /* Length of end of lines */
}; // end of DOSDEF
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* that are standard files with columns starting at fixed offset. */
/* The last column (and record) is of variable length. */
/***********************************************************************/
class DllExport TDBDOS : public TDBASE {
//friend class KINDEX;
friend class XINDEX;
friend class DOSCOL;
friend class MAPCOL;
friend class TXTFAM;
friend class DOSFAM;
friend class VCTCOL;
//friend class TDBMUL;
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
public:
// Constructors
TDBDOS(PDOSDEF tdp, PTXF txfp);
TDBDOS(PGLOBAL g, PTDBDOS tdbp);
// Inline functions
inline void SetTxfp(PTXF txfp) {Txfp = txfp; Txfp->SetTdbp(this);}
inline PTXF GetTxfp(void) {return Txfp;}
inline char *GetLine(void) {return To_Line;}
inline int GetCurBlk(void) {return Txfp->GetCurBlk();}
inline void SetLine(char *toline) {To_Line = toline;}
inline void IncLine(int inc) {To_Line += inc;}
inline bool IsRead(void) {return Txfp->IsRead;}
inline PXOB *GetLink(void) {return To_Link;}
//inline PCOL *GetKeyCol(void) {return To_Key_Col;}
// Implementation
virtual AMT GetAmType(void) {return Txfp->GetAmType();}
virtual PSZ GetFile(PGLOBAL g) {return Txfp->To_File;}
virtual void SetFile(PGLOBAL g, PSZ fn) {Txfp->To_File = fn;}
virtual RECFM GetFtype(void) {return Ftype;}
virtual bool SkipHeader(PGLOBAL g) {return false;}
virtual void RestoreNrec(void) {Txfp->SetNrec(1);}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBDOS(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual void ResetDB(void) {Txfp->Reset();}
virtual bool IsUsingTemp(PGLOBAL g);
//virtual bool NeedIndexing(PGLOBAL g);
virtual void ResetSize(void) {MaxSize = Cardinal = -1;}
virtual int ResetTableOpt(PGLOBAL g, bool dox);
//virtual int MakeBlockValues(PGLOBAL g);
//virtual bool SaveBlockValues(PGLOBAL g);
//virtual bool GetBlockValues(PGLOBAL g);
//virtual PBF InitBlockFilter(PGLOBAL g, PFIL filp);
//virtual PBX InitBlockIndex(PGLOBAL g);
//virtual int TestBlock(PGLOBAL g);
virtual void PrintAM(FILE *f, char *m);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual char *GetOpenMode(PGLOBAL g, char *opmode) {return NULL;}
virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);}
virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void);
virtual int GetAffectedRows(void) {return Txfp->GetDelRows();}
virtual int GetRecpos(void) {return Txfp->GetPos();}
virtual bool SetRecpos(PGLOBAL g, int recpos)
{return Txfp->SetPos(g, recpos);}
virtual int RowNumber(PGLOBAL g, bool b = false);
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g) {return Txfp->ReadBuffer(g);}
// Specific routine
virtual int EstimatedLength(PGLOBAL g);
// Optimization routines
// void ResetBlockFilter(PGLOBAL g);
int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add);
// bool GetDistinctColumnValues(PGLOBAL g, int nrec);
protected:
// PBF CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv);
// Members
PTXF Txfp; // To the File access method class
//PBX To_BlkIdx; // To index test block
//PBF To_BlkFil; // To evaluation block filter
//PFIL SavFil; // Saved hidden filter
char *To_Line; // Points to current processed line
int Cardinal; // Table Cardinality
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT)
int Lrecl; // Logical Record Length
int AvgLen; // Logical Record Average Length
//int Xeval; // BlockTest return value
//int Beval; // BlockEval return value
}; // end of class TDBDOS
/***********************************************************************/
/* Class DOSCOL: DOS access method column descriptor. */
/* This A.M. is used for text file tables under operating systems */
/* DOS, OS2, UNIX, WIN16 and WIN32. */
/***********************************************************************/
class DllExport DOSCOL : public COLBLK {
friend class TDBDOS;
friend class TDBFIX;
public:
// Constructors
DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "DOS");
DOSCOL(DOSCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_DOS;}
//virtual int GetClustered(void) {return Clustered;}
//virtual int IsClustered(void) {return (Clustered &&
// ((PDOSDEF)(((PTDBDOS)To_Tdb)->To_Def))->IsOptimized());}
//virtual int IsSorted(void) {return Sorted;}
virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
//virtual PVBLK GetMin(void) {return Min;}
//virtual PVBLK GetMax(void) {return Max;}
//virtual int GetNdv(void) {return Ndv;}
//virtual int GetNbm(void) {return Nbm;}
//virtual PVBLK GetBmap(void) {return Bmap;}
//virtual PVBLK GetDval(void) {return Dval;}
// Methods
virtual bool VarSize(void);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint);
protected:
//virtual bool SetMinMax(PGLOBAL g);
//virtual bool SetBitMap(PGLOBAL g);
// bool CheckSorted(PGLOBAL g);
// bool AddDistinctValue(PGLOBAL g);
// Default constructor not to be used
DOSCOL(void) {}
// Members
//PVBLK Min; // Array of block min values
//PVBLK Max; // Array of block max values
//PVBLK Bmap; // Array of block bitmap values
//PVBLK Dval; // Array of column distinct values
PVAL To_Val; // To value used for Update/Insert
PVAL OldVal; // The previous value of the object.
char *Buf; // Buffer used in write operations
bool Ldz; // True if field contains leading zeros
bool Nod; // True if no decimal point
int Dcm; // Last Dcm digits are decimals
//int Clustered; // 0:No 1:Yes
//int Sorted; // 0:No 1:Asc (2:Desc - NIY)
int Deplac; // Offset in dos_buf
//int Ndv; // Number of distinct values
//int Nbm; // Number of uint in bitmap
}; // end of class DOSCOL
#endif // __TABDOS_H
/*************** TabDos H Declares Source Code File (.H) ***************/
/* Name: TABDOS.H Version 3.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */
/* */
/* This file contains the DOS classes declares. */
/***********************************************************************/
#ifndef __TABDOS_H
#define __TABDOS_H
#include "xtable.h" // Table base class declares
#include "colblk.h" // Column base class declares
#include "xindex.h"
typedef struct _tabdesc *PTABD; // For friend setting
typedef class TXTFAM *PTXF;
/***********************************************************************/
/* DOS table. */
/***********************************************************************/
class DllExport DOSDEF : public TABDEF { /* Logical table description */
friend class OEMDEF;
friend class TDBDOS;
friend class TDBFIX;
friend class TXTFAM;
friend class DBFBASE;
public:
// Constructor
DOSDEF(void);
// Implementation
virtual AMT GetDefType(void) {return TYPE_AM_DOS;}
virtual const char *GetType(void) {return "DOS";}
virtual PIXDEF GetIndx(void) {return To_Indx;}
virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;}
PSZ GetOfn(void) {return Ofn;}
void SetBlock(int block) {Block = block;}
int GetBlock(void) {return Block;}
int GetLast(void) {return Last;}
void SetLast(int last) {Last = last;}
int GetLrecl(void) {return Lrecl;}
void SetLrecl(int lrecl) {Lrecl = lrecl;}
bool GetPadded(void) {return Padded;}
bool GetEof(void) {return Eof;}
int GetBlksize(void) {return Blksize;}
int GetEnding(void) {return Ending;}
int *GetTo_Pos(void) {return To_Pos;}
virtual bool IsHuge(void) {return Huge;}
// Methods
virtual bool DeleteTableFile(PGLOBAL g);
virtual bool Indexable(void) {return Compressed != 1;}
virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
bool InvalidateIndex(PGLOBAL g);
protected:
virtual bool Erase(char *filename);
// Members
PSZ Fn; /* Path/Name of corresponding file */
PSZ Ofn; /* Base Path/Name of matching index files*/
PIXDEF To_Indx; /* To index definitions blocks */
RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */
bool Mapped; /* 0: disk file, 1: memory mapped file */
bool Padded; /* true for padded table file */
bool Huge; /* true for files larger than 2GB */
bool Accept; /* true if wrong lines are accepted (DBF)*/
bool Eof; /* true if an EOF (0xA) character exists */
int *To_Pos; /* To array of block starting positions */
int Compressed; /* 0: No, 1: gz, 2:zlib compressed file */
int Lrecl; /* Size of biggest record */
int AvgLen; /* Average size of records */
int Block; /* Number de blocks of FIX/VCT tables */
int Last; /* Number of elements of last block */
int Blksize; /* Size of padded blocks */
int Maxerr; /* Maximum number of bad records (DBF) */
int ReadMode; /* Specific to DBF */
int Ending; /* Length of end of lines */
}; // end of DOSDEF
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* that are standard files with columns starting at fixed offset. */
/* The last column (and record) is of variable length. */
/***********************************************************************/
class DllExport TDBDOS : public TDBASE {
//friend class KINDEX;
friend class XINDEX;
friend class DOSCOL;
friend class MAPCOL;
friend class TXTFAM;
friend class DOSFAM;
friend class VCTCOL;
//friend class TDBMUL;
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
public:
// Constructors
TDBDOS(PDOSDEF tdp, PTXF txfp);
TDBDOS(PGLOBAL g, PTDBDOS tdbp);
// Inline functions
inline void SetTxfp(PTXF txfp) {Txfp = txfp; Txfp->SetTdbp(this);}
inline PTXF GetTxfp(void) {return Txfp;}
inline char *GetLine(void) {return To_Line;}
inline int GetCurBlk(void) {return Txfp->GetCurBlk();}
inline void SetLine(char *toline) {To_Line = toline;}
inline void IncLine(int inc) {To_Line += inc;}
inline bool IsRead(void) {return Txfp->IsRead;}
inline PXOB *GetLink(void) {return To_Link;}
//inline PCOL *GetKeyCol(void) {return To_Key_Col;}
// Implementation
virtual AMT GetAmType(void) {return Txfp->GetAmType();}
virtual PSZ GetFile(PGLOBAL g) {return Txfp->To_File;}
virtual void SetFile(PGLOBAL g, PSZ fn) {Txfp->To_File = fn;}
virtual RECFM GetFtype(void) {return Ftype;}
virtual bool SkipHeader(PGLOBAL g) {return false;}
virtual void RestoreNrec(void) {Txfp->SetNrec(1);}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBDOS(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual void ResetDB(void) {Txfp->Reset();}
virtual bool IsUsingTemp(PGLOBAL g);
//virtual bool NeedIndexing(PGLOBAL g);
virtual void ResetSize(void) {MaxSize = Cardinal = -1;}
virtual int ResetTableOpt(PGLOBAL g, bool dox);
//virtual int MakeBlockValues(PGLOBAL g);
//virtual bool SaveBlockValues(PGLOBAL g);
//virtual bool GetBlockValues(PGLOBAL g);
//virtual PBF InitBlockFilter(PGLOBAL g, PFIL filp);
//virtual PBX InitBlockIndex(PGLOBAL g);
//virtual int TestBlock(PGLOBAL g);
virtual void PrintAM(FILE *f, char *m);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual char *GetOpenMode(PGLOBAL g, char *opmode) {return NULL;}
virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);}
virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void);
virtual int GetAffectedRows(void) {return Txfp->GetDelRows();}
virtual int GetRecpos(void) {return Txfp->GetPos();}
virtual bool SetRecpos(PGLOBAL g, int recpos)
{return Txfp->SetPos(g, recpos);}
virtual int RowNumber(PGLOBAL g, bool b = false);
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g) {return Txfp->ReadBuffer(g);}
// Specific routine
virtual int EstimatedLength(PGLOBAL g);
// Optimization routines
// void ResetBlockFilter(PGLOBAL g);
int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add);
// bool GetDistinctColumnValues(PGLOBAL g, int nrec);
protected:
// PBF CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv);
// Members
PTXF Txfp; // To the File access method class
//PBX To_BlkIdx; // To index test block
//PBF To_BlkFil; // To evaluation block filter
//PFIL SavFil; // Saved hidden filter
char *To_Line; // Points to current processed line
int Cardinal; // Table Cardinality
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT)
int Lrecl; // Logical Record Length
int AvgLen; // Logical Record Average Length
//int Xeval; // BlockTest return value
//int Beval; // BlockEval return value
}; // end of class TDBDOS
/***********************************************************************/
/* Class DOSCOL: DOS access method column descriptor. */
/* This A.M. is used for text file tables under operating systems */
/* DOS, OS2, UNIX, WIN16 and WIN32. */
/***********************************************************************/
class DllExport DOSCOL : public COLBLK {
friend class TDBDOS;
friend class TDBFIX;
public:
// Constructors
DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "DOS");
DOSCOL(DOSCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_DOS;}
//virtual int GetClustered(void) {return Clustered;}
//virtual int IsClustered(void) {return (Clustered &&
// ((PDOSDEF)(((PTDBDOS)To_Tdb)->To_Def))->IsOptimized());}
//virtual int IsSorted(void) {return Sorted;}
virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
//virtual PVBLK GetMin(void) {return Min;}
//virtual PVBLK GetMax(void) {return Max;}
//virtual int GetNdv(void) {return Ndv;}
//virtual int GetNbm(void) {return Nbm;}
//virtual PVBLK GetBmap(void) {return Bmap;}
//virtual PVBLK GetDval(void) {return Dval;}
// Methods
virtual bool VarSize(void);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint);
protected:
//virtual bool SetMinMax(PGLOBAL g);
//virtual bool SetBitMap(PGLOBAL g);
// bool CheckSorted(PGLOBAL g);
// bool AddDistinctValue(PGLOBAL g);
// Default constructor not to be used
DOSCOL(void) {}
// Members
//PVBLK Min; // Array of block min values
//PVBLK Max; // Array of block max values
//PVBLK Bmap; // Array of block bitmap values
//PVBLK Dval; // Array of column distinct values
PVAL To_Val; // To value used for Update/Insert
PVAL OldVal; // The previous value of the object.
char *Buf; // Buffer used in write operations
bool Ldz; // True if field contains leading zeros
bool Nod; // True if no decimal point
int Dcm; // Last Dcm digits are decimals
//int Clustered; // 0:No 1:Yes
//int Sorted; // 0:No 1:Asc (2:Desc - NIY)
int Deplac; // Offset in dos_buf
//int Ndv; // Number of distinct values
//int Nbm; // Number of uint in bitmap
}; // end of class DOSCOL
#endif // __TABDOS_H

View File

@@ -1,492 +1,492 @@
/************* TabFix C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABFIX */
/* ------------- */
/* Version 4.8 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
/* This program are the TDBFIX class DB routines. */
/* */
/***********************************************************************/
/***********************************************************************/
/* Include relevant section of system dependant header files. */
/***********************************************************************/
#include "my_global.h"
#if defined(WIN32)
#include <io.h>
#include <fcntl.h>
#include <errno.h>
#if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__
//#include <windows.h>
#else // !WIN32
#if defined(UNIX)
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#else // !UNIX
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
#endif // !WIN32
/***********************************************************************/
/* Include application header files: */
/***********************************************************************/
#include "global.h" // global declares
#include "plgdbsem.h" // DB application declares
#include "filamfix.h"
#include "filamdbf.h"
#include "tabfix.h" // TDBFIX, FIXCOL classes declares
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
extern "C" int trace;
extern int num_read, num_there, num_eq[2]; // Statistics
static const longlong M2G = 0x80000000;
static const longlong M4G = (longlong)2 * M2G;
/* ------------------------------------------------------------------- */
/***********************************************************************/
/* Implementation of the TDBFIX class. */
/***********************************************************************/
TDBFIX::TDBFIX(PDOSDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
{
//Cardinal = -1;
} // end of TDBFIX standard constructor
TDBFIX::TDBFIX(PGLOBAL g, PTDBFIX tdbp) : TDBDOS(g, tdbp)
{
//Cardinal = tdbp->Cardinal;
} // end of TDBFIX copy constructor
// Method
PTDB TDBFIX::CopyOne(PTABS t)
{
PTDB tp;
PGLOBAL g = t->G;
tp = new(g) TDBFIX(g, this);
if (Ftype < 2) {
// File is text
PDOSCOL cp1, cp2;
for (cp1 = (PDOSCOL)Columns; cp1; cp1 = (PDOSCOL)cp1->GetNext()) {
cp2 = new(g) DOSCOL(cp1, tp); // Make a copy
NewPointer(t, cp1, cp2);
} // endfor cp1
} else {
// File is binary
PBINCOL cp1, cp2;
for (cp1 = (PBINCOL)Columns; cp1; cp1 = (PBINCOL)cp1->GetNext()) {
cp2 = new(g) BINCOL(cp1, tp); // Make a copy
NewPointer(t, cp1, cp2);
} // endfor cp1
} // endif Ftype
return tp;
} // end of CopyOne
/***********************************************************************/
/* Reset read/write position values. */
/***********************************************************************/
void TDBFIX::ResetDB(void)
{
TDBDOS::ResetDB();
} // end of ResetDB
/***********************************************************************/
/* Allocate FIX (DOS) or BIN column description block. */
/***********************************************************************/
PCOL TDBFIX::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
{
if (Ftype == RECFM_BIN)
return new(g) BINCOL(g, cdp, this, cprec, n);
else
return new(g) DOSCOL(g, cdp, this, cprec, n);
} // end of MakeCol
/***********************************************************************/
/* Remake the indexes after the table was modified. */
/***********************************************************************/
int TDBFIX::ResetTableOpt(PGLOBAL g, bool dox)
{
RestoreNrec(); // May have been modified
return TDBDOS::ResetTableOpt(g, dox);
} // end of ResetTableOpt
/***********************************************************************/
/* Reset the Nrec and BlkSize values that can have been modified. */
/***********************************************************************/
void TDBFIX::RestoreNrec(void)
{
if (!Txfp->Padded) {
Txfp->Nrec = (To_Def && To_Def->GetElemt()) ? To_Def->GetElemt()
: DOS_BUFF_LEN;
Txfp->Blksize = Txfp->Nrec * Txfp->Lrecl;
} // endif Padded
} // end of RestoreNrec
/***********************************************************************/
/* FIX Cardinality: returns table cardinality in number of rows. */
/* This function can be called with a null argument to test the */
/* availability of Cardinality implementation (1 yes, 0 no). */
/***********************************************************************/
int TDBFIX::Cardinality(PGLOBAL g)
{
if (!g)
return Txfp->Cardinality(g);
if (Cardinal < 0)
Cardinal = Txfp->Cardinality(g);
return Cardinal;
} // end of Cardinality
/***********************************************************************/
/* FIX GetMaxSize: returns file size in number of lines. */
/***********************************************************************/
int TDBFIX::GetMaxSize(PGLOBAL g)
{
if (MaxSize < 0)
MaxSize = Cardinality(g);
return MaxSize;
} // end of GetMaxSize
/***********************************************************************/
/* FIX ResetSize: Must reset Headlen for DBF tables only. */
/***********************************************************************/
void TDBFIX::ResetSize(void)
{
if (Txfp->GetAmType() == TYPE_AM_DBF)
Txfp->Headlen = 0;
MaxSize = Cardinal = -1;
} // end of ResetSize
/***********************************************************************/
/* FIX GetProgMax: get the max value for progress information. */
/***********************************************************************/
int TDBFIX::GetProgMax(PGLOBAL g)
{
return Cardinality(g);
} // end of GetProgMax
/***********************************************************************/
/* RowNumber: return the ordinal number of the current row. */
/***********************************************************************/
int TDBFIX::RowNumber(PGLOBAL g, bool b)
{
if (Txfp->GetAmType() == TYPE_AM_DBF) {
if (!b && To_Kindex) {
/*****************************************************************/
/* Don't know how to retrieve Rows from DBF file address */
/* because of eventual deleted lines still in the file. */
/*****************************************************************/
sprintf(g->Message, MSG(NO_ROWID_FOR_AM),
GetAmName(g, Txfp->GetAmType()));
return 0;
} // endif To_Kindex
if (!b)
return Txfp->GetRows();
} // endif DBF
return Txfp->GetRowID();
} // end of RowNumber
/***********************************************************************/
/* FIX tables don't use temporary files except if specified as do it. */
/***********************************************************************/
bool TDBFIX::IsUsingTemp(PGLOBAL g)
{
USETEMP usetemp = PlgGetUser(g)->UseTemp;
return (usetemp == TMP_YES || usetemp == TMP_FORCE);
} // end of IsUsingTemp
/***********************************************************************/
/* FIX Access Method opening routine (also used by the BIN a.m.) */
/* New method now that this routine is called recursively (last table */
/* first in reverse order): index blocks are immediately linked to */
/* join block of next table if it exists or else are discarted. */
/***********************************************************************/
bool TDBFIX::OpenDB(PGLOBAL g)
{
if (trace)
htrc("FIX OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d Ftype=%d\n",
this, Tdb_No, Use, To_Key_Col, Mode, Ftype);
if (Use == USE_OPEN) {
/*******************************************************************/
/* Table already open, just replace it at its beginning. */
/*******************************************************************/
if (To_Kindex)
/*****************************************************************/
/* Table is to be accessed through a sorted index table. */
/*****************************************************************/
To_Kindex->Reset();
else
Txfp->Rewind(); // see comment in Work.log
return false;
} // endif use
/*********************************************************************/
/* Call Cardinality to calculate Block in the case of Func queries. */
/* and also in the case of multiple tables. */
/*********************************************************************/
if (Cardinality(g) < 0)
return true;
/*********************************************************************/
/* Open according to required logical input/output mode. */
/* Use conventionnal input/output functions. */
/* Treat fixed length text files as binary. */
/*********************************************************************/
if (Txfp->OpenTableFile(g))
return true;
Use = USE_OPEN; // Do it now in case we are recursively called
/*********************************************************************/
/* Initialize To_Line at the beginning of the block buffer. */
/*********************************************************************/
To_Line = Txfp->GetBuf(); // For WriteDB
if (trace)
htrc("OpenDos: R%hd mode=%d\n", Tdb_No, Mode);
/*********************************************************************/
/* Reset buffer access according to indexing and to mode. */
/*********************************************************************/
Txfp->ResetBuffer(g);
/*********************************************************************/
/* Reset statistics values. */
/*********************************************************************/
num_read = num_there = num_eq[0] = num_eq[1] = 0;
return false;
} // end of OpenDB
/***********************************************************************/
/* WriteDB: Data Base write routine for FIX access method. */
/***********************************************************************/
int TDBFIX::WriteDB(PGLOBAL g)
{
return Txfp->WriteBuffer(g);
} // end of WriteDB
// ------------------------ BINCOL functions ----------------------------
/***********************************************************************/
/* BINCOL public constructor. */
/***********************************************************************/
BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
: DOSCOL(g, cdp, tp, cp, i, am)
{
Fmt = (cdp->GetFmt()) ? toupper(*cdp->GetFmt()) : 'X';
} // end of BINCOL constructor
/***********************************************************************/
/* FIXCOL constructor used for copying columns. */
/* tdbp is the pointer to the new table descriptor. */
/***********************************************************************/
BINCOL::BINCOL(BINCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
{
Fmt = col1->Fmt;
} // end of BINCOL copy constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to access the last line */
/* read from the corresponding table and extract from it the field */
/* corresponding to this column. */
/***********************************************************************/
void BINCOL::ReadColumn(PGLOBAL g)
{
char *p;
int rc;
PTDBFIX tdbp = (PTDBFIX)To_Tdb;
if (trace)
htrc("BIN ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type);
/*********************************************************************/
/* If physical reading of the line was deferred, do it now. */
/*********************************************************************/
if (!tdbp->IsRead())
if ((rc = tdbp->ReadBuffer(g)) != RC_OK) {
if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc);
longjmp(g->jumper[g->jump_level], 11);
} // endif
p = tdbp->To_Line + Deplac;
/*********************************************************************/
/* Set Value from the line field. */
/*********************************************************************/
switch (Fmt) {
case 'X': // Standard not converted values
Value->SetBinValue(p);
break;
case 'S': // Short integer
Value->SetValue((int)*(short*)p);
break;
case 'T': // Tiny integer
Value->SetValue((int)*p);
break;
case 'L': // Long Integer
strcpy(g->Message, "Format L is deprecated, use I");
longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer
Value->SetValue(*(int*)p);
break;
case 'F': // Float
case 'R': // Real
Value->SetValue((double)*(float*)p);
break;
case 'D': // Double
Value->SetValue(*(double*)p);
break;
case 'C': // Text
Value->SetValue_char(p, Long);
break;
default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
longjmp(g->jumper[g->jump_level], 11);
} // endswitch Fmt
} // end of ReadColumn
/***********************************************************************/
/* WriteColumn: what this routine does is to access the last line */
/* read from the corresponding table, and rewrite the field */
/* corresponding to this column from the column buffer. */
/***********************************************************************/
void BINCOL::WriteColumn(PGLOBAL g)
{
char *p, *s;
longlong n;
PTDBFIX tdbp = (PTDBFIX)To_Tdb;
if (trace) {
htrc("BIN WriteColumn: col %s R%d coluse=%.4X status=%.4X",
Name, tdbp->GetTdb_No(), ColUse, Status);
htrc(" Lrecl=%d\n", tdbp->Lrecl);
htrc("Long=%d deplac=%d coltype=%d ftype=%c\n",
Long, Deplac, Buf_Type, *Format.Type);
} // endif trace
/*********************************************************************/
/* Check whether the new value has to be converted to Buf_Type. */
/*********************************************************************/
if (Value != To_Val)
Value->SetValue_pval(To_Val, false); // Convert the updated value
p = tdbp->To_Line + Deplac;
/*********************************************************************/
/* Check whether updating is Ok, meaning col value is not too long. */
/* Updating will be done only during the second pass (Status=true) */
/* Conversion occurs if the external format Fmt is specified. */
/*********************************************************************/
switch (Fmt) {
case 'X':
// Standard not converted values
if (Value->GetBinValue(p, Long, Status)) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG),
Name, Value->GetSize(), Long);
longjmp(g->jumper[g->jump_level], 31);
} // endif Fmt
break;
case 'S': // Short integer
n = Value->GetBigintValue();
if (n > 32767LL || n < -32768LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31);
} else if (Status)
*(short *)p = (short)n;
break;
case 'T': // Tiny integer
n = Value->GetBigintValue();
if (n > 255LL || n < -256LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31);
} else if (Status)
*p = (char)n;
break;
case 'L': // Long Integer
strcpy(g->Message, "Format L is deprecated, use I");
longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer
n = Value->GetBigintValue();
if (n > INT_MAX || n < INT_MIN) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31);
} else if (Status)
*(int *)p = Value->GetIntValue();
break;
case 'B': // Large (big) integer
if (Status)
*(longlong *)p = (longlong)Value->GetBigintValue();
break;
case 'F': // Float
case 'R': // Real
if (Status)
*(float *)p = (float)Value->GetFloatValue();
break;
case 'D': // Double
if (Status)
*(double *)p = Value->GetFloatValue();
break;
case 'C': // Characters
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, n, Long);
longjmp(g->jumper[g->jump_level], 31);
} // endif n
if (Status) {
s = Value->GetCharString(Buf);
memset(p, ' ', Long);
memcpy(p, s, strlen(s));
} // endif Status
break;
default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
longjmp(g->jumper[g->jump_level], 11);
} // endswitch Fmt
} // end of WriteColumn
/* ------------------------ End of TabFix ---------------------------- */
/************* TabFix C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABFIX */
/* ------------- */
/* Version 4.8 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
/* This program are the TDBFIX class DB routines. */
/* */
/***********************************************************************/
/***********************************************************************/
/* Include relevant section of system dependant header files. */
/***********************************************************************/
#include "my_global.h"
#if defined(WIN32)
#include <io.h>
#include <fcntl.h>
#include <errno.h>
#if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__
//#include <windows.h>
#else // !WIN32
#if defined(UNIX)
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#else // !UNIX
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
#endif // !WIN32
/***********************************************************************/
/* Include application header files: */
/***********************************************************************/
#include "global.h" // global declares
#include "plgdbsem.h" // DB application declares
#include "filamfix.h"
#include "filamdbf.h"
#include "tabfix.h" // TDBFIX, FIXCOL classes declares
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
extern "C" int trace;
extern int num_read, num_there, num_eq[2]; // Statistics
static const longlong M2G = 0x80000000;
static const longlong M4G = (longlong)2 * M2G;
/* ------------------------------------------------------------------- */
/***********************************************************************/
/* Implementation of the TDBFIX class. */
/***********************************************************************/
TDBFIX::TDBFIX(PDOSDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
{
//Cardinal = -1;
} // end of TDBFIX standard constructor
TDBFIX::TDBFIX(PGLOBAL g, PTDBFIX tdbp) : TDBDOS(g, tdbp)
{
//Cardinal = tdbp->Cardinal;
} // end of TDBFIX copy constructor
// Method
PTDB TDBFIX::CopyOne(PTABS t)
{
PTDB tp;
PGLOBAL g = t->G;
tp = new(g) TDBFIX(g, this);
if (Ftype < 2) {
// File is text
PDOSCOL cp1, cp2;
for (cp1 = (PDOSCOL)Columns; cp1; cp1 = (PDOSCOL)cp1->GetNext()) {
cp2 = new(g) DOSCOL(cp1, tp); // Make a copy
NewPointer(t, cp1, cp2);
} // endfor cp1
} else {
// File is binary
PBINCOL cp1, cp2;
for (cp1 = (PBINCOL)Columns; cp1; cp1 = (PBINCOL)cp1->GetNext()) {
cp2 = new(g) BINCOL(cp1, tp); // Make a copy
NewPointer(t, cp1, cp2);
} // endfor cp1
} // endif Ftype
return tp;
} // end of CopyOne
/***********************************************************************/
/* Reset read/write position values. */
/***********************************************************************/
void TDBFIX::ResetDB(void)
{
TDBDOS::ResetDB();
} // end of ResetDB
/***********************************************************************/
/* Allocate FIX (DOS) or BIN column description block. */
/***********************************************************************/
PCOL TDBFIX::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
{
if (Ftype == RECFM_BIN)
return new(g) BINCOL(g, cdp, this, cprec, n);
else
return new(g) DOSCOL(g, cdp, this, cprec, n);
} // end of MakeCol
/***********************************************************************/
/* Remake the indexes after the table was modified. */
/***********************************************************************/
int TDBFIX::ResetTableOpt(PGLOBAL g, bool dox)
{
RestoreNrec(); // May have been modified
return TDBDOS::ResetTableOpt(g, dox);
} // end of ResetTableOpt
/***********************************************************************/
/* Reset the Nrec and BlkSize values that can have been modified. */
/***********************************************************************/
void TDBFIX::RestoreNrec(void)
{
if (!Txfp->Padded) {
Txfp->Nrec = (To_Def && To_Def->GetElemt()) ? To_Def->GetElemt()
: DOS_BUFF_LEN;
Txfp->Blksize = Txfp->Nrec * Txfp->Lrecl;
} // endif Padded
} // end of RestoreNrec
/***********************************************************************/
/* FIX Cardinality: returns table cardinality in number of rows. */
/* This function can be called with a null argument to test the */
/* availability of Cardinality implementation (1 yes, 0 no). */
/***********************************************************************/
int TDBFIX::Cardinality(PGLOBAL g)
{
if (!g)
return Txfp->Cardinality(g);
if (Cardinal < 0)
Cardinal = Txfp->Cardinality(g);
return Cardinal;
} // end of Cardinality
/***********************************************************************/
/* FIX GetMaxSize: returns file size in number of lines. */
/***********************************************************************/
int TDBFIX::GetMaxSize(PGLOBAL g)
{
if (MaxSize < 0)
MaxSize = Cardinality(g);
return MaxSize;
} // end of GetMaxSize
/***********************************************************************/
/* FIX ResetSize: Must reset Headlen for DBF tables only. */
/***********************************************************************/
void TDBFIX::ResetSize(void)
{
if (Txfp->GetAmType() == TYPE_AM_DBF)
Txfp->Headlen = 0;
MaxSize = Cardinal = -1;
} // end of ResetSize
/***********************************************************************/
/* FIX GetProgMax: get the max value for progress information. */
/***********************************************************************/
int TDBFIX::GetProgMax(PGLOBAL g)
{
return Cardinality(g);
} // end of GetProgMax
/***********************************************************************/
/* RowNumber: return the ordinal number of the current row. */
/***********************************************************************/
int TDBFIX::RowNumber(PGLOBAL g, bool b)
{
if (Txfp->GetAmType() == TYPE_AM_DBF) {
if (!b && To_Kindex) {
/*****************************************************************/
/* Don't know how to retrieve Rows from DBF file address */
/* because of eventual deleted lines still in the file. */
/*****************************************************************/
sprintf(g->Message, MSG(NO_ROWID_FOR_AM),
GetAmName(g, Txfp->GetAmType()));
return 0;
} // endif To_Kindex
if (!b)
return Txfp->GetRows();
} // endif DBF
return Txfp->GetRowID();
} // end of RowNumber
/***********************************************************************/
/* FIX tables don't use temporary files except if specified as do it. */
/***********************************************************************/
bool TDBFIX::IsUsingTemp(PGLOBAL g)
{
USETEMP usetemp = PlgGetUser(g)->UseTemp;
return (usetemp == TMP_YES || usetemp == TMP_FORCE);
} // end of IsUsingTemp
/***********************************************************************/
/* FIX Access Method opening routine (also used by the BIN a.m.) */
/* New method now that this routine is called recursively (last table */
/* first in reverse order): index blocks are immediately linked to */
/* join block of next table if it exists or else are discarted. */
/***********************************************************************/
bool TDBFIX::OpenDB(PGLOBAL g)
{
if (trace)
htrc("FIX OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d Ftype=%d\n",
this, Tdb_No, Use, To_Key_Col, Mode, Ftype);
if (Use == USE_OPEN) {
/*******************************************************************/
/* Table already open, just replace it at its beginning. */
/*******************************************************************/
if (To_Kindex)
/*****************************************************************/
/* Table is to be accessed through a sorted index table. */
/*****************************************************************/
To_Kindex->Reset();
else
Txfp->Rewind(); // see comment in Work.log
return false;
} // endif use
/*********************************************************************/
/* Call Cardinality to calculate Block in the case of Func queries. */
/* and also in the case of multiple tables. */
/*********************************************************************/
if (Cardinality(g) < 0)
return true;
/*********************************************************************/
/* Open according to required logical input/output mode. */
/* Use conventionnal input/output functions. */
/* Treat fixed length text files as binary. */
/*********************************************************************/
if (Txfp->OpenTableFile(g))
return true;
Use = USE_OPEN; // Do it now in case we are recursively called
/*********************************************************************/
/* Initialize To_Line at the beginning of the block buffer. */
/*********************************************************************/
To_Line = Txfp->GetBuf(); // For WriteDB
if (trace)
htrc("OpenDos: R%hd mode=%d\n", Tdb_No, Mode);
/*********************************************************************/
/* Reset buffer access according to indexing and to mode. */
/*********************************************************************/
Txfp->ResetBuffer(g);
/*********************************************************************/
/* Reset statistics values. */
/*********************************************************************/
num_read = num_there = num_eq[0] = num_eq[1] = 0;
return false;
} // end of OpenDB
/***********************************************************************/
/* WriteDB: Data Base write routine for FIX access method. */
/***********************************************************************/
int TDBFIX::WriteDB(PGLOBAL g)
{
return Txfp->WriteBuffer(g);
} // end of WriteDB
// ------------------------ BINCOL functions ----------------------------
/***********************************************************************/
/* BINCOL public constructor. */
/***********************************************************************/
BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
: DOSCOL(g, cdp, tp, cp, i, am)
{
Fmt = (cdp->GetFmt()) ? toupper(*cdp->GetFmt()) : 'X';
} // end of BINCOL constructor
/***********************************************************************/
/* FIXCOL constructor used for copying columns. */
/* tdbp is the pointer to the new table descriptor. */
/***********************************************************************/
BINCOL::BINCOL(BINCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
{
Fmt = col1->Fmt;
} // end of BINCOL copy constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to access the last line */
/* read from the corresponding table and extract from it the field */
/* corresponding to this column. */
/***********************************************************************/
void BINCOL::ReadColumn(PGLOBAL g)
{
char *p;
int rc;
PTDBFIX tdbp = (PTDBFIX)To_Tdb;
if (trace)
htrc("BIN ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type);
/*********************************************************************/
/* If physical reading of the line was deferred, do it now. */
/*********************************************************************/
if (!tdbp->IsRead())
if ((rc = tdbp->ReadBuffer(g)) != RC_OK) {
if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc);
longjmp(g->jumper[g->jump_level], 11);
} // endif
p = tdbp->To_Line + Deplac;
/*********************************************************************/
/* Set Value from the line field. */
/*********************************************************************/
switch (Fmt) {
case 'X': // Standard not converted values
Value->SetBinValue(p);
break;
case 'S': // Short integer
Value->SetValue((int)*(short*)p);
break;
case 'T': // Tiny integer
Value->SetValue((int)*p);
break;
case 'L': // Long Integer
strcpy(g->Message, "Format L is deprecated, use I");
longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer
Value->SetValue(*(int*)p);
break;
case 'F': // Float
case 'R': // Real
Value->SetValue((double)*(float*)p);
break;
case 'D': // Double
Value->SetValue(*(double*)p);
break;
case 'C': // Text
Value->SetValue_char(p, Long);
break;
default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
longjmp(g->jumper[g->jump_level], 11);
} // endswitch Fmt
} // end of ReadColumn
/***********************************************************************/
/* WriteColumn: what this routine does is to access the last line */
/* read from the corresponding table, and rewrite the field */
/* corresponding to this column from the column buffer. */
/***********************************************************************/
void BINCOL::WriteColumn(PGLOBAL g)
{
char *p, *s;
longlong n;
PTDBFIX tdbp = (PTDBFIX)To_Tdb;
if (trace) {
htrc("BIN WriteColumn: col %s R%d coluse=%.4X status=%.4X",
Name, tdbp->GetTdb_No(), ColUse, Status);
htrc(" Lrecl=%d\n", tdbp->Lrecl);
htrc("Long=%d deplac=%d coltype=%d ftype=%c\n",
Long, Deplac, Buf_Type, *Format.Type);
} // endif trace
/*********************************************************************/
/* Check whether the new value has to be converted to Buf_Type. */
/*********************************************************************/
if (Value != To_Val)
Value->SetValue_pval(To_Val, false); // Convert the updated value
p = tdbp->To_Line + Deplac;
/*********************************************************************/
/* Check whether updating is Ok, meaning col value is not too long. */
/* Updating will be done only during the second pass (Status=true) */
/* Conversion occurs if the external format Fmt is specified. */
/*********************************************************************/
switch (Fmt) {
case 'X':
// Standard not converted values
if (Value->GetBinValue(p, Long, Status)) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG),
Name, Value->GetSize(), Long);
longjmp(g->jumper[g->jump_level], 31);
} // endif Fmt
break;
case 'S': // Short integer
n = Value->GetBigintValue();
if (n > 32767LL || n < -32768LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31);
} else if (Status)
*(short *)p = (short)n;
break;
case 'T': // Tiny integer
n = Value->GetBigintValue();
if (n > 255LL || n < -256LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31);
} else if (Status)
*p = (char)n;
break;
case 'L': // Long Integer
strcpy(g->Message, "Format L is deprecated, use I");
longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer
n = Value->GetBigintValue();
if (n > INT_MAX || n < INT_MIN) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31);
} else if (Status)
*(int *)p = Value->GetIntValue();
break;
case 'B': // Large (big) integer
if (Status)
*(longlong *)p = (longlong)Value->GetBigintValue();
break;
case 'F': // Float
case 'R': // Real
if (Status)
*(float *)p = (float)Value->GetFloatValue();
break;
case 'D': // Double
if (Status)
*(double *)p = Value->GetFloatValue();
break;
case 'C': // Characters
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
longjmp(g->jumper[g->jump_level], 31);
} // endif n
if (Status) {
s = Value->GetCharString(Buf);
memset(p, ' ', Long);
memcpy(p, s, strlen(s));
} // endif Status
break;
default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
longjmp(g->jumper[g->jump_level], 11);
} // endswitch Fmt
} // end of WriteColumn
/* ------------------------ End of TabFix ---------------------------- */

View File

@@ -1,80 +1,80 @@
/*************** TabDos H Declares Source Code File (.H) ***************/
/* Name: TABFIX.H Version 2.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */
/* */
/* This file contains the TDBFIX and (FIX/BIN)COL classes declares. */
/***********************************************************************/
#ifndef __TABFIX__
#define __TABFIX__
#include "tabdos.h" /* Base class declares */
typedef class FIXCOL *PFIXCOL;
typedef class BINCOL *PBINCOL;
typedef class TXTFAM *PTXF;
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* that are standard files with columns starting at fixed offset. */
/* This class is for fixed formatted files. */
/***********************************************************************/
class DllExport TDBFIX : public TDBDOS {
friend class FIXCOL;
friend class BINCOL;
public:
// Constructor
TDBFIX(PDOSDEF tdp, PTXF txfp);
TDBFIX(PGLOBAL g, PTDBFIX tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FIX;}
virtual void RestoreNrec(void);
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBFIX(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual void ResetDB(void);
virtual bool IsUsingTemp(PGLOBAL g);
virtual int RowNumber(PGLOBAL g, bool b = false);
virtual int ResetTableOpt(PGLOBAL g, bool dox);
virtual void ResetSize(void);
virtual int GetBadLines(void) {return Txfp->GetNerr();}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetProgMax(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
protected:
// Members are inherited from TDBDOS
}; // end of class TDBFIX
/***********************************************************************/
/* Class BINCOL: BIN access method column descriptor. */
/* This A.M. is used for file processed by blocks. */
/***********************************************************************/
class DllExport BINCOL : public DOSCOL {
friend class TDBFIX;
public:
// Constructors
BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "BIN");
BINCOL(BINCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_BIN;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
protected:
BINCOL(void) {} // Default constructor not to be used
// Members
char Fmt; // The column numeric format
}; // end of class BINCOL
#endif // __TABFIX__
/*************** TabDos H Declares Source Code File (.H) ***************/
/* Name: TABFIX.H Version 2.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */
/* */
/* This file contains the TDBFIX and (FIX/BIN)COL classes declares. */
/***********************************************************************/
#ifndef __TABFIX__
#define __TABFIX__
#include "tabdos.h" /* Base class declares */
typedef class FIXCOL *PFIXCOL;
typedef class BINCOL *PBINCOL;
typedef class TXTFAM *PTXF;
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* that are standard files with columns starting at fixed offset. */
/* This class is for fixed formatted files. */
/***********************************************************************/
class DllExport TDBFIX : public TDBDOS {
friend class FIXCOL;
friend class BINCOL;
public:
// Constructor
TDBFIX(PDOSDEF tdp, PTXF txfp);
TDBFIX(PGLOBAL g, PTDBFIX tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FIX;}
virtual void RestoreNrec(void);
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBFIX(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual void ResetDB(void);
virtual bool IsUsingTemp(PGLOBAL g);
virtual int RowNumber(PGLOBAL g, bool b = false);
virtual int ResetTableOpt(PGLOBAL g, bool dox);
virtual void ResetSize(void);
virtual int GetBadLines(void) {return Txfp->GetNerr();}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetProgMax(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
protected:
// Members are inherited from TDBDOS
}; // end of class TDBFIX
/***********************************************************************/
/* Class BINCOL: BIN access method column descriptor. */
/* This A.M. is used for file processed by blocks. */
/***********************************************************************/
class DllExport BINCOL : public DOSCOL {
friend class TDBFIX;
public:
// Constructors
BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "BIN");
BINCOL(BINCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_BIN;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
protected:
BINCOL(void) {} // Default constructor not to be used
// Members
char Fmt; // The column numeric format
}; // end of class BINCOL
#endif // __TABFIX__

File diff suppressed because it is too large Load Diff

View File

@@ -1,164 +1,164 @@
/*************** TabFmt H Declares Source Code File (.H) ***************/
/* Name: TABFMT.H Version 2.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2012 */
/* */
/* This file contains the CSV and FMT classes declares. */
/***********************************************************************/
#include "xtable.h" // Base class declares
#include "tabdos.h"
//pedef struct _tabdesc *PTABD; // For friend setting
typedef class TDBFMT *PTDBFMT;
/***********************************************************************/
/* CSV table. */
/***********************************************************************/
class DllExport CSVDEF : public DOSDEF { /* Logical table description */
friend class TDBCSV;
//friend class TDBMCV;
public:
// Constructor
CSVDEF(void);
// Implementation
virtual const char *GetType(void) {return "CSV";}
char GetSep(void) {return Sep;}
char GetQot(void) {return Qot;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected:
// Members
bool Fmtd; /* true for formatted files */
//bool Accept; /* true if wrong lines are accepted */
bool Header; /* true if first line contains headers */
//int Maxerr; /* Maximum number of bad records */
int Quoted; /* Quoting level for quoted fields */
char Sep; /* Separator for standard CSV files */
char Qot; /* Character for quoted strings */
}; // end of CSVDEF
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* that are CSV files with columns separated by the Sep character. */
/***********************************************************************/
class TDBCSV : public TDBDOS {
friend class CSVCOL;
public:
// Constructor
TDBCSV(PCSVDEF tdp, PTXF txfp);
TDBCSV(PGLOBAL g, PTDBCSV tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_CSV;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBCSV(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
//virtual bool IsUsingTemp(PGLOBAL g);
virtual int GetBadLines(void) {return (int)Nerr;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual bool OpenDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int CheckWrite(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); // Physical file read
// Specific routines
virtual int EstimatedLength(PGLOBAL g);
virtual bool SkipHeader(PGLOBAL g);
virtual bool CheckErr(void);
protected:
// Members
PSZ *Field; // Field to write to current line
int *Offset; // Column offsets for current record
int *Fldlen; // Column field length for current record
bool *Fldtyp; // true for numeric fields
int Fields; // Number of fields to handle
int Nerr; // Number of bad records
int Maxerr; // Maximum number of bad records
int Quoted; // Quoting level for quoted fields
bool Accept; // true if bad lines are accepted
bool Header; // true if first line contains column headers
char Sep; // Separator
char Qot; // Quoting character
}; // end of class TDBCSV
/***********************************************************************/
/* Class CSVCOL: CSV access method column descriptor. */
/* This A.M. is used for Comma Separated V(?) files. */
/***********************************************************************/
class CSVCOL : public DOSCOL {
friend class TDBCSV;
friend class TDBFMT;
public:
// Constructors
CSVCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
CSVCOL(CSVCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType() {return TYPE_AM_CSV;}
// Methods
virtual bool VarSize(void);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
// void Print(FILE *, uint);
protected:
// Default constructor not to be used
CSVCOL(void) {}
// Members
int Fldnum; // Field ordinal number (0 based)
}; // end of class CSVCOL
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* whose record format is described by a Format keyword. */
/***********************************************************************/
class TDBFMT : public TDBCSV {
friend class CSVCOL;
//friend class FMTCOL;
public:
// Standard constructor
TDBFMT(PCSVDEF tdp, PTXF txfp) : TDBCSV(tdp, txfp)
{FldFormat = NULL; To_Fld = NULL; FmtTest = NULL; Linenum = 0;}
// Copy constructor
TDBFMT(PGLOBAL g, PTDBFMT tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FMT;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBFMT(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
//virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
//virtual int CheckWrite(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); // Physical file read
// Specific routines
virtual int EstimatedLength(PGLOBAL g);
protected:
// Members
PSZ *FldFormat; // Field read format
void *To_Fld; // To field test buffer
int *FmtTest; // Test on ending by %n or %m
int Linenum; // Last read line
}; // end of class TDBFMT
/* ------------------------- End of TabFmt.H ------------------------- */
/*************** TabFmt H Declares Source Code File (.H) ***************/
/* Name: TABFMT.H Version 2.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2012 */
/* */
/* This file contains the CSV and FMT classes declares. */
/***********************************************************************/
#include "xtable.h" // Base class declares
#include "tabdos.h"
//pedef struct _tabdesc *PTABD; // For friend setting
typedef class TDBFMT *PTDBFMT;
/***********************************************************************/
/* CSV table. */
/***********************************************************************/
class DllExport CSVDEF : public DOSDEF { /* Logical table description */
friend class TDBCSV;
//friend class TDBMCV;
public:
// Constructor
CSVDEF(void);
// Implementation
virtual const char *GetType(void) {return "CSV";}
char GetSep(void) {return Sep;}
char GetQot(void) {return Qot;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected:
// Members
bool Fmtd; /* true for formatted files */
//bool Accept; /* true if wrong lines are accepted */
bool Header; /* true if first line contains headers */
//int Maxerr; /* Maximum number of bad records */
int Quoted; /* Quoting level for quoted fields */
char Sep; /* Separator for standard CSV files */
char Qot; /* Character for quoted strings */
}; // end of CSVDEF
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* that are CSV files with columns separated by the Sep character. */
/***********************************************************************/
class TDBCSV : public TDBDOS {
friend class CSVCOL;
public:
// Constructor
TDBCSV(PCSVDEF tdp, PTXF txfp);
TDBCSV(PGLOBAL g, PTDBCSV tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_CSV;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBCSV(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
//virtual bool IsUsingTemp(PGLOBAL g);
virtual int GetBadLines(void) {return (int)Nerr;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual bool OpenDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int CheckWrite(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); // Physical file read
// Specific routines
virtual int EstimatedLength(PGLOBAL g);
virtual bool SkipHeader(PGLOBAL g);
virtual bool CheckErr(void);
protected:
// Members
PSZ *Field; // Field to write to current line
int *Offset; // Column offsets for current record
int *Fldlen; // Column field length for current record
bool *Fldtyp; // true for numeric fields
int Fields; // Number of fields to handle
int Nerr; // Number of bad records
int Maxerr; // Maximum number of bad records
int Quoted; // Quoting level for quoted fields
bool Accept; // true if bad lines are accepted
bool Header; // true if first line contains column headers
char Sep; // Separator
char Qot; // Quoting character
}; // end of class TDBCSV
/***********************************************************************/
/* Class CSVCOL: CSV access method column descriptor. */
/* This A.M. is used for Comma Separated V(?) files. */
/***********************************************************************/
class CSVCOL : public DOSCOL {
friend class TDBCSV;
friend class TDBFMT;
public:
// Constructors
CSVCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
CSVCOL(CSVCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType() {return TYPE_AM_CSV;}
// Methods
virtual bool VarSize(void);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
// void Print(FILE *, uint);
protected:
// Default constructor not to be used
CSVCOL(void) {}
// Members
int Fldnum; // Field ordinal number (0 based)
}; // end of class CSVCOL
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* whose record format is described by a Format keyword. */
/***********************************************************************/
class TDBFMT : public TDBCSV {
friend class CSVCOL;
//friend class FMTCOL;
public:
// Standard constructor
TDBFMT(PCSVDEF tdp, PTXF txfp) : TDBCSV(tdp, txfp)
{FldFormat = NULL; To_Fld = NULL; FmtTest = NULL; Linenum = 0;}
// Copy constructor
TDBFMT(PGLOBAL g, PTDBFMT tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FMT;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBFMT(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
//virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
//virtual int CheckWrite(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); // Physical file read
// Specific routines
virtual int EstimatedLength(PGLOBAL g);
protected:
// Members
PSZ *FldFormat; // Field read format
void *To_Fld; // To field test buffer
int *FmtTest; // Test on ending by %n or %m
int Linenum; // Last read line
}; // end of class TDBFMT
/* ------------------------- End of TabFmt.H ------------------------- */

View File

@@ -1,427 +1,427 @@
/************** Table C++ Functions Source Code File (.CPP) ************/
/* Name: TABLE.CPP Version 2.5 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */
/* */
/* This file contains the TBX, TDB and OPJOIN classes functions. */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
/***********************************************************************/
/* Include required application header files */
/* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */
/* xobject.h is header containing XOBJECT derived classes declares. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "xtable.h"
#include "tabcol.h"
#include "filamtxt.h"
#include "tabdos.h"
//#include "catalog.h"
#include "reldef.h"
int TDB::Tnum = 0;
extern "C" int trace; // The general trace value
/***********************************************************************/
/* Utility routines. */
/***********************************************************************/
void NewPointer(PTABS, void *, void *);
void AddPointer(PTABS, void *);
/* ---------------------------- class TBX ---------------------------- */
/***********************************************************************/
/* TBX public constructors. */
/***********************************************************************/
TBX::TBX(void)
{
Use = USE_NO;
To_Orig = NULL;
To_Filter = NULL;
} // end of TBX constructor
TBX::TBX(PTBX txp)
{
Use = txp->Use;
To_Orig = txp;
To_Filter = NULL;
} // end of TBX copy constructor
// Methods
/* ---------------------------- class TDB ---------------------------- */
/***********************************************************************/
/* TDB public constructors. */
/***********************************************************************/
TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
{
Next = NULL;
Name = (tdp) ? tdp->GetName() : NULL;
To_Table = NULL;
Columns = NULL;
Degree = (tdp) ? tdp->GetDegree() : 0;
Mode = MODE_READ;
} // end of TDB standard constructor
TDB::TDB(PTDB tdbp) : TBX(tdbp), Tdb_No(++Tnum)
{
Next = NULL;
Name = tdbp->Name;
To_Table = tdbp->To_Table;
Columns = NULL;
Degree = tdbp->Degree;
Mode = tdbp->Mode;
} // end of TDB copy constructor
/***********************************************************************/
/* OpenTable: Call AM open routine. */
/***********************************************************************/
bool TDB::OpenTable(PGLOBAL g, PSQL sqlp, MODE mode)
{
if (trace)
htrc("Open Tdb_No=%d use=%d type=%d tdb.Mode=%d mode=%d\n",
Tdb_No, Use, GetAmType(), Mode, mode);
switch (Use) {
case USE_LIN:
/*****************************************************************/
/* If table is read/only, only MODE_READ is allowed. */
/*****************************************************************/
if (IsReadOnly() && mode != MODE_READ) {
strcpy(g->Message, MSG(READ_ONLY));
return true;
} // endif ReadOnly
/*****************************************************************/
/* This could be done in any order. */
/* Note: for not Read only first table in open in that mode. */
/*****************************************************************/
if (Next)
Next->OpenTable(g, sqlp, MODE_READ);
Mode = mode;
/*****************************************************************/
/* Pre-opening is done, allocate select buffers now. */
/*****************************************************************/
Use = USE_READY;
break;
case USE_READY:
/*****************************************************************/
/* This is to open files in reverse order. */
/*****************************************************************/
if (Next)
if (Next->OpenTable(g, sqlp, mode))
return true;
/*****************************************************************/
/* This was moved after filter conversion so filtering can be */
/* done when making index tables for DOS files. */
/* Also it was moved after allocating select buffers so some */
/* data can be pre-read during open to allow storage sorting. */
/*****************************************************************/
if (OpenDB(g)) // Do open the table file
return true;
Use = USE_OPEN;
break;
case USE_OPEN:
/*****************************************************************/
/* Table is already open. */
/* Call open routine that will just "rewind" the files. */
/*****************************************************************/
if (OpenDB(g)) // Rewind the table file
return true;
break;
default:
sprintf(g->Message, MSG(TDB_USE_ERROR), Use);
return true;
} // endswitch Use
return false;
} // end of OpenTable
/***********************************************************************/
/* CloseTable: Close a table of any AM type. */
/***********************************************************************/
void TDB::CloseTable(PGLOBAL g)
{
if (trace)
htrc("CloseTable: tdb_no %d use=%d amtype=%d am.Mode=%d\n",
Tdb_No, Use, GetAmType(), Mode);
CloseDB(g);
Use = USE_READY; // x'7FFD'
Mode = MODE_ANY;
} // end of CloseTable
// Methods
/***********************************************************************/
/* RowNumber: returns the current row ordinal number. */
/***********************************************************************/
int TDB::RowNumber(PGLOBAL g, bool b)
{
sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType()));
return 0;
} // end of RowNumber
PTBX TDB::Copy(PTABS t)
{
PTDB tp, tdb1, tdb2 = NULL, outp = NULL;
//PGLOBAL g = t->G; // Is this really useful ???
for (tdb1 = this; tdb1; tdb1 = tdb1->Next) {
tp = tdb1->CopyOne(t);
if (!outp)
outp = tp;
else
tdb2->Next = tp;
tdb2 = tp;
NewPointer(t, tdb1, tdb2);
} // endfor tdb1
return outp;
} // end of Copy
void TDB::Print(PGLOBAL g, FILE *f, uint n)
{
PCOL cp;
char m[64];
memset(m, ' ', n); // Make margin string
m[n] = '\0';
for (PTDB tp = this; tp; tp = tp->Next) {
fprintf(f, "%sTDB (%p) %s no=%d use=%d type=%d\n", m,
tp, tp->Name, tp->Tdb_No, tp->Use, tp->GetAmType());
tp->PrintAM(f, m);
fprintf(f, "%s Columns (deg=%d):\n", m, tp->Degree);
for (cp = tp->Columns; cp; cp = cp->GetNext())
cp->Print(g, f, n);
} /* endfor tp */
} // end of Print
void TDB::Print(PGLOBAL g, char *ps, uint z)
{
sprintf(ps, "R%d.%s", Tdb_No, Name);
} // end of Print
/* -------------------------- class TDBASE --------------------------- */
/***********************************************************************/
/* Implementation of the TDBASE class. This is the base class to all */
/* classes for tables that can be joined together. */
/***********************************************************************/
TDBASE::TDBASE(PTABDEF tdp) : TDB(tdp)
{
To_Def = tdp;
To_Link = NULL;
To_Key_Col = NULL;
To_Kindex = NULL;
To_SetCols = NULL;
MaxSize = -1;
Knum = 0;
Read_Only = (tdp) ? tdp->IsReadOnly() : false;
} // end of TDBASE constructor
TDBASE::TDBASE(PTDBASE tdbp) : TDB(tdbp)
{
To_Def = tdbp->To_Def;
To_SetCols = tdbp->To_SetCols; // ???
MaxSize = tdbp->MaxSize;
Read_Only = tdbp->Read_Only;
} // end of TDBASE copy constructor
/***********************************************************************/
/* Return the pointer on the DB catalog this table belongs to. */
/***********************************************************************/
PCATLG TDBASE::GetCat(void)
{
return (To_Def) ? To_Def->GetCat() : NULL;
} // end of GetCat
/***********************************************************************/
/* Return the datapath of the DB this table belongs to. */
/***********************************************************************/
PSZ TDBASE::GetPath(void)
{
return To_Def->GetPath();
} // end of GetPath
/***********************************************************************/
/* Initialize TDBASE based column description block construction. */
/* name is used to call columns by name. */
/* num is used by TBL to construct columns by index number. */
/* Note: name=Null and num=0 for constructing all columns (select *) */
/***********************************************************************/
PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num)
{
int i;
PCOLDEF cdp;
PCOL cp, colp = NULL, cprec = NULL;
if (trace)
htrc("ColDB: am=%d colname=%s tabname=%s num=%d\n",
GetAmType(), SVP(name), Name, num);
for (cdp = To_Def->GetCols(), i = 1; cdp; cdp = cdp->GetNext(), i++)
if ((!name && !num) ||
(name && !stricmp(cdp->GetName(), name)) || num == i) {
/*****************************************************************/
/* Check for existence of desired column. */
/* Also find where to insert the new block. */
/*****************************************************************/
for (cp = Columns; cp; cp = cp->GetNext())
if (cp->GetIndex() < i)
cprec = cp;
else if (cp->GetIndex() == i)
break;
if (trace)
htrc("cdp(%d).Name=%s cp=%p\n", i, cdp->GetName(), cp);
/*****************************************************************/
/* Now take care of Column Description Block. */
/*****************************************************************/
if (cp)
colp = cp;
else
colp = MakeCol(g, cdp, cprec, i);
if (trace)
htrc("colp=%p\n", colp);
if (name || num)
break;
else if (colp)
cprec = colp;
} // endif Name
return (colp);
} // end of ColDB
/***********************************************************************/
/* InsertSpecialColumn: Put a special column ahead of the column list.*/
/***********************************************************************/
PCOL TDBASE::InsertSpecialColumn(PGLOBAL g, PCOL colp)
{
if (!colp->IsSpecial())
return NULL;
colp->SetNext(Columns);
Columns = colp;
return colp;
} // end of InsertSpecialColumn
/***********************************************************************/
/* Make a special COLBLK to insert in a table. */
/***********************************************************************/
PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLUMN cp)
{
char *name = (char*)cp->GetName();
PCOL colp;
if (!strcmp(name, "FILEID")) {
// !strcmp(name, "SERVID")) {
if (!To_Def || !(To_Def->GetPseudo() & 2)) {
sprintf(g->Message, MSG(BAD_SPEC_COLUMN));
return NULL;
} // endif Pseudo
// if (!strcmp(name, "FILEID"))
colp = new(g) FIDBLK(cp);
// else
// colp = new(g) SIDBLK(cp);
} else if (!strcmp(name, "TABID")) {
colp = new(g) TIDBLK(cp);
//} else if (!strcmp(name, "CONID")) {
// colp = new(g) CIDBLK(cp);
} else if (!strcmp(name, "ROWID")) {
colp = new(g) RIDBLK(cp, false);
} else if (!strcmp(name, "ROWNUM")) {
colp = new(g) RIDBLK(cp, true);
} else {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
return NULL;
} // endif's name
if (!(colp = InsertSpecialColumn(g, colp))) {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
return NULL;
} // endif Insert
return (colp);
} // end of InsertSpcBlk
/***********************************************************************/
/* ResetTableOpt: Wrong for this table type. */
/***********************************************************************/
int TDBASE::ResetTableOpt(PGLOBAL g, bool dox)
{
strcpy(g->Message, "This table is not indexable");
return RC_INFO;
} // end of ResetTableOpt
/***********************************************************************/
/* SetKindex: set or reset the index pointer. */
/***********************************************************************/
void TDBASE::SetKindex(PKXBASE kxp)
{
if (To_Kindex)
To_Kindex->Close(); // Discard old index
To_Kindex = kxp;
} // end of SetKindex
/***********************************************************************/
/* SetRecpos: Replace the table at the specified position. */
/***********************************************************************/
bool TDBASE::SetRecpos(PGLOBAL g, int recpos)
{
strcpy(g->Message, MSG(SETRECPOS_NIY));
return true;
} // end of SetRecpos
/***********************************************************************/
/* Methods */
/***********************************************************************/
void TDBASE::PrintAM(FILE *f, char *m)
{
fprintf(f, "%s AM(%d): mode=%d\n", m, GetAmType(), Mode);
} // end of PrintAM
/***********************************************************************/
/* Marks DOS/MAP table columns used in internal joins. */
/* tdb2 is the top of tree or first tdb in chained tdb's and tdbp */
/* points to the currently marked tdb. */
/* Two questions here: exact meaning of U_J_INT ? */
/* Why is the eventual reference to To_Key_Col not marked U_J_EXT ? */
/***********************************************************************/
void TDBASE::MarkDB(PGLOBAL g, PTDB tdb2)
{
if (trace)
htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2);
} // end of MarkDB
/************** Table C++ Functions Source Code File (.CPP) ************/
/* Name: TABLE.CPP Version 2.5 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */
/* */
/* This file contains the TBX, TDB and OPJOIN classes functions. */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
/***********************************************************************/
/* Include required application header files */
/* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */
/* xobject.h is header containing XOBJECT derived classes declares. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "xtable.h"
#include "tabcol.h"
#include "filamtxt.h"
#include "tabdos.h"
//#include "catalog.h"
#include "reldef.h"
int TDB::Tnum = 0;
extern "C" int trace; // The general trace value
/***********************************************************************/
/* Utility routines. */
/***********************************************************************/
void NewPointer(PTABS, void *, void *);
void AddPointer(PTABS, void *);
/* ---------------------------- class TBX ---------------------------- */
/***********************************************************************/
/* TBX public constructors. */
/***********************************************************************/
TBX::TBX(void)
{
Use = USE_NO;
To_Orig = NULL;
To_Filter = NULL;
} // end of TBX constructor
TBX::TBX(PTBX txp)
{
Use = txp->Use;
To_Orig = txp;
To_Filter = NULL;
} // end of TBX copy constructor
// Methods
/* ---------------------------- class TDB ---------------------------- */
/***********************************************************************/
/* TDB public constructors. */
/***********************************************************************/
TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
{
Next = NULL;
Name = (tdp) ? tdp->GetName() : NULL;
To_Table = NULL;
Columns = NULL;
Degree = (tdp) ? tdp->GetDegree() : 0;
Mode = MODE_READ;
} // end of TDB standard constructor
TDB::TDB(PTDB tdbp) : TBX(tdbp), Tdb_No(++Tnum)
{
Next = NULL;
Name = tdbp->Name;
To_Table = tdbp->To_Table;
Columns = NULL;
Degree = tdbp->Degree;
Mode = tdbp->Mode;
} // end of TDB copy constructor
/***********************************************************************/
/* OpenTable: Call AM open routine. */
/***********************************************************************/
bool TDB::OpenTable(PGLOBAL g, PSQL sqlp, MODE mode)
{
if (trace)
htrc("Open Tdb_No=%d use=%d type=%d tdb.Mode=%d mode=%d\n",
Tdb_No, Use, GetAmType(), Mode, mode);
switch (Use) {
case USE_LIN:
/*****************************************************************/
/* If table is read/only, only MODE_READ is allowed. */
/*****************************************************************/
if (IsReadOnly() && mode != MODE_READ) {
strcpy(g->Message, MSG(READ_ONLY));
return true;
} // endif ReadOnly
/*****************************************************************/
/* This could be done in any order. */
/* Note: for not Read only first table in open in that mode. */
/*****************************************************************/
if (Next)
Next->OpenTable(g, sqlp, MODE_READ);
Mode = mode;
/*****************************************************************/
/* Pre-opening is done, allocate select buffers now. */
/*****************************************************************/
Use = USE_READY;
break;
case USE_READY:
/*****************************************************************/
/* This is to open files in reverse order. */
/*****************************************************************/
if (Next)
if (Next->OpenTable(g, sqlp, mode))
return true;
/*****************************************************************/
/* This was moved after filter conversion so filtering can be */
/* done when making index tables for DOS files. */
/* Also it was moved after allocating select buffers so some */
/* data can be pre-read during open to allow storage sorting. */
/*****************************************************************/
if (OpenDB(g)) // Do open the table file
return true;
Use = USE_OPEN;
break;
case USE_OPEN:
/*****************************************************************/
/* Table is already open. */
/* Call open routine that will just "rewind" the files. */
/*****************************************************************/
if (OpenDB(g)) // Rewind the table file
return true;
break;
default:
sprintf(g->Message, MSG(TDB_USE_ERROR), Use);
return true;
} // endswitch Use
return false;
} // end of OpenTable
/***********************************************************************/
/* CloseTable: Close a table of any AM type. */
/***********************************************************************/
void TDB::CloseTable(PGLOBAL g)
{
if (trace)
htrc("CloseTable: tdb_no %d use=%d amtype=%d am.Mode=%d\n",
Tdb_No, Use, GetAmType(), Mode);
CloseDB(g);
Use = USE_READY; // x'7FFD'
Mode = MODE_ANY;
} // end of CloseTable
// Methods
/***********************************************************************/
/* RowNumber: returns the current row ordinal number. */
/***********************************************************************/
int TDB::RowNumber(PGLOBAL g, bool b)
{
sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType()));
return 0;
} // end of RowNumber
PTBX TDB::Copy(PTABS t)
{
PTDB tp, tdb1, tdb2 = NULL, outp = NULL;
//PGLOBAL g = t->G; // Is this really useful ???
for (tdb1 = this; tdb1; tdb1 = tdb1->Next) {
tp = tdb1->CopyOne(t);
if (!outp)
outp = tp;
else
tdb2->Next = tp;
tdb2 = tp;
NewPointer(t, tdb1, tdb2);
} // endfor tdb1
return outp;
} // end of Copy
void TDB::Print(PGLOBAL g, FILE *f, uint n)
{
PCOL cp;
char m[64];
memset(m, ' ', n); // Make margin string
m[n] = '\0';
for (PTDB tp = this; tp; tp = tp->Next) {
fprintf(f, "%sTDB (%p) %s no=%d use=%d type=%d\n", m,
tp, tp->Name, tp->Tdb_No, tp->Use, tp->GetAmType());
tp->PrintAM(f, m);
fprintf(f, "%s Columns (deg=%d):\n", m, tp->Degree);
for (cp = tp->Columns; cp; cp = cp->GetNext())
cp->Print(g, f, n);
} /* endfor tp */
} // end of Print
void TDB::Print(PGLOBAL g, char *ps, uint z)
{
sprintf(ps, "R%d.%s", Tdb_No, Name);
} // end of Print
/* -------------------------- class TDBASE --------------------------- */
/***********************************************************************/
/* Implementation of the TDBASE class. This is the base class to all */
/* classes for tables that can be joined together. */
/***********************************************************************/
TDBASE::TDBASE(PTABDEF tdp) : TDB(tdp)
{
To_Def = tdp;
To_Link = NULL;
To_Key_Col = NULL;
To_Kindex = NULL;
To_SetCols = NULL;
MaxSize = -1;
Knum = 0;
Read_Only = (tdp) ? tdp->IsReadOnly() : false;
} // end of TDBASE constructor
TDBASE::TDBASE(PTDBASE tdbp) : TDB(tdbp)
{
To_Def = tdbp->To_Def;
To_SetCols = tdbp->To_SetCols; // ???
MaxSize = tdbp->MaxSize;
Read_Only = tdbp->Read_Only;
} // end of TDBASE copy constructor
/***********************************************************************/
/* Return the pointer on the DB catalog this table belongs to. */
/***********************************************************************/
PCATLG TDBASE::GetCat(void)
{
return (To_Def) ? To_Def->GetCat() : NULL;
} // end of GetCat
/***********************************************************************/
/* Return the datapath of the DB this table belongs to. */
/***********************************************************************/
PSZ TDBASE::GetPath(void)
{
return To_Def->GetPath();
} // end of GetPath
/***********************************************************************/
/* Initialize TDBASE based column description block construction. */
/* name is used to call columns by name. */
/* num is used by TBL to construct columns by index number. */
/* Note: name=Null and num=0 for constructing all columns (select *) */
/***********************************************************************/
PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num)
{
int i;
PCOLDEF cdp;
PCOL cp, colp = NULL, cprec = NULL;
if (trace)
htrc("ColDB: am=%d colname=%s tabname=%s num=%d\n",
GetAmType(), SVP(name), Name, num);
for (cdp = To_Def->GetCols(), i = 1; cdp; cdp = cdp->GetNext(), i++)
if ((!name && !num) ||
(name && !stricmp(cdp->GetName(), name)) || num == i) {
/*****************************************************************/
/* Check for existence of desired column. */
/* Also find where to insert the new block. */
/*****************************************************************/
for (cp = Columns; cp; cp = cp->GetNext())
if (cp->GetIndex() < i)
cprec = cp;
else if (cp->GetIndex() == i)
break;
if (trace)
htrc("cdp(%d).Name=%s cp=%p\n", i, cdp->GetName(), cp);
/*****************************************************************/
/* Now take care of Column Description Block. */
/*****************************************************************/
if (cp)
colp = cp;
else
colp = MakeCol(g, cdp, cprec, i);
if (trace)
htrc("colp=%p\n", colp);
if (name || num)
break;
else if (colp)
cprec = colp;
} // endif Name
return (colp);
} // end of ColDB
/***********************************************************************/
/* InsertSpecialColumn: Put a special column ahead of the column list.*/
/***********************************************************************/
PCOL TDBASE::InsertSpecialColumn(PGLOBAL g, PCOL colp)
{
if (!colp->IsSpecial())
return NULL;
colp->SetNext(Columns);
Columns = colp;
return colp;
} // end of InsertSpecialColumn
/***********************************************************************/
/* Make a special COLBLK to insert in a table. */
/***********************************************************************/
PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLUMN cp)
{
char *name = (char*)cp->GetName();
PCOL colp;
if (!strcmp(name, "FILEID")) {
// !strcmp(name, "SERVID")) {
if (!To_Def || !(To_Def->GetPseudo() & 2)) {
sprintf(g->Message, MSG(BAD_SPEC_COLUMN));
return NULL;
} // endif Pseudo
// if (!strcmp(name, "FILEID"))
colp = new(g) FIDBLK(cp);
// else
// colp = new(g) SIDBLK(cp);
} else if (!strcmp(name, "TABID")) {
colp = new(g) TIDBLK(cp);
//} else if (!strcmp(name, "CONID")) {
// colp = new(g) CIDBLK(cp);
} else if (!strcmp(name, "ROWID")) {
colp = new(g) RIDBLK(cp, false);
} else if (!strcmp(name, "ROWNUM")) {
colp = new(g) RIDBLK(cp, true);
} else {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
return NULL;
} // endif's name
if (!(colp = InsertSpecialColumn(g, colp))) {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
return NULL;
} // endif Insert
return (colp);
} // end of InsertSpcBlk
/***********************************************************************/
/* ResetTableOpt: Wrong for this table type. */
/***********************************************************************/
int TDBASE::ResetTableOpt(PGLOBAL g, bool dox)
{
strcpy(g->Message, "This table is not indexable");
return RC_INFO;
} // end of ResetTableOpt
/***********************************************************************/
/* SetKindex: set or reset the index pointer. */
/***********************************************************************/
void TDBASE::SetKindex(PKXBASE kxp)
{
if (To_Kindex)
To_Kindex->Close(); // Discard old index
To_Kindex = kxp;
} // end of SetKindex
/***********************************************************************/
/* SetRecpos: Replace the table at the specified position. */
/***********************************************************************/
bool TDBASE::SetRecpos(PGLOBAL g, int recpos)
{
strcpy(g->Message, MSG(SETRECPOS_NIY));
return true;
} // end of SetRecpos
/***********************************************************************/
/* Methods */
/***********************************************************************/
void TDBASE::PrintAM(FILE *f, char *m)
{
fprintf(f, "%s AM(%d): mode=%d\n", m, GetAmType(), Mode);
} // end of PrintAM
/***********************************************************************/
/* Marks DOS/MAP table columns used in internal joins. */
/* tdb2 is the top of tree or first tdb in chained tdb's and tdbp */
/* points to the currently marked tdb. */
/* Two questions here: exact meaning of U_J_INT ? */
/* Why is the eventual reference to To_Key_Col not marked U_J_EXT ? */
/***********************************************************************/
void TDBASE::MarkDB(PGLOBAL g, PTDB tdb2)
{
if (trace)
htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2);
} // end of MarkDB

View File

@@ -1,458 +1,458 @@
/***********************************************************************/
/* TABMAC: Author Olivier Bertrand -- PlugDB -- 2008-2012 */
/* From the article and sample code by Khalid Shaikh. */
/* TABMAC: virtual table to get the list of MAC addresses. */
/***********************************************************************/
#if defined(WIN32)
#include "my_global.h"
//#include <iphlpapi.h>
#else // !WIN32
#error This is a WIN32 only table type
#endif // !WIN32
#include "global.h"
#include "plgdbsem.h"
//#include "catalog.h"
#include "reldef.h"
#include "xtable.h"
#include "colblk.h"
#include "tabmac.h"
#if 0 // This is placed here just to know what are the actual values
#define MAX_ADAPTER_DESCRIPTION_LENGTH 128
#define MAX_ADAPTER_NAME_LENGTH 256
#define MAX_ADAPTER_ADDRESS_LENGTH 8
#define DEFAULT_MINIMUM_ENTITIES 32
#define MAX_HOSTNAME_LEN 128
#define MAX_DOMAIN_NAME_LEN 128
#define MAX_SCOPE_ID_LEN 256
#define BROADCAST_NODETYPE 1
#define PEER_TO_PEER_NODETYPE 2
#define MIXED_NODETYPE 4
#define HYBRID_NODETYPE 8
#define IP_ADAPTER_DDNS_ENABLED 0x01
#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x02
#define IP_ADAPTER_DHCP_ENABLED 0x04
#define IP_ADAPTER_RECEIVE_ONLY 0x08
#define IP_ADAPTER_NO_MULTICAST 0x10
#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x20
#endif // 0
/* -------------- Implementation of the MAC classes ------------------ */
/***********************************************************************/
/* DefineAM: define specific AM block values from MAC file. */
/***********************************************************************/
bool MACDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
return false;
} // end of DefineAM
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
PTDB MACDEF::GetTable(PGLOBAL g, MODE m)
{
return new(g) TDBMAC(this);
} // end of GetTable
/* ------------------------------------------------------------------- */
/***********************************************************************/
/* Implementation of the TDBMAC class. */
/***********************************************************************/
TDBMAC::TDBMAC(PMACDEF tdp) : TDBASE(tdp)
{
FixedInfo = NULL;
Piaf = NULL;
Curp = NULL;
Next = NULL;
Buflen = 0;
Fix = false;
Adap = false;
N = 0;
} // end of TDBMAC constructor
/***********************************************************************/
/* Allocate MAC column description block. */
/***********************************************************************/
PCOL TDBMAC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
{
PCOL colp;
colp = new(g) MACCOL(cdp, this, n);
if (cprec) {
colp->SetNext(cprec->GetNext());
cprec->SetNext(colp);
} else {
colp->SetNext(Columns);
Columns = colp;
} // endif cprec
return colp;
} // end of MakeCol
/***********************************************************************/
/* MAC: Get the number of found adapters. */
/***********************************************************************/
void TDBMAC::MakeErrorMsg(PGLOBAL g, DWORD drc)
{
if (drc == ERROR_BUFFER_OVERFLOW)
sprintf(g->Message,
"GetAdaptersInfo: Buffer Overflow buflen=%d maxsize=%d",
Buflen, MaxSize);
else if (drc == ERROR_INVALID_PARAMETER)
strcpy(g->Message, "GetAdaptersInfo: Invalid parameters");
else if (drc == ERROR_NO_DATA)
strcpy(g->Message,
"No adapter information exists for the local computer");
else if (drc == ERROR_NOT_SUPPORTED)
strcpy(g->Message, "GetAdaptersInfo is not supported");
else
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(),
0, g->Message, sizeof(g->Message), NULL);
} // end of MakeErrorMsg
/***********************************************************************/
/* GetMacInfo: Get info for all found adapters. */
/***********************************************************************/
bool TDBMAC::GetMacInfo(PGLOBAL g)
{
DWORD drc;
if (GetMaxSize(g) < 0)
return true;
else if (MaxSize == 0)
return false;
Piaf = (PIP_ADAPTER_INFO)PlugSubAlloc(g, NULL, Buflen);
drc = GetAdaptersInfo(Piaf, &Buflen);
if (drc == ERROR_SUCCESS) {
Next = Piaf; // Next is the first one
return false; // Success
} // endif drc
MakeErrorMsg(g, drc);
return true;
} // end of GetMacInfo
/***********************************************************************/
/* GetFixedInfo: Get info for network parameters. */
/***********************************************************************/
bool TDBMAC::GetFixedInfo(PGLOBAL g)
{
ULONG len;
DWORD drc;
FixedInfo = (FIXED_INFO*)PlugSubAlloc(g, NULL, sizeof(FIXED_INFO));
len = sizeof(FIXED_INFO);
drc = GetNetworkParams(FixedInfo, &len);
if (drc == ERROR_BUFFER_OVERFLOW) {
FixedInfo = (FIXED_INFO*)PlugSubAlloc(g, NULL, len);
drc = GetNetworkParams(FixedInfo, &len);
} // endif drc
if (drc != ERROR_SUCCESS) {
sprintf(g->Message, "GetNetworkParams failed. Rc=%08x\n", drc);
return true;
} // endif drc
return false;
} // end of GetFixedInfo
/***********************************************************************/
/* MAC: Get the number of found adapters. */
/***********************************************************************/
int TDBMAC::GetMaxSize(PGLOBAL g)
{
if (Use != USE_OPEN)
// Called from info, Adap and Fix are not set yet
return 1;
if (MaxSize < 0) {
// Best method
if (Adap) {
DWORD drc = GetAdaptersInfo(NULL, &(Buflen = 0));
if (drc == ERROR_SUCCESS)
MaxSize = (Fix) ? 1 : 0;
else if (drc == ERROR_BUFFER_OVERFLOW) {
// sizeof(IP_ADAPTER_INFO) was returning 640 but is now sometimes
// returning 648 while the Buflen setting remains the same (n*640)
// >> Of course, the code above contains a race condition....
// if the size of the structure Windows wants to return grows after
// the first call to GetAdaptersInfo() but before the second call
// to GetAdaptersInfo(), the second call to GetAdaptersInfo() will
// fail with ERROR_BUFFER_OVERFLOW as well, and your function won't
// work (by Jeremy Friesner on stackoverflow.com).
// That's why we add something to it to be comfortable.
MaxSize = (Buflen + 600) / sizeof(IP_ADAPTER_INFO);
// Now Buflen must be updated if 648 is true.
Buflen = MaxSize * sizeof(IP_ADAPTER_INFO);
} else
MakeErrorMsg(g, drc);
} else
MaxSize = (Fix) ? 1 : 0;
#if 0
// This method returns too many adapters
DWORD dw, drc = GetNumberOfInterfaces((PDWORD)&dw);
if (drc == NO_ERROR) {
MaxSize = (int)dw;
Buflen = MaxSize * sizeof(IP_ADAPTER_INFO);
} else
MakeErrorMsg(g, 0);
#endif
} // endif MaxSize
return MaxSize;
} // end of GetMaxSize
/***********************************************************************/
/* MAC Access Method opening routine. */
/***********************************************************************/
bool TDBMAC::OpenDB(PGLOBAL g)
{
if (Use == USE_OPEN) {
/*******************************************************************/
/* Table already open, this should not happen. */
/*******************************************************************/
strcpy(g->Message, "TDBMAC should not be reopened");
return true;
} // endif use
if (Mode != MODE_READ) {
/*******************************************************************/
/* MAC tables cannot be modified. */
/*******************************************************************/
strcpy(g->Message, "MAC tables are read only");
return true;
} else
Use = USE_OPEN;
/*********************************************************************/
/* Get the adapters info. */
/*********************************************************************/
if (Adap && GetMacInfo(g))
return true;
if (Fix && GetFixedInfo(g))
return true;
/*********************************************************************/
/* All is done. */
/*********************************************************************/
return false;
} // end of OpenDB
/***********************************************************************/
/* Data Base read routine for MAC access method. */
/***********************************************************************/
int TDBMAC::ReadDB(PGLOBAL g)
{
Curp = Next;
if (Curp)
Next = Curp->Next;
else if (N || !Fix)
return RC_EF;
N++;
return RC_OK;
} // end of ReadDB
/***********************************************************************/
/* WriteDB: Data Base write routine for MAC access methods. */
/***********************************************************************/
int TDBMAC::WriteDB(PGLOBAL g)
{
strcpy(g->Message, "MAC tables are read only");
return RC_FX;
} // end of WriteDB
/***********************************************************************/
/* Data Base delete line routine for MAC access methods. */
/***********************************************************************/
int TDBMAC::DeleteDB(PGLOBAL g, int irc)
{
strcpy(g->Message, "Delete not enabled for MAC tables");
return RC_FX;
} // end of DeleteDB
// ------------------------ MACCOL functions ----------------------------
/***********************************************************************/
/* MACCOL public constructor. */
/***********************************************************************/
MACCOL::MACCOL(PCOLDEF cdp, PTDB tdbp, int n)
: COLBLK(cdp, tdbp, n)
{
Tdbp = (PTDBMAC)tdbp;
Flag = cdp->GetOffset();
if (Flag < 10)
Tdbp->Fix = true;
else
Tdbp->Adap = true;
} // end of MACCOL constructor
/***********************************************************************/
/* Read the next MAC address elements. */
/***********************************************************************/
void MACCOL::ReadColumn(PGLOBAL g)
{
// Type conversion is handled by Value set routines
char *p = NULL, buf[260] = "";
unsigned int i;
int n = 0;
PIP_ADAPTER_INFO adp = Tdbp->Curp;
FIXED_INFO *fip = Tdbp->FixedInfo;
if (!adp && Flag >= 10) {
// Fix info row, no adapter info available
switch (Flag) {
case 13:
case 14:
case 19:
case 22:
case 23:
n = 0;
break;
default:
p = "";
} // endswitch Flag
} else switch (Flag) {
// FIXED INFO
case 1: // Host Name
p = fip->HostName;
break;
case 2: // Domain Name
p = fip->DomainName;
break;
case 3: // DNS IPaddress
p = (fip->CurrentDnsServer)
? (char*)&fip->CurrentDnsServer->IpAddress
: (char*)&fip->DnsServerList.IpAddress;
break;
case 4: // Node Type
n = (int)fip->NodeType;
break;
case 5: // Scope ID ???
p = fip->ScopeId;
break;
case 6: // Routing enabled
n = (int)fip->EnableRouting;
break;
case 7: // Proxy enabled
n = (int)fip->EnableProxy;
break;
case 8: // DNS enabled
n = (int)fip->EnableDns;
break;
// ADAPTERS INFO
case 10: // Name
p = adp->AdapterName;
break;
case 11: // Description
if ((p = strstr(adp->Description, " - Packet Scheduler Miniport"))) {
strncpy(buf, adp->Description, p - adp->Description);
i = p - adp->Description;
strncpy(buf, adp->Description, i);
buf[i] = 0;
p = buf;
} else if ((p = strstr(adp->Description,
" - Miniport d'ordonnancement de paquets"))) {
i = p - adp->Description;
strncpy(buf, adp->Description, i);
buf[i] = 0;
p = buf;
} else
p = adp->Description;
break;
case 12: // MAC Address
for (p = buf, i = 0; i < adp->AddressLength; i++) {
if (i)
strcat(p++, "-");
p += sprintf(p, "%.2X", adp->Address[i]);
} // endfor i
p = buf;
break;
case 13: // Type
#if 0 // This is not found in the SDK
switch (adp->Type) {
case IF_ETHERNET_ADAPTERTYPE: p = "Ethernet Adapter"; break;
case IF_TOKEN_RING_ADAPTERTYPE: p = "Token Ring Adapter"; break;
case IF_FDDI_ADAPTERTYPE: p = "FDDI Adapter"; break;
case IF_PPP_ADAPTERTYPE: p = "PPP Adapter"; break;
case IF_LOOPBACK_ADAPTERTYPE: p = "Loop Back Adapter"; break;
// case IF_SLIP_ADAPTERTYPE: p = "Generic Slip Adapter"; break;
default:
sprintf(buf, "Other Adapter, type=%d", adp->Type);
p = buf;
} // endswitch Type
#endif // 0
n = (int)adp->Type;
break;
case 14: // DHCP enabled
n = (int)adp->DhcpEnabled;
break;
case 15: // IP Address
p = (adp->CurrentIpAddress)
? (char*)&adp->CurrentIpAddress->IpAddress
: (char*)&adp->IpAddressList.IpAddress;
break;
case 16: // Subnet Mask
p = (adp->CurrentIpAddress)
? (char*)&adp->CurrentIpAddress->IpMask
: (char*)&adp->IpAddressList.IpMask;
break;
case 17: // Gateway
p = (char*)&adp->GatewayList.IpAddress;
break;
case 18: // DHCP Server
p = (char*)&adp->DhcpServer.IpAddress;
break;
case 19: // Have WINS
n = (adp->HaveWins) ? 1 : 0;
break;
case 20: // Primary WINS
p = (char*)&adp->PrimaryWinsServer.IpAddress;
break;
case 21: // Secondary WINS
p = (char*)&adp->SecondaryWinsServer.IpAddress;
break;
case 22: // Lease obtained
n = (int)adp->LeaseObtained;
break;
case 23: // Lease expires
n = (int)adp->LeaseExpires;
break;
default:
if (Buf_Type == TYPE_STRING) {
sprintf(buf, "Invalid flag value %d", Flag);
p = buf;
} else
n = 0;
} // endswitch Flag
if (p)
Value->SetValue_psz(p);
else
Value->SetValue(n);
} // end of ReadColumn
/***********************************************************************/
/* TABMAC: Author Olivier Bertrand -- PlugDB -- 2008-2012 */
/* From the article and sample code by Khalid Shaikh. */
/* TABMAC: virtual table to get the list of MAC addresses. */
/***********************************************************************/
#if defined(WIN32)
#include "my_global.h"
//#include <iphlpapi.h>
#else // !WIN32
#error This is a WIN32 only table type
#endif // !WIN32
#include "global.h"
#include "plgdbsem.h"
//#include "catalog.h"
#include "reldef.h"
#include "xtable.h"
#include "colblk.h"
#include "tabmac.h"
#if 0 // This is placed here just to know what are the actual values
#define MAX_ADAPTER_DESCRIPTION_LENGTH 128
#define MAX_ADAPTER_NAME_LENGTH 256
#define MAX_ADAPTER_ADDRESS_LENGTH 8
#define DEFAULT_MINIMUM_ENTITIES 32
#define MAX_HOSTNAME_LEN 128
#define MAX_DOMAIN_NAME_LEN 128
#define MAX_SCOPE_ID_LEN 256
#define BROADCAST_NODETYPE 1
#define PEER_TO_PEER_NODETYPE 2
#define MIXED_NODETYPE 4
#define HYBRID_NODETYPE 8
#define IP_ADAPTER_DDNS_ENABLED 0x01
#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x02
#define IP_ADAPTER_DHCP_ENABLED 0x04
#define IP_ADAPTER_RECEIVE_ONLY 0x08
#define IP_ADAPTER_NO_MULTICAST 0x10
#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x20
#endif // 0
/* -------------- Implementation of the MAC classes ------------------ */
/***********************************************************************/
/* DefineAM: define specific AM block values from MAC file. */
/***********************************************************************/
bool MACDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
return false;
} // end of DefineAM
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
PTDB MACDEF::GetTable(PGLOBAL g, MODE m)
{
return new(g) TDBMAC(this);
} // end of GetTable
/* ------------------------------------------------------------------- */
/***********************************************************************/
/* Implementation of the TDBMAC class. */
/***********************************************************************/
TDBMAC::TDBMAC(PMACDEF tdp) : TDBASE(tdp)
{
FixedInfo = NULL;
Piaf = NULL;
Curp = NULL;
Next = NULL;
Buflen = 0;
Fix = false;
Adap = false;
N = 0;
} // end of TDBMAC constructor
/***********************************************************************/
/* Allocate MAC column description block. */
/***********************************************************************/
PCOL TDBMAC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
{
PCOL colp;
colp = new(g) MACCOL(cdp, this, n);
if (cprec) {
colp->SetNext(cprec->GetNext());
cprec->SetNext(colp);
} else {
colp->SetNext(Columns);
Columns = colp;
} // endif cprec
return colp;
} // end of MakeCol
/***********************************************************************/
/* MAC: Get the number of found adapters. */
/***********************************************************************/
void TDBMAC::MakeErrorMsg(PGLOBAL g, DWORD drc)
{
if (drc == ERROR_BUFFER_OVERFLOW)
sprintf(g->Message,
"GetAdaptersInfo: Buffer Overflow buflen=%d maxsize=%d",
Buflen, MaxSize);
else if (drc == ERROR_INVALID_PARAMETER)
strcpy(g->Message, "GetAdaptersInfo: Invalid parameters");
else if (drc == ERROR_NO_DATA)
strcpy(g->Message,
"No adapter information exists for the local computer");
else if (drc == ERROR_NOT_SUPPORTED)
strcpy(g->Message, "GetAdaptersInfo is not supported");
else
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(),
0, g->Message, sizeof(g->Message), NULL);
} // end of MakeErrorMsg
/***********************************************************************/
/* GetMacInfo: Get info for all found adapters. */
/***********************************************************************/
bool TDBMAC::GetMacInfo(PGLOBAL g)
{
DWORD drc;
if (GetMaxSize(g) < 0)
return true;
else if (MaxSize == 0)
return false;
Piaf = (PIP_ADAPTER_INFO)PlugSubAlloc(g, NULL, Buflen);
drc = GetAdaptersInfo(Piaf, &Buflen);
if (drc == ERROR_SUCCESS) {
Next = Piaf; // Next is the first one
return false; // Success
} // endif drc
MakeErrorMsg(g, drc);
return true;
} // end of GetMacInfo
/***********************************************************************/
/* GetFixedInfo: Get info for network parameters. */
/***********************************************************************/
bool TDBMAC::GetFixedInfo(PGLOBAL g)
{
ULONG len;
DWORD drc;
FixedInfo = (FIXED_INFO*)PlugSubAlloc(g, NULL, sizeof(FIXED_INFO));
len = sizeof(FIXED_INFO);
drc = GetNetworkParams(FixedInfo, &len);
if (drc == ERROR_BUFFER_OVERFLOW) {
FixedInfo = (FIXED_INFO*)PlugSubAlloc(g, NULL, len);
drc = GetNetworkParams(FixedInfo, &len);
} // endif drc
if (drc != ERROR_SUCCESS) {
sprintf(g->Message, "GetNetworkParams failed. Rc=%08x\n", drc);
return true;
} // endif drc
return false;
} // end of GetFixedInfo
/***********************************************************************/
/* MAC: Get the number of found adapters. */
/***********************************************************************/
int TDBMAC::GetMaxSize(PGLOBAL g)
{
if (Use != USE_OPEN)
// Called from info, Adap and Fix are not set yet
return 1;
if (MaxSize < 0) {
// Best method
if (Adap) {
DWORD drc = GetAdaptersInfo(NULL, &(Buflen = 0));
if (drc == ERROR_SUCCESS)
MaxSize = (Fix) ? 1 : 0;
else if (drc == ERROR_BUFFER_OVERFLOW) {
// sizeof(IP_ADAPTER_INFO) was returning 640 but is now sometimes
// returning 648 while the Buflen setting remains the same (n*640)
// >> Of course, the code above contains a race condition....
// if the size of the structure Windows wants to return grows after
// the first call to GetAdaptersInfo() but before the second call
// to GetAdaptersInfo(), the second call to GetAdaptersInfo() will
// fail with ERROR_BUFFER_OVERFLOW as well, and your function won't
// work (by Jeremy Friesner on stackoverflow.com).
// That's why we add something to it to be comfortable.
MaxSize = (Buflen + 600) / sizeof(IP_ADAPTER_INFO);
// Now Buflen must be updated if 648 is true.
Buflen = MaxSize * sizeof(IP_ADAPTER_INFO);
} else
MakeErrorMsg(g, drc);
} else
MaxSize = (Fix) ? 1 : 0;
#if 0
// This method returns too many adapters
DWORD dw, drc = GetNumberOfInterfaces((PDWORD)&dw);
if (drc == NO_ERROR) {
MaxSize = (int)dw;
Buflen = MaxSize * sizeof(IP_ADAPTER_INFO);
} else
MakeErrorMsg(g, 0);
#endif
} // endif MaxSize
return MaxSize;
} // end of GetMaxSize
/***********************************************************************/
/* MAC Access Method opening routine. */
/***********************************************************************/
bool TDBMAC::OpenDB(PGLOBAL g)
{
if (Use == USE_OPEN) {
/*******************************************************************/
/* Table already open, this should not happen. */
/*******************************************************************/
strcpy(g->Message, "TDBMAC should not be reopened");
return true;
} // endif use
if (Mode != MODE_READ) {
/*******************************************************************/
/* MAC tables cannot be modified. */
/*******************************************************************/
strcpy(g->Message, "MAC tables are read only");
return true;
} else
Use = USE_OPEN;
/*********************************************************************/
/* Get the adapters info. */
/*********************************************************************/
if (Adap && GetMacInfo(g))
return true;
if (Fix && GetFixedInfo(g))
return true;
/*********************************************************************/
/* All is done. */
/*********************************************************************/
return false;
} // end of OpenDB
/***********************************************************************/
/* Data Base read routine for MAC access method. */
/***********************************************************************/
int TDBMAC::ReadDB(PGLOBAL g)
{
Curp = Next;
if (Curp)
Next = Curp->Next;
else if (N || !Fix)
return RC_EF;
N++;
return RC_OK;
} // end of ReadDB
/***********************************************************************/
/* WriteDB: Data Base write routine for MAC access methods. */
/***********************************************************************/
int TDBMAC::WriteDB(PGLOBAL g)
{
strcpy(g->Message, "MAC tables are read only");
return RC_FX;
} // end of WriteDB
/***********************************************************************/
/* Data Base delete line routine for MAC access methods. */
/***********************************************************************/
int TDBMAC::DeleteDB(PGLOBAL g, int irc)
{
strcpy(g->Message, "Delete not enabled for MAC tables");
return RC_FX;
} // end of DeleteDB
// ------------------------ MACCOL functions ----------------------------
/***********************************************************************/
/* MACCOL public constructor. */
/***********************************************************************/
MACCOL::MACCOL(PCOLDEF cdp, PTDB tdbp, int n)
: COLBLK(cdp, tdbp, n)
{
Tdbp = (PTDBMAC)tdbp;
Flag = cdp->GetOffset();
if (Flag < 10)
Tdbp->Fix = true;
else
Tdbp->Adap = true;
} // end of MACCOL constructor
/***********************************************************************/
/* Read the next MAC address elements. */
/***********************************************************************/
void MACCOL::ReadColumn(PGLOBAL g)
{
// Type conversion is handled by Value set routines
char *p = NULL, buf[260] = "";
unsigned int i;
int n = 0;
PIP_ADAPTER_INFO adp = Tdbp->Curp;
FIXED_INFO *fip = Tdbp->FixedInfo;
if (!adp && Flag >= 10) {
// Fix info row, no adapter info available
switch (Flag) {
case 13:
case 14:
case 19:
case 22:
case 23:
n = 0;
break;
default:
p = "";
} // endswitch Flag
} else switch (Flag) {
// FIXED INFO
case 1: // Host Name
p = fip->HostName;
break;
case 2: // Domain Name
p = fip->DomainName;
break;
case 3: // DNS IPaddress
p = (fip->CurrentDnsServer)
? (char*)&fip->CurrentDnsServer->IpAddress
: (char*)&fip->DnsServerList.IpAddress;
break;
case 4: // Node Type
n = (int)fip->NodeType;
break;
case 5: // Scope ID ???
p = fip->ScopeId;
break;
case 6: // Routing enabled
n = (int)fip->EnableRouting;
break;
case 7: // Proxy enabled
n = (int)fip->EnableProxy;
break;
case 8: // DNS enabled
n = (int)fip->EnableDns;
break;
// ADAPTERS INFO
case 10: // Name
p = adp->AdapterName;
break;
case 11: // Description
if ((p = strstr(adp->Description, " - Packet Scheduler Miniport"))) {
strncpy(buf, adp->Description, p - adp->Description);
i = p - adp->Description;
strncpy(buf, adp->Description, i);
buf[i] = 0;
p = buf;
} else if ((p = strstr(adp->Description,
" - Miniport d'ordonnancement de paquets"))) {
i = p - adp->Description;
strncpy(buf, adp->Description, i);
buf[i] = 0;
p = buf;
} else
p = adp->Description;
break;
case 12: // MAC Address
for (p = buf, i = 0; i < adp->AddressLength; i++) {
if (i)
strcat(p++, "-");
p += sprintf(p, "%.2X", adp->Address[i]);
} // endfor i
p = buf;
break;
case 13: // Type
#if 0 // This is not found in the SDK
switch (adp->Type) {
case IF_ETHERNET_ADAPTERTYPE: p = "Ethernet Adapter"; break;
case IF_TOKEN_RING_ADAPTERTYPE: p = "Token Ring Adapter"; break;
case IF_FDDI_ADAPTERTYPE: p = "FDDI Adapter"; break;
case IF_PPP_ADAPTERTYPE: p = "PPP Adapter"; break;
case IF_LOOPBACK_ADAPTERTYPE: p = "Loop Back Adapter"; break;
// case IF_SLIP_ADAPTERTYPE: p = "Generic Slip Adapter"; break;
default:
sprintf(buf, "Other Adapter, type=%d", adp->Type);
p = buf;
} // endswitch Type
#endif // 0
n = (int)adp->Type;
break;
case 14: // DHCP enabled
n = (int)adp->DhcpEnabled;
break;
case 15: // IP Address
p = (adp->CurrentIpAddress)
? (char*)&adp->CurrentIpAddress->IpAddress
: (char*)&adp->IpAddressList.IpAddress;
break;
case 16: // Subnet Mask
p = (adp->CurrentIpAddress)
? (char*)&adp->CurrentIpAddress->IpMask
: (char*)&adp->IpAddressList.IpMask;
break;
case 17: // Gateway
p = (char*)&adp->GatewayList.IpAddress;
break;
case 18: // DHCP Server
p = (char*)&adp->DhcpServer.IpAddress;
break;
case 19: // Have WINS
n = (adp->HaveWins) ? 1 : 0;
break;
case 20: // Primary WINS
p = (char*)&adp->PrimaryWinsServer.IpAddress;
break;
case 21: // Secondary WINS
p = (char*)&adp->SecondaryWinsServer.IpAddress;
break;
case 22: // Lease obtained
n = (int)adp->LeaseObtained;
break;
case 23: // Lease expires
n = (int)adp->LeaseExpires;
break;
default:
if (Buf_Type == TYPE_STRING) {
sprintf(buf, "Invalid flag value %d", Flag);
p = buf;
} else
n = 0;
} // endswitch Flag
if (p)
Value->SetValue_psz(p);
else
Value->SetValue(n);
} // end of ReadColumn

View File

@@ -1,107 +1,107 @@
// TABMAC.H Olivier Bertrand 2011-2012
// MAC: virtual table to Get Mac Addresses via GetAdaptersInfo
#if defined(WIN32)
#include <windows.h>
#include <iphlpapi.h>
#else // !WIN32
#error This is a WIN32 only table TYPE
#endif // !WIN32
/***********************************************************************/
/* Definitions. */
/***********************************************************************/
typedef class MACDEF *PMACDEF;
typedef class TDBMAC *PTDBMAC;
typedef class MACCOL *PMACCOL;
/* -------------------------- MAC classes ---------------------------- */
/***********************************************************************/
/* MAC: virtual table to get the list of MAC addresses. */
/***********************************************************************/
class DllExport MACDEF : public TABDEF { /* Logical table description */
friend class TDBMAC;
public:
// Constructor
MACDEF(void) {Pseudo = 3;}
// Implementation
virtual const char *GetType(void) {return "MAC";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g) {return true;}
protected:
// Members
}; // end of MACDEF
/***********************************************************************/
/* This is the class declaration for the MAC table. */
/***********************************************************************/
class TDBMAC : public TDBASE {
friend class MACCOL;
public:
// Constructor
TDBMAC(PMACDEF tdp);
//TDBMAC(PGLOBAL g, PTDBMAC tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MAC;}
//virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMAC(g, this);}
// Methods
//virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g) {}
protected:
// Specific routines
bool GetMacInfo(PGLOBAL g);
bool GetFixedInfo(PGLOBAL g);
void MakeErrorMsg(PGLOBAL g, DWORD drc);
// Members
FIXED_INFO *FixedInfo; // Points to fixed info structure
PIP_ADAPTER_INFO Piaf; // Points on Adapter info array
PIP_ADAPTER_INFO Curp; // Points on current Adapt info
PIP_ADAPTER_INFO Next; // Points on next Adapt info
ULONG Buflen; // Buffer length
bool Fix; // true if FixedInfo is needed
bool Adap; // true if Piaf is needed
int N; // Row number
}; // end of class TDBMAC
/***********************************************************************/
/* Class MACCOL: MAC Address column. */
/***********************************************************************/
class MACCOL : public COLBLK {
friend class TDBMAC;
public:
// Constructors
MACCOL(PCOLDEF cdp, PTDB tdbp, int n);
//MACCOL(MACCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_MAC;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
MACCOL(void) {} // Default constructor not to be used
// Members
PTDBMAC Tdbp; // Points to MAC table block
int Flag; // Indicates what to display
}; // end of class MACCOL
// TABMAC.H Olivier Bertrand 2011-2012
// MAC: virtual table to Get Mac Addresses via GetAdaptersInfo
#if defined(WIN32)
#include <windows.h>
#include <iphlpapi.h>
#else // !WIN32
#error This is a WIN32 only table TYPE
#endif // !WIN32
/***********************************************************************/
/* Definitions. */
/***********************************************************************/
typedef class MACDEF *PMACDEF;
typedef class TDBMAC *PTDBMAC;
typedef class MACCOL *PMACCOL;
/* -------------------------- MAC classes ---------------------------- */
/***********************************************************************/
/* MAC: virtual table to get the list of MAC addresses. */
/***********************************************************************/
class DllExport MACDEF : public TABDEF { /* Logical table description */
friend class TDBMAC;
public:
// Constructor
MACDEF(void) {Pseudo = 3;}
// Implementation
virtual const char *GetType(void) {return "MAC";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g) {return true;}
protected:
// Members
}; // end of MACDEF
/***********************************************************************/
/* This is the class declaration for the MAC table. */
/***********************************************************************/
class TDBMAC : public TDBASE {
friend class MACCOL;
public:
// Constructor
TDBMAC(PMACDEF tdp);
//TDBMAC(PGLOBAL g, PTDBMAC tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MAC;}
//virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMAC(g, this);}
// Methods
//virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g) {}
protected:
// Specific routines
bool GetMacInfo(PGLOBAL g);
bool GetFixedInfo(PGLOBAL g);
void MakeErrorMsg(PGLOBAL g, DWORD drc);
// Members
FIXED_INFO *FixedInfo; // Points to fixed info structure
PIP_ADAPTER_INFO Piaf; // Points on Adapter info array
PIP_ADAPTER_INFO Curp; // Points on current Adapt info
PIP_ADAPTER_INFO Next; // Points on next Adapt info
ULONG Buflen; // Buffer length
bool Fix; // true if FixedInfo is needed
bool Adap; // true if Piaf is needed
int N; // Row number
}; // end of class TDBMAC
/***********************************************************************/
/* Class MACCOL: MAC Address column. */
/***********************************************************************/
class MACCOL : public COLBLK {
friend class TDBMAC;
public:
// Constructors
MACCOL(PCOLDEF cdp, PTDB tdbp, int n);
//MACCOL(MACCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_MAC;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
MACCOL(void) {} // Default constructor not to be used
// Members
PTDBMAC Tdbp; // Points to MAC table block
int Flag; // Indicates what to display
}; // end of class MACCOL

File diff suppressed because it is too large Load Diff

View File

@@ -1,220 +1,220 @@
/*************** Tabmul H Declares Source Code File (.H) ***************/
/* Name: TABMUL.H Version 1.4 */
/* */
/* (C) Copyright to PlugDB Software Development 2003-2012 */
/* Author: Olivier BERTRAND */
/* */
/* This file contains the TDBMUL and TDBDIR classes declares. */
/***********************************************************************/
#if defined(WIN32)
#include <io.h>
#else // !WIN32
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#endif // !WIN32
//#include "osutil.h"
#include "block.h"
typedef class TDBMUL *PTDBMUL;
typedef class TDBSDR *PTDBSDR;
/***********************************************************************/
/* This is the MUL Access Method class declaration for files that are */
/* physically split in multiple files having the same format. */
/***********************************************************************/
class DllExport TDBMUL : public TDBASE {
//friend class MULCOL;
public:
// Constructor
TDBMUL(PTDBASE tdbp);
TDBMUL(PTDBMUL tdbp);
// Implementation
virtual AMT GetAmType(void) {return Tdbp->GetAmType();}
virtual PTDB Duplicate(PGLOBAL g);
// Methods
virtual void ResetDB(void);
virtual PTDB CopyOne(PTABS t);
virtual bool IsSame(PTBX tp) {return tp == (PTBX)Tdbp;}
virtual PSZ GetFile(PGLOBAL g) {return Tdbp->GetFile(g);}
virtual int GetRecpos(void) {return 0;}
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
bool InitFileNames(PGLOBAL g);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
{strcpy(g->Message, MSG(MUL_MAKECOL_ERR)); return NULL;}
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void);
virtual int RowNumber(PGLOBAL g, bool b = false);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Members
TDBASE *Tdbp; // Points to a (file) table class
char* *Filenames; // Points to file names
int Rows; // Total rows of already read files
int Mul; // Type of multiple file list
int NumFiles; // Number of physical files
int iFile; // Index of currently processed file
}; // end of class TDBMUL
/***********************************************************************/
/* Directory listing table. */
/***********************************************************************/
class DllExport DIRDEF : public TABDEF { /* Directory listing table */
friend class CATALOG;
friend class TDBDIR;
public:
// Constructor
DIRDEF(void) {Fn = NULL; Incl = false; Huge = false;}
// Implementation
virtual const char *GetType(void) {return "DIR";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PSZ Fn; /* Path/Name of file search */
bool Incl; /* true to include sub-directories */
bool Huge; /* true if files can be larger than 2GB */
}; // end of DIRDEF
/***********************************************************************/
/* This is the DIR Access Method class declaration for tables that */
/* represent a directory listing. The pathname is given at the create */
/* time and can contain wildcard characters in the file name, and the */
/* (virtual) table is populated when it is in use. */
/***********************************************************************/
class TDBDIR : public TDBASE {
friend class DIRCOL;
public:
// Constructor
TDBDIR(PDIRDEF tdp);
TDBDIR(PTDBDIR tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DIR;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBDIR(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return iFile;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);}
virtual int GetProgCur(void) {return iFile;}
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
char *Path(PGLOBAL g);
// Members
PSZ To_File; // Points to file search pathname
int iFile; // Index of currently retrieved file
#if defined(WIN32)
_finddata_t FileData; // Find data structure
int Hsearch; // Search handle
char Drive[_MAX_DRIVE]; // Drive name
#else // !WIN32
struct stat Fileinfo; // File info structure
struct dirent *Entry; // Point to directory entry structure
DIR *Dir; // To searched directory structure
bool Done; // true when _splipath is done
char Pattern[_MAX_FNAME+_MAX_EXT];
#endif // !WIN32
char Fpath[_MAX_PATH]; // Absolute file search pattern
char Direc[_MAX_DIR]; // Search path
char Fname[_MAX_FNAME]; // File name
char Ftype[_MAX_EXT]; // File extention
}; // end of class TDBDIR
/***********************************************************************/
/* This is the DIR Access Method class declaration for tables that */
/* represent a directory listing. The pathname is given at the create */
/* time and can contain wildcard characters in the file name, and the */
/* (virtual) table is populated when it is in use. In addition, this */
/* class also includes files of included sub-directories. */
/***********************************************************************/
class TDBSDR : public TDBDIR {
friend class DIRCOL;
public:
// Constructors
TDBSDR(PDIRDEF tdp) : TDBDIR(tdp) {Sub = NULL;}
TDBSDR(PTDBSDR tdbp);
// Implementation
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBSDR(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
// Database routines
virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);}
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
//virtual void CloseDB(PGLOBAL g);
protected:
int FindInDir(PGLOBAL g);
typedef struct _Sub_Dir {
struct _Sub_Dir *Next;
struct _Sub_Dir *Prev;
#if defined(WIN32)
int H; // Search handle
#else // !WIN32
DIR *D;
#endif // !WIN32
size_t Len; // Initial directory name length
} SUBDIR, *PSUBDIR;
// Members
PSUBDIR Sub; // To current Subdir block
}; // end of class TDBSDR
/***********************************************************************/
/* Class DIRCOL: DIR access method column descriptor. */
/* This A.M. is used for tables populated by DIR file name list. */
/***********************************************************************/
class DIRCOL : public COLBLK {
public:
// Constructors
DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "DIR");
DIRCOL(DIRCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_DIR;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
// Default constructor not to be used
DIRCOL(void) {}
// Members
int N; // Column number
}; // end of class DIRCOL
/*************** Tabmul H Declares Source Code File (.H) ***************/
/* Name: TABMUL.H Version 1.4 */
/* */
/* (C) Copyright to PlugDB Software Development 2003-2012 */
/* Author: Olivier BERTRAND */
/* */
/* This file contains the TDBMUL and TDBDIR classes declares. */
/***********************************************************************/
#if defined(WIN32)
#include <io.h>
#else // !WIN32
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#endif // !WIN32
//#include "osutil.h"
#include "block.h"
typedef class TDBMUL *PTDBMUL;
typedef class TDBSDR *PTDBSDR;
/***********************************************************************/
/* This is the MUL Access Method class declaration for files that are */
/* physically split in multiple files having the same format. */
/***********************************************************************/
class DllExport TDBMUL : public TDBASE {
//friend class MULCOL;
public:
// Constructor
TDBMUL(PTDBASE tdbp);
TDBMUL(PTDBMUL tdbp);
// Implementation
virtual AMT GetAmType(void) {return Tdbp->GetAmType();}
virtual PTDB Duplicate(PGLOBAL g);
// Methods
virtual void ResetDB(void);
virtual PTDB CopyOne(PTABS t);
virtual bool IsSame(PTBX tp) {return tp == (PTBX)Tdbp;}
virtual PSZ GetFile(PGLOBAL g) {return Tdbp->GetFile(g);}
virtual int GetRecpos(void) {return 0;}
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
bool InitFileNames(PGLOBAL g);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
{strcpy(g->Message, MSG(MUL_MAKECOL_ERR)); return NULL;}
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void);
virtual int RowNumber(PGLOBAL g, bool b = false);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Members
TDBASE *Tdbp; // Points to a (file) table class
char* *Filenames; // Points to file names
int Rows; // Total rows of already read files
int Mul; // Type of multiple file list
int NumFiles; // Number of physical files
int iFile; // Index of currently processed file
}; // end of class TDBMUL
/***********************************************************************/
/* Directory listing table. */
/***********************************************************************/
class DllExport DIRDEF : public TABDEF { /* Directory listing table */
friend class CATALOG;
friend class TDBDIR;
public:
// Constructor
DIRDEF(void) {Fn = NULL; Incl = false; Huge = false;}
// Implementation
virtual const char *GetType(void) {return "DIR";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PSZ Fn; /* Path/Name of file search */
bool Incl; /* true to include sub-directories */
bool Huge; /* true if files can be larger than 2GB */
}; // end of DIRDEF
/***********************************************************************/
/* This is the DIR Access Method class declaration for tables that */
/* represent a directory listing. The pathname is given at the create */
/* time and can contain wildcard characters in the file name, and the */
/* (virtual) table is populated when it is in use. */
/***********************************************************************/
class TDBDIR : public TDBASE {
friend class DIRCOL;
public:
// Constructor
TDBDIR(PDIRDEF tdp);
TDBDIR(PTDBDIR tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DIR;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBDIR(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return iFile;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);}
virtual int GetProgCur(void) {return iFile;}
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
char *Path(PGLOBAL g);
// Members
PSZ To_File; // Points to file search pathname
int iFile; // Index of currently retrieved file
#if defined(WIN32)
_finddata_t FileData; // Find data structure
int Hsearch; // Search handle
char Drive[_MAX_DRIVE]; // Drive name
#else // !WIN32
struct stat Fileinfo; // File info structure
struct dirent *Entry; // Point to directory entry structure
DIR *Dir; // To searched directory structure
bool Done; // true when _splipath is done
char Pattern[_MAX_FNAME+_MAX_EXT];
#endif // !WIN32
char Fpath[_MAX_PATH]; // Absolute file search pattern
char Direc[_MAX_DIR]; // Search path
char Fname[_MAX_FNAME]; // File name
char Ftype[_MAX_EXT]; // File extention
}; // end of class TDBDIR
/***********************************************************************/
/* This is the DIR Access Method class declaration for tables that */
/* represent a directory listing. The pathname is given at the create */
/* time and can contain wildcard characters in the file name, and the */
/* (virtual) table is populated when it is in use. In addition, this */
/* class also includes files of included sub-directories. */
/***********************************************************************/
class TDBSDR : public TDBDIR {
friend class DIRCOL;
public:
// Constructors
TDBSDR(PDIRDEF tdp) : TDBDIR(tdp) {Sub = NULL;}
TDBSDR(PTDBSDR tdbp);
// Implementation
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBSDR(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
// Database routines
virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);}
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
//virtual void CloseDB(PGLOBAL g);
protected:
int FindInDir(PGLOBAL g);
typedef struct _Sub_Dir {
struct _Sub_Dir *Next;
struct _Sub_Dir *Prev;
#if defined(WIN32)
int H; // Search handle
#else // !WIN32
DIR *D;
#endif // !WIN32
size_t Len; // Initial directory name length
} SUBDIR, *PSUBDIR;
// Members
PSUBDIR Sub; // To current Subdir block
}; // end of class TDBSDR
/***********************************************************************/
/* Class DIRCOL: DIR access method column descriptor. */
/* This A.M. is used for tables populated by DIR file name list. */
/***********************************************************************/
class DIRCOL : public COLBLK {
public:
// Constructors
DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "DIR");
DIRCOL(DIRCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_DIR;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
// Default constructor not to be used
DIRCOL(void) {}
// Members
int N; // Column number
}; // end of class DIRCOL

File diff suppressed because it is too large Load Diff

View File

@@ -1,139 +1,143 @@
// TDBMYSQL.H Olivier Bertrand 2007-2012
#include "myconn.h" // MySQL connection declares
typedef class MYSQLDEF *PMYDEF;
typedef class TDBMYSQL *PTDBMY;
typedef class MYSQLC *PMYC;
typedef class MYSQLCOL *PMYCOL;
/* ------------------------- MYSQL classes --------------------------- */
/***********************************************************************/
/* MYSQL: table type that are MySQL tables. */
/* Using embedded MySQL library (or optionally calling a MySQL server)*/
/***********************************************************************/
/***********************************************************************/
/* MYSQL table. */
/***********************************************************************/
class MYSQLDEF : public TABDEF {/* Logical table description */
friend class TDBMYSQL;
public:
// Constructor
MYSQLDEF(void);
// Implementation
virtual const char *GetType(void) {return "MYSQL";}
inline PSZ GetHostname(void) {return Hostname;};
inline PSZ GetDatabase(void) {return Database;};
inline PSZ GetTabname(void) {return Tabname;}
inline PSZ GetUsername(void) {return Username;};
inline PSZ GetPassword(void) {return Password;};
inline int GetPortnumber(void) {return Portnumber;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PSZ Hostname; /* Host machine to use */
PSZ Database; /* Database to be used by server */
PSZ Tabname; /* External table name */
PSZ Username; /* User logon name */
PSZ Password; /* Password logon info */
int Portnumber; /* MySQL port number (0 = default) */
bool Bind; /* Use prepared statement on insert */
bool Delayed; /* Delayed insert */
}; // end of MYSQLDEF
/***********************************************************************/
/* This is the class declaration for the MYSQL table. */
/***********************************************************************/
class TDBMYSQL : public TDBASE {
friend class MYSQLCOL;
public:
// Constructor
TDBMYSQL(PMYDEF tdp);
TDBMYSQL(PGLOBAL g, PTDBMY tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MYSQL;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetAffectedRows(void) {return AftRows;}
virtual int GetRecpos(void) {return N;}
virtual int GetProgMax(PGLOBAL g);
virtual void ResetDB(void) {N = 0;}
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Internal functions
bool MakeSelect(PGLOBAL g);
bool MakeInsert(PGLOBAL g);
//bool MakeUpdate(PGLOBAL g);
//bool MakeDelete(PGLOBAL g);
int BindColumns(PGLOBAL g);
// Members
MYSQLC Myc; // MySQL connection class
MYSQL_BIND *Bind; // To the MySQL bind structure array
char *Host; // Host machine to use
char *User; // User logon info
char *Pwd; // Password logon info
char *Database; // Database to be used by server
char *Tabname; // External table name
char *Query; // Points to SQL query
char *Qbuf; // Used for not prepared insert
bool Fetched; // True when fetch was done
bool Prep; // Use prepared statement on insert
bool Delayed; // Use delayed insert
int m_Rc; // Return code from command
int AftRows; // The number of affected rows
int N; // The current table index
int Port; // MySQL port number (0 = default)
int Nparm; // The number of statement parameters
}; // end of class TDBMYSQL
/***********************************************************************/
/* Class MYSQLCOL: MySQL table column. */
/***********************************************************************/
class MYSQLCOL : public COLBLK {
friend class TDBMYSQL;
public:
// Constructors
MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "MYSQL");
MYSQLCOL(MYSQLCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_MYSQL;}
void InitBind(PGLOBAL g);
// Methods
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
protected:
// Default constructor not to be used
MYSQLCOL(void) {}
// Members
MYSQL_BIND *Bind; // This column bind structure pointer
PVAL To_Val; // To value used for Update/Insert
unsigned long Slen; // Bind string lengh
int Rank; // Rank (position) number in the query
}; // end of class MYSQLCOL
// TDBMYSQL.H Olivier Bertrand 2007-2012
#include "myconn.h" // MySQL connection declares
typedef class MYSQLDEF *PMYDEF;
typedef class TDBMYSQL *PTDBMY;
typedef class MYSQLC *PMYC;
typedef class MYSQLCOL *PMYCOL;
/* ------------------------- MYSQL classes --------------------------- */
/***********************************************************************/
/* MYSQL: table type that are MySQL tables. */
/* Using embedded MySQL library (or optionally calling a MySQL server)*/
/***********************************************************************/
/***********************************************************************/
/* MYSQL table. */
/***********************************************************************/
class MYSQLDEF : public TABDEF {/* Logical table description */
friend class TDBMYSQL;
public:
// Constructor
MYSQLDEF(void);
// Implementation
virtual const char *GetType(void) {return "MYSQL";}
inline PSZ GetHostname(void) {return Hostname;};
inline PSZ GetDatabase(void) {return Database;};
inline PSZ GetTabname(void) {return Tabname;}
inline PSZ GetUsername(void) {return Username;};
inline PSZ GetPassword(void) {return Password;};
inline int GetPortnumber(void) {return Portnumber;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PSZ Hostname; /* Host machine to use */
PSZ Database; /* Database to be used by server */
PSZ Tabname; /* External table name */
PSZ Username; /* User logon name */
PSZ Password; /* Password logon info */
int Portnumber; /* MySQL port number (0 = default) */
bool Bind; /* Use prepared statement on insert */
bool Delayed; /* Delayed insert */
}; // end of MYSQLDEF
/***********************************************************************/
/* This is the class declaration for the MYSQL table. */
/***********************************************************************/
class TDBMYSQL : public TDBASE {
friend class MYSQLCOL;
public:
// Constructor
TDBMYSQL(PMYDEF tdp);
TDBMYSQL(PGLOBAL g, PTDBMY tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MYSQL;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetAffectedRows(void) {return AftRows;}
virtual int GetRecpos(void) {return N;}
virtual int GetProgMax(PGLOBAL g);
virtual void ResetDB(void) {N = 0;}
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Internal functions
bool MakeSelect(PGLOBAL g);
bool MakeInsert(PGLOBAL g);
//bool MakeUpdate(PGLOBAL g);
//bool MakeDelete(PGLOBAL g);
int BindColumns(PGLOBAL g);
// Members
MYSQLC Myc; // MySQL connection class
MYSQL_BIND *Bind; // To the MySQL bind structure array
char *Host; // Host machine to use
char *User; // User logon info
char *Pwd; // Password logon info
char *Database; // Database to be used by server
char *Tabname; // External table name
char *Query; // Points to SQL query
char *Qbuf; // Used for not prepared insert
bool Fetched; // True when fetch was done
bool Prep; // Use prepared statement on insert
bool Delayed; // Use delayed insert
int m_Rc; // Return code from command
int AftRows; // The number of affected rows
int N; // The current table index
int Port; // MySQL port number (0 = default)
int Nparm; // The number of statement parameters
}; // end of class TDBMYSQL
/***********************************************************************/
/* Class MYSQLCOL: MySQL table column. */
/***********************************************************************/
class MYSQLCOL : public COLBLK {
friend class TDBMYSQL;
public:
// Constructors
MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "MYSQL");
MYSQLCOL(MYSQLCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_MYSQL;}
void InitBind(PGLOBAL g);
// Methods
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
protected:
// Default constructor not to be used
MYSQLCOL(void) {}
// Members
MYSQL_BIND *Bind; // This column bind structure pointer
PVAL To_Val; // To value used for Update/Insert
unsigned long Slen; // Bind string lengh
int Rank; // Rank (position) number in the query
}; // end of class MYSQLCOL
PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
const char *user, const char *pwd,
const char *table, const char *colpat, int port, bool key);

File diff suppressed because it is too large Load Diff

View File

@@ -1,260 +1,259 @@
/*************** Tabodbc H Declares Source Code File (.H) **************/
/* Name: TABODBC.H Version 1.5 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2013 */
/* */
/* This file contains the TDBODBC classes declares. */
/***********************************************************************/
#include "colblk.h"
#include "resource.h"
typedef class ODBCDEF *PODEF;
typedef class TDBODBC *PTDBODBC;
typedef class ODBCCOL *PODBCCOL;
typedef class TDBOIF *PTDBOIF;
typedef class OIFCOL *POIFCOL;
typedef class TDBSRC *PTDBSRC;
/***********************************************************************/
/* ODBC table. */
/***********************************************************************/
class DllExport ODBCDEF : public TABDEF { /* Logical table description */
public:
// Constructor
ODBCDEF(void);
// Implementation
virtual const char *GetType(void) {return "ODBC";}
PSZ GetConnect(void) {return Connect;}
PSZ GetTabname(void) {return Tabname;}
PSZ GetTabowner(void) {return Tabowner;}
PSZ GetTabqual(void) {return Tabqual;}
PSZ GetQchar(void) {return (Qchar && *Qchar) ? Qchar : NULL;}
int GetCatver(void) {return Catver;}
int GetOptions(void) {return Options;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PSZ Connect; /* ODBC connection string */
PSZ Tabname; /* External table name */
PSZ Tabowner; /* External table owner */
PSZ Tabqual; /* External table qualifier */
PSZ Qchar; /* Identifier quoting character */
PSZ Info; /* Information value */
int Catver; /* ODBC version for catalog functions */
int Options; /* Open connection options */
}; // end of ODBCDEF
#if !defined(NODBC)
#include "odbconn.h"
/***********************************************************************/
/* This is the ODBC Access Method class declaration for files from */
/* other DB drivers to be accessed via ODBC. */
/***********************************************************************/
class TDBODBC : public TDBASE {
friend class ODBCCOL;
friend class ODBConn;
public:
// Constructor
TDBODBC(PODEF tdp = NULL);
TDBODBC(PTDBODBC tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ODBC;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBODBC(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void);
virtual PSZ GetFile(PGLOBAL g);
virtual void SetFile(PGLOBAL g, PSZ fn);
virtual void ResetSize(void);
virtual int GetAffectedRows(void) {return AftRows;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetProgMax(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Internal functions
int Decode(char *utf, char *buf, size_t n);
char *MakeSQL(PGLOBAL g, bool cnt);
//bool MakeUpdate(PGLOBAL g, PSELECT selist);
//bool MakeInsert(PGLOBAL g);
//bool MakeDelete(PGLOBAL g);
//bool MakeFilter(PGLOBAL g, bool c);
//bool BindParameters(PGLOBAL g);
// Members
ODBConn *Ocp; // Points to an ODBC connection class
ODBCCOL *Cnp; // Points to count(*) column
char *Connect; // Points to connection string
char *TableName; // Points to ODBC table name
char *Owner; // Points to ODBC table Owner
char *Qualifier; // Points to ODBC table Qualifier
char *Query; // Points to SQL statement
char *Count; // Points to count(*) SQL statement
//char *Where; // Points to local where clause
char *Quote; // The identifier quoting character
char *MulConn; // Used for multiple ODBC tables
char *DBQ; // The address part of Connect string
int Options; // Connect options
int Fpos; // Position of last read record
int AftRows; // The number of affected rows
int Rows; // Rowset size
int Catver; // Catalog ODBC version
int CurNum; // Current buffer line number
int Rbuf; // Number of lines read in buffer
int BufSize; // Size of connect string buffer
int Nparm; // The number of statement parameters
}; // end of class TDBODBC
/***********************************************************************/
/* Class ODBCCOL: DOS access method column descriptor. */
/* This A.M. is used for ODBC tables. */
/***********************************************************************/
class ODBCCOL : public COLBLK {
friend class TDBODBC;
public:
// Constructors
ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "ODBC");
ODBCCOL(ODBCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_ODBC;}
SQLLEN *GetStrLen(void) {return StrLen;}
int GetRank(void) {return Rank;}
// PVBLK GetBlkp(void) {return Blkp;}
// Methods
//virtual bool CheckLocal(PTDB tdbp);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
void AllocateBuffers(PGLOBAL g, int rows);
void *GetBuffer(DWORD rows);
SWORD GetBuflen(void);
// void Print(PGLOBAL g, FILE *, uint);
protected:
// Constructor used by GetMaxSize
ODBCCOL(void);
// Members
TIMESTAMP_STRUCT *Sqlbuf; // To get SQL_TIMESTAMP's
void *Bufp; // To extended buffer
PVBLK Blkp; // To Value Block
//char F_Date[12]; // Internal Date format
PVAL To_Val; // To value used for Insert
SQLLEN *StrLen; // As returned by ODBC
SQLLEN Slen; // Used with Fetch
int Rank; // Rank (position) number in the query
}; // end of class ODBCCOL
/***********************************************************************/
/* This is the base class declaration for the ODBC info tables. */
/***********************************************************************/
class TDBOIF : public TDBASE {
friend class OIFCOL;
public:
// Constructor
TDBOIF(PODEF tdp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ODBC;}
// Methods
virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Specific routines
virtual bool Initialize(PGLOBAL g) = 0;
bool InitCol(PGLOBAL g);
// Members
PQRYRES Qrp; // Result set
int ID; // Base of Column names
int NC; // Number of valid flags
int N; // Row number
bool Init;
}; // end of class TDBOIF
/***********************************************************************/
/* Class OIFCOL: ODBC info column. */
/***********************************************************************/
class OIFCOL : public COLBLK {
friend class TDBOIF;
public:
// Constructors
OIFCOL(PCOLDEF cdp, PTDB tdbp, int n);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_ODBC;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
OIFCOL(void) {} // Default constructor not to be used
// Members
PTDBOIF Tdbp; // Points to ODBC table block
PCOLRES Crp; // The column data array
int Flag;
}; // end of class OIFCOL
/***********************************************************************/
/* This is the class declaration for the Data Sources info table. */
/***********************************************************************/
class TDBSRC : public TDBOIF {
public:
// Constructor
TDBSRC(PODEF tdp) : TDBOIF(tdp) {ID = IDS_DSRC; NC = 2;}
protected:
// Specific routines
virtual bool Initialize(PGLOBAL g);
}; // end of class TDBSRC
/***********************************************************************/
/* This is the class declaration for the columns info table. */
/***********************************************************************/
class TDBOCL : public TDBOIF {
public:
// Constructor
TDBOCL(PODEF tdp);
protected:
// Specific routines
virtual bool Initialize(PGLOBAL g);
// Members
char *Dsn; // Points to connection string
char *Tabn; // Points to ODBC table name
}; // end of class TDBOCL
#endif // !NODBC
/*************** Tabodbc H Declares Source Code File (.H) **************/
/* Name: TABODBC.H Version 1.5 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2013 */
/* */
/* This file contains the TDBODBC classes declares. */
/***********************************************************************/
#include "colblk.h"
#include "resource.h"
typedef class ODBCDEF *PODEF;
typedef class TDBODBC *PTDBODBC;
typedef class ODBCCOL *PODBCCOL;
typedef class TDBOIF *PTDBOIF;
typedef class OIFCOL *POIFCOL;
typedef class TDBSRC *PTDBSRC;
/***********************************************************************/
/* ODBC table. */
/***********************************************************************/
class DllExport ODBCDEF : public TABDEF { /* Logical table description */
public:
// Constructor
ODBCDEF(void);
// Implementation
virtual const char *GetType(void) {return "ODBC";}
PSZ GetConnect(void) {return Connect;}
PSZ GetTabname(void) {return Tabname;}
PSZ GetTabowner(void) {return Tabowner;}
PSZ GetTabqual(void) {return Tabqual;}
PSZ GetQchar(void) {return (Qchar && *Qchar) ? Qchar : NULL;}
int GetCatver(void) {return Catver;}
int GetOptions(void) {return Options;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PSZ Connect; /* ODBC connection string */
PSZ Tabname; /* External table name */
PSZ Tabowner; /* External table owner */
PSZ Tabqual; /* External table qualifier */
PSZ Qchar; /* Identifier quoting character */
PSZ Info; /* Information value */
int Catver; /* ODBC version for catalog functions */
int Options; /* Open connection options */
}; // end of ODBCDEF
#if !defined(NODBC)
#include "odbconn.h"
/***********************************************************************/
/* This is the ODBC Access Method class declaration for files from */
/* other DB drivers to be accessed via ODBC. */
/***********************************************************************/
class TDBODBC : public TDBASE {
friend class ODBCCOL;
friend class ODBConn;
public:
// Constructor
TDBODBC(PODEF tdp = NULL);
TDBODBC(PTDBODBC tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ODBC;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBODBC(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void);
virtual PSZ GetFile(PGLOBAL g);
virtual void SetFile(PGLOBAL g, PSZ fn);
virtual void ResetSize(void);
virtual int GetAffectedRows(void) {return AftRows;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetProgMax(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Internal functions
int Decode(char *utf, char *buf, size_t n);
char *MakeSQL(PGLOBAL g, bool cnt);
//bool MakeUpdate(PGLOBAL g, PSELECT selist);
//bool MakeInsert(PGLOBAL g);
//bool MakeDelete(PGLOBAL g);
//bool MakeFilter(PGLOBAL g, bool c);
//bool BindParameters(PGLOBAL g);
// Members
ODBConn *Ocp; // Points to an ODBC connection class
ODBCCOL *Cnp; // Points to count(*) column
char *Connect; // Points to connection string
char *TableName; // Points to ODBC table name
char *Owner; // Points to ODBC table Owner
char *Qualifier; // Points to ODBC table Qualifier
char *Query; // Points to SQL statement
char *Count; // Points to count(*) SQL statement
//char *Where; // Points to local where clause
char *Quote; // The identifier quoting character
char *MulConn; // Used for multiple ODBC tables
char *DBQ; // The address part of Connect string
int Options; // Connect options
int Fpos; // Position of last read record
int AftRows; // The number of affected rows
int Rows; // Rowset size
int Catver; // Catalog ODBC version
int CurNum; // Current buffer line number
int Rbuf; // Number of lines read in buffer
int BufSize; // Size of connect string buffer
int Nparm; // The number of statement parameters
}; // end of class TDBODBC
/***********************************************************************/
/* Class ODBCCOL: DOS access method column descriptor. */
/* This A.M. is used for ODBC tables. */
/***********************************************************************/
class ODBCCOL : public COLBLK {
friend class TDBODBC;
public:
// Constructors
ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "ODBC");
ODBCCOL(ODBCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_ODBC;}
SQLLEN *GetStrLen(void) {return StrLen;}
int GetRank(void) {return Rank;}
// PVBLK GetBlkp(void) {return Blkp;}
// Methods
//virtual bool CheckLocal(PTDB tdbp);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
void AllocateBuffers(PGLOBAL g, int rows);
void *GetBuffer(DWORD rows);
SWORD GetBuflen(void);
// void Print(PGLOBAL g, FILE *, uint);
protected:
// Constructor used by GetMaxSize
ODBCCOL(void);
// Members
TIMESTAMP_STRUCT *Sqlbuf; // To get SQL_TIMESTAMP's
void *Bufp; // To extended buffer
PVBLK Blkp; // To Value Block
//char F_Date[12]; // Internal Date format
PVAL To_Val; // To value used for Insert
SQLLEN *StrLen; // As returned by ODBC
SQLLEN Slen; // Used with Fetch
int Rank; // Rank (position) number in the query
}; // end of class ODBCCOL
/***********************************************************************/
/* This is the base class declaration for the ODBC info tables. */
/***********************************************************************/
class TDBOIF : public TDBASE {
friend class OIFCOL;
public:
// Constructor
TDBOIF(PODEF tdp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ODBC;}
// Methods
virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Specific routines
virtual bool Initialize(PGLOBAL g) = 0;
bool InitCol(PGLOBAL g);
// Members
PQRYRES Qrp;
int ID; // Base of Column names
int NC; // Number of valid flags
int N; // Row number
bool Init;
}; // end of class TDBOIF
/***********************************************************************/
/* Class OIFCOL: ODBC info column. */
/***********************************************************************/
class OIFCOL : public COLBLK {
friend class TDBOIF;
public:
// Constructors
OIFCOL(PCOLDEF cdp, PTDB tdbp, int n);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_ODBC;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
OIFCOL(void) {} // Default constructor not to be used
// Members
PTDBOIF Tdbp; // Points to ODBC table block
PCOLRES Crp; // The column data array
int Flag;
}; // end of class OIFCOL
/***********************************************************************/
/* This is the class declaration for the Data Sources info table. */
/***********************************************************************/
class TDBSRC : public TDBOIF {
public:
// Constructor
TDBSRC(PODEF tdp) : TDBOIF(tdp) {ID = IDS_DSRC; NC = 2;}
protected:
// Specific routines
virtual bool Initialize(PGLOBAL g);
}; // end of class TDBSRC
/***********************************************************************/
/* This is the class declaration for the columns info table. */
/***********************************************************************/
class TDBOCL : public TDBOIF {
public:
// Constructor
TDBOCL(PODEF tdp);
protected:
// Specific routines
virtual bool Initialize(PGLOBAL g);
// Members
char *Dsn; // Points to connection string
char *Tabn; // Points to ODBC table name
}; // end of class TDBOCL
#endif // !NODBC

File diff suppressed because it is too large Load Diff

View File

@@ -1,241 +1,241 @@
/************** TabPivot H Declares Source Code File (.H) **************/
/* Name: TABPIVOT.H Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the PIVOT classes declares. */
/***********************************************************************/
typedef class TDBPIVOT *PTDBPIVOT;
typedef class FNCCOL *PFNCCOL;
typedef class SRCCOL *PSRCCOL;
typedef class TDBQRS *PTDBQRS;
typedef class QRSCOL *PQRSCOL;
/* -------------------------- PIVOT classes -------------------------- */
/***********************************************************************/
/* PIVOT: table that provides a view of a source table where the */
/* pivot column is expended in as many columns as there are distinct */
/* values in it and containing the function value matching other cols.*/
/***********************************************************************/
/***********************************************************************/
/* PIVOT table. */
/***********************************************************************/
//ass DllExport PIVOTDEF : public TABDEF {/* Logical table description */
class PIVOTDEF : public TABDEF { /* Logical table description */
friend class TDBPIVOT;
public:
// Constructor
PIVOTDEF(void) {Pseudo = 3;
Tabname = Tabsrc = Picol = Fncol = Function = NULL;}
// Implementation
virtual const char *GetType(void) {return "PIVOT";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
char *Host; /* Host machine to use */
char *User; /* User logon info */
char *Pwd; /* Password logon info */
char *DB; /* Database to be used by server */
char *Tabname; /* Name of source table */
char *Tabsrc; /* The source table SQL description */
char *Picol; /* The pivot column */
char *Fncol; /* The function column */
char *Function; /* The function applying to group by */
bool GBdone; /* True if tabname as group by format */
int Port; /* MySQL port number */
}; // end of PIVOTDEF
/***********************************************************************/
/* This is the class declaration for the PIVOT table. */
/***********************************************************************/
//ass DllExport TDBPIVOT : public TDBASE, public CSORT {
class TDBPIVOT : public TDBASE, public CSORT {
friend class FNCCOL;
friend class SRCCOL;
public:
// Constructor
TDBPIVOT(PPIVOTDEF tdp);
//TDBPIVOT(PTDBPIVOT tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_PIVOT;}
//virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBPIVOT(this);}
// void SetTdbp(PTDB tdbp) {Tdbp = tdbp;}
// Methods
//virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return N;}
virtual void ResetDB(void) {N = 0;}
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
// The sorting function
virtual int Qcompare(int *, int *);
protected:
PQRYRES GetSourceTable(PGLOBAL g);
int MakePivotColumns(PGLOBAL g);
bool UpdateTableFields(PGLOBAL g, int n);
// Members
MYSQLC Myc; // MySQL connection class
PTDBQRS Tqrp; // To the source table result
char *Host; // Host machine to use
char *User; // User logon info
char *Pwd; // Password logon info
char *Database; // Database to be used by server
PQRYRES Qryp; // Points to Query result block
char *Tabname; // Name of source table
char *Tabsrc; // SQL of source table
char *Picol; // Pivot column name
char *Fncol; // Function column name
char *Function; // The function applying to group by
PQRSCOL Fcolp; // To the function column in source
PQRSCOL Xcolp; // To the pivot column in source
PCOLRES Xresp; // To the pivot result column
//PCOLRES To_Sort; // Saved Qryp To_Sort pointer
PVBLK Rblkp; // The value block of the pivot column
bool GBdone; // True when subtable is "Group by"
int Mult; // Multiplication factor
int Ncol; // The number of generated columns
int N; // The current table index
int M; // The occurence rank
int Port; // MySQL port number
BYTE FileStatus; // 0: First 1: Rows 2: End-of-File
BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip
}; // end of class TDBPIVOT
/***********************************************************************/
/* Class FNCCOL: for the multiple generated column. */
/***********************************************************************/
class FNCCOL : public COLBLK {
friend class TDBPIVOT;
public:
// Constructor
FNCCOL(PCOL colp, PTDBPIVOT tdbp);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_FNC;}
// Methods
virtual void Reset(void) {}
bool InitColumn(PGLOBAL g, PVAL valp);
protected:
// Member
PVAL Hval; // The original value used to generate the header
}; // end of class FNCCOL
/***********************************************************************/
/* Class SRCCOL: for other source columns. */
/***********************************************************************/
class SRCCOL : public COLBLK {
friend class TDBPIVOT;
public:
// Constructors
//SRCCOL(PCOLDEF cdp, PTDBPIVOT tdbp, int n);
SRCCOL(PCOL cp, PTDBPIVOT tdbp, int n);
//SRCCOL(SRCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_SRC;}
// Methods
virtual void Reset(void) {}
void SetColumn(void);
bool Init(PGLOBAL g, PTDBPIVOT tdbp);
bool CompareColumn(void);
protected:
// Default constructor not to be used
SRCCOL(void) {}
// Members
PQRSCOL Colp;
PVAL Cnval;
}; // end of class SRCCOL
/***********************************************************************/
/* TDBQRS: This is the Access Method class declaration for the Query */
/* Result stored in memory in the current work area (volatil). */
/***********************************************************************/
class DllExport TDBQRS : public TDBASE {
friend class QRSCOL;
public:
// Constructor
TDBQRS(PQRYRES qrp) : TDBASE() {Qrp = qrp; CurPos = 0;}
TDBQRS(PTDBQRS tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_QRS;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBQRS(this);}
PQRYRES GetQrp(void) {return Qrp;}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int RowNumber(PGLOBAL g, BOOL b = FALSE);
virtual int GetRecpos(void);
//virtual PCATLG GetCat(void);
//virtual PSZ GetPath(void);
virtual int GetBadLines(void) {return Qrp->BadLines;}
// Database routines
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
private:
TDBQRS(void) : TDBASE() {} // Standard constructor not to be used
protected:
// Members
PQRYRES Qrp; // Points to Query Result block
int CurPos; // Current line position
}; // end of class TDBQRS
/***********************************************************************/
/* Class QRSCOL: QRS access method column descriptor. */
/***********************************************************************/
class DllExport QRSCOL : public COLBLK {
friend class TDBQRS;
public:
// Constructors
QRSCOL(PGLOBAL g, PCOLRES crp, PTDB tdbp, PCOL cprec, int i);
QRSCOL(QRSCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_QRS;}
PCOLRES GetCrp(void) {return Crp;}
void *GetQrsData(void) {return Crp->Kdata;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, UINT);
protected:
QRSCOL(void) {} // Default constructor not to be used
// Members
PCOLRES Crp;
}; // end of class QRSCOL
/************** TabPivot H Declares Source Code File (.H) **************/
/* Name: TABPIVOT.H Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */
/* This file contains the PIVOT classes declares. */
/***********************************************************************/
typedef class TDBPIVOT *PTDBPIVOT;
typedef class FNCCOL *PFNCCOL;
typedef class SRCCOL *PSRCCOL;
typedef class TDBQRS *PTDBQRS;
typedef class QRSCOL *PQRSCOL;
/* -------------------------- PIVOT classes -------------------------- */
/***********************************************************************/
/* PIVOT: table that provides a view of a source table where the */
/* pivot column is expended in as many columns as there are distinct */
/* values in it and containing the function value matching other cols.*/
/***********************************************************************/
/***********************************************************************/
/* PIVOT table. */
/***********************************************************************/
//ass DllExport PIVOTDEF : public TABDEF {/* Logical table description */
class PIVOTDEF : public TABDEF { /* Logical table description */
friend class TDBPIVOT;
public:
// Constructor
PIVOTDEF(void) {Pseudo = 3;
Tabname = Tabsrc = Picol = Fncol = Function = NULL;}
// Implementation
virtual const char *GetType(void) {return "PIVOT";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
char *Host; /* Host machine to use */
char *User; /* User logon info */
char *Pwd; /* Password logon info */
char *DB; /* Database to be used by server */
char *Tabname; /* Name of source table */
char *Tabsrc; /* The source table SQL description */
char *Picol; /* The pivot column */
char *Fncol; /* The function column */
char *Function; /* The function applying to group by */
bool GBdone; /* True if tabname as group by format */
int Port; /* MySQL port number */
}; // end of PIVOTDEF
/***********************************************************************/
/* This is the class declaration for the PIVOT table. */
/***********************************************************************/
//ass DllExport TDBPIVOT : public TDBASE, public CSORT {
class TDBPIVOT : public TDBASE, public CSORT {
friend class FNCCOL;
friend class SRCCOL;
public:
// Constructor
TDBPIVOT(PPIVOTDEF tdp);
//TDBPIVOT(PTDBPIVOT tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_PIVOT;}
//virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBPIVOT(this);}
// void SetTdbp(PTDB tdbp) {Tdbp = tdbp;}
// Methods
//virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return N;}
virtual void ResetDB(void) {N = 0;}
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
// The sorting function
virtual int Qcompare(int *, int *);
protected:
PQRYRES GetSourceTable(PGLOBAL g);
int MakePivotColumns(PGLOBAL g);
bool UpdateTableFields(PGLOBAL g, int n);
// Members
MYSQLC Myc; // MySQL connection class
PTDBQRS Tqrp; // To the source table result
char *Host; // Host machine to use
char *User; // User logon info
char *Pwd; // Password logon info
char *Database; // Database to be used by server
PQRYRES Qryp; // Points to Query result block
char *Tabname; // Name of source table
char *Tabsrc; // SQL of source table
char *Picol; // Pivot column name
char *Fncol; // Function column name
char *Function; // The function applying to group by
PQRSCOL Fcolp; // To the function column in source
PQRSCOL Xcolp; // To the pivot column in source
PCOLRES Xresp; // To the pivot result column
//PCOLRES To_Sort; // Saved Qryp To_Sort pointer
PVBLK Rblkp; // The value block of the pivot column
bool GBdone; // True when subtable is "Group by"
int Mult; // Multiplication factor
int Ncol; // The number of generated columns
int N; // The current table index
int M; // The occurence rank
int Port; // MySQL port number
BYTE FileStatus; // 0: First 1: Rows 2: End-of-File
BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip
}; // end of class TDBPIVOT
/***********************************************************************/
/* Class FNCCOL: for the multiple generated column. */
/***********************************************************************/
class FNCCOL : public COLBLK {
friend class TDBPIVOT;
public:
// Constructor
FNCCOL(PCOL colp, PTDBPIVOT tdbp);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_FNC;}
// Methods
virtual void Reset(void) {}
bool InitColumn(PGLOBAL g, PVAL valp);
protected:
// Member
PVAL Hval; // The original value used to generate the header
}; // end of class FNCCOL
/***********************************************************************/
/* Class SRCCOL: for other source columns. */
/***********************************************************************/
class SRCCOL : public COLBLK {
friend class TDBPIVOT;
public:
// Constructors
//SRCCOL(PCOLDEF cdp, PTDBPIVOT tdbp, int n);
SRCCOL(PCOL cp, PTDBPIVOT tdbp, int n);
//SRCCOL(SRCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_SRC;}
// Methods
virtual void Reset(void) {}
void SetColumn(void);
bool Init(PGLOBAL g, PTDBPIVOT tdbp);
bool CompareColumn(void);
protected:
// Default constructor not to be used
SRCCOL(void) {}
// Members
PQRSCOL Colp;
PVAL Cnval;
}; // end of class SRCCOL
/***********************************************************************/
/* TDBQRS: This is the Access Method class declaration for the Query */
/* Result stored in memory in the current work area (volatil). */
/***********************************************************************/
class DllExport TDBQRS : public TDBASE {
friend class QRSCOL;
public:
// Constructor
TDBQRS(PQRYRES qrp) : TDBASE() {Qrp = qrp; CurPos = 0;}
TDBQRS(PTDBQRS tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_QRS;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBQRS(this);}
PQRYRES GetQrp(void) {return Qrp;}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int RowNumber(PGLOBAL g, BOOL b = FALSE);
virtual int GetRecpos(void);
//virtual PCATLG GetCat(void);
//virtual PSZ GetPath(void);
virtual int GetBadLines(void) {return Qrp->BadLines;}
// Database routines
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
private:
TDBQRS(void) : TDBASE() {} // Standard constructor not to be used
protected:
// Members
PQRYRES Qrp; // Points to Query Result block
int CurPos; // Current line position
}; // end of class TDBQRS
/***********************************************************************/
/* Class QRSCOL: QRS access method column descriptor. */
/***********************************************************************/
class DllExport QRSCOL : public COLBLK {
friend class TDBQRS;
public:
// Constructors
QRSCOL(PGLOBAL g, PCOLRES crp, PTDB tdbp, PCOL cprec, int i);
QRSCOL(QRSCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_QRS;}
PCOLRES GetCrp(void) {return Crp;}
void *GetQrsData(void) {return Crp->Kdata;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, UINT);
protected:
QRSCOL(void) {} // Default constructor not to be used
// Members
PCOLRES Crp;
}; // end of class QRSCOL

File diff suppressed because it is too large Load Diff

View File

@@ -1,184 +1,183 @@
/*************** TabSys H Declares Source Code File (.H) ***************/
/* Name: TABSYS.H Version 2.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2004-2013 */
/* */
/* This file contains the XDB system tables classes declares. */
/***********************************************************************/
typedef class INIDEF *PINIDEF;
typedef class TDBINI *PTDBINI;
typedef class INICOL *PINICOL;
typedef class TDBXIN *PTDBXIN;
typedef class XINCOL *PXINCOL;
/* --------------------------- INI classes --------------------------- */
/***********************************************************************/
/* INI, XDB and XCL tables. */
/***********************************************************************/
class DllExport INIDEF : public TABDEF { /* INI table description */
friend class TDBINI;
friend class TDBXIN;
friend class TDBXTB;
friend class TDBRTB;
friend class TDBXCL;
public:
// Constructor
INIDEF(void);
// Implementation
virtual const char *GetType(void) {return "INI";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g);
protected:
// Members
char *Fn; /* Path/Name of corresponding file */
char *Xname; /* The eventual table name */
char Subtype; /* I: INI, T: Table, C: Column */
char Layout; /* R: Row, C: Column */
int Ln; /* Length of section list buffer */
}; // end of INIDEF
/***********************************************************************/
/* This is the class declaration for the INI tables. */
/* These are tables represented by a INI like file. */
/***********************************************************************/
class TDBINI : public TDBASE {
friend class INICOL;
public:
// Constructor
TDBINI(PINIDEF tdp);
TDBINI(PTDBINI tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_INI;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;}
virtual int GetAffectedRows(void) {return 0;}
virtual PSZ GetFile(PGLOBAL g) {return Ifile;}
virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;}
virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;}
virtual void ResetSize(void) {MaxSize = -1; Seclist = NULL;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;}
char *GetSeclist(PGLOBAL g);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Members
char *Ifile; // The INI file
char *Seclist; // The section list
char *Section; // The current section
int Seclen; // Length of seclist buffer
int N; // The current section index
}; // end of class TDBINI
/***********************************************************************/
/* Class INICOL: XDB table access method column descriptor. */
/***********************************************************************/
class INICOL : public COLBLK {
public:
// Constructors
INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI");
INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_INI;}
virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
// Methods
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual void AllocBuf(PGLOBAL g);
protected:
// Default constructor not to be used
INICOL(void) {}
// Members
char *Valbuf; // To the key value buffer
int Flag; // Tells what set in value
int Long; // Buffer length
PVAL To_Val; // To value used for Update/Insert
}; // end of class INICOL
/* --------------------------- XINI class ---------------------------- */
/***********************************************************************/
/* This is the class declaration for the XINI tables. */
/* These are tables represented by a INI like file */
/* having 3 columns Section, Key, and Value. */
/***********************************************************************/
class TDBXIN : public TDBINI {
friend class XINCOL;
public:
// Constructor
TDBXIN(PINIDEF tdp);
TDBXIN(PTDBXIN tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_INI;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void);
virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual void ResetDB(void)
{Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;}
char *GetKeylist(PGLOBAL g, char *sec);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
protected:
// Members
char *Keylist; // The key list
char *Keycur; // The current key
int Keylen; // Length of keylist buffer
short Oldsec; // Last current section
}; // end of class TDBXIN
/***********************************************************************/
/* Class XINCOL: XIN table access method column descriptor. */
/***********************************************************************/
class XINCOL : public INICOL {
public:
// Constructors
XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI");
XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
protected:
// Default constructor not to be used
XINCOL(void) {}
// Members
}; // end of class XINICOL
/*************** TabSys H Declares Source Code File (.H) ***************/
/* Name: TABSYS.H Version 2.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2004-2013 */
/* */
/* This file contains the XDB system tables classes declares. */
/***********************************************************************/
typedef class INIDEF *PINIDEF;
typedef class TDBINI *PTDBINI;
typedef class INICOL *PINICOL;
typedef class TDBXIN *PTDBXIN;
typedef class XINCOL *PXINCOL;
/* --------------------------- INI classes --------------------------- */
/***********************************************************************/
/* INI, XDB and XCL tables. */
/***********************************************************************/
class DllExport INIDEF : public TABDEF { /* INI table description */
friend class TDBINI;
friend class TDBXIN;
friend class TDBXTB;
friend class TDBRTB;
friend class TDBXCL;
public:
// Constructor
INIDEF(void);
// Implementation
virtual const char *GetType(void) {return "INI";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g);
protected:
// Members
char *Fn; /* Path/Name of corresponding file */
char *Xname; /* The eventual table name */
char Subtype; /* I: INI, T: Table, C: Column */
char Layout; /* R: Row, C: Column */
int Ln; /* Length of section list buffer */
}; // end of INIDEF
/***********************************************************************/
/* This is the class declaration for the INI tables. */
/* These are tables represented by a INI like file. */
/***********************************************************************/
class TDBINI : public TDBASE {
friend class INICOL;
public:
// Constructor
TDBINI(PINIDEF tdp);
TDBINI(PTDBINI tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_INI;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;}
virtual int GetAffectedRows(void) {return 0;}
virtual PSZ GetFile(PGLOBAL g) {return Ifile;}
virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;}
virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;}
virtual void ResetSize(void) {MaxSize = -1; Seclist = NULL;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;}
char *GetSeclist(PGLOBAL g);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Members
char *Ifile; // The INI file
char *Seclist; // The section list
char *Section; // The current section
int Seclen; // Length of seclist buffer
int N; // The current section index
}; // end of class TDBINI
/***********************************************************************/
/* Class INICOL: XDB table access method column descriptor. */
/***********************************************************************/
class INICOL : public COLBLK {
public:
// Constructors
INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI");
INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_INI;}
virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
// Methods
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual void AllocBuf(PGLOBAL g);
protected:
// Default constructor not to be used
INICOL(void) {}
// Members
char *Valbuf; // To the key value buffer
int Flag; // Tells what set in value
int Long; // Buffer length
PVAL To_Val; // To value used for Update/Insert
}; // end of class INICOL
/* --------------------------- XINI class ---------------------------- */
/***********************************************************************/
/* This is the class declaration for the XINI tables. */
/* These are tables represented by a INI like file */
/* having 3 columns Section, Key, and Value. */
/***********************************************************************/
class TDBXIN : public TDBINI {
friend class XINCOL;
public:
// Constructor
TDBXIN(PINIDEF tdp);
TDBXIN(PTDBXIN tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_INI;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void);
virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual void ResetDB(void)
{Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;}
char *GetKeylist(PGLOBAL g, char *sec);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
protected:
// Members
char *Keylist; // The key list
char *Keycur; // The current key
int Keylen; // Length of keylist buffer
short Oldsec; // Last current section
}; // end of class TDBXIN
/***********************************************************************/
/* Class XINCOL: XIN table access method column descriptor. */
/***********************************************************************/
class XINCOL : public INICOL {
public:
// Constructors
XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI");
XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
protected:
// Default constructor not to be used
XINCOL(void) {}
// Members
}; // end of class XINICOL

File diff suppressed because it is too large Load Diff

View File

@@ -1,162 +1,162 @@
/*************** TabTbl H Declares Source Code File (.H) ***************/
/* Name: TABTBL.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2008-2012 */
/* */
/* This file contains the TDBTBL classes declares. */
/***********************************************************************/
//#include "osutil.h"
#include "block.h"
#include "colblk.h"
typedef class TBLDEF *PTBLDEF;
typedef class TDBTBL *PTDBTBL;
typedef class TBLCOL *PTBLCOL;
/***********************************************************************/
/* Defines the structure used for multiple tables. */
/***********************************************************************/
typedef struct _tablist *PTBL;
typedef struct _tablist {
PTBL Next;
char *Name;
char *DB;
} TBLIST;
/***********************************************************************/
/* TBL table. */
/***********************************************************************/
class DllExport TBLDEF : public TABDEF { /* Logical table description */
friend class TDBTBL;
public:
// Constructor
TBLDEF(void);
// Implementation
virtual const char *GetType(void) {return "TBL";}
PTBL GetTables(void) {return To_Tables;}
//int GetNtables(void) {return Ntables;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PTBL To_Tables; /* To the list of tables */
bool Accept; /* TRUE if bad tables are accepted */
int Maxerr; /* Maximum number of bad tables */
int Ntables; /* Number of tables */
}; // end of TBLDEF
/***********************************************************************/
/* This is the TBL Access Method class declaration. */
/***********************************************************************/
class DllExport TDBTBL : public TDBASE {
friend class TBLCOL;
friend class TBTBLK;
friend class TDBPLG;
public:
// Constructor
TDBTBL(PTBLDEF tdp = NULL);
//TDBTBL(PTDBTBL tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_TBL;}
//virtual PTDB Duplicate(PGLOBAL g)
// {return (PTDB)new(g) TDBTBL(this);}
// Methods
virtual void ResetDB(void);
//virtual PTABLE GetTablist(void) {return (PSZ)Tablist;}
//virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return Rows;}
virtual int GetBadLines(void) {return (int)Nbf;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void);
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Internal functions
PTDB GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp);
bool InitTableList(PGLOBAL g);
bool TestFil(PGLOBAL g, PFIL filp, PTBL tblp);
// Members
PTABLE Tablist; // Points to the table list
PTABLE CurTable; // Points to the current table
PTDBASE Tdbp; // Current table PTDB
bool Accept; // TRUE if bad tables are accepted
int Maxerr; // Maximum number of bad tables
int Nbf; // Number of bad connections
int Rows; // Used for RowID
int Crp; // Used for CurPos
}; // end of class TDBTBL
/***********************************************************************/
/* Class TBLCOL: TBL access method column descriptor. */
/* This A.M. is used for TBL tables. */
/***********************************************************************/
class DllExport TBLCOL : public COLBLK {
friend class TDBTBL;
public:
// Constructors
TBLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "TBL");
TBLCOL(TBLCOL *colp, PTDB tdbp); // Constructor used in copy process
//TBLCOL(SPCBLK *colp, PTDB tdbp); // Constructor used for pseudo columns
// Implementation
virtual int GetAmType(void) {return TYPE_AM_TBL;}
// Methods
virtual bool IsSpecial(void) {return Pseudo;}
virtual void ReadColumn(PGLOBAL g);
//virtual void WriteColumn(PGLOBAL g);
// void Print(PGLOBAL g, FILE *, UINT);
bool Init(PGLOBAL g);
protected:
// Default constructor not to be used
TBLCOL(void) {}
// Members
PCOL Colp; // Points to matching table column
PVAL To_Val; // To the matching column value
bool Pseudo; // TRUE for special columns
int Colnum; // Used when retrieving columns by number
}; // end of class TBLCOL
/***********************************************************************/
/* Class TBTBLK: TDBPLG TABID special column descriptor. */
/***********************************************************************/
class TBTBLK : public TIDBLK {
public:
// The constructor must restore Value because XOBJECT has a void
// constructor called by default that set Value to NULL
TBTBLK(PVAL valp) {Value = valp;}
// Methods
virtual void ReadColumn(PGLOBAL g);
// Fake operator new used to change TIDBLK into SDTBLK
void * operator new(size_t size, TIDBLK *sp) {return sp;}
#if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, TIDBLK*) {}
#endif
protected:
// Must not have additional members
}; // end of class TBTBLK
/*************** TabTbl H Declares Source Code File (.H) ***************/
/* Name: TABTBL.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2008-2012 */
/* */
/* This file contains the TDBTBL classes declares. */
/***********************************************************************/
//#include "osutil.h"
#include "block.h"
#include "colblk.h"
typedef class TBLDEF *PTBLDEF;
typedef class TDBTBL *PTDBTBL;
typedef class TBLCOL *PTBLCOL;
/***********************************************************************/
/* Defines the structure used for multiple tables. */
/***********************************************************************/
typedef struct _tablist *PTBL;
typedef struct _tablist {
PTBL Next;
char *Name;
char *DB;
} TBLIST;
/***********************************************************************/
/* TBL table. */
/***********************************************************************/
class DllExport TBLDEF : public TABDEF { /* Logical table description */
friend class TDBTBL;
public:
// Constructor
TBLDEF(void);
// Implementation
virtual const char *GetType(void) {return "TBL";}
PTBL GetTables(void) {return To_Tables;}
//int GetNtables(void) {return Ntables;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PTBL To_Tables; /* To the list of tables */
bool Accept; /* TRUE if bad tables are accepted */
int Maxerr; /* Maximum number of bad tables */
int Ntables; /* Number of tables */
}; // end of TBLDEF
/***********************************************************************/
/* This is the TBL Access Method class declaration. */
/***********************************************************************/
class DllExport TDBTBL : public TDBASE {
friend class TBLCOL;
friend class TBTBLK;
friend class TDBPLG;
public:
// Constructor
TDBTBL(PTBLDEF tdp = NULL);
//TDBTBL(PTDBTBL tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_TBL;}
//virtual PTDB Duplicate(PGLOBAL g)
// {return (PTDB)new(g) TDBTBL(this);}
// Methods
virtual void ResetDB(void);
//virtual PTABLE GetTablist(void) {return (PSZ)Tablist;}
//virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return Rows;}
virtual int GetBadLines(void) {return (int)Nbf;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void);
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Internal functions
PTDB GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp);
bool InitTableList(PGLOBAL g);
bool TestFil(PGLOBAL g, PFIL filp, PTBL tblp);
// Members
PTABLE Tablist; // Points to the table list
PTABLE CurTable; // Points to the current table
PTDBASE Tdbp; // Current table PTDB
bool Accept; // TRUE if bad tables are accepted
int Maxerr; // Maximum number of bad tables
int Nbf; // Number of bad connections
int Rows; // Used for RowID
int Crp; // Used for CurPos
}; // end of class TDBTBL
/***********************************************************************/
/* Class TBLCOL: TBL access method column descriptor. */
/* This A.M. is used for TBL tables. */
/***********************************************************************/
class DllExport TBLCOL : public COLBLK {
friend class TDBTBL;
public:
// Constructors
TBLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "TBL");
TBLCOL(TBLCOL *colp, PTDB tdbp); // Constructor used in copy process
//TBLCOL(SPCBLK *colp, PTDB tdbp); // Constructor used for pseudo columns
// Implementation
virtual int GetAmType(void) {return TYPE_AM_TBL;}
// Methods
virtual bool IsSpecial(void) {return Pseudo;}
virtual void ReadColumn(PGLOBAL g);
//virtual void WriteColumn(PGLOBAL g);
// void Print(PGLOBAL g, FILE *, UINT);
bool Init(PGLOBAL g);
protected:
// Default constructor not to be used
TBLCOL(void) {}
// Members
PCOL Colp; // Points to matching table column
PVAL To_Val; // To the matching column value
bool Pseudo; // TRUE for special columns
int Colnum; // Used when retrieving columns by number
}; // end of class TBLCOL
/***********************************************************************/
/* Class TBTBLK: TDBPLG TABID special column descriptor. */
/***********************************************************************/
class TBTBLK : public TIDBLK {
public:
// The constructor must restore Value because XOBJECT has a void
// constructor called by default that set Value to NULL
TBTBLK(PVAL valp) {Value = valp;}
// Methods
virtual void ReadColumn(PGLOBAL g);
// Fake operator new used to change TIDBLK into SDTBLK
void * operator new(size_t size, TIDBLK *sp) {return sp;}
#if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, TIDBLK*) {}
#endif
protected:
// Must not have additional members
}; // end of class TBTBLK

File diff suppressed because it is too large Load Diff

View File

@@ -1,123 +1,123 @@
/*************** TabVct H Declares Source Code File (.H) ***************/
/* Name: TABVCT.H Version 3.4 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2011 */
/* */
/* This file contains the TDBVCT class declares. */
/***********************************************************************/
#ifndef __TABVCT__
#define __TABVCT__
#include "tabfix.h"
#if defined(UNIX)
//#include <string.h.SUNWCCh>
#endif
typedef class TDBVCT *PTDBVCT;
typedef class VCTCOL *PVCTCOL;
/***********************************************************************/
/* VCT table. */
/***********************************************************************/
class DllExport VCTDEF : public DOSDEF { /* Logical table description */
friend class VCTFAM;
friend class VECFAM;
friend class VMPFAM;
public:
// Constructor
VCTDEF(void) {Split = Estimate = Header = 0;}
// Implementation
virtual const char *GetType(void) {return "VCT";}
int GetEstimate(void) {return Estimate;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected:
// Specific file erase routine for vertical tables
virtual bool Erase(char *filename);
int MakeFnPattern(char *fpat);
// Members
int Split; /* Columns in separate files */
int Estimate; /* Estimated maximum size of table */
int Header; /* 0: no, 1: separate, 2: in data file */
}; // end of VCTDEF
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in blocked vector format. In each block containing "Elements" */
/* records, values of each columns are consecutively stored (vector). */
/***********************************************************************/
class DllExport TDBVCT : public TDBFIX {
friend class VCTCOL;
friend class VCTFAM;
friend class VCMFAM;
friend class VECFAM;
friend class VMPFAM;
public:
// Constructors
TDBVCT(PVCTDEF tdp, PTXF txfp);
TDBVCT(PGLOBAL g, PTDBVCT tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBVCT(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual void CloseDB(PGLOBAL g);
protected:
// Members
}; // end of class TDBVCT
/***********************************************************************/
/* Class VCTCOL: VCT access method column descriptor. */
/* This A.M. is used for file having column wise organization. */
/***********************************************************************/
class DllExport VCTCOL : public DOSCOL {
friend class TDBVCT;
friend class VCTFAM;
friend class VCMFAM;
friend class VECFAM;
friend class VMPFAM;
friend class BGVFAM;
public:
// Constructors
VCTCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
VCTCOL(VCTCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_VCT;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetOk(void);
protected:
virtual void ReadBlock(PGLOBAL g);
virtual void WriteBlock(PGLOBAL g);
VCTCOL(void) {} // Default constructor not to be used
// Members
PVBLK Blk; // Block buffer
int Clen; // Internal length in table
int ColBlk; // Block pointed by column
int ColPos; // Last position read
int Modif; // Number of modified lines in block
}; // end of class VCTCOL
#endif // __TABVCT__
/*************** TabVct H Declares Source Code File (.H) ***************/
/* Name: TABVCT.H Version 3.4 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2011 */
/* */
/* This file contains the TDBVCT class declares. */
/***********************************************************************/
#ifndef __TABVCT__
#define __TABVCT__
#include "tabfix.h"
#if defined(UNIX)
//#include <string.h.SUNWCCh>
#endif
typedef class TDBVCT *PTDBVCT;
typedef class VCTCOL *PVCTCOL;
/***********************************************************************/
/* VCT table. */
/***********************************************************************/
class DllExport VCTDEF : public DOSDEF { /* Logical table description */
friend class VCTFAM;
friend class VECFAM;
friend class VMPFAM;
public:
// Constructor
VCTDEF(void) {Split = Estimate = Header = 0;}
// Implementation
virtual const char *GetType(void) {return "VCT";}
int GetEstimate(void) {return Estimate;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected:
// Specific file erase routine for vertical tables
virtual bool Erase(char *filename);
int MakeFnPattern(char *fpat);
// Members
int Split; /* Columns in separate files */
int Estimate; /* Estimated maximum size of table */
int Header; /* 0: no, 1: separate, 2: in data file */
}; // end of VCTDEF
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* in blocked vector format. In each block containing "Elements" */
/* records, values of each columns are consecutively stored (vector). */
/***********************************************************************/
class DllExport TDBVCT : public TDBFIX {
friend class VCTCOL;
friend class VCTFAM;
friend class VCMFAM;
friend class VECFAM;
friend class VMPFAM;
public:
// Constructors
TDBVCT(PVCTDEF tdp, PTXF txfp);
TDBVCT(PGLOBAL g, PTDBVCT tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBVCT(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual void CloseDB(PGLOBAL g);
protected:
// Members
}; // end of class TDBVCT
/***********************************************************************/
/* Class VCTCOL: VCT access method column descriptor. */
/* This A.M. is used for file having column wise organization. */
/***********************************************************************/
class DllExport VCTCOL : public DOSCOL {
friend class TDBVCT;
friend class VCTFAM;
friend class VCMFAM;
friend class VECFAM;
friend class VMPFAM;
friend class BGVFAM;
public:
// Constructors
VCTCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
VCTCOL(VCTCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_VCT;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetOk(void);
protected:
virtual void ReadBlock(PGLOBAL g);
virtual void WriteBlock(PGLOBAL g);
VCTCOL(void) {} // Default constructor not to be used
// Members
PVBLK Blk; // Block buffer
int Clen; // Internal length in table
int ColBlk; // Block pointed by column
int ColPos; // Last position read
int Modif; // Number of modified lines in block
}; // end of class VCTCOL
#endif // __TABVCT__

File diff suppressed because it is too large Load Diff

View File

@@ -1,191 +1,191 @@
// TABWMI.H Olivier Bertrand 2012
// WMI: Virtual table to Get WMI information
#define _WIN32_DCOM
#include <wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
#include <iostream>
using namespace std;
#include <comdef.h>
/***********************************************************************/
/* Definitions. */
/***********************************************************************/
typedef class WMIDEF *PWMIDEF;
typedef class TDBWMI *PTDBWMI;
typedef class WMICOL *PWMICOL;
typedef class TDBWCL *PTDBWCL;
typedef class WCLCOL *PWCLCOL;
/* -------------------------- WMI classes ---------------------------- */
/***********************************************************************/
/* WMI: Virtual table to get the WMI information. */
/***********************************************************************/
class WMIDEF : public TABDEF { /* Logical table description */
friend class TDBWMI;
friend class TDBWCL;
public:
// Constructor
WMIDEF(void)
{Pseudo = 3; Nspace = NULL; Wclass = NULL; Ems = 0; Info = false;}
// Implementation
virtual const char *GetType(void) {return "WMI";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g) {return true;}
protected:
// Members
char *Nspace;
char *Wclass;
int Ems;
bool Info;
}; // end of WMIDEF
/***********************************************************************/
/* This is the class declaration for the WMI table. */
/***********************************************************************/
class TDBWMI : public TDBASE {
friend class WMICOL;
public:
// Constructor
TDBWMI(PWMIDEF tdp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_WMI;}
// Methods
virtual int GetRecpos(void);
virtual int GetProgCur(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Specific routines
bool Initialize(PGLOBAL g);
char *MakeWQL(PGLOBAL g);
void DoubleSlash(PGLOBAL g);
bool GetWMIInfo(PGLOBAL g);
// Members
IWbemServices *Svc; // IWbemServices pointer
IEnumWbemClassObject *Enumerator;
IWbemClassObject *ClsObj;
char *Nspace; // Namespace
char *Wclass; // Class name
char *ObjPath; // Used for direct access
char *Kvp; // Itou
int Ems; // Estimated max size
PCOL Kcol; // Key column
HRESULT Res;
PVBLK Vbp;
bool Init;
bool Done;
ULONG Rc;
int N; // Row number
}; // end of class TDBWMI
/***********************************************************************/
/* Class WMICOL: WMI Address column. */
/***********************************************************************/
class WMICOL : public COLBLK {
friend class TDBWMI;
public:
// Constructors
WMICOL(PCOLDEF cdp, PTDB tdbp, int n);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_WMI;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
WMICOL(void) {} // Default constructor not to be used
// Members
PTDBWMI Tdbp; // Points to WMI table block
VARIANT Prop; // Property value
CIMTYPE Ctype; // CIM Type
HRESULT Res;
}; // end of class WMICOL
/***********************************************************************/
/* This is the class declaration for the WCL table. */
/***********************************************************************/
class TDBWCL : public TDBASE {
friend class WCLCOL;
public:
// Constructor
TDBWCL(PWMIDEF tdp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_WMI;}
// Methods
virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Specific routines
bool Initialize(PGLOBAL g);
// Members
IWbemServices *Svc; // IWbemServices pointer
IWbemClassObject *ClsObj;
BSTR Propname;
char *Nspace; // Namespace
char *Wclass; // Class name
HRESULT Res;
bool Init;
bool Done;
int N; // Row number
int Lng;
int Typ;
int Prec;
}; // end of class TDBWCL
/***********************************************************************/
/* Class WMICOL: WMI Address column. */
/***********************************************************************/
class WCLCOL : public COLBLK {
friend class TDBWCL;
public:
// Constructors
WCLCOL(PCOLDEF cdp, PTDB tdbp, int n);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_WMI;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
WCLCOL(void) {} // Default constructor not to be used
// Members
PTDBWCL Tdbp; // Points to WMI table block
HRESULT Res;
int Flag;
}; // end of class WCLCOL
// TABWMI.H Olivier Bertrand 2012
// WMI: Virtual table to Get WMI information
#define _WIN32_DCOM
#include <wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
#include <iostream>
using namespace std;
#include <comdef.h>
/***********************************************************************/
/* Definitions. */
/***********************************************************************/
typedef class WMIDEF *PWMIDEF;
typedef class TDBWMI *PTDBWMI;
typedef class WMICOL *PWMICOL;
typedef class TDBWCL *PTDBWCL;
typedef class WCLCOL *PWCLCOL;
/* -------------------------- WMI classes ---------------------------- */
/***********************************************************************/
/* WMI: Virtual table to get the WMI information. */
/***********************************************************************/
class WMIDEF : public TABDEF { /* Logical table description */
friend class TDBWMI;
friend class TDBWCL;
public:
// Constructor
WMIDEF(void)
{Pseudo = 3; Nspace = NULL; Wclass = NULL; Ems = 0; Info = false;}
// Implementation
virtual const char *GetType(void) {return "WMI";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g) {return true;}
protected:
// Members
char *Nspace;
char *Wclass;
int Ems;
bool Info;
}; // end of WMIDEF
/***********************************************************************/
/* This is the class declaration for the WMI table. */
/***********************************************************************/
class TDBWMI : public TDBASE {
friend class WMICOL;
public:
// Constructor
TDBWMI(PWMIDEF tdp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_WMI;}
// Methods
virtual int GetRecpos(void);
virtual int GetProgCur(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Specific routines
bool Initialize(PGLOBAL g);
char *MakeWQL(PGLOBAL g);
void DoubleSlash(PGLOBAL g);
bool GetWMIInfo(PGLOBAL g);
// Members
IWbemServices *Svc; // IWbemServices pointer
IEnumWbemClassObject *Enumerator;
IWbemClassObject *ClsObj;
char *Nspace; // Namespace
char *Wclass; // Class name
char *ObjPath; // Used for direct access
char *Kvp; // Itou
int Ems; // Estimated max size
PCOL Kcol; // Key column
HRESULT Res;
PVBLK Vbp;
bool Init;
bool Done;
ULONG Rc;
int N; // Row number
}; // end of class TDBWMI
/***********************************************************************/
/* Class WMICOL: WMI Address column. */
/***********************************************************************/
class WMICOL : public COLBLK {
friend class TDBWMI;
public:
// Constructors
WMICOL(PCOLDEF cdp, PTDB tdbp, int n);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_WMI;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
WMICOL(void) {} // Default constructor not to be used
// Members
PTDBWMI Tdbp; // Points to WMI table block
VARIANT Prop; // Property value
CIMTYPE Ctype; // CIM Type
HRESULT Res;
}; // end of class WMICOL
/***********************************************************************/
/* This is the class declaration for the WCL table. */
/***********************************************************************/
class TDBWCL : public TDBASE {
friend class WCLCOL;
public:
// Constructor
TDBWCL(PWMIDEF tdp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_WMI;}
// Methods
virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
protected:
// Specific routines
bool Initialize(PGLOBAL g);
// Members
IWbemServices *Svc; // IWbemServices pointer
IWbemClassObject *ClsObj;
BSTR Propname;
char *Nspace; // Namespace
char *Wclass; // Class name
HRESULT Res;
bool Init;
bool Done;
int N; // Row number
int Lng;
int Typ;
int Prec;
}; // end of class TDBWCL
/***********************************************************************/
/* Class WMICOL: WMI Address column. */
/***********************************************************************/
class WCLCOL : public COLBLK {
friend class TDBWCL;
public:
// Constructors
WCLCOL(PCOLDEF cdp, PTDB tdbp, int n);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_WMI;}
// Methods
virtual void ReadColumn(PGLOBAL g);
protected:
WCLCOL(void) {} // Default constructor not to be used
// Members
PTDBWCL Tdbp; // Points to WMI table block
HRESULT Res;
int Flag;
}; // end of class WCLCOL

File diff suppressed because it is too large Load Diff

View File

@@ -1,246 +1,246 @@
/*************** Tabxml H Declares Source Code File (.H) ***************/
/* Name: TABXML.H Version 1.6 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */
/* */
/* This file contains the XML table classes declares. */
/***********************************************************************/
#define TYPE_AM_XML (AMT)127
typedef class XMLDEF *PXMLDEF;
typedef class TDBXML *PTDBXML;
typedef class XMLCOL *PXMLCOL;
// These functions are exported from the Extended.dll
//PTABDEF __stdcall GetXML(PGLOBAL g, void *memp);
/* --------------------------- XML classes --------------------------- */
/***********************************************************************/
/* XML table. */
/***********************************************************************/
class DllExport XMLDEF : public TABDEF { /* Logical table description */
friend class TDBXML;
public:
// Constructor
XMLDEF(void);
// Implementation
virtual const char *GetType(void) {return "XML";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g);
protected:
// Members
char *Fn; /* Path/Name of corresponding file */
char *Encoding; /* New XML table file encoding */
char *Tabname; /* Name of Table node */
char *Rowname; /* Name of first level nodes */
char *Colname; /* Name of second level nodes */
char *Mulnode; /* Name of multiple node */
char *XmlDB; /* Name of XML DB node */
char *Nslist; /* List of namespaces to register */
char *DefNs; /* Dummy name of default namespace */
char *Attrib; /* Table node attributes */
char *Hdattr; /* Header node attributes */
int Coltype; /* Default column type */
int Limit; /* Limit of multiple values */
int Header; /* n first rows are header rows */
bool Xpand; /* Put multiple tags in several rows */
bool Usedom; /* True: DOM, False: libxml2 */
bool Skipnull; /* True: skip writing null nodes */
}; // end of XMLDEF
#if defined(INCLUDE_TDBXML)
/***********************************************************************/
/* This is the class declaration for the simple XML tables. */
/***********************************************************************/
class DllExport TDBXML : public TDBASE {
friend class XMLCOL;
friend class XMULCOL;
friend class XPOSCOL;
public:
// Constructor
TDBXML(PXMLDEF tdp);
TDBXML(PTDBXML tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_XML;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXML(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void);
virtual int GetProgCur(void) {return N;}
virtual PSZ GetFile(PGLOBAL g) {return Xfile;}
virtual void SetFile(PGLOBAL g, PSZ fn) {Xfile = fn;}
virtual void ResetDB(void) {N = 0;}
virtual void ResetSize(void) {MaxSize = -1;}
virtual int RowNumber(PGLOBAL g, bool b = false);
int LoadTableFile(PGLOBAL g);
bool Initialize(PGLOBAL g);
bool SetTabNode(PGLOBAL g);
void SetNodeAttr(PGLOBAL g, char *attr, PXNODE node);
bool CheckRow(PGLOBAL g, bool b);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp);
//virtual int GetMaxSame(PGLOBAL g) {return (Xpand) ? Limit : 1;}
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
//virtual bool NeedIndexing(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
virtual int CheckWrite(PGLOBAL g) {Checked = true; return 0;}
protected:
// Members
PXDOC Docp;
PXNODE Root;
PXNODE Curp;
PXNODE DBnode;
PXNODE TabNode;
PXNODE RowNode;
PXNODE ColNode;
PXLIST Nlist;
PXLIST Clist;
PFBLOCK To_Xb; // Pointer to XML file block
PCOL Colp; // The multiple column
bool Changed; // After Update, Insert or Delete
bool Checked; // After Update check pass
bool NextSame; // Same next row
bool Xpand; // Put multiple tags in several rows
bool NewRow; // True when inserting a new row
bool Hasnod; // True if rows have subnodes
bool Write; // True for Insert and Update
bool Usedom; // True for DOM, False for libxml2
bool Bufdone; // True when column buffers allocated
bool Nodedone; // True when column nodes allocated
bool Skipnull; // True to skip writing nullnodes
bool Void; // True if the file does not exist
char *Xfile; // The XML file
char *Enc; // New XML table file encoding
char *Tabname; // Name of Table node
char *Rowname; // Name of first level nodes
char *Colname; // Name of second level nodes
char *Mulnode; // Name of multiple node
char *XmlDB; // Name of XML DB node
char *Nslist; // List of namespaces to register
char *DefNs; // Dummy name of default namespace
char *Attrib; // Table node attribut(s)
char *Hdattr; // Header node attribut(s)
int Coltype; // Default column type
int Limit; // Limit of multiple values
int Header; // n first rows are header rows
int Nrow; // The table cardinality
int Irow; // The current row index
int Nsub; // The current subrow index
int N; // The current Rowid
}; // end of class TDBXML
/***********************************************************************/
/* Class XMLCOL: XDB table access method column descriptor. */
/***********************************************************************/
class XMLCOL : public COLBLK {
public:
// Constructors
XMLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "XML");
XMLCOL(XMLCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_XML;}
virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
bool ParseXpath(PGLOBAL g, bool mode);
// Methods
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
bool AllocBuf(PGLOBAL g, bool mode);
void AllocNodes(PGLOBAL g, PXDOC dp);
protected:
//xmlNodePtr SelectSingleNode(xmlNodePtr node, char *name);
// Default constructor not to be used
XMLCOL(void) : COLBLK(1) {}
// Members
PXLIST Nl;
PXLIST Nlx;
PXNODE ColNode;
PXNODE ValNode;
PXNODE Cxnp;
PXNODE Vxnp;
PXATTR Vxap;
PXATTR AttNode;
PTDBXML Tdbp;
char *Valbuf; // To the node value buffer
char *Xname; // The node or attribute name
char* *Nodes; // The intermediate nodes
int Type; // 0: Attribute, 1: Tag, 2: position
int Nod; // The number of intermediate nodes
int Inod; // Index of multiple node
int Rank; // Position
bool Mul; // true for multiple column
bool Checked; // Was checked while Updating
int Long; // Buffer length
int Nx; // The last read row
int Sx; // The last read sub-row
PVAL To_Val; // To value used for Update/Insert
}; // end of class XMLCOL
/***********************************************************************/
/* Derived class XMLCOLX: used to replace a multiple XMLCOL by the */
/* derived class XMULCOL that has specialize read and write functions.*/
/* Note: this works only if the members of the derived class are the */
/* same than the ones of the original class (NO added members). */
/***********************************************************************/
class XMLCOLX : public XMLCOL {
public:
// Fake operator new used to change a filter into a derived filter
void * operator new(size_t size, PXMLCOL colp) {return colp;}
#if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, PXMLCOL) {}
#endif
}; // end of class XMLCOLX
/***********************************************************************/
/* Class XMULCOL: XML table access method multiple column descriptor. */
/***********************************************************************/
class XMULCOL : public XMLCOLX {
public:
// The constructor must restore Value because XOBJECT has a void
// constructor called by default that set Value to NULL
XMULCOL(PVAL valp) {Value = valp; Mul = true;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
}; // end of class XMULCOL
/***********************************************************************/
/* Class XPOSCOL: XML table column accessed by position. */
/***********************************************************************/
class XPOSCOL : public XMLCOLX {
public:
// The constructor must restore Value because XOBJECT has a void
// constructor called by default that set Value to NULL
XPOSCOL(PVAL valp) {Value = valp;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
}; // end of class XPOSCOL
#endif // INCLUDE_TDBXML
/*************** Tabxml H Declares Source Code File (.H) ***************/
/* Name: TABXML.H Version 1.6 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */
/* */
/* This file contains the XML table classes declares. */
/***********************************************************************/
#define TYPE_AM_XML (AMT)127
typedef class XMLDEF *PXMLDEF;
typedef class TDBXML *PTDBXML;
typedef class XMLCOL *PXMLCOL;
// These functions are exported from the Extended.dll
//PTABDEF __stdcall GetXML(PGLOBAL g, void *memp);
/* --------------------------- XML classes --------------------------- */
/***********************************************************************/
/* XML table. */
/***********************************************************************/
class DllExport XMLDEF : public TABDEF { /* Logical table description */
friend class TDBXML;
public:
// Constructor
XMLDEF(void);
// Implementation
virtual const char *GetType(void) {return "XML";}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g);
protected:
// Members
char *Fn; /* Path/Name of corresponding file */
char *Encoding; /* New XML table file encoding */
char *Tabname; /* Name of Table node */
char *Rowname; /* Name of first level nodes */
char *Colname; /* Name of second level nodes */
char *Mulnode; /* Name of multiple node */
char *XmlDB; /* Name of XML DB node */
char *Nslist; /* List of namespaces to register */
char *DefNs; /* Dummy name of default namespace */
char *Attrib; /* Table node attributes */
char *Hdattr; /* Header node attributes */
int Coltype; /* Default column type */
int Limit; /* Limit of multiple values */
int Header; /* n first rows are header rows */
bool Xpand; /* Put multiple tags in several rows */
bool Usedom; /* True: DOM, False: libxml2 */
bool Skipnull; /* True: skip writing null nodes */
}; // end of XMLDEF
#if defined(INCLUDE_TDBXML)
/***********************************************************************/
/* This is the class declaration for the simple XML tables. */
/***********************************************************************/
class DllExport TDBXML : public TDBASE {
friend class XMLCOL;
friend class XMULCOL;
friend class XPOSCOL;
public:
// Constructor
TDBXML(PXMLDEF tdp);
TDBXML(PTDBXML tdbp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_XML;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXML(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void);
virtual int GetProgCur(void) {return N;}
virtual PSZ GetFile(PGLOBAL g) {return Xfile;}
virtual void SetFile(PGLOBAL g, PSZ fn) {Xfile = fn;}
virtual void ResetDB(void) {N = 0;}
virtual void ResetSize(void) {MaxSize = -1;}
virtual int RowNumber(PGLOBAL g, bool b = false);
int LoadTableFile(PGLOBAL g);
bool Initialize(PGLOBAL g);
bool SetTabNode(PGLOBAL g);
void SetNodeAttr(PGLOBAL g, char *attr, PXNODE node);
bool CheckRow(PGLOBAL g, bool b);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp);
//virtual int GetMaxSame(PGLOBAL g) {return (Xpand) ? Limit : 1;}
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
//virtual bool NeedIndexing(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
virtual int CheckWrite(PGLOBAL g) {Checked = true; return 0;}
protected:
// Members
PXDOC Docp;
PXNODE Root;
PXNODE Curp;
PXNODE DBnode;
PXNODE TabNode;
PXNODE RowNode;
PXNODE ColNode;
PXLIST Nlist;
PXLIST Clist;
PFBLOCK To_Xb; // Pointer to XML file block
PCOL Colp; // The multiple column
bool Changed; // After Update, Insert or Delete
bool Checked; // After Update check pass
bool NextSame; // Same next row
bool Xpand; // Put multiple tags in several rows
bool NewRow; // True when inserting a new row
bool Hasnod; // True if rows have subnodes
bool Write; // True for Insert and Update
bool Usedom; // True for DOM, False for libxml2
bool Bufdone; // True when column buffers allocated
bool Nodedone; // True when column nodes allocated
bool Skipnull; // True to skip writing nullnodes
bool Void; // True if the file does not exist
char *Xfile; // The XML file
char *Enc; // New XML table file encoding
char *Tabname; // Name of Table node
char *Rowname; // Name of first level nodes
char *Colname; // Name of second level nodes
char *Mulnode; // Name of multiple node
char *XmlDB; // Name of XML DB node
char *Nslist; // List of namespaces to register
char *DefNs; // Dummy name of default namespace
char *Attrib; // Table node attribut(s)
char *Hdattr; // Header node attribut(s)
int Coltype; // Default column type
int Limit; // Limit of multiple values
int Header; // n first rows are header rows
int Nrow; // The table cardinality
int Irow; // The current row index
int Nsub; // The current subrow index
int N; // The current Rowid
}; // end of class TDBXML
/***********************************************************************/
/* Class XMLCOL: XDB table access method column descriptor. */
/***********************************************************************/
class XMLCOL : public COLBLK {
public:
// Constructors
XMLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "XML");
XMLCOL(XMLCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
virtual int GetAmType(void) {return TYPE_AM_XML;}
virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
bool ParseXpath(PGLOBAL g, bool mode);
// Methods
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
bool AllocBuf(PGLOBAL g, bool mode);
void AllocNodes(PGLOBAL g, PXDOC dp);
protected:
//xmlNodePtr SelectSingleNode(xmlNodePtr node, char *name);
// Default constructor not to be used
XMLCOL(void) : COLBLK(1) {}
// Members
PXLIST Nl;
PXLIST Nlx;
PXNODE ColNode;
PXNODE ValNode;
PXNODE Cxnp;
PXNODE Vxnp;
PXATTR Vxap;
PXATTR AttNode;
PTDBXML Tdbp;
char *Valbuf; // To the node value buffer
char *Xname; // The node or attribute name
char* *Nodes; // The intermediate nodes
int Type; // 0: Attribute, 1: Tag, 2: position
int Nod; // The number of intermediate nodes
int Inod; // Index of multiple node
int Rank; // Position
bool Mul; // true for multiple column
bool Checked; // Was checked while Updating
int Long; // Buffer length
int Nx; // The last read row
int Sx; // The last read sub-row
PVAL To_Val; // To value used for Update/Insert
}; // end of class XMLCOL
/***********************************************************************/
/* Derived class XMLCOLX: used to replace a multiple XMLCOL by the */
/* derived class XMULCOL that has specialize read and write functions.*/
/* Note: this works only if the members of the derived class are the */
/* same than the ones of the original class (NO added members). */
/***********************************************************************/
class XMLCOLX : public XMLCOL {
public:
// Fake operator new used to change a filter into a derived filter
void * operator new(size_t size, PXMLCOL colp) {return colp;}
#if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, PXMLCOL) {}
#endif
}; // end of class XMLCOLX
/***********************************************************************/
/* Class XMULCOL: XML table access method multiple column descriptor. */
/***********************************************************************/
class XMULCOL : public XMLCOLX {
public:
// The constructor must restore Value because XOBJECT has a void
// constructor called by default that set Value to NULL
XMULCOL(PVAL valp) {Value = valp; Mul = true;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
}; // end of class XMULCOL
/***********************************************************************/
/* Class XPOSCOL: XML table column accessed by position. */
/***********************************************************************/
class XPOSCOL : public XMLCOLX {
public:
// The constructor must restore Value because XOBJECT has a void
// constructor called by default that set Value to NULL
XPOSCOL(PVAL valp) {Value = valp;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
}; // end of class XPOSCOL
#endif // INCLUDE_TDBXML

View File

@@ -1,154 +1,154 @@
/* Copyright (C) Olivier Bertrand 2004 - 2012
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**
@file user_connect.cc
@brief
Implements the user_connect class.
@details
To support multi_threading, each query creates and use a PlugDB "user"
that is a connection with its personnal memory allocation.
@note
*/
/****************************************************************************/
/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2012 */
/****************************************************************************/
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#define DONT_DEFINE_VOID
#define MYSQL_SERVER
#include "sql_class.h"
#undef OFFSET
#define NOPARSE
#include "osutil.h"
#include "global.h"
#include "plgdbsem.h"
#include "user_connect.h"
#include "mycat.h"
extern "C" char plgxini[];
extern int xtrace;
/****************************************************************************/
/* Initialize the user_connect static member. */
/****************************************************************************/
PCONNECT user_connect::to_users= NULL;
/****************************************************************************/
/* CONNECT functions called externally. */
/****************************************************************************/
PGLOBAL CntExit(PGLOBAL g);
/* -------------------------- class user_connect -------------------------- */
/****************************************************************************/
/* Constructor. */
/****************************************************************************/
user_connect::user_connect(THD *thd, const char *dbn)
{
thdp= thd;
next= NULL;
previous= NULL;
g= NULL;
tabp= NULL;
last_query_id= 0;
count= 0;
// Statistics
nrd= fnd= nfd= 0;
tb1= 0;
} // end of user_connect constructor
/****************************************************************************/
/* Destructor. */
/****************************************************************************/
user_connect::~user_connect()
{
// Terminate CONNECT and Plug-like environment, should return NULL
g= CntExit(g);
} // end of user_connect destructor
/****************************************************************************/
/* Initialization. */
/****************************************************************************/
bool user_connect::user_init(PHC hc)
{
// Initialize Plug-like environment
PACTIVITY ap= NULL;
PDBUSER dup= NULL;
// Areasize= 64M because of VEC tables. Should be parameterisable
g= PlugInit(NULL, 67108864);
// Check whether the initialization is complete
if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size)
|| !(dup= PlgMakeUser(g))) {
if (g)
printf("%s\n", g->Message);
int rc= PlugExit(g);
g= NULL;
free(dup);
return true;
} // endif g->
dup->Catalog= new MYCAT(hc);
ap= new ACTIVITY;
memset(ap, 0, sizeof(ACTIVITY));
strcpy(ap->Ap_Name, "CONNECT");
g->Activityp= ap;
g->Activityp->Aptr= dup;
next= to_users;
to_users= this;
if (next)
next->previous= this;
last_query_id= thdp->query_id;
count= 1;
return false;
} // end of user_init
/****************************************************************************/
/* Check whether we begin a new query and if so cleanup the previous one. */
/****************************************************************************/
bool user_connect::CheckCleanup(void)
{
if (thdp->query_id > last_query_id) {
PlugCleanup(g, true);
PlugSubSet(g, g->Sarea, g->Sarea_Size);
last_query_id= thdp->query_id;
if (xtrace)
printf("=====> Begin new query %d\n", last_query_id);
return true;
} // endif query_id
return false;
} // end of CheckCleanup
/* Copyright (C) Olivier Bertrand 2004 - 2012
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**
@file user_connect.cc
@brief
Implements the user_connect class.
@details
To support multi_threading, each query creates and use a PlugDB "user"
that is a connection with its personnal memory allocation.
@note
*/
/****************************************************************************/
/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2012 */
/****************************************************************************/
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#define DONT_DEFINE_VOID
#define MYSQL_SERVER
#include "sql_class.h"
#undef OFFSET
#define NOPARSE
#include "osutil.h"
#include "global.h"
#include "plgdbsem.h"
#include "user_connect.h"
#include "mycat.h"
extern "C" char plgxini[];
extern int xtrace;
/****************************************************************************/
/* Initialize the user_connect static member. */
/****************************************************************************/
PCONNECT user_connect::to_users= NULL;
/****************************************************************************/
/* CONNECT functions called externally. */
/****************************************************************************/
PGLOBAL CntExit(PGLOBAL g);
/* -------------------------- class user_connect -------------------------- */
/****************************************************************************/
/* Constructor. */
/****************************************************************************/
user_connect::user_connect(THD *thd, const char *dbn)
{
thdp= thd;
next= NULL;
previous= NULL;
g= NULL;
tabp= NULL;
last_query_id= 0;
count= 0;
// Statistics
nrd= fnd= nfd= 0;
tb1= 0;
} // end of user_connect constructor
/****************************************************************************/
/* Destructor. */
/****************************************************************************/
user_connect::~user_connect()
{
// Terminate CONNECT and Plug-like environment, should return NULL
g= CntExit(g);
} // end of user_connect destructor
/****************************************************************************/
/* Initialization. */
/****************************************************************************/
bool user_connect::user_init(PHC hc)
{
// Initialize Plug-like environment
PACTIVITY ap= NULL;
PDBUSER dup= NULL;
// Areasize= 64M because of VEC tables. Should be parameterisable
g= PlugInit(NULL, 67108864);
// Check whether the initialization is complete
if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size)
|| !(dup= PlgMakeUser(g))) {
if (g)
printf("%s\n", g->Message);
int rc= PlugExit(g);
g= NULL;
free(dup);
return true;
} // endif g->
dup->Catalog= new MYCAT(hc);
ap= new ACTIVITY;
memset(ap, 0, sizeof(ACTIVITY));
strcpy(ap->Ap_Name, "CONNECT");
g->Activityp= ap;
g->Activityp->Aptr= dup;
next= to_users;
to_users= this;
if (next)
next->previous= this;
last_query_id= thdp->query_id;
count= 1;
return false;
} // end of user_init
/****************************************************************************/
/* Check whether we begin a new query and if so cleanup the previous one. */
/****************************************************************************/
bool user_connect::CheckCleanup(void)
{
if (thdp->query_id > last_query_id) {
PlugCleanup(g, true);
PlugSubSet(g, g->Sarea, g->Sarea_Size);
last_query_id= thdp->query_id;
if (xtrace)
printf("=====> Begin new query %llu\n", last_query_id);
return true;
} // endif query_id
return false;
} // end of CheckCleanup

View File

@@ -1,80 +1,80 @@
/* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/** @file user_connect.h
@brief
Declaration of the user_connect class.
@note
@see
/sql/handler.h and /storage/connect/user_connect.cc
*/
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
#if defined(WIN32)
#include <sys\timeb.h>
#else
#include <sys/timeb.h>
#endif // UBUNTU
/*****************************************************************************/
/* This is the global structure having all CONNECT information. */
/*****************************************************************************/
//typedef struct _global *PGLOBAL;
typedef class user_connect *PCONNECT;
typedef class ha_connect *PHC;
static int connect_done_func(void *);
/*****************************************************************************/
/* The CONNECT users. There should be one by connected users. */
/*****************************************************************************/
class user_connect
{
friend class ha_connect;
friend int connect_done_func(void *);
public:
// Constructor
user_connect(THD *thd, const char *dbn);
// Destructor
virtual ~user_connect();
// Implementation
bool user_init(ha_connect *hc);
bool CheckCleanup(void);
bool CheckQueryID(void) {return thdp->query_id > last_query_id;}
bool CheckQuery(query_id_t vid) {return last_query_id > vid;}
protected:
// Members
static PCONNECT to_users; // To the chain of users
THD *thdp; // To the user thread
PCONNECT next; // Next user in chain
PCONNECT previous; // Previous user in chain
PGLOBAL g; // The common handle to CONNECT
//char dbname[32]; // The DBCONNECT database
PTDBDOS tabp; // The table used on create
query_id_t last_query_id; // the latest user query id
int count; // if used by several handlers
// Statistics
ulong nrd, fnd, nfd;
ulonglong tb1;
}; // end of user_connect class definition
/* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/** @file user_connect.h
@brief
Declaration of the user_connect class.
@note
@see
/sql/handler.h and /storage/connect/user_connect.cc
*/
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
#if defined(WIN32)
#include <sys\timeb.h>
#else
#include <sys/timeb.h>
#endif // UBUNTU
/*****************************************************************************/
/* This is the global structure having all CONNECT information. */
/*****************************************************************************/
//typedef struct _global *PGLOBAL;
typedef class user_connect *PCONNECT;
typedef class ha_connect *PHC;
static int connect_done_func(void *);
/*****************************************************************************/
/* The CONNECT users. There should be one by connected users. */
/*****************************************************************************/
class user_connect
{
friend class ha_connect;
friend int connect_done_func(void *);
public:
// Constructor
user_connect(THD *thd, const char *dbn);
// Destructor
virtual ~user_connect();
// Implementation
bool user_init(ha_connect *hc);
bool CheckCleanup(void);
bool CheckQueryID(void) {return thdp->query_id > last_query_id;}
bool CheckQuery(query_id_t vid) {return last_query_id > vid;}
protected:
// Members
static PCONNECT to_users; // To the chain of users
THD *thdp; // To the user thread
PCONNECT next; // Next user in chain
PCONNECT previous; // Previous user in chain
PGLOBAL g; // The common handle to CONNECT
//char dbname[32]; // The DBCONNECT database
PTDBDOS tabp; // The table used on create
query_id_t last_query_id; // the latest user query id
int count; // if used by several handlers
// Statistics
ulong nrd, fnd, nfd;
ulonglong tb1;
}; // end of user_connect class definition

File diff suppressed because it is too large Load Diff

View File

@@ -1,359 +1,359 @@
/*************** Valblk H Declares Source Code File (.H) ***************/
/* Name: VALBLK.H Version 1.7 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* */
/* This file contains the VALBLK and derived classes declares. */
/***********************************************************************/
/***********************************************************************/
/* Include required application header files */
/* assert.h is header required when using the assert function. */
/* block.h is header containing Block global declarations. */
/***********************************************************************/
#ifndef __VALBLK__H__
#define __VALBLK__H__
#include "value.h"
/***********************************************************************/
/* Utility used to allocate value blocks. */
/***********************************************************************/
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, bool, bool);
/***********************************************************************/
/* Class VALBLK represent a base class for variable blocks. */
/***********************************************************************/
class VALBLK : public BLOCK {
//friend void SemColData(PGLOBAL g, PSEM semp);
public:
// Constructors
VALBLK(void *mp, int type, int nval)
{Blkp = mp; Type = type; Nval = nval; Check = true;}
// Implementation
int GetNval(void) {return Nval;}
void SetNval(int n) {Nval = n;}
void *GetValPointer(void) {return Blkp;}
void SetValPointer(void *mp) {Blkp = mp;}
int GetType(void) {return Type;}
void SetCheck(bool b) {Check = b;}
virtual void Init(PGLOBAL g, bool check) = 0;
virtual int GetVlen(void) = 0;
virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) = 0;
virtual int GetIntValue(int n) = 0;
virtual longlong GetBigintValue(int n) = 0;
virtual double GetFloatValue(int n) = 0;
virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;}
virtual void Reset(int n) = 0;
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
virtual void SetPrec(int p) {}
virtual bool IsCi(void) {return false;}
// Methods
virtual void SetValue(short sval, int n) {assert(false);}
virtual void SetValue(int lval, int n) {assert(false);}
virtual void SetValue(longlong lval, int n) {assert(false);}
virtual void SetValue(PSZ sp, int n) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0;
virtual void SetMin(PVAL valp, int n) = 0;
virtual void SetMax(PVAL valp, int n) = 0;
virtual void SetValue(PVBLK pv, int n1, int n2) = 0;
virtual void SetValues(PVBLK pv, int i, int n) = 0;
virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);}
virtual void Move(int i, int j) = 0;
virtual int CompVal(PVAL vp, int n) = 0;
virtual int CompVal(int i1, int i2) = 0;
virtual void *GetValPtr(int n) = 0;
virtual void *GetValPtrEx(int n) = 0;
virtual int Find(PVAL vp) = 0;
virtual int GetMaxLength(void) = 0;
bool Locate(PVAL vp, int& i);
protected:
#if defined(_DEBUG) || defined(DEBTRACE)
void ChkIndx(int n);
void ChkPrm(PVAL v, int n);
void ChkTyp(PVAL v);
void ChkTyp(PVBLK vb);
#endif // _DEBUG) || DEBTRACE
// Members
PGLOBAL Global; // Used for messages and allocation
void *Blkp; // To value block
int Type; // Type of individual values
int Nval; // Max number of values in block
bool Check; // If true SetValue types must match
}; // end of class VALBLK
/***********************************************************************/
/* Class CHRBLK: represent a block of fixed length strings. */
/***********************************************************************/
class CHRBLK : public VALBLK {
public:
// Constructors
CHRBLK(void *mp, int size, int len, int prec, bool b);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return Long;}
virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n);
virtual int GetIntValue(int n);
virtual longlong GetBigintValue(int n);
virtual double GetFloatValue(int n);
virtual void Reset(int n);
virtual void SetPrec(int p) {Ci = (p != 0);}
virtual bool IsCi(void) {return Ci;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
char* const &Chrp; // Pointer to char buffer
PSZ Valp; // Used to make a zero ended value
bool Blanks; // True for right filling with blanks
bool Ci; // True if case insensitive
int Long; // Length of each string
}; // end of class CHRBLK
/***********************************************************************/
/* Class STRBLK: represent a block of string pointers. */
/* Currently this class is used only by the DECODE scalar function */
/* and by the MyColumn function to store date formats. */
/***********************************************************************/
class STRBLK : public VALBLK {
public:
// Constructors
STRBLK(PGLOBAL g, void *mp, int size);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(PSZ);}
virtual PSZ GetCharValue(int n) {return Strp[n];}
virtual short GetShortValue(int n) {return (short)atoi(Strp[n]);}
virtual int GetIntValue(int n) {return atol(Strp[n]);}
virtual longlong GetBigintValue(int n) {return atoll(Strp[n]);}
virtual double GetFloatValue(int n) {return atof(Strp[n]);}
virtual void Reset(int n) {Strp[n] = NULL;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
PSZ* const &Strp; // Pointer to PSZ buffer
}; // end of class STRBLK
/***********************************************************************/
/* Class SHRBLK: represents a block of int integer values. */
/***********************************************************************/
class SHRBLK : public VALBLK {
public:
// Constructors
SHRBLK(void *mp, int size);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(short);}
//virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return Shrp[n];}
virtual int GetIntValue(int n) {return (int)Shrp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Shrp[n];}
virtual double GetFloatValue(int n) {return (double)Shrp[n];}
virtual void Reset(int n) {Shrp[n] = 0;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(short sval, int n) {Shrp[n] = sval;}
virtual void SetValue(int lval, int n) {Shrp[n] = (short)lval;}
virtual void SetValue(longlong lval, int n) {Shrp[n] = (short)lval;}
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
short* const &Shrp;
}; // end of class SHRBLK
/***********************************************************************/
/* Class LNGBLK: represents a block of int integer values. */
/***********************************************************************/
class LNGBLK : public VALBLK {
public:
// Constructors
LNGBLK(void *mp, int size);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(int);}
//virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Lngp[n];}
virtual int GetIntValue(int n) {return Lngp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Lngp[n];}
virtual double GetFloatValue(int n) {return (double)Lngp[n];}
virtual void Reset(int n) {Lngp[n] = 0;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(short sval, int n) {Lngp[n] = (int)sval;}
virtual void SetValue(int lval, int n) {Lngp[n] = lval;}
virtual void SetValue(longlong lval, int n) {Lngp[n] = (int)lval;}
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
int* const &Lngp;
}; // end of class LNGBLK
/***********************************************************************/
/* Class DATBLK: represents a block of time stamp values. */
/***********************************************************************/
class DATBLK : public LNGBLK {
public:
// Constructor
DATBLK(void *mp, int size);
// Implementation
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
// Methods
virtual void SetValue(PSZ sp, int n);
protected:
// Members
PVAL Dvalp; // Date value used to convert string
}; // end of class DATBLK
/***********************************************************************/
/* Class BIGBLK: represents a block of big integer values. */
/***********************************************************************/
class BIGBLK : public VALBLK {
public:
// Constructors
BIGBLK(void *mp, int size);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(longlong);}
//virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Lngp[n];}
virtual int GetIntValue(int n) {return (int)Lngp[n];}
virtual longlong GetBigintValue(int n) {return Lngp[n];}
virtual double GetFloatValue(int n) {return (double)Lngp[n];}
virtual void Reset(int n) {Lngp[n] = 0LL;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(short sval, int n) {Lngp[n] = (longlong)sval;}
virtual void SetValue(int lval, int n) {Lngp[n] = (longlong)lval;}
virtual void SetValue(longlong lval, int n) {Lngp[n] = lval;}
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
longlong* const &Lngp;
}; // end of class BIGBLK
/***********************************************************************/
/* Class DBLBLK: represents a block of double float values. */
/***********************************************************************/
class DBLBLK : public VALBLK {
public:
// Constructors
DBLBLK(void *mp, int size, int prec);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(double);}
//virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Dblp[n];}
virtual int GetIntValue(int n) {return (int)Dblp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Dblp[n];}
virtual double GetFloatValue(int n) {return Dblp[n];}
virtual void Reset(int n) {Dblp[n] = 0.0;}
virtual void SetPrec(int p) {Prec = p;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
double* const &Dblp;
int Prec;
}; // end of class DBLBLK
#endif // __VALBLK__H__
/*************** Valblk H Declares Source Code File (.H) ***************/
/* Name: VALBLK.H Version 1.7 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* */
/* This file contains the VALBLK and derived classes declares. */
/***********************************************************************/
/***********************************************************************/
/* Include required application header files */
/* assert.h is header required when using the assert function. */
/* block.h is header containing Block global declarations. */
/***********************************************************************/
#ifndef __VALBLK__H__
#define __VALBLK__H__
#include "value.h"
/***********************************************************************/
/* Utility used to allocate value blocks. */
/***********************************************************************/
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, bool, bool);
/***********************************************************************/
/* Class VALBLK represent a base class for variable blocks. */
/***********************************************************************/
class VALBLK : public BLOCK {
//friend void SemColData(PGLOBAL g, PSEM semp);
public:
// Constructors
VALBLK(void *mp, int type, int nval)
{Blkp = mp; Type = type; Nval = nval; Check = true;}
// Implementation
int GetNval(void) {return Nval;}
void SetNval(int n) {Nval = n;}
void *GetValPointer(void) {return Blkp;}
void SetValPointer(void *mp) {Blkp = mp;}
int GetType(void) {return Type;}
void SetCheck(bool b) {Check = b;}
virtual void Init(PGLOBAL g, bool check) = 0;
virtual int GetVlen(void) = 0;
virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) = 0;
virtual int GetIntValue(int n) = 0;
virtual longlong GetBigintValue(int n) = 0;
virtual double GetFloatValue(int n) = 0;
virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;}
virtual void Reset(int n) = 0;
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
virtual void SetPrec(int p) {}
virtual bool IsCi(void) {return false;}
// Methods
virtual void SetValue(short sval, int n) {assert(false);}
virtual void SetValue(int lval, int n) {assert(false);}
virtual void SetValue(longlong lval, int n) {assert(false);}
virtual void SetValue(PSZ sp, int n) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0;
virtual void SetMin(PVAL valp, int n) = 0;
virtual void SetMax(PVAL valp, int n) = 0;
virtual void SetValue(PVBLK pv, int n1, int n2) = 0;
virtual void SetValues(PVBLK pv, int i, int n) = 0;
virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);}
virtual void Move(int i, int j) = 0;
virtual int CompVal(PVAL vp, int n) = 0;
virtual int CompVal(int i1, int i2) = 0;
virtual void *GetValPtr(int n) = 0;
virtual void *GetValPtrEx(int n) = 0;
virtual int Find(PVAL vp) = 0;
virtual int GetMaxLength(void) = 0;
bool Locate(PVAL vp, int& i);
protected:
#if defined(_DEBUG) || defined(DEBTRACE)
void ChkIndx(int n);
void ChkPrm(PVAL v, int n);
void ChkTyp(PVAL v);
void ChkTyp(PVBLK vb);
#endif // _DEBUG) || DEBTRACE
// Members
PGLOBAL Global; // Used for messages and allocation
void *Blkp; // To value block
int Type; // Type of individual values
int Nval; // Max number of values in block
bool Check; // If true SetValue types must match
}; // end of class VALBLK
/***********************************************************************/
/* Class CHRBLK: represent a block of fixed length strings. */
/***********************************************************************/
class CHRBLK : public VALBLK {
public:
// Constructors
CHRBLK(void *mp, int size, int len, int prec, bool b);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return Long;}
virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n);
virtual int GetIntValue(int n);
virtual longlong GetBigintValue(int n);
virtual double GetFloatValue(int n);
virtual void Reset(int n);
virtual void SetPrec(int p) {Ci = (p != 0);}
virtual bool IsCi(void) {return Ci;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
char* const &Chrp; // Pointer to char buffer
PSZ Valp; // Used to make a zero ended value
bool Blanks; // True for right filling with blanks
bool Ci; // True if case insensitive
int Long; // Length of each string
}; // end of class CHRBLK
/***********************************************************************/
/* Class STRBLK: represent a block of string pointers. */
/* Currently this class is used only by the DECODE scalar function */
/* and by the MyColumn function to store date formats. */
/***********************************************************************/
class STRBLK : public VALBLK {
public:
// Constructors
STRBLK(PGLOBAL g, void *mp, int size);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(PSZ);}
virtual PSZ GetCharValue(int n) {return Strp[n];}
virtual short GetShortValue(int n) {return (short)atoi(Strp[n]);}
virtual int GetIntValue(int n) {return atol(Strp[n]);}
virtual longlong GetBigintValue(int n) {return atoll(Strp[n]);}
virtual double GetFloatValue(int n) {return atof(Strp[n]);}
virtual void Reset(int n) {Strp[n] = NULL;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
PSZ* const &Strp; // Pointer to PSZ buffer
}; // end of class STRBLK
/***********************************************************************/
/* Class SHRBLK: represents a block of int integer values. */
/***********************************************************************/
class SHRBLK : public VALBLK {
public:
// Constructors
SHRBLK(void *mp, int size);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(short);}
//virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return Shrp[n];}
virtual int GetIntValue(int n) {return (int)Shrp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Shrp[n];}
virtual double GetFloatValue(int n) {return (double)Shrp[n];}
virtual void Reset(int n) {Shrp[n] = 0;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(short sval, int n) {Shrp[n] = sval;}
virtual void SetValue(int lval, int n) {Shrp[n] = (short)lval;}
virtual void SetValue(longlong lval, int n) {Shrp[n] = (short)lval;}
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
short* const &Shrp;
}; // end of class SHRBLK
/***********************************************************************/
/* Class LNGBLK: represents a block of int integer values. */
/***********************************************************************/
class LNGBLK : public VALBLK {
public:
// Constructors
LNGBLK(void *mp, int size);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(int);}
//virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Lngp[n];}
virtual int GetIntValue(int n) {return Lngp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Lngp[n];}
virtual double GetFloatValue(int n) {return (double)Lngp[n];}
virtual void Reset(int n) {Lngp[n] = 0;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(short sval, int n) {Lngp[n] = (int)sval;}
virtual void SetValue(int lval, int n) {Lngp[n] = lval;}
virtual void SetValue(longlong lval, int n) {Lngp[n] = (int)lval;}
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
int* const &Lngp;
}; // end of class LNGBLK
/***********************************************************************/
/* Class DATBLK: represents a block of time stamp values. */
/***********************************************************************/
class DATBLK : public LNGBLK {
public:
// Constructor
DATBLK(void *mp, int size);
// Implementation
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
// Methods
virtual void SetValue(PSZ sp, int n);
protected:
// Members
PVAL Dvalp; // Date value used to convert string
}; // end of class DATBLK
/***********************************************************************/
/* Class BIGBLK: represents a block of big integer values. */
/***********************************************************************/
class BIGBLK : public VALBLK {
public:
// Constructors
BIGBLK(void *mp, int size);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(longlong);}
//virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Lngp[n];}
virtual int GetIntValue(int n) {return (int)Lngp[n];}
virtual longlong GetBigintValue(int n) {return Lngp[n];}
virtual double GetFloatValue(int n) {return (double)Lngp[n];}
virtual void Reset(int n) {Lngp[n] = 0LL;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(short sval, int n) {Lngp[n] = (longlong)sval;}
virtual void SetValue(int lval, int n) {Lngp[n] = (longlong)lval;}
virtual void SetValue(longlong lval, int n) {Lngp[n] = lval;}
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
longlong* const &Lngp;
}; // end of class BIGBLK
/***********************************************************************/
/* Class DBLBLK: represents a block of double float values. */
/***********************************************************************/
class DBLBLK : public VALBLK {
public:
// Constructors
DBLBLK(void *mp, int size, int prec);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(double);}
//virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Dblp[n];}
virtual int GetIntValue(int n) {return (int)Dblp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Dblp[n];}
virtual double GetFloatValue(int n) {return Dblp[n];}
virtual void Reset(int n) {Dblp[n] = 0.0;}
virtual void SetPrec(int p) {Prec = p;}
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
protected:
// Members
double* const &Dblp;
int Prec;
}; // end of class DBLBLK
#endif // __VALBLK__H__

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,487 +1,487 @@
/*************** Xindex H Declares Source Code File (.H) ***************/
/* Name: XINDEX.H Version 3.4 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2004 - 2012 */
/* */
/* This file contains the XINDEX class declares. */
/***********************************************************************/
#ifndef __XINDEX_H__
#define __XINDEX_H__
#include "block.h"
#include "csort.h" /* Base class declares */
#include "xtable.h"
#include "valblk.h"
enum IDT {TYPE_IDX_ERROR = 0, /* Type not defined */
TYPE_IDX_INDX = 4, /* Permanent standard index */
TYPE_IDX_XROW = 5}; /* Permanent row index */
typedef struct mem_map *MMP;
typedef class INDEXDEF *PIXDEF;
typedef class KPARTDEF *PKPDEF;
typedef class XINDEX *PXINDEX;
typedef class XLOAD *PXLOAD;
typedef class KXYCOL *PXCOL;
/***********************************************************************/
/* Structures used when checking for possible indexing */
/***********************************************************************/
typedef struct index_col *PICOL;
typedef struct index_val *PIVAL;
typedef struct index_def *PINDX;
typedef struct indx_used *PXUSED;
typedef struct index_val : public BLOCK {
index_val(PXOB xp) {Next = NULL; Xval = xp; Kp = NULL;}
PIVAL Next; // Next value
PXOB Xval; // To value or array
int *Kp; // The coordonates in a LSTBLK
} IVAL;
typedef struct index_col : public BLOCK {
index_col(PCOL cp)
{Next = Nxtgrp = NULL; Colp = cp; Ngrp = N = 0; Vals = NULL;}
PICOL Next; // Next column
PICOL Nxtgrp; // Next group
PCOL Colp; // The column
PIVAL Vals; // To column values
int Ngrp; // Group number of values
int N; // Column number of values
} ICOL;
typedef struct index_def : public BLOCK {
index_def(PIXDEF xdp)
{Next = NULL; Pxdf = xdp; Cols = NULL; Alloc = false;}
PINDX Next;
PIXDEF Pxdf;
PICOL Cols;
bool Alloc; // Must allocate values
} INDX;
/***********************************************************************/
/* Index definition block. */
/***********************************************************************/
class DllExport INDEXDEF : public BLOCK { /* Index description block */
friend class PLUGCAT;
friend class DOSDEF;
friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add);
public:
// Constructor
INDEXDEF(char *name, bool uniq = false, int n = 0);
// Implementation
PIXDEF GetNext(void) {return Next;}
void SetNext(PIXDEF pxdf) {Next = pxdf;}
PSZ GetName(void) {return (PSZ)Name;}
bool IsUnique(void) {return Unique;}
bool IsAuto(void) {return AutoInc;}
void SetAuto(bool b) {AutoInc = b;}
void SetInvalid(bool b) {Invalid = b;}
int GetNparts(void) {return Nparts;}
int GetID(void) {return ID;}
void SetID(int n) {ID = n;}
PKPDEF GetToKeyParts(void) {return ToKeyParts;}
void SetToKeyParts(PKPDEF kp) {ToKeyParts = kp;}
void SetNParts(uint np) {Nparts = (signed)np;}
void SetMaxSame(int mxs) {MaxSame = mxs;}
void SetMxsame(PXINDEX x);
int GetOffset(void) {return Offset;}
void SetOffset(int off) {Offset = off;}
int GetOffhigh(void) {return Offhigh;}
void SetOffhigh(int hof) {Offhigh = hof;}
int GetSize(void) {return Size;}
void SetSize(int size) {Size = size;}
int GetMaxSame(void) {return MaxSame;}
bool Define(PGLOBAL g, void *memp, PTABDEF dfp, LPCSTR p);
PIXDEF GetIndexOf(PCOL colp, bool hd = false);
int IsIndexOf(PCOL colp);
PKXBASE CheckIndexing(PGLOBAL g, PTDBDOS tdbp);
PINDX CheckAND(PGLOBAL g, PINDX pix1, PINDX pix2);
PINDX CheckOR(PGLOBAL g, PINDX pix1, PINDX pix2);
PINDX CheckEQ(PGLOBAL g, PTDB tdbp, PXOB *arg, int op, int *kp = NULL);
bool TestEQ(PGLOBAL g, PTDB tdbp, PXOB *arg, int op, bool b = false);
protected:
PIXDEF Next; /* To next block */
PKPDEF ToKeyParts; /* To the key part definitions */
char *Name; /* Index name */
bool Unique; /* true if defined as unique */
bool Invalid; /* true if marked as Invalid */
bool AutoInc; /* true if unique key in auto increment */
int Nparts; /* Number of key parts */
int ID; /* Index ID number */
int Offset; /* Offset in index file */
int Offhigh; /* Offset high in big index file */
int Size; /* Size of index file */
int MaxSame; /* Max number of same values */
}; // end of INDEXDEF
typedef struct indx_used : public BLOCK {
indx_used(PTDB tp, PIXDEF xdp, PCOL *cp, int k)
{Tname = (char*)tp->GetName(); Xname = xdp->GetName(); Cp = cp; K = k;}
PXUSED Next;
char *Tname;
PSZ Xname;
PCOL *Cp;
int K;
} XUSED;
/***********************************************************************/
/* Index Key Part definition block. */
/***********************************************************************/
class DllExport KPARTDEF : public BLOCK { /* Index Key Part desc block */
friend class INDEXDEF;
friend class XINDEX;
friend class PLUGCAT;
friend class DOSDEF;
friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add);
public:
KPARTDEF(PSZ name, int n); // Constructor
// Implementation
PKPDEF GetNext(void) {return Next;}
PSZ GetName(void) {return (PSZ)Name;}
int GetNcol(void) {return Ncol;}
void SetNext(PKPDEF pkdf) {Next = pkdf;}
void SetKlen(int len) {Klen = len;}
void SetMxsame(int mxs) {Mxsame = mxs;}
protected:
PKPDEF Next; /* To next block */
PSZ Name; /* Field name */
int Mxsame; /* Field max same values */
int Ncol; /* Field number */
int Klen; /* Key length */
}; // end of KPARTDEF
/***********************************************************************/
/* This is the XDB Index virtual base class declaration. */
/***********************************************************************/
class DllExport XXBASE : public CSORT, public BLOCK {
friend class INDEXDEF;
friend class KXYCOL;
public:
// Constructor
XXBASE(PTDBDOS tbxp, bool b);
// Implementation
virtual IDT GetType(void) = 0;
virtual void Reset(void) = 0;
virtual bool IsMul(void) {return false;}
virtual bool IsRandom(void) {return true;}
virtual bool HaveSame(void) {return false;}
virtual int GetCurPos(void) {return Cur_K;}
virtual void SetNval(int n) {assert(n == 1);}
virtual void SetOp(OPVAL op) {Op = op;}
int GetNdif(void) {return Ndif;}
int GetNum_K(void) {return Num_K;}
int GetCur_K(void) {return Cur_K;}
int GetID(void) {return ID;}
void SetID(int id) {ID = id;}
void SetNth(int n) {Nth = n;}
int *GetPof(void) {return Pof;}
int *GetPex(void) {return Pex;}
void FreeIndex(void) {PlgDBfree(Index);}
// Methods
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
virtual bool Init(PGLOBAL g) = 0;
virtual int MaxRange(void) {return 1;}
virtual int Fetch(PGLOBAL g) = 0;
virtual bool NextVal(bool eq) {return true;}
virtual int FastFind(int nk) = 0;
virtual bool Reorder(PGLOBAL g) {return true;}
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true)
{return -1;} // Means error
virtual int Qcompare(int *, int *) = 0;
virtual int GroupSize(void) {return 1;}
virtual void Close(void) = 0;
protected:
// Members
PTDBASE Tbxp; // Points to calling table TDB
PXCOL To_KeyCol; // To KeyCol class list
MBLOCK Record; // Record allocation block
int* &To_Rec; // We are using ftell, fseek
int Cur_K; // Index of current record
int Old_K; // Index of last record
int Num_K; // Size of Rec_K pointer array
int Ndif; // Number of distinct values
int Bot; // Bottom of research index
int Top; // Top of research index
int Inf, Sup; // Used for block optimization
OPVAL Op; // Search operator
bool Mul; // true if multiple
bool Srtd; // true for sorted column
int Val_K; // Index of current value
int Nblk; // Number of blocks
int Sblk; // Block size
int Thresh; // Thresh for sorting join indexes
int ID; // Index ID number
int Nth; // Nth constant to fetch
}; // end of class XXBASE
/***********************************************************************/
/* This is the standard (multicolumn) Index class declaration. */
/***********************************************************************/
class DllExport XINDEX : public XXBASE {
friend class KXYCOL;
public:
// Constructor
XINDEX(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp,
PCOL *cp, PXOB *xp = NULL, int k = 0);
// Implementation
virtual IDT GetType(void) {return TYPE_IDX_INDX;}
virtual bool IsMul(void) {return (Nval < Nk) ? true : Mul;}
virtual bool HaveSame(void) {return Op == OP_SAME;}
virtual int GetCurPos(void) {return (Pex) ? Pex[Cur_K] : Cur_K;}
virtual void SetNval(int n) {Nval = n;}
int GetMaxSame(void) {return MaxSame;}
int GetDefoff(void) {return Defoff;}
int GetDefhigh(void) {return Defhigh;}
int GetSize(void) {return Size;}
// Methods
virtual void Reset(void);
virtual bool Init(PGLOBAL g);
virtual int Qcompare(int *, int *);
virtual int Fetch(PGLOBAL g);
virtual int FastFind(int nk);
virtual int GroupSize(void);
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int MaxRange(void) {return MaxSame;}
virtual int ColMaxSame(PXCOL kp);
virtual void Close(void);
virtual bool NextVal(bool eq);
virtual bool Make(PGLOBAL g, PIXDEF sxp);
virtual bool SaveIndex(PGLOBAL g, PIXDEF sxp);
virtual bool Reorder(PGLOBAL g);
bool GetAllSizes(PGLOBAL g, int &ndif, int &numk);
protected:
bool NextValDif(void);
// Members
PIXDEF Xdp; // To index definition
PTDBDOS Tdbp; // Points to calling table TDB
PXLOAD X; // To XLOAD class
PXCOL To_LastCol; // To the last key part block
PXCOL To_LastVal; // To the last used key part block
PCOL *To_Cols; // To array of indexed columns
PXOB *To_Vals; // To array of column values
int Nk; // The number of indexed columns
int Nval; // The number of used columns
int Incr; // Increment of record position
int Defoff; // Offset of definition in index file
int Defhigh; // High order of offset big value
int Size; // Size of definition in index file
int MaxSame; // Max number of same values
}; // end of class XINDEX
/***********************************************************************/
/* This is the fast single column index class declaration. */
/***********************************************************************/
class DllExport XINDXS : public XINDEX {
friend class KXYCOL;
public:
// Constructor
XINDXS(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp = NULL);
// Implementation
virtual void SetNval(int n) {assert(n == 1);}
// Methods
virtual int Qcompare(int *, int *);
virtual int Fetch(PGLOBAL g);
virtual int FastFind(int nk);
virtual bool NextVal(bool eq);
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int GroupSize(void);
protected:
// Members
}; // end of class XINDXS
/***********************************************************************/
/* This is the saving/loading index utility base class. */
/***********************************************************************/
class DllExport XLOAD : public BLOCK {
friend class XBIGEX;
friend class XBIGXS;
public:
// Constructor
XLOAD(void);
// Methods
virtual bool Open(PGLOBAL g, char *filename, MODE mode) = 0;
virtual bool GetOff(int& low, int& high, PIXDEF sxp) = 0;
virtual bool Seek(PGLOBAL g, int low, int high, int origin) = 0;
virtual bool Read(PGLOBAL g, void *buf, int n, int size) = 0;
virtual int Write(PGLOBAL g, void *buf, int n,
int size, bool& rc) = 0;
virtual void Close(void);
#if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff,
int hoff, int size) = 0;
#endif // XMAP
protected:
// Members
#if defined(WIN32)
HANDLE Hfile; // Handle to file or map
#if defined(XMAP)
void *ViewBase; // Mapped view base address
#endif // XMAP
#else // UNIX
int Hfile; // Descriptor to file or map
#endif // UNIX
}; // end of class XLOAD
/***********************************************************************/
/* This is the saving/loading indexes utility class. */
/***********************************************************************/
class DllExport XFILE : public XLOAD {
public:
// Constructor
XFILE(void);
// Methods
virtual bool Open(PGLOBAL g, char *filename, MODE mode);
virtual bool GetOff(int& low, int& high, PIXDEF sxp);
virtual bool Seek(PGLOBAL g, int low, int high, int origin);
virtual bool Read(PGLOBAL g, void *buf, int n, int size);
virtual int Write(PGLOBAL g, void *buf, int n, int size, bool& rc);
virtual void Close(void);
#if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff,
int hoff, int size);
#endif // XMAP
protected:
// Members
FILE *Xfile; // Index stream file
#if defined(XMAP) && !defined(WIN32)
MMP Mmp; // To UNIX mapped index file
#endif // XMAP
}; // end of class XFILE
/***********************************************************************/
/* This is the saving/loading huge indexes utility class. */
/***********************************************************************/
class DllExport XHUGE : public XLOAD {
public:
// Constructor
XHUGE(void) : XLOAD() {}
// Methods
virtual bool Open(PGLOBAL g, char *filename, MODE mode);
virtual bool GetOff(int& low, int& high, PIXDEF sxp);
virtual bool Seek(PGLOBAL g, int low, int high, int origin);
virtual bool Read(PGLOBAL g, void *buf, int n, int size);
virtual int Write(PGLOBAL g, void *buf, int n, int size, bool& rc);
#if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff,
int hoff, int size);
#endif // XMAP
protected:
// Members
}; // end of class XHUGE
/***********************************************************************/
/* This is the XDB index for columns containing ROWID values. */
/***********************************************************************/
class DllExport XXROW : public XXBASE {
friend class KXYCOL;
public:
// Constructor
XXROW(PTDBDOS tbxp);
// Implementation
virtual IDT GetType(void) {return TYPE_IDX_XROW;}
virtual void Reset(void);
// Methods
virtual bool Init(PGLOBAL g);
virtual int Fetch(PGLOBAL g);
virtual int FastFind(int nk);
virtual int MaxRange(void) {return 1;}
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int Qcompare(int *, int *) {assert(false); return 0;}
virtual void Close(void) {}
protected:
// Members
PTDBDOS Tdbp; // Points to calling table TDB
PVAL Valp; // The value to match in index
}; // end of class XXROW
/***********************************************************************/
/* Definition of class KXYCOL used to store values of indexed columns */
/***********************************************************************/
class KXYCOL: public BLOCK {
friend class INDEXDEF;
friend class XINDEX;
friend class XINDXS;
friend class XBIGEX;
friend class XBIGXS;
friend class TDBDOS;
public:
// Constructors
KXYCOL(PKXBASE kp);
// Implementation
int GetType(void) {return Type;}
void SetValue(PCOL colp, int i);
public:
// Methods
virtual bool Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln);
virtual bool InitFind(PGLOBAL g, PXOB xp);
virtual void ReAlloc(PGLOBAL g, int n);
virtual void FreeData(void);
virtual void FillValue(PVAL valp);
virtual int CompVal(int i);
void InitBinFind(void *vp);
bool MakeBlockArray(PGLOBAL g, int nb, int size);
int Compare(int i1, int i2);
int CompBval(int i);
void Save(int i) {Valp->SetBinValue(Kblp->GetValPtr(i));}
void Restore(int j) {Kblp->SetValue(Valp, j);}
void Move(int j, int k) {Kblp->Move(k, j);}
// Specific functions
#if defined(XMAP)
BYTE *MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m);
#endif // XMAP
int *MakeOffset(PGLOBAL g, int n);
protected:
// Members
PXCOL Next; // To next in the key part list
PXCOL Previous; // To previous in the key part list
PKXBASE Kxp; // To the INDEX class block
PCOL Colp; // To matching object if a column
bool IsSorted; // true if column is already sorted
bool Asc; // true for ascending sort, false for Desc
MBLOCK Keys; // Data array allocation block
void* &To_Keys; // To data array
PVBLK Kblp; // To Valblock of the data array
MBLOCK Bkeys; // Block array allocation block
void* &To_Bkeys; // To block array
PVBLK Blkp; // To Valblock of the block array
PVAL Valp; // Value use by Find
int Klen; // Length of character string or num value
int Kprec; // The Value(s) precision or CI
int Type; // The Value(s) type
bool Prefix; // Key on CHAR column prefix
MBLOCK Koff; // Offset allocation block
CPINT &Kof; // Reference to offset array
int Val_K; // Index of current column value
int Ndf; // Number of stored values
int Mxs; // Max same for this column
}; // end of class KXYCOL
#endif // __XINDEX_H__
/*************** Xindex H Declares Source Code File (.H) ***************/
/* Name: XINDEX.H Version 3.4 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2004 - 2012 */
/* */
/* This file contains the XINDEX class declares. */
/***********************************************************************/
#ifndef __XINDEX_H__
#define __XINDEX_H__
#include "block.h"
#include "csort.h" /* Base class declares */
#include "xtable.h"
#include "valblk.h"
enum IDT {TYPE_IDX_ERROR = 0, /* Type not defined */
TYPE_IDX_INDX = 4, /* Permanent standard index */
TYPE_IDX_XROW = 5}; /* Permanent row index */
typedef struct mem_map *MMP;
typedef class INDEXDEF *PIXDEF;
typedef class KPARTDEF *PKPDEF;
typedef class XINDEX *PXINDEX;
typedef class XLOAD *PXLOAD;
typedef class KXYCOL *PXCOL;
/***********************************************************************/
/* Structures used when checking for possible indexing */
/***********************************************************************/
typedef struct index_col *PICOL;
typedef struct index_val *PIVAL;
typedef struct index_def *PINDX;
typedef struct indx_used *PXUSED;
typedef struct index_val : public BLOCK {
index_val(PXOB xp) {Next = NULL; Xval = xp; Kp = NULL;}
PIVAL Next; // Next value
PXOB Xval; // To value or array
int *Kp; // The coordonates in a LSTBLK
} IVAL;
typedef struct index_col : public BLOCK {
index_col(PCOL cp)
{Next = Nxtgrp = NULL; Colp = cp; Ngrp = N = 0; Vals = NULL;}
PICOL Next; // Next column
PICOL Nxtgrp; // Next group
PCOL Colp; // The column
PIVAL Vals; // To column values
int Ngrp; // Group number of values
int N; // Column number of values
} ICOL;
typedef struct index_def : public BLOCK {
index_def(PIXDEF xdp)
{Next = NULL; Pxdf = xdp; Cols = NULL; Alloc = false;}
PINDX Next;
PIXDEF Pxdf;
PICOL Cols;
bool Alloc; // Must allocate values
} INDX;
/***********************************************************************/
/* Index definition block. */
/***********************************************************************/
class DllExport INDEXDEF : public BLOCK { /* Index description block */
friend class PLUGCAT;
friend class DOSDEF;
friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add);
public:
// Constructor
INDEXDEF(char *name, bool uniq = false, int n = 0);
// Implementation
PIXDEF GetNext(void) {return Next;}
void SetNext(PIXDEF pxdf) {Next = pxdf;}
PSZ GetName(void) {return (PSZ)Name;}
bool IsUnique(void) {return Unique;}
bool IsAuto(void) {return AutoInc;}
void SetAuto(bool b) {AutoInc = b;}
void SetInvalid(bool b) {Invalid = b;}
int GetNparts(void) {return Nparts;}
int GetID(void) {return ID;}
void SetID(int n) {ID = n;}
PKPDEF GetToKeyParts(void) {return ToKeyParts;}
void SetToKeyParts(PKPDEF kp) {ToKeyParts = kp;}
void SetNParts(uint np) {Nparts = (signed)np;}
void SetMaxSame(int mxs) {MaxSame = mxs;}
void SetMxsame(PXINDEX x);
int GetOffset(void) {return Offset;}
void SetOffset(int off) {Offset = off;}
int GetOffhigh(void) {return Offhigh;}
void SetOffhigh(int hof) {Offhigh = hof;}
int GetSize(void) {return Size;}
void SetSize(int size) {Size = size;}
int GetMaxSame(void) {return MaxSame;}
bool Define(PGLOBAL g, void *memp, PTABDEF dfp, LPCSTR p);
PIXDEF GetIndexOf(PCOL colp, bool hd = false);
int IsIndexOf(PCOL colp);
PKXBASE CheckIndexing(PGLOBAL g, PTDBDOS tdbp);
PINDX CheckAND(PGLOBAL g, PINDX pix1, PINDX pix2);
PINDX CheckOR(PGLOBAL g, PINDX pix1, PINDX pix2);
PINDX CheckEQ(PGLOBAL g, PTDB tdbp, PXOB *arg, int op, int *kp = NULL);
bool TestEQ(PGLOBAL g, PTDB tdbp, PXOB *arg, int op, bool b = false);
protected:
PIXDEF Next; /* To next block */
PKPDEF ToKeyParts; /* To the key part definitions */
char *Name; /* Index name */
bool Unique; /* true if defined as unique */
bool Invalid; /* true if marked as Invalid */
bool AutoInc; /* true if unique key in auto increment */
int Nparts; /* Number of key parts */
int ID; /* Index ID number */
int Offset; /* Offset in index file */
int Offhigh; /* Offset high in big index file */
int Size; /* Size of index file */
int MaxSame; /* Max number of same values */
}; // end of INDEXDEF
typedef struct indx_used : public BLOCK {
indx_used(PTDB tp, PIXDEF xdp, PCOL *cp, int k)
{Tname = (char*)tp->GetName(); Xname = xdp->GetName(); Cp = cp; K = k;}
PXUSED Next;
char *Tname;
PSZ Xname;
PCOL *Cp;
int K;
} XUSED;
/***********************************************************************/
/* Index Key Part definition block. */
/***********************************************************************/
class DllExport KPARTDEF : public BLOCK { /* Index Key Part desc block */
friend class INDEXDEF;
friend class XINDEX;
friend class PLUGCAT;
friend class DOSDEF;
friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add);
public:
KPARTDEF(PSZ name, int n); // Constructor
// Implementation
PKPDEF GetNext(void) {return Next;}
PSZ GetName(void) {return (PSZ)Name;}
int GetNcol(void) {return Ncol;}
void SetNext(PKPDEF pkdf) {Next = pkdf;}
void SetKlen(int len) {Klen = len;}
void SetMxsame(int mxs) {Mxsame = mxs;}
protected:
PKPDEF Next; /* To next block */
PSZ Name; /* Field name */
int Mxsame; /* Field max same values */
int Ncol; /* Field number */
int Klen; /* Key length */
}; // end of KPARTDEF
/***********************************************************************/
/* This is the XDB Index virtual base class declaration. */
/***********************************************************************/
class DllExport XXBASE : public CSORT, public BLOCK {
friend class INDEXDEF;
friend class KXYCOL;
public:
// Constructor
XXBASE(PTDBDOS tbxp, bool b);
// Implementation
virtual IDT GetType(void) = 0;
virtual void Reset(void) = 0;
virtual bool IsMul(void) {return false;}
virtual bool IsRandom(void) {return true;}
virtual bool HaveSame(void) {return false;}
virtual int GetCurPos(void) {return Cur_K;}
virtual void SetNval(int n) {assert(n == 1);}
virtual void SetOp(OPVAL op) {Op = op;}
int GetNdif(void) {return Ndif;}
int GetNum_K(void) {return Num_K;}
int GetCur_K(void) {return Cur_K;}
int GetID(void) {return ID;}
void SetID(int id) {ID = id;}
void SetNth(int n) {Nth = n;}
int *GetPof(void) {return Pof;}
int *GetPex(void) {return Pex;}
void FreeIndex(void) {PlgDBfree(Index);}
// Methods
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
virtual bool Init(PGLOBAL g) = 0;
virtual int MaxRange(void) {return 1;}
virtual int Fetch(PGLOBAL g) = 0;
virtual bool NextVal(bool eq) {return true;}
virtual int FastFind(int nk) = 0;
virtual bool Reorder(PGLOBAL g) {return true;}
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true)
{return -1;} // Means error
virtual int Qcompare(int *, int *) = 0;
virtual int GroupSize(void) {return 1;}
virtual void Close(void) = 0;
protected:
// Members
PTDBASE Tbxp; // Points to calling table TDB
PXCOL To_KeyCol; // To KeyCol class list
MBLOCK Record; // Record allocation block
int* &To_Rec; // We are using ftell, fseek
int Cur_K; // Index of current record
int Old_K; // Index of last record
int Num_K; // Size of Rec_K pointer array
int Ndif; // Number of distinct values
int Bot; // Bottom of research index
int Top; // Top of research index
int Inf, Sup; // Used for block optimization
OPVAL Op; // Search operator
bool Mul; // true if multiple
bool Srtd; // true for sorted column
int Val_K; // Index of current value
int Nblk; // Number of blocks
int Sblk; // Block size
int Thresh; // Thresh for sorting join indexes
int ID; // Index ID number
int Nth; // Nth constant to fetch
}; // end of class XXBASE
/***********************************************************************/
/* This is the standard (multicolumn) Index class declaration. */
/***********************************************************************/
class DllExport XINDEX : public XXBASE {
friend class KXYCOL;
public:
// Constructor
XINDEX(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp,
PCOL *cp, PXOB *xp = NULL, int k = 0);
// Implementation
virtual IDT GetType(void) {return TYPE_IDX_INDX;}
virtual bool IsMul(void) {return (Nval < Nk) ? true : Mul;}
virtual bool HaveSame(void) {return Op == OP_SAME;}
virtual int GetCurPos(void) {return (Pex) ? Pex[Cur_K] : Cur_K;}
virtual void SetNval(int n) {Nval = n;}
int GetMaxSame(void) {return MaxSame;}
int GetDefoff(void) {return Defoff;}
int GetDefhigh(void) {return Defhigh;}
int GetSize(void) {return Size;}
// Methods
virtual void Reset(void);
virtual bool Init(PGLOBAL g);
virtual int Qcompare(int *, int *);
virtual int Fetch(PGLOBAL g);
virtual int FastFind(int nk);
virtual int GroupSize(void);
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int MaxRange(void) {return MaxSame;}
virtual int ColMaxSame(PXCOL kp);
virtual void Close(void);
virtual bool NextVal(bool eq);
virtual bool Make(PGLOBAL g, PIXDEF sxp);
virtual bool SaveIndex(PGLOBAL g, PIXDEF sxp);
virtual bool Reorder(PGLOBAL g);
bool GetAllSizes(PGLOBAL g, int &ndif, int &numk);
protected:
bool NextValDif(void);
// Members
PIXDEF Xdp; // To index definition
PTDBDOS Tdbp; // Points to calling table TDB
PXLOAD X; // To XLOAD class
PXCOL To_LastCol; // To the last key part block
PXCOL To_LastVal; // To the last used key part block
PCOL *To_Cols; // To array of indexed columns
PXOB *To_Vals; // To array of column values
int Nk; // The number of indexed columns
int Nval; // The number of used columns
int Incr; // Increment of record position
int Defoff; // Offset of definition in index file
int Defhigh; // High order of offset big value
int Size; // Size of definition in index file
int MaxSame; // Max number of same values
}; // end of class XINDEX
/***********************************************************************/
/* This is the fast single column index class declaration. */
/***********************************************************************/
class DllExport XINDXS : public XINDEX {
friend class KXYCOL;
public:
// Constructor
XINDXS(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp = NULL);
// Implementation
virtual void SetNval(int n) {assert(n == 1);}
// Methods
virtual int Qcompare(int *, int *);
virtual int Fetch(PGLOBAL g);
virtual int FastFind(int nk);
virtual bool NextVal(bool eq);
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int GroupSize(void);
protected:
// Members
}; // end of class XINDXS
/***********************************************************************/
/* This is the saving/loading index utility base class. */
/***********************************************************************/
class DllExport XLOAD : public BLOCK {
friend class XBIGEX;
friend class XBIGXS;
public:
// Constructor
XLOAD(void);
// Methods
virtual bool Open(PGLOBAL g, char *filename, MODE mode) = 0;
virtual bool GetOff(int& low, int& high, PIXDEF sxp) = 0;
virtual bool Seek(PGLOBAL g, int low, int high, int origin) = 0;
virtual bool Read(PGLOBAL g, void *buf, int n, int size) = 0;
virtual int Write(PGLOBAL g, void *buf, int n,
int size, bool& rc) = 0;
virtual void Close(void);
#if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff,
int hoff, int size) = 0;
#endif // XMAP
protected:
// Members
#if defined(WIN32)
HANDLE Hfile; // Handle to file or map
#if defined(XMAP)
void *ViewBase; // Mapped view base address
#endif // XMAP
#else // UNIX
int Hfile; // Descriptor to file or map
#endif // UNIX
}; // end of class XLOAD
/***********************************************************************/
/* This is the saving/loading indexes utility class. */
/***********************************************************************/
class DllExport XFILE : public XLOAD {
public:
// Constructor
XFILE(void);
// Methods
virtual bool Open(PGLOBAL g, char *filename, MODE mode);
virtual bool GetOff(int& low, int& high, PIXDEF sxp);
virtual bool Seek(PGLOBAL g, int low, int high, int origin);
virtual bool Read(PGLOBAL g, void *buf, int n, int size);
virtual int Write(PGLOBAL g, void *buf, int n, int size, bool& rc);
virtual void Close(void);
#if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff,
int hoff, int size);
#endif // XMAP
protected:
// Members
FILE *Xfile; // Index stream file
#if defined(XMAP) && !defined(WIN32)
MMP Mmp; // To UNIX mapped index file
#endif // XMAP
}; // end of class XFILE
/***********************************************************************/
/* This is the saving/loading huge indexes utility class. */
/***********************************************************************/
class DllExport XHUGE : public XLOAD {
public:
// Constructor
XHUGE(void) : XLOAD() {}
// Methods
virtual bool Open(PGLOBAL g, char *filename, MODE mode);
virtual bool GetOff(int& low, int& high, PIXDEF sxp);
virtual bool Seek(PGLOBAL g, int low, int high, int origin);
virtual bool Read(PGLOBAL g, void *buf, int n, int size);
virtual int Write(PGLOBAL g, void *buf, int n, int size, bool& rc);
#if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff,
int hoff, int size);
#endif // XMAP
protected:
// Members
}; // end of class XHUGE
/***********************************************************************/
/* This is the XDB index for columns containing ROWID values. */
/***********************************************************************/
class DllExport XXROW : public XXBASE {
friend class KXYCOL;
public:
// Constructor
XXROW(PTDBDOS tbxp);
// Implementation
virtual IDT GetType(void) {return TYPE_IDX_XROW;}
virtual void Reset(void);
// Methods
virtual bool Init(PGLOBAL g);
virtual int Fetch(PGLOBAL g);
virtual int FastFind(int nk);
virtual int MaxRange(void) {return 1;}
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int Qcompare(int *, int *) {assert(false); return 0;}
virtual void Close(void) {}
protected:
// Members
PTDBDOS Tdbp; // Points to calling table TDB
PVAL Valp; // The value to match in index
}; // end of class XXROW
/***********************************************************************/
/* Definition of class KXYCOL used to store values of indexed columns */
/***********************************************************************/
class KXYCOL: public BLOCK {
friend class INDEXDEF;
friend class XINDEX;
friend class XINDXS;
friend class XBIGEX;
friend class XBIGXS;
friend class TDBDOS;
public:
// Constructors
KXYCOL(PKXBASE kp);
// Implementation
int GetType(void) {return Type;}
void SetValue(PCOL colp, int i);
public:
// Methods
virtual bool Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln);
virtual bool InitFind(PGLOBAL g, PXOB xp);
virtual void ReAlloc(PGLOBAL g, int n);
virtual void FreeData(void);
virtual void FillValue(PVAL valp);
virtual int CompVal(int i);
void InitBinFind(void *vp);
bool MakeBlockArray(PGLOBAL g, int nb, int size);
int Compare(int i1, int i2);
int CompBval(int i);
void Save(int i) {Valp->SetBinValue(Kblp->GetValPtr(i));}
void Restore(int j) {Kblp->SetValue(Valp, j);}
void Move(int j, int k) {Kblp->Move(k, j);}
// Specific functions
#if defined(XMAP)
BYTE *MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m);
#endif // XMAP
int *MakeOffset(PGLOBAL g, int n);
protected:
// Members
PXCOL Next; // To next in the key part list
PXCOL Previous; // To previous in the key part list
PKXBASE Kxp; // To the INDEX class block
PCOL Colp; // To matching object if a column
bool IsSorted; // true if column is already sorted
bool Asc; // true for ascending sort, false for Desc
MBLOCK Keys; // Data array allocation block
void* &To_Keys; // To data array
PVBLK Kblp; // To Valblock of the data array
MBLOCK Bkeys; // Block array allocation block
void* &To_Bkeys; // To block array
PVBLK Blkp; // To Valblock of the block array
PVAL Valp; // Value use by Find
int Klen; // Length of character string or num value
int Kprec; // The Value(s) precision or CI
int Type; // The Value(s) type
bool Prefix; // Key on CHAR column prefix
MBLOCK Koff; // Offset allocation block
CPINT &Kof; // Reference to offset array
int Val_K; // Index of current column value
int Ndf; // Number of stored values
int Mxs; // Max same for this column
}; // end of class KXYCOL
#endif // __XINDEX_H__

View File

@@ -1,178 +1,178 @@
/************ Xobject C++ Functions Source Code File (.CPP) ************/
/* Name: XOBJECT.CPP Version 2.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* This file contains base XOBJECT class functions. */
/* Also here is the implementation of the CONSTANT class. */
/***********************************************************************/
/***********************************************************************/
/* Include mariaDB header file. */
/***********************************************************************/
#include "my_global.h"
/***********************************************************************/
/* Include required application header files */
/* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "xobject.h"
/***********************************************************************/
/* Macro definitions. */
/***********************************************************************/
#if defined(_DEBUG) || defined(DEBTRACE)
#define ASSERT(B) assert(B);
#else
#define ASSERT(B)
#endif
/***********************************************************************/
/* The one and only needed void object. */
/***********************************************************************/
XVOID Xvoid;
PXOB const pXVOID = &Xvoid; // Pointer used by other classes
/* ------------------------- Class XOBJECT --------------------------- */
/***********************************************************************/
/* GetCharValue: returns the Result value as a char string. */
/* Using GetCharValue provides no conversion from numeric types. */
/***********************************************************************/
PSZ XOBJECT::GetCharValue(void)
{
ASSERT(Value)
return Value->GetCharValue();
} // end of GetCharValue()
/***********************************************************************/
/* GetShortValue: returns the Result value as a short integer. */
/***********************************************************************/
short XOBJECT::GetShortValue(void)
{
ASSERT(Value)
return Value->GetShortValue();
} // end of GetShortValue
/***********************************************************************/
/* GetIntValue: returns the Result value as a int integer. */
/***********************************************************************/
int XOBJECT::GetIntValue(void)
{
ASSERT(Value)
return Value->GetIntValue();
} // end of GetIntValue
/***********************************************************************/
/* GetFloatValue: returns the Result value as a double float. */
/***********************************************************************/
double XOBJECT::GetFloatValue(void)
{
ASSERT(Value)
return Value->GetFloatValue();
} // end of GetFloatValue
/* ------------------------- Class CONSTANT -------------------------- */
/***********************************************************************/
/* CONSTANT public constructor. */
/***********************************************************************/
CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
{
if (!(Value = AllocateValue(g, value, (int)type)))
longjmp(g->jumper[g->jump_level], TYPE_CONST);
Constant = true;
} // end of CONSTANT constructor
/***********************************************************************/
/* CONSTANT public constructor. */
/***********************************************************************/
CONSTANT::CONSTANT(PGLOBAL g, int n)
{
if (!(Value = AllocateValue(g, &n, TYPE_INT)))
longjmp(g->jumper[g->jump_level], TYPE_CONST);
Constant = true;
} // end of CONSTANT constructor
/***********************************************************************/
/* GetLengthEx: returns an evaluation of the constant string length. */
/* Note: When converting from token to string, length has to be */
/* specified but we need the domain length, not the value length. */
/***********************************************************************/
int CONSTANT::GetLengthEx(void)
{
return Value->GetValLen();
} // end of GetLengthEx
/***********************************************************************/
/* Convert a constant to the given type. */
/***********************************************************************/
void CONSTANT::Convert(PGLOBAL g, int newtype)
{
if (Value->GetType() != newtype)
if (!(Value = AllocateValue(g, Value, newtype)))
longjmp(g->jumper[g->jump_level], TYPE_CONST);
} // end of Convert
/***********************************************************************/
/* Compare: returns true if this object is equivalent to xp. */
/***********************************************************************/
bool CONSTANT::Compare(PXOB xp)
{
if (this == xp)
return true;
else if (xp->GetType() != TYPE_CONST)
return false;
else
return Value->IsEqual(xp->GetValue(), true);
} // end of Compare
/***********************************************************************/
/* Rephrase: temporary implementation used by PlugRephraseSQL. */
/***********************************************************************/
bool CONSTANT::Rephrase(PGLOBAL g, PSZ work)
{
switch (Value->GetType()) {
case TYPE_STRING:
sprintf(work + strlen(work), "'%s'", Value->GetCharValue());
break;
case TYPE_SHORT:
sprintf(work + strlen(work), "%hd", Value->GetShortValue());
break;
case TYPE_INT:
case TYPE_DATE:
sprintf(work + strlen(work), "%d", Value->GetIntValue());
break;
case TYPE_FLOAT:
sprintf(work + strlen(work), "%lf", Value->GetFloatValue());
break;
default:
sprintf(g->Message, MSG(BAD_CONST_TYPE), Value->GetType());
return false;
} // endswitch
return false;
} // end of Rephrase
/***********************************************************************/
/* Make file output of a constant object. */
/***********************************************************************/
void CONSTANT::Print(PGLOBAL g, FILE *f, uint n)
{
Value->Print(g, f, n);
} /* end of Print */
/***********************************************************************/
/* Make string output of a constant object. */
/***********************************************************************/
void CONSTANT::Print(PGLOBAL g, char *ps, uint z)
{
Value->Print(g, ps, z);
} /* end of Print */
/************ Xobject C++ Functions Source Code File (.CPP) ************/
/* Name: XOBJECT.CPP Version 2.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
/* */
/* This file contains base XOBJECT class functions. */
/* Also here is the implementation of the CONSTANT class. */
/***********************************************************************/
/***********************************************************************/
/* Include mariaDB header file. */
/***********************************************************************/
#include "my_global.h"
/***********************************************************************/
/* Include required application header files */
/* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "xobject.h"
/***********************************************************************/
/* Macro definitions. */
/***********************************************************************/
#if defined(_DEBUG) || defined(DEBTRACE)
#define ASSERT(B) assert(B);
#else
#define ASSERT(B)
#endif
/***********************************************************************/
/* The one and only needed void object. */
/***********************************************************************/
XVOID Xvoid;
PXOB const pXVOID = &Xvoid; // Pointer used by other classes
/* ------------------------- Class XOBJECT --------------------------- */
/***********************************************************************/
/* GetCharValue: returns the Result value as a char string. */
/* Using GetCharValue provides no conversion from numeric types. */
/***********************************************************************/
PSZ XOBJECT::GetCharValue(void)
{
ASSERT(Value)
return Value->GetCharValue();
} // end of GetCharValue()
/***********************************************************************/
/* GetShortValue: returns the Result value as a short integer. */
/***********************************************************************/
short XOBJECT::GetShortValue(void)
{
ASSERT(Value)
return Value->GetShortValue();
} // end of GetShortValue
/***********************************************************************/
/* GetIntValue: returns the Result value as a int integer. */
/***********************************************************************/
int XOBJECT::GetIntValue(void)
{
ASSERT(Value)
return Value->GetIntValue();
} // end of GetIntValue
/***********************************************************************/
/* GetFloatValue: returns the Result value as a double float. */
/***********************************************************************/
double XOBJECT::GetFloatValue(void)
{
ASSERT(Value)
return Value->GetFloatValue();
} // end of GetFloatValue
/* ------------------------- Class CONSTANT -------------------------- */
/***********************************************************************/
/* CONSTANT public constructor. */
/***********************************************************************/
CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
{
if (!(Value = AllocateValue(g, value, (int)type)))
longjmp(g->jumper[g->jump_level], TYPE_CONST);
Constant = true;
} // end of CONSTANT constructor
/***********************************************************************/
/* CONSTANT public constructor. */
/***********************************************************************/
CONSTANT::CONSTANT(PGLOBAL g, int n)
{
if (!(Value = AllocateValue(g, &n, TYPE_INT)))
longjmp(g->jumper[g->jump_level], TYPE_CONST);
Constant = true;
} // end of CONSTANT constructor
/***********************************************************************/
/* GetLengthEx: returns an evaluation of the constant string length. */
/* Note: When converting from token to string, length has to be */
/* specified but we need the domain length, not the value length. */
/***********************************************************************/
int CONSTANT::GetLengthEx(void)
{
return Value->GetValLen();
} // end of GetLengthEx
/***********************************************************************/
/* Convert a constant to the given type. */
/***********************************************************************/
void CONSTANT::Convert(PGLOBAL g, int newtype)
{
if (Value->GetType() != newtype)
if (!(Value = AllocateValue(g, Value, newtype)))
longjmp(g->jumper[g->jump_level], TYPE_CONST);
} // end of Convert
/***********************************************************************/
/* Compare: returns true if this object is equivalent to xp. */
/***********************************************************************/
bool CONSTANT::Compare(PXOB xp)
{
if (this == xp)
return true;
else if (xp->GetType() != TYPE_CONST)
return false;
else
return Value->IsEqual(xp->GetValue(), true);
} // end of Compare
/***********************************************************************/
/* Rephrase: temporary implementation used by PlugRephraseSQL. */
/***********************************************************************/
bool CONSTANT::Rephrase(PGLOBAL g, PSZ work)
{
switch (Value->GetType()) {
case TYPE_STRING:
sprintf(work + strlen(work), "'%s'", Value->GetCharValue());
break;
case TYPE_SHORT:
sprintf(work + strlen(work), "%hd", Value->GetShortValue());
break;
case TYPE_INT:
case TYPE_DATE:
sprintf(work + strlen(work), "%d", Value->GetIntValue());
break;
case TYPE_FLOAT:
sprintf(work + strlen(work), "%lf", Value->GetFloatValue());
break;
default:
sprintf(g->Message, MSG(BAD_CONST_TYPE), Value->GetType());
return false;
} // endswitch
return false;
} // end of Rephrase
/***********************************************************************/
/* Make file output of a constant object. */
/***********************************************************************/
void CONSTANT::Print(PGLOBAL g, FILE *f, uint n)
{
Value->Print(g, f, n);
} /* end of Print */
/***********************************************************************/
/* Make string output of a constant object. */
/***********************************************************************/
void CONSTANT::Print(PGLOBAL g, char *ps, uint z)
{
Value->Print(g, ps, z);
} /* end of Print */

Some files were not shown because too many files have changed in this diff Show More