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(UNIX)
if(WITH_WARNINGS) if(WITH_WARNINGS)
add_definitions(-Wall -Wfatal-errors -Wextra) add_definitions(-Wall -Wfatal-errors -Wextra -Wmissing-declarations)
message(STATUS "CONNECT: GCC: All warnings enabled") message(STATUS "CONNECT: GCC: All warnings enabled")
else() else()
add_definitions(--no-warnings) add_definitions(-Wall -Wfatal-errors -Wmissing-declarations)
message(STATUS "CONNECT: GCC: All warnings disabled") 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) endif(WITH_WARNINGS)
add_definitions( -DUNIX -DLINUX -DUBUNTU ) add_definitions( -DUNIX -DLINUX -DUBUNTU )

View File

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

View File

@@ -1,150 +1,127 @@
/*************** Catalog H Declares Source Code File (.H) **************/ /*************** Catalog H Declares Source Code File (.H) **************/
/* Name: CATALOG.H Version 3.2 */ /* Name: CATALOG.H Version 3.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2000-2012 */
/* */ /* */
/* This file contains the CATALOG PlugDB classes definitions. */ /* This file contains the CATALOG PlugDB classes definitions. */
/***********************************************************************/ /***********************************************************************/
#ifndef __CATALOG__H #ifndef __CATALOG__H
#define __CATALOG__H #define __CATALOG__H
#include "block.h" #include "block.h"
/***********************************************************************/ /***********************************************************************/
/* Defines the length of a buffer to contain entire table section. */ /* Defines the length of a buffer to contain entire table section. */
/***********************************************************************/ /***********************************************************************/
#define PLG_MAX_PATH 144 /* Must be the same across systems */ #define PLG_MAX_PATH 144 /* Must be the same across systems */
#define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */ #define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */
#if !defined(WIN32)
/**************************************************************************/ //typedef class INDEXDEF *PIXDEF;
/* Defines specific to Windows and ODBC. */
/**************************************************************************/ /***********************************************************************/
#define SQL_CHAR 1 /* Defines the structure used to enumerate tables or views. */
#define SQL_NUMERIC 2 /***********************************************************************/
#define SQL_DECIMAL 3 typedef struct _curtab {
#define SQL_INTEGER 4 PRELDEF CurTdb;
#define SQL_SMALLINT 5 char *Curp;
#define SQL_FLOAT 6 char *Tabpat;
#define SQL_REAL 7 bool Ispat;
#define SQL_DOUBLE 8 bool NoView;
#define SQL_TIMESTAMP 11 int Nt;
#define SQL_VARCHAR 12 char *Type[16];
#define SQL_NULLABLE_UNKNOWN 2 } CURTAB, *PCURTAB;
#define SQL_ALL_EXCEPT_LIKE 2
#define SQL_SEARCHABLE 3 /***********************************************************************/
#define SQL_ALL_TYPES 0 /* Defines the structure used to get column catalog info. */
#define SQL_TABLE_STAT 0 /***********************************************************************/
#define SQL_BEST_ROWID 1 typedef struct _colinfo {
#define SQL_PC_NOT_PSEUDO 1 char *Name;
#define SQL_PC_PSEUDO 2 int Type;
#define SQL_SCOPE_CURROW 0 int Offset;
#endif // !WIN32 int Length;
int Key;
//typedef class INDEXDEF *PIXDEF; int Prec;
int Opt;
/***********************************************************************/ char *Remark;
/* Defines the structure used to enumerate tables or views. */ char *Datefmt;
/***********************************************************************/ char *Fieldfmt;
typedef struct _curtab { ushort Flags; // Used by MariaDB CONNECT handlers
PRELDEF CurTdb; } COLINFO, *PCOLINFO;
char *Curp;
char *Tabpat; /***********************************************************************/
bool Ispat; /* CATALOG: base class for catalog classes. */
bool NoView; /***********************************************************************/
int Nt; class DllExport CATALOG {
char *Type[16]; friend class RELDEF;
} CURTAB, *PCURTAB; friend class TABDEF;
friend class DIRDEF;
/***********************************************************************/ friend class OEMDEF;
/* Defines the structure used to get column catalog info. */ public:
/***********************************************************************/ CATALOG(void); // Constructor
typedef struct _colinfo { virtual ~CATALOG() { } // Make -Wdelete-non-virtual-dtor happy
char *Name;
int Type; // Implementation
int Offset; void *GetDescp(void) {return Descp;}
int Length; PRELDEF GetTo_Desc(void) {return To_Desc;}
int Key; //PSZ GetDescFile(void) {return DescFile;}
int Prec; int GetCblen(void) {return Cblen;}
int Opt; bool GetDefHuge(void) {return DefHuge;}
char *Remark; void SetDefHuge(bool b) {DefHuge = b;}
char *Datefmt; bool GetSepIndex(void) {return SepIndex;}
char *Fieldfmt; void SetSepIndex(bool b) {SepIndex = b;}
ushort Flags; // Used by MariaDB CONNECT handlers char *GetCbuf(void) {return Cbuf;}
} COLINFO, *PCOLINFO; char *GetDataPath(void) {return (char*)DataPath;}
/***********************************************************************/ // Methods
/* CATALOG: base class for catalog classes. */ virtual void Reset(void) {}
/***********************************************************************/ virtual void SetDataPath(PGLOBAL g, const char *path) {}
class DllExport CATALOG { virtual bool GetBoolCatInfo(LPCSTR name, PSZ what, bool bdef) {return bdef;}
friend class RELDEF; virtual bool SetIntCatInfo(LPCSTR name, PSZ what, int ival) {return false;}
friend class TABDEF; virtual int GetIntCatInfo(LPCSTR name, PSZ what, int idef) {return idef;}
friend class DIRDEF; virtual int GetSizeCatInfo(LPCSTR name, PSZ what, PSZ sdef) {return 0;}
friend class OEMDEF; virtual int GetCharCatInfo(LPCSTR name, PSZ what, PSZ sdef, char *buf, int size)
public: {strncpy(buf, sdef, size); return size;}
CATALOG(void); // Constructor virtual char *GetStringCatInfo(PGLOBAL g, PSZ name, PSZ what, PSZ sdef)
{return sdef;}
// Implementation virtual int GetColCatInfo(PGLOBAL g, PTABDEF defp) {return -1;}
void *GetDescp(void) {return Descp;} virtual bool GetIndexInfo(PGLOBAL g, PTABDEF defp) {return true;}
PRELDEF GetTo_Desc(void) {return To_Desc;} virtual bool CheckName(PGLOBAL g, char *name) {return true;}
//PSZ GetDescFile(void) {return DescFile;} virtual bool ClearName(PGLOBAL g, PSZ name) {return true;}
int GetCblen(void) {return Cblen;} virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
bool GetDefHuge(void) {return DefHuge;} virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;}
void SetDefHuge(bool b) {DefHuge = b;} virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am,
bool GetSepIndex(void) {return SepIndex;} PRELDEF *prp = NULL) {return NULL;}
void SetSepIndex(bool b) {SepIndex = b;} virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;}
char *GetCbuf(void) {return Cbuf;} virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;}
char *GetDataPath(void) {return (char*)DataPath;} virtual bool TestCond(PGLOBAL g, const char *name, const char *type) {return true;}
virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;}
// Methods virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, MODE mode = MODE_READ) {return NULL;}
virtual void Reset(void) {} virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {}
virtual void SetDataPath(PGLOBAL g, const char *path) {} virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer,
virtual bool GetBoolCatInfo(LPCSTR name, PSZ what, bool bdef) {return bdef;} int maxbuf, int info[]) {}
virtual bool SetIntCatInfo(LPCSTR name, PSZ what, int ival) {return false;} virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer,
virtual int GetIntCatInfo(LPCSTR name, PSZ what, int idef) {return idef;} int maxbuf, int info[]) {}
virtual int GetSizeCatInfo(LPCSTR name, PSZ what, PSZ sdef) {return 0;} virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname,
virtual int GetCharCatInfo(LPCSTR name, PSZ what, PSZ sdef, char *buf, int size) char *buffer, int maxbuf, int info[]) {return NULL;}
{strncpy(buf, sdef, size); return size;} virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;}
virtual char *GetStringCatInfo(PGLOBAL g, PSZ name, PSZ what, PSZ sdef) virtual void ClearDB(PGLOBAL g) {}
{return sdef;}
virtual int GetColCatInfo(PGLOBAL g, PTABDEF defp) {return -1;} protected:
virtual bool GetIndexInfo(PGLOBAL g, PTABDEF defp) {return true;} virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;}
virtual bool CheckName(PGLOBAL g, char *name) {return true;} virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
virtual bool ClearName(PGLOBAL g, PSZ name) {return true;}
virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} // Members
virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;} PRELDEF To_Desc; /* To chain of relation desc. */
virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am, void *Descp; /* To DB description area */
PRELDEF *prp = NULL) {return NULL;} //AREADEF DescArea; /* Table desc. area size */
virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;} char *Cbuf; /* Buffer used for col section */
virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;} int Cblen; /* Length of suballoc. buffer */
virtual bool TestCond(PGLOBAL g, const char *name, const char *type) {return true;} CURTAB Ctb; /* Used to enumerate tables */
virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;} bool DefHuge; /* true: tables default to huge */
virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, MODE mode = MODE_READ) {return NULL;} bool SepIndex; /* true: separate index files */
virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {} //char DescFile[_MAX_PATH]; /* DB description filename */
virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer, LPCSTR DataPath; /* Is the Path of DB data dir */
int maxbuf, int info[]) {} }; // end of class CATALOG
virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer,
int maxbuf, int info[]) {} #endif // __CATALOG__H
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) **************/ /************** PlgDBSem H Declares Source Code File (.H) **************/
/* Name: CHKLVL.H Version 1.1 */ /* Name: CHKLVL.H Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2009 */ /* (C) Copyright to the author Olivier BERTRAND 2009 */
/* */ /* */
/* This file contains the definition of the checking level constants. */ /* This file contains the definition of the checking level constants. */
/***********************************************************************/ /***********************************************************************/
#if !defined(_CHKLVL_DEFINED_) #if !defined(_CHKLVL_DEFINED_)
#define _CHKLVL_DEFINED_ #define _CHKLVL_DEFINED_
/***********************************************************************/ /***********************************************************************/
/* Following definitions are used to indicate the level of checking. */ /* Following definitions are used to indicate the level of checking. */
/***********************************************************************/ /***********************************************************************/
enum CHKLVL {CHK_NO = 0x00, /* No checking */ enum CHKLVL {CHK_NO = 0x00, /* No checking */
CHK_TYPE = 0x01, /* Check types for Insert/Update */ CHK_TYPE = 0x01, /* Check types for Insert/Update */
CHK_UPDATE = 0x02, /* Two pass checking of Update */ CHK_UPDATE = 0x02, /* Two pass checking of Update */
CHK_DELETE = 0x04, /* Indexed checking of Delete */ CHK_DELETE = 0x04, /* Indexed checking of Delete */
CHK_JOIN = 0x08, /* Check types joining tables */ CHK_JOIN = 0x08, /* Check types joining tables */
CHK_OPT = 0x10, /* Automatic optimize on changes */ CHK_OPT = 0x10, /* Automatic optimize on changes */
CHK_MANY = 0x20, /* Check many-to-many joins */ CHK_MANY = 0x20, /* Check many-to-many joins */
CHK_ALL = 0x3F, /* All of the above */ CHK_ALL = 0x3F, /* All of the above */
CHK_STD = 0x1E, /* Standard level of checking */ CHK_STD = 0x1E, /* Standard level of checking */
CHK_MAXRES = 0x40, /* Prevent Maxres recalculation */ CHK_MAXRES = 0x40, /* Prevent Maxres recalculation */
CHK_ONLY = 0x100}; /* Just check, no action (NIY) */ CHK_ONLY = 0x100}; /* Just check, no action (NIY) */
/***********************************************************************/ /***********************************************************************/
/* Following definitions are used to indicate the execution mode. */ /* Following definitions are used to indicate the execution mode. */
/***********************************************************************/ /***********************************************************************/
enum XMOD {XMOD_EXECUTE = 0, /* DOS execution mode */ enum XMOD {XMOD_EXECUTE = 0, /* DOS execution mode */
XMOD_PREPARE = 1, /* Prepare mode */ XMOD_PREPARE = 1, /* Prepare mode */
XMOD_TEST = 2, /* Test mode */ XMOD_TEST = 2, /* Test mode */
XMOD_CONVERT = 3}; /* HQL conversion mode */ XMOD_CONVERT = 3}; /* HQL conversion mode */
/***********************************************************************/ /***********************************************************************/
/* Following definitions indicate the use of a temporay file. */ /* Following definitions indicate the use of a temporay file. */
/***********************************************************************/ /***********************************************************************/
enum USETEMP {TMP_AUTO = 0, /* Best choice */ enum USETEMP {TMP_AUTO = 0, /* Best choice */
TMP_NO = 1, /* Never */ TMP_NO = 1, /* Never */
TMP_YES = 2, /* Always */ TMP_YES = 2, /* Always */
TMP_FORCE = 3}; /* Forced for MAP tables */ TMP_FORCE = 3}; /* Forced for MAP tables */
#endif // _CHKLVL_DEFINED_ #endif // _CHKLVL_DEFINED_

View File

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

View File

@@ -1,180 +1,180 @@
/*************** Colblk H Declares Source Code File (.H) ***************/ /*************** Colblk H Declares Source Code File (.H) ***************/
/* Name: COLBLK.H Version 1.5 */ /* Name: COLBLK.H Version 1.5 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the COLBLK and derived classes declares. */ /* This file contains the COLBLK and derived classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __COLBLK__H #ifndef __COLBLK__H
#define __COLBLK__H #define __COLBLK__H
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/***********************************************************************/ /***********************************************************************/
#include "xobject.h" #include "xobject.h"
#include "reldef.h" #include "reldef.h"
/***********************************************************************/ /***********************************************************************/
/* Class COLBLK: Base class for table column descriptors. */ /* Class COLBLK: Base class for table column descriptors. */
/***********************************************************************/ /***********************************************************************/
class DllExport COLBLK : public XOBJECT { class DllExport COLBLK : public XOBJECT {
friend class TDBPIVOT; friend class TDBPIVOT;
protected: protected:
// Default constructors used by derived classes // Default constructors used by derived classes
COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0); COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0);
COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process
COLBLK(int n) {} // Used when changing a column class in TDBXML COLBLK(int n) {} // Used when changing a column class in TDBXML
public: public:
// Implementation // Implementation
virtual int GetType(void) {return TYPE_COLBLK;} virtual int GetType(void) {return TYPE_COLBLK;}
virtual int GetResultType(void) {return Buf_Type;} virtual int GetResultType(void) {return Buf_Type;}
virtual int GetPrecision(void) {return Format.Prec;} virtual int GetPrecision(void) {return Format.Prec;}
virtual int GetLength(void) {return Long;} virtual int GetLength(void) {return Long;}
virtual int GetLengthEx(void); virtual int GetLengthEx(void);
virtual int GetAmType() {return TYPE_AM_ERROR;} virtual int GetAmType() {return TYPE_AM_ERROR;}
virtual void SetOk(void) {Status |= BUF_EMPTY;} virtual void SetOk(void) {Status |= BUF_EMPTY;}
virtual PTDB GetTo_Tdb(void) {return To_Tdb;} virtual PTDB GetTo_Tdb(void) {return To_Tdb;}
PCOL GetNext(void) {return Next;} PCOL GetNext(void) {return Next;}
PSZ GetName(void) {return Name;} PSZ GetName(void) {return Name;}
int GetIndex(void) {return Index;} int GetIndex(void) {return Index;}
int GetOpt(void) {return Opt;} int GetOpt(void) {return Opt;}
ushort GetColUse(void) {return ColUse;} ushort GetColUse(void) {return ColUse;}
ushort GetColUse(ushort u) {return (ColUse & u);} ushort GetColUse(ushort u) {return (ColUse & u);}
ushort GetStatus(void) {return Status;} ushort GetStatus(void) {return Status;}
ushort GetStatus(ushort u) {return (Status & u);} ushort GetStatus(ushort u) {return (Status & u);}
void SetColUse(ushort u) {ColUse = u;} void SetColUse(ushort u) {ColUse = u;}
void SetStatus(ushort u) {Status = u;} void SetStatus(ushort u) {Status = u;}
void AddColUse(ushort u) {ColUse |= u;} void AddColUse(ushort u) {ColUse |= u;}
void AddStatus(ushort u) {Status |= u;} void AddStatus(ushort u) {Status |= u;}
void SetNext(PCOL cp) {Next = cp;} void SetNext(PCOL cp) {Next = cp;}
void SetKcol(PXCOL kcp) {To_Kcol = kcp;} void SetKcol(PXCOL kcp) {To_Kcol = kcp;}
PCOLDEF GetCdp(void) {return Cdp;} PCOLDEF GetCdp(void) {return Cdp;}
PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;} PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;}
PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;} PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;}
PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;} PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual bool Compare(PXOB xp); virtual bool Compare(PXOB xp);
virtual bool SetFormat(PGLOBAL, FORMAT&); virtual bool SetFormat(PGLOBAL, FORMAT&);
virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag); virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag);
virtual bool IsSpecial(void) {return false;} virtual bool IsSpecial(void) {return false;}
virtual int CheckSpcCol(PTDB tdbp, int n) {return 2;} virtual int CheckSpcCol(PTDB tdbp, int n) {return 2;}
virtual bool CheckSort(PTDB tdbp); virtual bool CheckSort(PTDB tdbp);
virtual void MarkCol(ushort bits); virtual void MarkCol(ushort bits);
virtual bool Eval(PGLOBAL g); virtual bool Eval(PGLOBAL g);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetTo_Val(PVAL valp) {} virtual void SetTo_Val(PVAL valp) {}
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint); virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint); virtual void Print(PGLOBAL g, char *, uint);
virtual bool VarSize(void) {return false;} virtual bool VarSize(void) {return false;}
virtual bool IsColInside(PCOL colp) {return this == colp;} virtual bool IsColInside(PCOL colp) {return this == colp;}
bool InitValue(PGLOBAL g); bool InitValue(PGLOBAL g);
protected: protected:
// Members // Members
PCOL Next; // Next column in table PCOL Next; // Next column in table
PSZ Name; // Column name PSZ Name; // Column name
PCOLDEF Cdp; // To column definition block PCOLDEF Cdp; // To column definition block
PTDB To_Tdb; // Points to Table Descriptor Block PTDB To_Tdb; // Points to Table Descriptor Block
PXCOL To_Kcol; // Points to Xindex matching column PXCOL To_Kcol; // Points to Xindex matching column
int Index; // Column number in table int Index; // Column number in table
int Opt; // Cluster/sort information int Opt; // Cluster/sort information
int Buf_Type; // Data type int Buf_Type; // Data type
int Long; // Internal length in table int Long; // Internal length in table
FORMAT Format; // Output format FORMAT Format; // Output format
ushort ColUse; // Column usage ushort ColUse; // Column usage
ushort Status; // Column read status ushort Status; // Column read status
}; // end of class COLBLK }; // end of class COLBLK
/***********************************************************************/ /***********************************************************************/
/* Class SPCBLK: Base class for special column descriptors. */ /* Class SPCBLK: Base class for special column descriptors. */
/***********************************************************************/ /***********************************************************************/
class SPCBLK : public COLBLK { class SPCBLK : public COLBLK {
public: public:
// Constructor // Constructor
SPCBLK(PCOLUMN cp); SPCBLK(PCOLUMN cp);
// Implementation // Implementation
virtual int GetAmType(void) = 0; virtual int GetAmType(void) = 0;
virtual bool GetRnm(void) {return false;} virtual bool GetRnm(void) {return false;}
// Methods // Methods
virtual bool IsSpecial(void) {return true;} virtual bool IsSpecial(void) {return true;}
virtual void ReadColumn(PGLOBAL g) = 0; virtual void ReadColumn(PGLOBAL g) = 0;
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
protected: protected:
// Default constructor not to be used // Default constructor not to be used
SPCBLK(void) : COLBLK(1) {} SPCBLK(void) : COLBLK(1) {}
}; // end of class SPCBLK }; // end of class SPCBLK
/***********************************************************************/ /***********************************************************************/
/* Class RIDBLK: ROWID special column descriptor. */ /* Class RIDBLK: ROWID special column descriptor. */
/***********************************************************************/ /***********************************************************************/
class RIDBLK : public SPCBLK { class RIDBLK : public SPCBLK {
public: public:
// Constructor // Constructor
RIDBLK(PCOLUMN cp, bool rnm); RIDBLK(PCOLUMN cp, bool rnm);
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_ROWID;} virtual int GetAmType(void) {return TYPE_AM_ROWID;}
virtual bool GetRnm(void) {return Rnm;} virtual bool GetRnm(void) {return Rnm;}
// Methods // Methods
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
bool Rnm; // False for RowID, True for RowNum bool Rnm; // False for RowID, True for RowNum
}; // end of class RIDBLK }; // end of class RIDBLK
/***********************************************************************/ /***********************************************************************/
/* Class FIDBLK: FILEID special column descriptor. */ /* Class FIDBLK: FILEID special column descriptor. */
/***********************************************************************/ /***********************************************************************/
class FIDBLK : public SPCBLK { class FIDBLK : public SPCBLK {
public: public:
// Constructor // Constructor
FIDBLK(PCOLUMN cp); FIDBLK(PCOLUMN cp);
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_FILID;} virtual int GetAmType(void) {return TYPE_AM_FILID;}
// Methods // Methods
virtual void Reset(void) {} // This is a pseudo constant column virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n) virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 2 && tdbp == To_Tdb) ? 1 : 2;} {return (n == 2 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
PSZ Fn; // The current To_File of the table PSZ Fn; // The current To_File of the table
}; // end of class FIDBLK }; // end of class FIDBLK
/***********************************************************************/ /***********************************************************************/
/* Class TIDBLK: TABID special column descriptor. */ /* Class TIDBLK: TABID special column descriptor. */
/***********************************************************************/ /***********************************************************************/
class TIDBLK : public SPCBLK { class TIDBLK : public SPCBLK {
public: public:
// Constructor // Constructor
TIDBLK(PCOLUMN cp); TIDBLK(PCOLUMN cp);
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_TABID;} virtual int GetAmType(void) {return TYPE_AM_TABID;}
// Methods // Methods
virtual void Reset(void) {} // This is a pseudo constant column virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n) virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 3 && tdbp == To_Tdb) ? 1 : 2;} {return (n == 3 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
// Default constructor not to be used // Default constructor not to be used
TIDBLK(void) {} TIDBLK(void) {}
// Members // Members
PSZ Tname; // The current table name PSZ Tname; // The current table name
}; // end of class TIDBLK }; // end of class TIDBLK
#endif // __COLBLK__H #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 /* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**************** Cnt H Declares Source Code File (.H) *****************/ /**************** Cnt H Declares Source Code File (.H) *****************/
/* Name: CONNECT.H Version 2.4 */ /* Name: CONNECT.H Version 2.4 */
/* This file contains the some based classes declares. */ /* This file contains the some based classes declares. */
/***********************************************************************/ /***********************************************************************/
//#include "xtable.h" // Base class declares //#include "xtable.h" // Base class declares
#include "filamtxt.h" #include "filamtxt.h"
#include "tabdos.h" #include "tabdos.h"
//typedef struct _tabdesc *PTABD; // For friend setting //typedef struct _tabdesc *PTABD; // For friend setting
typedef struct _xinfo *PXF; typedef struct _xinfo *PXF;
typedef struct _create_xinfo *PCXF; typedef struct _create_xinfo *PCXF;
typedef class TDBDOX *PTDBDOX; typedef class TDBDOX *PTDBDOX;
/***********************************************************************/ /***********************************************************************/
/* Definition of classes XCOLCRT, XIXDEF, XKPDEF, DOXDEF, TDBDOX */ /* Definition of classes XCOLCRT, XIXDEF, XKPDEF, DOXDEF, TDBDOX */
/* These classes purpose is chiefly to access protected items! */ /* These classes purpose is chiefly to access protected items! */
/***********************************************************************/ /***********************************************************************/
class XCOLCRT: public COLCRT { class XCOLCRT: public COLCRT {
friend class ha_connect; friend class ha_connect;
friend bool CntCreateTable(PGLOBAL, char *, PCXF); friend bool CntCreateTable(PGLOBAL, char *, PCXF);
public: public:
XCOLCRT(PSZ name) : COLCRT(name) {Nulls= -1;} // Constructor XCOLCRT(PSZ name) : COLCRT(name) {Nulls= -1;} // Constructor
bool HasNulls(void) {return (Nulls != 0);} bool HasNulls(void) {return (Nulls != 0);}
private: private:
int Nulls; int Nulls;
}; // end of class XCOLCRT }; // end of class XCOLCRT
class DOXDEF: public DOSDEF { class DOXDEF: public DOSDEF {
//friend class TDBDOX; //friend class TDBDOX;
//friend int MakeIndex(PGLOBAL, PTDB, PIXDEF); //friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int); friend int CntIndexInit(PGLOBAL, PTDB, int);
}; // end of class DOXDEF }; // end of class DOXDEF
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method base class declaration. */ /* This is the DOS/UNIX Access Method base class declaration. */
/***********************************************************************/ /***********************************************************************/
class TDBDOX: public TDBDOS { class TDBDOX: public TDBDOS {
friend int MakeIndex(PGLOBAL, PTDB, PIXDEF); friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntCloseTable(PGLOBAL, PTDB); friend int CntCloseTable(PGLOBAL, PTDB);
friend int CntIndexInit(PGLOBAL, PTDB, int); friend int CntIndexInit(PGLOBAL, PTDB, int);
friend RCODE CntIndexRead(PGLOBAL, PTDB, OPVAL, const void*, int); friend RCODE CntIndexRead(PGLOBAL, PTDB, OPVAL, const void*, int);
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool); friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*, friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*,
bool*, key_part_map*); bool*, key_part_map*);
friend class ha_connect; friend class ha_connect;
}; // end of class TDBDOX }; // end of class TDBDOX
class XKPDEF: public KPARTDEF { class XKPDEF: public KPARTDEF {
friend class TDBDOX; friend class TDBDOX;
friend class ha_connect; friend class ha_connect;
//friend int CntMakeIndex(PGLOBAL, const char *, PIXDEF); //friend int CntMakeIndex(PGLOBAL, const char *, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int); friend int CntIndexInit(PGLOBAL, PTDB, int);
public: public:
XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {HasNulls= false;} XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {HasNulls= false;}
void SetNulls(bool b) {HasNulls= b;} void SetNulls(bool b) {HasNulls= b;}
protected: protected:
bool HasNulls; /* Can have null values */ bool HasNulls; /* Can have null values */
}; // end of class XKPDEF }; // end of class XKPDEF
RCODE CheckRecord(PGLOBAL g, PTDB tdbp, char *oldbuf, char *newbuf); 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) ****************/ /*************** Csort H Declares Source Code File (.H) ****************/
/* Name: CSORT.H Version 1.2 */ /* Name: CSORT.H Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2000-2012 */
/* */ /* */
/* This file contains the CSORT class declares (not 64-bits ready) */ /* 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 */ /* 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 */ /* base class by the calling class. This is because the comparison */
/* routine must belong to both CSORT and the calling class. */ /* routine must belong to both CSORT and the calling class. */
/* This avoids to pass explicitly to it the calling "this" pointer. */ /* This avoids to pass explicitly to it the calling "this" pointer. */
/***********************************************************************/ /***********************************************************************/
#if !defined(CSORT_DEFINED) #if !defined(CSORT_DEFINED)
#define CSORT_DEFINED #define CSORT_DEFINED
#include <math.h> /* Required for log function */ #include <math.h> /* Required for log function */
#undef DOMAIN // Was defined in math.h #undef DOMAIN // Was defined in math.h
/***********************************************************************/ /***********************************************************************/
/* Constant and external definitions. */ /* Constant and external definitions. */
/***********************************************************************/ /***********************************************************************/
#define THRESH 4 /* Threshold for insertion (was 4) */ #define THRESH 4 /* Threshold for insertion (was 4) */
#define MTHRESH 6 /* Threshold for median */ #define MTHRESH 6 /* Threshold for median */
#ifdef DEBTRACE #ifdef DEBTRACE
extern FILE *debug; /* Debug file */ extern FILE *debug; /* Debug file */
#endif #endif
typedef int* const CPINT; typedef int* const CPINT;
/***********************************************************************/ /***********************************************************************/
/* This is the CSORT base class declaration. */ /* This is the CSORT base class declaration. */
/***********************************************************************/ /***********************************************************************/
class DllExport CSORT { class DllExport CSORT {
public: public:
// Constructor // Constructor
CSORT(bool cns, int th = THRESH, int mth = MTHRESH); CSORT(bool cns, int th = THRESH, int mth = MTHRESH);
protected: protected:
// Implementation // Implementation
/*********************************************************************/ /*********************************************************************/
/* qsortx/qstx are NOT conservative but use less storage space. */ /* qsortx/qstx are NOT conservative but use less storage space. */
/* qsortc/qstc ARE conservative but use more storage space. */ /* qsortc/qstc ARE conservative but use more storage space. */
/*********************************************************************/ /*********************************************************************/
int Qsortx(void); /* Index quick/insert sort */ int Qsortx(void); /* Index quick/insert sort */
void Qstx(int *base, int *max); /* Preliminary quick sort */ void Qstx(int *base, int *max); /* Preliminary quick sort */
int Qsortc(void); /* Conservative q/ins sort */ int Qsortc(void); /* Conservative q/ins sort */
void Qstc(int *base, int *max); /* Preliminary quick sort */ void Qstc(int *base, int *max); /* Preliminary quick sort */
void Istc(int *base, int *hi, int *max); /* Insertion sort routine */ void Istc(int *base, int *hi, int *max); /* Insertion sort routine */
public: public:
// Methods // Methods
int Qsort(PGLOBAL g, int n); /* Sort calling routine */ int Qsort(PGLOBAL g, int n); /* Sort calling routine */
//virtual void Print(PGLOBAL g, FILE *f, uint n); //virtual void Print(PGLOBAL g, FILE *f, uint n);
//virtual void Print(PGLOBAL g, char *ps, uint z); //virtual void Print(PGLOBAL g, char *ps, uint z);
#ifdef DEBTRACE #ifdef DEBTRACE
int GetNcmp(void) {return num_comp;} int GetNcmp(void) {return num_comp;}
#endif #endif
protected: protected:
// Overridable // Overridable
virtual int Qcompare(int *, int *) = 0; /* Item compare routine */ virtual int Qcompare(int *, int *) = 0; /* Item compare routine */
#ifdef DEBTRACE #ifdef DEBTRACE
virtual void DebugSort(int ph, int n, int *base, int *mid, int *tmp); virtual void DebugSort(int ph, int n, int *base, int *mid, int *tmp);
#endif #endif
public: public:
// Utility // Utility
static void SetCmpNum(void) static void SetCmpNum(void)
{for (int i = 1; i < 1000; i++) Cpn[i] = Cmpnum(i); Limit = 1000;} {for (int i = 1; i < 1000; i++) Cpn[i] = Cmpnum(i); Limit = 1000;}
protected: protected:
static size_t Cmpnum(int n) static size_t Cmpnum(int n)
#if defined(AIX) #if defined(AIX)
{return (n < Limit) ? Cpn[n] {return (n < Limit) ? Cpn[n]
: (size_t)round(1.0 + (double)n * (log2((double)n) - 1.0));} : (size_t)round(1.0 + (double)n * (log2((double)n) - 1.0));}
#else // !AIX #else // !AIX
{return (n < Limit) ? Cpn[n] {return (n < Limit) ? Cpn[n]
: (size_t)(1.5 + (double)n * (log((double)n)/Lg2 - 1.0));} : (size_t)(1.5 + (double)n * (log((double)n)/Lg2 - 1.0));}
#endif // !AIX #endif // !AIX
// Members // Members
static int Limit; /* Size of precalculated array */ static int Limit; /* Size of precalculated array */
static size_t Cpn[1000]; /* Precalculated cmpnum values */ static size_t Cpn[1000]; /* Precalculated cmpnum values */
static double Lg2; /* Precalculated log(2) value */ static double Lg2; /* Precalculated log(2) value */
PGLOBAL G; PGLOBAL G;
PDBUSER Dup; /* Used for progress info */ PDBUSER Dup; /* Used for progress info */
bool Cons; /* true for conservative sort */ bool Cons; /* true for conservative sort */
int Thresh; /* Threshold for using qsort */ int Thresh; /* Threshold for using qsort */
int Mthresh; /* Threshold for median find */ int Mthresh; /* Threshold for median find */
int Nitem; /* Number of items to sort */ int Nitem; /* Number of items to sort */
MBLOCK Index; /* Index allocation block */ MBLOCK Index; /* Index allocation block */
MBLOCK Offset; /* Offset allocation block */ MBLOCK Offset; /* Offset allocation block */
CPINT &Pex; /* Reference to sort index */ CPINT &Pex; /* Reference to sort index */
CPINT &Pof; /* Reference to offset array */ CPINT &Pof; /* Reference to offset array */
int *Swix; /* Pointer on EQ/GT work area */ int *Swix; /* Pointer on EQ/GT work area */
int Savmax; /* Saved ProgMax value */ int Savmax; /* Saved ProgMax value */
int Savcur; /* Saved ProgCur value */ int Savcur; /* Saved ProgCur value */
LPCSTR Savstep; /* Saved progress step */ LPCSTR Savstep; /* Saved progress step */
#ifdef DEBTRACE #ifdef DEBTRACE
int num_comp; /* Number of quick sort calls */ int num_comp; /* Number of quick sort calls */
#endif #endif
}; // end of class CSORT }; // end of class CSORT
#endif // CSORT_DEFINED #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 */ /* Declaration of XML document processing using MS DOM */
/* Author: Olivier Bertrand 2007 - 2012 */ /* Author: Olivier Bertrand 2007 - 2012 */
/******************************************************************/ /******************************************************************/
#include "plgxml.h" #include "plgxml.h"
typedef class DOMDOC *PDOMDOC; typedef class DOMDOC *PDOMDOC;
typedef class DOMNODE *PDOMNODE; typedef class DOMNODE *PDOMNODE;
typedef class DOMATTR *PDOMATTR; typedef class DOMATTR *PDOMATTR;
typedef class DOMNODELIST *PDOMLIST; typedef class DOMNODELIST *PDOMLIST;
/******************************************************************/ /******************************************************************/
/* XML block. Must have the same layout than FBLOCK up to Type. */ /* XML block. Must have the same layout than FBLOCK up to Type. */
/******************************************************************/ /******************************************************************/
typedef struct _xblock { /* Loaded XML file block */ typedef struct _xblock { /* Loaded XML file block */
struct _xblock *Next; struct _xblock *Next;
LPCSTR Fname; /* Point on file name */ LPCSTR Fname; /* Point on file name */
size_t Length; /* Used to tell if read mode */ size_t Length; /* Used to tell if read mode */
short Count; /* Nb of times file is used */ short Count; /* Nb of times file is used */
short Type; /* TYPE_FB_XML */ short Type; /* TYPE_FB_XML */
int Retcode; /* Return code from Load */ int Retcode; /* Return code from Load */
MSXML2::IXMLDOMDocumentPtr Docp;/* Document interface pointer */ MSXML2::IXMLDOMDocumentPtr Docp;/* Document interface pointer */
//IXMLDOMNodeListPtr Nlist; //IXMLDOMNodeListPtr Nlist;
} XBLOCK, *PXBLOCK; } XBLOCK, *PXBLOCK;
/******************************************************************/ /******************************************************************/
/* Declaration of DOM document. */ /* Declaration of DOM document. */
/******************************************************************/ /******************************************************************/
class DOMDOC : public XMLDOCUMENT { class DOMDOC : public XMLDOCUMENT {
friend class DOMNODE; friend class DOMNODE;
public: public:
// Constructor // Constructor
DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp); DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp);
// Properties // Properties
virtual short GetDocType(void) {return TYPE_FB_XML;} virtual short GetDocType(void) {return TYPE_FB_XML;}
virtual void *GetDocPtr(void) {return Docp;} virtual void *GetDocPtr(void) {return Docp;}
// Methods // Methods
virtual bool Initialize(PGLOBAL g); virtual bool Initialize(PGLOBAL g);
virtual bool ParseFile(char *fn); virtual bool ParseFile(char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver); virtual bool NewDoc(PGLOBAL g, char *ver);
virtual void AddComment(PGLOBAL g, char *com); virtual void AddComment(PGLOBAL g, char *com);
virtual PXNODE GetRoot(PGLOBAL g); virtual PXNODE GetRoot(PGLOBAL g);
virtual PXNODE NewRoot(PGLOBAL g, char *name); virtual PXNODE NewRoot(PGLOBAL g, char *name);
virtual PXNODE NewPnode(PGLOBAL g, char *name); virtual PXNODE NewPnode(PGLOBAL g, char *name);
virtual PXATTR NewPattr(PGLOBAL g); virtual PXATTR NewPattr(PGLOBAL g);
virtual PXLIST NewPlist(PGLOBAL g); virtual PXLIST NewPlist(PGLOBAL g);
virtual int DumpDoc(PGLOBAL g, char *ofn); virtual int DumpDoc(PGLOBAL g, char *ofn);
virtual void CloseDoc(PGLOBAL g, PFBLOCK xp); virtual void CloseDoc(PGLOBAL g, PFBLOCK xp);
virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn); virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn);
protected: protected:
// Members // Members
MSXML2::IXMLDOMDocumentPtr Docp; MSXML2::IXMLDOMDocumentPtr Docp;
MSXML2::IXMLDOMNodeListPtr Nlist; MSXML2::IXMLDOMNodeListPtr Nlist;
HRESULT Hr; HRESULT Hr;
}; // end of class DOMDOC }; // end of class DOMDOC
/******************************************************************/ /******************************************************************/
/* Declaration of DOM XML node. */ /* Declaration of DOM XML node. */
/******************************************************************/ /******************************************************************/
class DOMNODE : public XMLNODE { class DOMNODE : public XMLNODE {
friend class DOMDOC; friend class DOMDOC;
friend class DOMNODELIST; friend class DOMNODELIST;
public: public:
// Properties // Properties
virtual char *GetName(PGLOBAL g); virtual char *GetName(PGLOBAL g);
virtual int GetType(void) {return Nodep->nodeType;} virtual int GetType(void) {return Nodep->nodeType;}
virtual PXNODE GetNext(PGLOBAL g); virtual PXNODE GetNext(PGLOBAL g);
virtual PXNODE GetChild(PGLOBAL g); virtual PXNODE GetChild(PGLOBAL g);
// Methods // Methods
virtual char *GetText(char *buf, int len); virtual char *GetText(char *buf, int len);
virtual bool SetContent(PGLOBAL g, char *txtp, int len); virtual bool SetContent(PGLOBAL g, char *txtp, int len);
virtual PXNODE Clone(PGLOBAL g, PXNODE np); virtual PXNODE Clone(PGLOBAL g, PXNODE np);
virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp); virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp);
virtual PXLIST SelectNodes(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 PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap); virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np); virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap); virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
virtual void AddText(PGLOBAL g, char *txtp); virtual void AddText(PGLOBAL g, char *txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp); virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected: protected:
// Constructor // Constructor
DOMNODE(PXDOC dp, MSXML2::IXMLDOMNodePtr np); DOMNODE(PXDOC dp, MSXML2::IXMLDOMNodePtr np);
// Members // Members
MSXML2::IXMLDOMDocumentPtr Docp; MSXML2::IXMLDOMDocumentPtr Docp;
MSXML2::IXMLDOMNodePtr Nodep; MSXML2::IXMLDOMNodePtr Nodep;
char Name[64]; char Name[64];
WCHAR *Ws; WCHAR *Ws;
int Len; int Len;
}; // end of class DOMNODE }; // end of class DOMNODE
/******************************************************************/ /******************************************************************/
/* Declaration of DOM XML node list. */ /* Declaration of DOM XML node list. */
/******************************************************************/ /******************************************************************/
class DOMNODELIST : public XMLNODELIST { class DOMNODELIST : public XMLNODELIST {
friend class DOMDOC; friend class DOMDOC;
friend class DOMNODE; friend class DOMNODE;
public: public:
// Methods // Methods
virtual int GetLength(void) {return Listp->length;} virtual int GetLength(void) {return Listp->length;}
virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np); virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np);
protected: protected:
// Constructor // Constructor
DOMNODELIST(PXDOC dp, MSXML2::IXMLDOMNodeListPtr lp); DOMNODELIST(PXDOC dp, MSXML2::IXMLDOMNodeListPtr lp);
// Members // Members
MSXML2::IXMLDOMNodeListPtr Listp; MSXML2::IXMLDOMNodeListPtr Listp;
}; // end of class DOMNODELIST }; // end of class DOMNODELIST
/******************************************************************/ /******************************************************************/
/* Declaration of DOM XML attribute. */ /* Declaration of DOM XML attribute. */
/******************************************************************/ /******************************************************************/
class DOMATTR : public XMLATTRIBUTE { class DOMATTR : public XMLATTRIBUTE {
friend class DOMDOC; friend class DOMDOC;
friend class DOMNODE; friend class DOMNODE;
public: public:
// Properties // Properties
//virtual char *GetText(void); //virtual char *GetText(void);
// Methods // Methods
virtual bool SetText(PGLOBAL g, char *txtp, int len); virtual bool SetText(PGLOBAL g, char *txtp, int len);
protected: protected:
// Constructor // Constructor
DOMATTR(PXDOC dp, MSXML2::IXMLDOMAttributePtr ap); DOMATTR(PXDOC dp, MSXML2::IXMLDOMAttributePtr ap);
// Members // Members
MSXML2::IXMLDOMAttributePtr Atrp; MSXML2::IXMLDOMAttributePtr Atrp;
WCHAR *Ws; WCHAR *Ws;
int Len; int Len;
}; // end of class DOMATTR }; // 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) **************/ /*************** FilAMap H Declares Source Code File (.H) **************/
/* Name: FILAMAP.H Version 1.2 */ /* Name: FILAMAP.H Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the MAP file access method classes declares. */ /* This file contains the MAP file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMAP_H #ifndef __FILAMAP_H
#define __FILAMAP_H #define __FILAMAP_H
#include "block.h" #include "block.h"
#include "filamtxt.h" #include "filamtxt.h"
typedef class MAPFAM *PMAPFAM; typedef class MAPFAM *PMAPFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the variable file access method using file mapping. */ /* This is the variable file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MAPFAM : public TXTFAM { class DllExport MAPFAM : public TXTFAM {
public: public:
// Constructor // Constructor
MAPFAM(PDOSDEF tdp); MAPFAM(PDOSDEF tdp);
MAPFAM(PMAPFAM tmfp); MAPFAM(PMAPFAM tmfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MAP;} virtual AMT GetAmType(void) {return TYPE_AM_MAP;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MAPFAM(this);} {return (PTXF)new(g) MAPFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;} virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual bool DeferReading(void) {return false;} virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
char *Memory; // Pointer on file mapping view. char *Memory; // Pointer on file mapping view.
char *Mempos; // Position of next data to read char *Mempos; // Position of next data to read
char *Fpos; // Position of last read record char *Fpos; // Position of last read record
char *Tpos; // Target Position for delete move char *Tpos; // Target Position for delete move
char *Spos; // Start position for delete move char *Spos; // Start position for delete move
char *Top; // Mark end of file mapping view char *Top; // Mark end of file mapping view
}; // end of class MAPFAM }; // end of class MAPFAM
/***********************************************************************/ /***********************************************************************/
/* This is the blocked file access method using file mapping. */ /* This is the blocked file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MBKFAM : public MAPFAM { class DllExport MBKFAM : public MAPFAM {
public: public:
// Constructor // Constructor
MBKFAM(PDOSDEF tdp); MBKFAM(PDOSDEF tdp);
MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {} MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {}
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MBKFAM(this);} {return (PTXF)new(g) MBKFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s) virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);} {return TXTFAM::MaxBlkSize(g, s);}
virtual int GetRowID(void); virtual int GetRowID(void);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// No additional members // No additional members
}; // end of class MBKFAM }; // end of class MBKFAM
/***********************************************************************/ /***********************************************************************/
/* This is the fixed file access method using file mapping. */ /* This is the fixed file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MPXFAM : public MBKFAM { class DllExport MPXFAM : public MBKFAM {
public: public:
// Constructor // Constructor
MPXFAM(PDOSDEF tdp); MPXFAM(PDOSDEF tdp);
MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {} MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {}
// Implementation // Implementation
virtual int GetPos(void); virtual int GetPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MPXFAM(this);} {return (PTXF)new(g) MPXFAM(this);}
// Methods // Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s) virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);} {return TXTFAM::MaxBlkSize(g, s);}
//virtual int GetRowID(void); //virtual int GetRowID(void);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual bool DeferReading(void) {return false;} virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
protected: protected:
// No additional members // No additional members
}; // end of class MPXFAM }; // end of class MPXFAM
#endif // __FILAMAP_H #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) ****************/ /***************** FilAmDbf H Declares Source Code File (.H) ****************/
/* Name: filamdbf.h Version 1.3 */ /* Name: filamdbf.h Version 1.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the DBF file access method classes declares. */ /* This file contains the DBF file access method classes declares. */
/****************************************************************************/ /****************************************************************************/
#ifndef __FILAMDBF_H #ifndef __FILAMDBF_H
#define __FILAMDBF_H #define __FILAMDBF_H
#include "filamfix.h" #include "filamfix.h"
#include "filamap.h" #include "filamap.h"
typedef class DBFBASE *PDBF; typedef class DBFBASE *PDBF;
typedef class DBFFAM *PDBFFAM; typedef class DBFFAM *PDBFFAM;
typedef class DBMFAM *PDBMFAM; typedef class DBMFAM *PDBMFAM;
/****************************************************************************/ /****************************************************************************/
/* This is the base class for dBASE file access methods. */ /* This is the base class for dBASE file access methods. */
/****************************************************************************/ /****************************************************************************/
class DllExport DBFBASE { class DllExport DBFBASE {
public: public:
// Constructors // Constructors
DBFBASE(PDOSDEF tdp); DBFBASE(PDOSDEF tdp);
DBFBASE(PDBF txfp); DBFBASE(PDBF txfp);
// Implementation // Implementation
int ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath); int ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath);
protected: protected:
// Default constructor, not to be used // Default constructor, not to be used
DBFBASE(void) {} DBFBASE(void) {}
// Members // Members
int Records; /* records in the file */ int Records; /* records in the file */
bool Accept; /* true if bad lines are accepted */ bool Accept; /* true if bad lines are accepted */
int Nerr; /* Number of bad records */ int Nerr; /* Number of bad records */
int Maxerr; /* Maximum number of bad records */ int Maxerr; /* Maximum number of bad records */
int ReadMode; /* 1: ALL 2: DEL 0: NOT DEL */ int ReadMode; /* 1: ALL 2: DEL 0: NOT DEL */
//PSZ Defpath; /* Default data path */ //PSZ Defpath; /* Default data path */
}; // end of class DBFBASE }; // end of class DBFBASE
/****************************************************************************/ /****************************************************************************/
/* This is the DOS/UNIX Access Method class declaration for DBase files. */ /* This is the DOS/UNIX Access Method class declaration for DBase files. */
/****************************************************************************/ /****************************************************************************/
class DllExport DBFFAM : public FIXFAM, public DBFBASE { class DllExport DBFFAM : public FIXFAM, public DBFBASE {
public: public:
// Constructors // Constructors
DBFFAM(PDOSDEF tdp) : FIXFAM(tdp), DBFBASE(tdp) {} DBFFAM(PDOSDEF tdp) : FIXFAM(tdp), DBFBASE(tdp) {}
DBFFAM(PDBFFAM txfp) : FIXFAM(txfp), DBFBASE((PDBF)txfp) {} DBFFAM(PDBFFAM txfp) : FIXFAM(txfp), DBFBASE((PDBF)txfp) {}
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DBF;} virtual AMT GetAmType(void) {return TYPE_AM_DBF;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DBFFAM(this);} {return (PTXF)new(g) DBFFAM(this);}
// Methods // Methods
virtual int GetNerr(void) {return Nerr;} virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed //virtual int GetRowID(void); // Temporarily suppressed
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g); virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g); //virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
virtual bool CopyHeader(PGLOBAL g); virtual bool CopyHeader(PGLOBAL g);
//int Records; in TXTFAM //int Records; in TXTFAM
//int Headlen; in TXTFAM //int Headlen; in TXTFAM
}; // end of class DBFFAM }; // end of class DBFFAM
/****************************************************************************/ /****************************************************************************/
/* This is the DOS/UNIX Access Method class declaration for DBase files */ /* This is the DOS/UNIX Access Method class declaration for DBase files */
/* using file mapping to access the file. */ /* using file mapping to access the file. */
/****************************************************************************/ /****************************************************************************/
class DllExport DBMFAM : public MPXFAM, public DBFBASE { class DllExport DBMFAM : public MPXFAM, public DBFBASE {
public: public:
// Constructors // Constructors
DBMFAM(PDOSDEF tdp) : MPXFAM(tdp), DBFBASE(tdp) {} DBMFAM(PDOSDEF tdp) : MPXFAM(tdp), DBFBASE(tdp) {}
DBMFAM(PDBMFAM txfp) : MPXFAM(txfp), DBFBASE((PDBF)txfp) {} DBMFAM(PDBMFAM txfp) : MPXFAM(txfp), DBFBASE((PDBF)txfp) {}
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DBF;} virtual AMT GetAmType(void) {return TYPE_AM_DBF;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DBMFAM(this);} {return (PTXF)new(g) DBMFAM(this);}
virtual int GetDelRows(void); virtual int GetDelRows(void);
// Methods // Methods
virtual int GetNerr(void) {return Nerr;} virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed //virtual int GetRowID(void); // Temporarily suppressed
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g); //virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
//int Records; in TXTFAM //int Records; in TXTFAM
//int Headlen; in TXTFAM //int Headlen; in TXTFAM
}; // end of class DBFFAM }; // end of class DBFFAM
#endif // __FILAMDBF_H #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) **************/ /************** FilAMFix H Declares Source Code File (.H) **************/
/* Name: FILAMFIX.H Version 1.2 */ /* Name: FILAMFIX.H Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005 - 2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005 - 2012 */
/* */ /* */
/* This file contains the FIX file access method classes declares. */ /* This file contains the FIX file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMFIX_H #ifndef __FILAMFIX_H
#define __FILAMFIX_H #define __FILAMFIX_H
#include "filamtxt.h" #include "filamtxt.h"
typedef class FIXFAM *PFIXFAM; typedef class FIXFAM *PFIXFAM;
typedef class BGXFAM *PBGXFAM; typedef class BGXFAM *PBGXFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */ /* This is the DOS/UNIX Access Method class declaration for standard */
/* files with fixed record format (FIX, BIN) */ /* files with fixed record format (FIX, BIN) */
/***********************************************************************/ /***********************************************************************/
class DllExport FIXFAM : public BLKFAM { class DllExport FIXFAM : public BLKFAM {
public: public:
// Constructor // Constructor
FIXFAM(PDOSDEF tdp); FIXFAM(PDOSDEF tdp);
FIXFAM(PFIXFAM txfp); FIXFAM(PFIXFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FIX;} virtual AMT GetAmType(void) {return TYPE_AM_FIX;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) FIXFAM(this);} {return (PTXF)new(g) FIXFAM(this);}
// Methods // Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s) virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);} {return TXTFAM::MaxBlkSize(g, s);}
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g); virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
protected: protected:
virtual bool CopyHeader(PGLOBAL g) {return false;} virtual bool CopyHeader(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
// No additional members // No additional members
}; // end of class FIXFAM }; // end of class FIXFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* that are standard files with columns starting at fixed offset */ /* that are standard files with columns starting at fixed offset */
/* This class is for fixed formatted files of more than 2 gigabytes. */ /* This class is for fixed formatted files of more than 2 gigabytes. */
/***********************************************************************/ /***********************************************************************/
class BGXFAM : public FIXFAM { class BGXFAM : public FIXFAM {
public: public:
// Constructor // Constructor
BGXFAM(PDOSDEF tdp); BGXFAM(PDOSDEF tdp);
BGXFAM(PBGXFAM txfp); BGXFAM(PBGXFAM txfp);
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BGXFAM(this);} {return (PTXF)new(g) BGXFAM(this);}
// Methods // Methods
//virtual void Reset(void); //virtual void Reset(void);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos
, int org = FILE_BEGIN); , int org = FILE_BEGIN);
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(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 OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
// Members // Members
HANDLE Hfile; // Handle(descriptor) to big file HANDLE Hfile; // Handle(descriptor) to big file
HANDLE Tfile; // Handle(descriptor) to big temp file HANDLE Tfile; // Handle(descriptor) to big temp file
//BIGINT Xpos; // Current file position //BIGINT Xpos; // Current file position
}; // end of class BGXFAM }; // end of class BGXFAM
#endif // __FILAMFIX_H #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) **************/ /************** FilAMTxt H Declares Source Code File (.H) **************/
/* Name: FILAMTXT.H Version 1.2 */ /* Name: FILAMTXT.H Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the file access method classes declares. */ /* This file contains the file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMTXT_H #ifndef __FILAMTXT_H
#define __FILAMTXT_H #define __FILAMTXT_H
#include "block.h" #include "block.h"
typedef class TXTFAM *PTXF; typedef class TXTFAM *PTXF;
typedef class DOSFAM *PDOSFAM; typedef class DOSFAM *PDOSFAM;
typedef class BLKFAM *PBLKFAM; typedef class BLKFAM *PBLKFAM;
typedef class DOSDEF *PDOSDEF; typedef class DOSDEF *PDOSDEF;
typedef class TDBDOS *PTDBDOS; typedef class TDBDOS *PTDBDOS;
#define TYPE_AM_BLK (AMT)160 #define TYPE_AM_BLK (AMT)160
/***********************************************************************/ /***********************************************************************/
/* This is the base class for all file access method classes. */ /* This is the base class for all file access method classes. */
/***********************************************************************/ /***********************************************************************/
class DllExport TXTFAM : public BLOCK { class DllExport TXTFAM : public BLOCK {
friend class TDBDOS; friend class TDBDOS;
friend class TDBCSV; friend class TDBCSV;
friend class TDBFIX; friend class TDBFIX;
friend class TDBVCT; friend class TDBVCT;
friend class DOSCOL; friend class DOSCOL;
friend class BINCOL; friend class BINCOL;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
TXTFAM(PDOSDEF tdp); TXTFAM(PDOSDEF tdp);
TXTFAM(PTXF txfp); TXTFAM(PTXF txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) = 0; virtual AMT GetAmType(void) = 0;
virtual int GetPos(void) = 0; virtual int GetPos(void) = 0;
virtual int GetNextPos(void) = 0; virtual int GetNextPos(void) = 0;
virtual PTXF Duplicate(PGLOBAL g) = 0; virtual PTXF Duplicate(PGLOBAL g) = 0;
virtual bool GetUseTemp(void) {return false;} virtual bool GetUseTemp(void) {return false;}
virtual int GetDelRows(void) {return DelRows;} virtual int GetDelRows(void) {return DelRows;}
int GetCurBlk(void) {return CurBlk;} int GetCurBlk(void) {return CurBlk;}
void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;} void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;}
int GetBlock(void) {return Block;} int GetBlock(void) {return Block;}
void SetBlkPos(int *bkp) {BlkPos = bkp;} void SetBlkPos(int *bkp) {BlkPos = bkp;}
void SetNrec(int n) {Nrec = n;} void SetNrec(int n) {Nrec = n;}
char *GetBuf(void) {return To_Buf;} char *GetBuf(void) {return To_Buf;}
int GetRows(void) {return Rows;} int GetRows(void) {return Rows;}
bool IsBlocked(void) {return Blocked;} bool IsBlocked(void) {return Blocked;}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g) {return false;} virtual bool AllocateBuffer(PGLOBAL g) {return false;}
virtual void ResetBuffer(PGLOBAL g) {} virtual void ResetBuffer(PGLOBAL g) {}
virtual int GetNerr(void) {return 0;} virtual int GetNerr(void) {return 0;}
virtual int GetRowID(void) = 0; virtual int GetRowID(void) = 0;
virtual bool RecordPos(PGLOBAL g) = 0; virtual bool RecordPos(PGLOBAL g) = 0;
virtual bool SetPos(PGLOBAL g, int recpos) = 0; virtual bool SetPos(PGLOBAL g, int recpos) = 0;
virtual int SkipRecord(PGLOBAL g, bool header) = 0; virtual int SkipRecord(PGLOBAL g, bool header) = 0;
virtual bool OpenTableFile(PGLOBAL g) = 0; virtual bool OpenTableFile(PGLOBAL g) = 0;
virtual bool DeferReading(void) {IsRead = false; return true;} virtual bool DeferReading(void) {IsRead = false; return true;}
virtual int ReadBuffer(PGLOBAL g) = 0; virtual int ReadBuffer(PGLOBAL g) = 0;
virtual int WriteBuffer(PGLOBAL g) = 0; virtual int WriteBuffer(PGLOBAL g) = 0;
virtual int DeleteRecords(PGLOBAL g, int irc) = 0; virtual int DeleteRecords(PGLOBAL g, int irc) = 0;
virtual void CloseTableFile(PGLOBAL g) = 0; virtual void CloseTableFile(PGLOBAL g) = 0;
virtual void Rewind(void) = 0; virtual void Rewind(void) = 0;
protected: protected:
// Members // Members
PTDBDOS Tdbp; // To table class PTDBDOS Tdbp; // To table class
PSZ To_File; // Points to table file name PSZ To_File; // Points to table file name
PFBLOCK To_Fb; // Pointer to file block PFBLOCK To_Fb; // Pointer to file block
bool Placed; // true if Recpos was externally set bool Placed; // true if Recpos was externally set
bool IsRead; // false for deferred reading bool IsRead; // false for deferred reading
bool Blocked; // true if using blocked I/O bool Blocked; // true if using blocked I/O
char *To_Buf; // Points to I/O buffer char *To_Buf; // Points to I/O buffer
void *DelBuf; // Buffer used to move lines in Delete void *DelBuf; // Buffer used to move lines in Delete
int *BlkPos; // To array of block positions int *BlkPos; // To array of block positions
int BlkLen; // Current block length int BlkLen; // Current block length
int Buflen; // Buffer length int Buflen; // Buffer length
int Dbflen; // Delete buffer length int Dbflen; // Delete buffer length
int Rows; // Number of rows read so far int Rows; // Number of rows read so far
int DelRows; // Number of deleted rows int DelRows; // Number of deleted rows
int Headlen; // Number of bytes in header int Headlen; // Number of bytes in header
int Lrecl; // Logical Record Length int Lrecl; // Logical Record Length
int Block; // Number of blocks in table int Block; // Number of blocks in table
int Last; // Number of elements of last block int Last; // Number of elements of last block
int Nrec; // Number of records in buffer int Nrec; // Number of records in buffer
int OldBlk; // Index of last read block int OldBlk; // Index of last read block
int CurBlk; // Index of current block int CurBlk; // Index of current block
int CurNum; // Current buffer line number int CurNum; // Current buffer line number
int ReadBlks; // Number of blocks read (selected) int ReadBlks; // Number of blocks read (selected)
int Rbuf; // Number of lines read in buffer int Rbuf; // Number of lines read in buffer
int Modif; // Number of modified lines in block int Modif; // Number of modified lines in block
int Blksize; // Size of padded blocks int Blksize; // Size of padded blocks
int Ending; // Length of line end int Ending; // Length of line end
bool Padded; // true if fixed size blocks are padded bool Padded; // true if fixed size blocks are padded
bool Eof; // true if an EOF (0xA) character exists bool Eof; // true if an EOF (0xA) character exists
char *CrLf; // End of line character(s) char *CrLf; // End of line character(s)
}; // end of class TXTFAM }; // end of class TXTFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */ /* This is the DOS/UNIX Access Method class declaration for standard */
/* text files with variable record format (DOS, CSV, FMT) */ /* text files with variable record format (DOS, CSV, FMT) */
/***********************************************************************/ /***********************************************************************/
class DllExport DOSFAM : public TXTFAM { class DllExport DOSFAM : public TXTFAM {
public: public:
// Constructor // Constructor
DOSFAM(PDOSDEF tdp); DOSFAM(PDOSDEF tdp);
DOSFAM(PDOSFAM txfp); DOSFAM(PDOSFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DOS;} virtual AMT GetAmType(void) {return TYPE_AM_DOS;}
virtual bool GetUseTemp(void) {return UseTemp;} virtual bool GetUseTemp(void) {return UseTemp;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DOSFAM(this);} {return (PTXF)new(g) DOSFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
virtual int RenameTempFile(PGLOBAL g); virtual int RenameTempFile(PGLOBAL g);
// Members // Members
FILE *Stream; // Points to Dos file structure FILE *Stream; // Points to Dos file structure
FILE *T_Stream; // Points to temporary file structure FILE *T_Stream; // Points to temporary file structure
PFBLOCK To_Fbt; // Pointer to temp file block PFBLOCK To_Fbt; // Pointer to temp file block
int Fpos; // Position of last read record int Fpos; // Position of last read record
int Tpos; // Target Position for delete move int Tpos; // Target Position for delete move
int Spos; // Start position for delete move int Spos; // Start position for delete move
bool UseTemp; // True to use a temporary file in Delete bool UseTemp; // True to use a temporary file in Delete
bool Bin; // True to force binary mode bool Bin; // True to force binary mode
}; // end of class DOSFAM }; // end of class DOSFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */ /* This is the DOS/UNIX Access Method class declaration for standard */
/* text files with variable record format (DOS, CSV, FMT) */ /* text files with variable record format (DOS, CSV, FMT) */
/***********************************************************************/ /***********************************************************************/
class DllExport BLKFAM : public DOSFAM { class DllExport BLKFAM : public DOSFAM {
public: public:
// Constructor // Constructor
BLKFAM(PDOSDEF tdp); BLKFAM(PDOSDEF tdp);
BLKFAM(PBLKFAM txfp); BLKFAM(PBLKFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_BLK;} virtual AMT GetAmType(void) {return TYPE_AM_BLK;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BLKFAM(this);} {return (PTXF)new(g) BLKFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
char *CurLine; // Position of current line in buffer char *CurLine; // Position of current line in buffer
char *NxtLine; // Position of Next line in buffer char *NxtLine; // Position of Next line in buffer
char *OutBuf; // Buffer to write in temporary file char *OutBuf; // Buffer to write in temporary file
bool Closing; // True when closing on Update bool Closing; // True when closing on Update
}; // end of class BLKFAM }; // end of class BLKFAM
#endif // __FILAMTXT_H #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) **************/ /************** FilAMVct H Declares Source Code File (.H) **************/
/* Name: FILAMVCT.H Version 1.5 */ /* Name: FILAMVCT.H Version 1.5 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the VCT file access method classes declares. */ /* This file contains the VCT file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMVCT__ #ifndef __FILAMVCT__
#define __FILAMVCT__ #define __FILAMVCT__
#include "filamfix.h" #include "filamfix.h"
typedef class VCTFAM *PVCTFAM; typedef class VCTFAM *PVCTFAM;
typedef class VCTCOL *PVCTCOL; typedef class VCTCOL *PVCTCOL;
typedef class VCMFAM *PVCMFAM; typedef class VCMFAM *PVCMFAM;
typedef class VECFAM *PVECFAM; typedef class VECFAM *PVECFAM;
typedef class VMPFAM *PVMPFAM; typedef class VMPFAM *PVMPFAM;
typedef class BGVFAM *PBGVFAM; typedef class BGVFAM *PBGVFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in vector format. If MaxBlk=0, each block containing "Elements" */ /* in vector format. If MaxBlk=0, each block containing "Elements" */
/* records, values of each columns are consecutively stored (vector). */ /* records, values of each columns are consecutively stored (vector). */
/* Otherwise, data is arranged by column in the file and MaxBlk is */ /* Otherwise, data is arranged by column in the file and MaxBlk is */
/* used to set the maximum number of blocks. This leave some white */ /* used to set the maximum number of blocks. This leave some white */
/* space allowing to insert new values up to this maximum size. */ /* space allowing to insert new values up to this maximum size. */
/***********************************************************************/ /***********************************************************************/
class DllExport VCTFAM : public FIXFAM { class DllExport VCTFAM : public FIXFAM {
friend class TDBVCT; friend class TDBVCT;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
VCTFAM(PVCTDEF tdp); VCTFAM(PVCTDEF tdp);
VCTFAM(PVCTFAM txfp); VCTFAM(PVCTFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VCT;} virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VCTFAM(this);} {return (PTXF)new(g) VCTFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g); virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g) {} virtual void ResetBuffer(PGLOBAL g) {}
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
// Specific functions // Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected: protected:
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g) {return false;} virtual bool MoveLines(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g); virtual bool CleanUnusedSpace(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g); virtual int GetBlockInfo(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g); virtual bool SetBlockInfo(PGLOBAL g);
bool ResetTableSize(PGLOBAL g, int block, int last); bool ResetTableSize(PGLOBAL g, int block, int last);
// Members // Members
char *NewBlock; // To block written on Insert char *NewBlock; // To block written on Insert
char *Colfn; // Pattern for column file names (VER) char *Colfn; // Pattern for column file names (VER)
char *Tempat; // Pattern for temp file names (VER) char *Tempat; // Pattern for temp file names (VER)
int *Clens; // Pointer to col size array int *Clens; // Pointer to col size array
int *Deplac; // Pointer to col start position array int *Deplac; // Pointer to col start position array
bool *Isnum; // Pointer to buffer type isnum result bool *Isnum; // Pointer to buffer type isnum result
bool AddBlock; // True when adding new blocks on Insert bool AddBlock; // True when adding new blocks on Insert
bool Split; // true: split column file vector format bool Split; // true: split column file vector format
int Header; // 0: no, 1: separate, 2: in data file int Header; // 0: no, 1: separate, 2: in data file
int MaxBlk; // Max number of blocks (True vector format) int MaxBlk; // Max number of blocks (True vector format)
int Bsize; // Because Nrec can be modified int Bsize; // Because Nrec can be modified
int Ncol; // The number of columns; int Ncol; // The number of columns;
}; // end of class VCTFAM }; // end of class VCTFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in vector format accessed using file mapping. */ /* in vector format accessed using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport VCMFAM : public VCTFAM { class DllExport VCMFAM : public VCTFAM {
friend class TDBVCT; friend class TDBVCT;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
VCMFAM(PVCTDEF tdp); VCMFAM(PVCTDEF tdp);
VCMFAM(PVCMFAM txfp); VCMFAM(PVCMFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VMP;} virtual AMT GetAmType(void) {return TYPE_AM_VMP;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VCMFAM(this);} {return (PTXF)new(g) VCMFAM(this);}
// Methods // Methods
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g); virtual bool InitInsert(PGLOBAL g);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
// Specific functions // Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
// Members // Members
char* Memory; // Pointer on file mapping view. char* Memory; // Pointer on file mapping view.
char* *Memcol; // Pointer on column start. char* *Memcol; // Pointer on column start.
}; // end of class VCMFAM }; // end of class VCMFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in full vertical format. Each column is contained in a separate */ /* in full vertical format. Each column is contained in a separate */
/* file whose name is the table name followed by the column number. */ /* file whose name is the table name followed by the column number. */
/***********************************************************************/ /***********************************************************************/
class DllExport VECFAM : public VCTFAM { class DllExport VECFAM : public VCTFAM {
friend class TDBVCT; friend class TDBVCT;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
VECFAM(PVCTDEF tdp); VECFAM(PVCTDEF tdp);
VECFAM(PVECFAM txfp); VECFAM(PVECFAM txfp);
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VECFAM(this);} {return (PTXF)new(g) VECFAM(this);}
// Methods // Methods
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g); virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g); virtual void ResetBuffer(PGLOBAL g);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
// Specific functions // Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected: protected:
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g); virtual bool MoveLines(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual int RenameTempFile(PGLOBAL g); virtual int RenameTempFile(PGLOBAL g);
bool OpenColumnFile(PGLOBAL g, char *opmode, int i); bool OpenColumnFile(PGLOBAL g, char *opmode, int i);
// Members // Members
FILE* *Streams; // Points to Dos file structure array FILE* *Streams; // Points to Dos file structure array
FILE* *T_Streams; // Points to temp file structure array FILE* *T_Streams; // Points to temp file structure array
PFBLOCK *To_Fbs; // Pointer to file block array PFBLOCK *To_Fbs; // Pointer to file block array
PFBLOCK *T_Fbs; // Pointer to temp file block array PFBLOCK *T_Fbs; // Pointer to temp file block array
void* *To_Bufs; // Pointer to col val block array void* *To_Bufs; // Pointer to col val block array
bool InitUpdate; // Used to initialize updating bool InitUpdate; // Used to initialize updating
}; // end of class VECFAM }; // end of class VECFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in full vertical format accessed using file mapping. */ /* in full vertical format accessed using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport VMPFAM : public VCMFAM { class DllExport VMPFAM : public VCMFAM {
friend class TDBVCT; friend class TDBVCT;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
VMPFAM(PVCTDEF tdp); VMPFAM(PVCTDEF tdp);
VMPFAM(PVMPFAM txfp); VMPFAM(PVMPFAM txfp);
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VMPFAM(this);} {return (PTXF)new(g) VMPFAM(this);}
// Methods // Methods
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
protected: protected:
bool MapColumnFile(PGLOBAL g, MODE mode, int i); bool MapColumnFile(PGLOBAL g, MODE mode, int i);
// Members // Members
PFBLOCK *To_Fbs; // Pointer to file block array PFBLOCK *To_Fbs; // Pointer to file block array
}; // end of class VMPFAM }; // end of class VMPFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in (possibly blocked) vector format that can be larger than 2GB. */ /* in (possibly blocked) vector format that can be larger than 2GB. */
/***********************************************************************/ /***********************************************************************/
class BGVFAM : public VCTFAM { class BGVFAM : public VCTFAM {
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructors // Constructors
BGVFAM(PVCTDEF tdp); BGVFAM(PVCTDEF tdp);
BGVFAM(PBGVFAM txfp); BGVFAM(PBGVFAM txfp);
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BGVFAM(this);} {return (PTXF)new(g) BGVFAM(this);}
// Methods // Methods
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
// Specific functions // Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected: protected:
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false); bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false);
bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(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 MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g); virtual bool CleanUnusedSpace(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g); virtual bool SetBlockInfo(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g); virtual int GetBlockInfo(PGLOBAL g);
// Members // Members
HANDLE Hfile; // Handle to big file HANDLE Hfile; // Handle to big file
HANDLE Tfile; // Handle to temporary file HANDLE Tfile; // Handle to temporary file
BIGINT *BigDep; // Pointer to col start position array BIGINT *BigDep; // Pointer to col start position array
}; // end of class BGVFAM }; // end of class BGVFAM
#endif // __FILAMVCT__ #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) **************/ /************** FilAmZip H Declares Source Code File (.H) **************/
/* Name: FILAMZIP.H Version 1.1 */ /* Name: FILAMZIP.H Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the GZIP access method classes declares. */ /* This file contains the GZIP access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMZIP_H #ifndef __FILAMZIP_H
#define __FILAMZIP_H #define __FILAMZIP_H
#include "zlib.h" #include "zlib.h"
#define TYPE_AM_ZIP (AMT)150 #define TYPE_AM_ZIP (AMT)150
#define TYPE_AM_ZLIB (AMT)155 #define TYPE_AM_ZLIB (AMT)155
typedef class ZIPFAM *PZIPFAM; typedef class ZIPFAM *PZIPFAM;
typedef class ZBKFAM *PZBKFAM; typedef class ZBKFAM *PZBKFAM;
typedef class ZIXFAM *PZIXFAM; typedef class ZIXFAM *PZIXFAM;
typedef class ZLBFAM *PZLBFAM; typedef class ZLBFAM *PZLBFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the access method class declaration for not optimized */ /* This is the access method class declaration for not optimized */
/* variable record length files compressed using the gzip library */ /* variable record length files compressed using the gzip library */
/* functions. File is accessed record by record (row). */ /* functions. File is accessed record by record (row). */
/***********************************************************************/ /***********************************************************************/
class DllExport ZIPFAM : public TXTFAM { class DllExport ZIPFAM : public TXTFAM {
// friend class DOSCOL; // friend class DOSCOL;
public: public:
// Constructor // Constructor
ZIPFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;} ZIPFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;}
ZIPFAM(PZIPFAM txfp); ZIPFAM(PZIPFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;} virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIPFAM(this);} {return (PTXF)new(g) ZIPFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;} virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
int Zerror(PGLOBAL g); // GZ error function int Zerror(PGLOBAL g); // GZ error function
// Members // Members
gzFile Zfile; // Points to GZ file structure gzFile Zfile; // Points to GZ file structure
z_off_t Zpos; // Uncompressed file position z_off_t Zpos; // Uncompressed file position
}; // end of class ZIPFAM }; // end of class ZIPFAM
/***********************************************************************/ /***********************************************************************/
/* This is the access method class declaration for optimized variable */ /* This is the access method class declaration for optimized variable */
/* record length files compressed using the gzip library functions. */ /* record length files compressed using the gzip library functions. */
/* The File is accessed by block (requires an opt file). */ /* The File is accessed by block (requires an opt file). */
/***********************************************************************/ /***********************************************************************/
class DllExport ZBKFAM : public ZIPFAM { class DllExport ZBKFAM : public ZIPFAM {
public: public:
// Constructor // Constructor
ZBKFAM(PDOSDEF tdp); ZBKFAM(PDOSDEF tdp);
ZBKFAM(PZBKFAM txfp); ZBKFAM(PZBKFAM txfp);
// Implementation // Implementation
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void) {return 0;} virtual int GetNextPos(void) {return 0;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZBKFAM(this);} {return (PTXF)new(g) ZBKFAM(this);}
// Methods // Methods
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
char *CurLine; // Position of current line in buffer char *CurLine; // Position of current line in buffer
char *NxtLine; // Position of Next line in buffer char *NxtLine; // Position of Next line in buffer
bool Closing; // True when closing on Insert bool Closing; // True when closing on Insert
}; // end of class ZBKFAM }; // end of class ZBKFAM
/***********************************************************************/ /***********************************************************************/
/* This is the access method class declaration for fixed record */ /* This is the access method class declaration for fixed record */
/* length files compressed using the gzip library functions. */ /* length files compressed using the gzip library functions. */
/* The file is always accessed by block. */ /* The file is always accessed by block. */
/***********************************************************************/ /***********************************************************************/
class DllExport ZIXFAM : public ZBKFAM { class DllExport ZIXFAM : public ZBKFAM {
public: public:
// Constructor // Constructor
ZIXFAM(PDOSDEF tdp); ZIXFAM(PDOSDEF tdp);
ZIXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {} ZIXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {}
// Implementation // Implementation
virtual int GetNextPos(void) {return 0;} virtual int GetNextPos(void) {return 0;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIXFAM(this);} {return (PTXF)new(g) ZIXFAM(this);}
// Methods // Methods
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
protected: protected:
// No additional Members // No additional Members
}; // end of class ZIXFAM }; // end of class ZIXFAM
#ifdef NOT_USED #ifdef NOT_USED
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for PlugDB */ /* This is the DOS/UNIX Access Method class declaration for PlugDB */
/* fixed/variable files compressed using the zlib library functions. */ /* fixed/variable files compressed using the zlib library functions. */
/* Physically these are written and read using the same technique */ /* Physically these are written and read using the same technique */
/* than blocked variable files, only the contain of each block is */ /* than blocked variable files, only the contain of each block is */
/* compressed using the deflate zlib function. The purpose of this */ /* compressed using the deflate zlib function. The purpose of this */
/* specific format is to have a fast mechanism for direct access of */ /* specific format is to have a fast mechanism for direct access of */
/* records so blocked optimization is fast and direct access (joins) */ /* records so blocked optimization is fast and direct access (joins) */
/* is allowed. Note that the block length is written ahead of each */ /* is allowed. Note that the block length is written ahead of each */
/* block to enable reading when optimization file is not available. */ /* block to enable reading when optimization file is not available. */
/***********************************************************************/ /***********************************************************************/
class DllExport ZLBFAM : public BLKFAM { class DllExport ZLBFAM : public BLKFAM {
public: public:
// Constructor // Constructor
ZLBFAM(PDOSDEF tdp); ZLBFAM(PDOSDEF tdp);
ZLBFAM(PZLBFAM txfp); ZLBFAM(PZLBFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZLIB;} virtual AMT GetAmType(void) {return TYPE_AM_ZLIB;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZLBFAM(this);} {return (PTXF)new(g) ZLBFAM(this);}
inline void SetOptimized(bool b) {Optimized = b;} inline void SetOptimized(bool b) {Optimized = b;}
// Methods // Methods
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
bool WriteCompressedBuffer(PGLOBAL g); bool WriteCompressedBuffer(PGLOBAL g);
int ReadCompressedBuffer(PGLOBAL g, void *rdbuf); int ReadCompressedBuffer(PGLOBAL g, void *rdbuf);
// Members // Members
z_streamp Zstream; // Compression/decompression stream z_streamp Zstream; // Compression/decompression stream
Byte *Zbuffer; // Compressed block buffer Byte *Zbuffer; // Compressed block buffer
int *Zlenp; // Pointer to block length int *Zlenp; // Pointer to block length
bool Optimized; // true when opt file is available bool Optimized; // true when opt file is available
}; // end of class ZLBFAM }; // end of class ZLBFAM
#endif // NOT_USED #endif // NOT_USED
#endif // __FILAMZIP_H #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. */ /* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright Olivier Bertrand 1993-2012 */ /* (C) Copyright Olivier Bertrand 1993-2012 */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* Included C-definition files common to all Plug routines */ /* Included C-definition files common to all Plug routines */
/***********************************************************************/ /***********************************************************************/
#include <string.h> /* String manipulation declares */ #include <string.h> /* String manipulation declares */
#include <stdlib.h> /* C standard library */ #include <stdlib.h> /* C standard library */
#include <ctype.h> /* C language specific types */ #include <ctype.h> /* C language specific types */
#include <stdio.h> /* FOPEN_MAX declaration */ #include <stdio.h> /* FOPEN_MAX declaration */
#include <time.h> /* time_t type declaration */ #include <time.h> /* time_t type declaration */
#include <setjmp.h> /* Long jump declarations */ #include <setjmp.h> /* Long jump declarations */
#if defined(WIN32) && !defined(NOEX) #if defined(WIN32) && !defined(NOEX)
#define DllExport __declspec( dllexport ) #define DllExport __declspec( dllexport )
#else // !WIN32 #else // !WIN32
#define DllExport #define DllExport
#endif // !WIN32 #endif // !WIN32
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT) #if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT)
#define XML_SUPPORT 1 #define XML_SUPPORT 1
#endif #endif
#if defined(XMSG) #if defined(XMSG)
// Definition used to read messages from message file. // Definition used to read messages from message file.
#include "msgid.h" #include "msgid.h"
#define MSG(I) PlugReadMessage(NULL, MSG_##I, #I) #define MSG(I) PlugReadMessage(NULL, MSG_##I, #I)
#define STEP(I) PlugReadMessage(g, MSG_##I, #I) #define STEP(I) PlugReadMessage(g, MSG_##I, #I)
#elif defined(NEWMSG) #elif defined(NEWMSG)
// Definition used to get messages from resource. // Definition used to get messages from resource.
#include "msgid.h" #include "msgid.h"
#define MSG(I) PlugGetMessage(NULL, MSG_##I) #define MSG(I) PlugGetMessage(NULL, MSG_##I)
#define STEP(I) PlugGetMessage(g, MSG_##I) #define STEP(I) PlugGetMessage(g, MSG_##I)
#else // !XMSG and !NEWMSG #else // !XMSG and !NEWMSG
// Definition used to replace messages ID's by their definition. // Definition used to replace messages ID's by their definition.
#include "messages.h" #include "messages.h"
#define MSG(I) MSG_##I #define MSG(I) MSG_##I
#define STEP(I) MSG_##I #define STEP(I) MSG_##I
#endif // !XMSG and !NEWMSG #endif // !XMSG and !NEWMSG
#if defined(WIN32) #if defined(WIN32)
#define CRLF 2 #define CRLF 2
#else // !WIN32 #else // !WIN32
#define CRLF 1 #define CRLF 1
#define BOOL my_bool #endif // !WIN32
#endif // !WIN32
/***********************************************************************/
/***********************************************************************/ /* Miscellaneous Constants */
/* Miscellaneous Constants */ /***********************************************************************/
/***********************************************************************/ #define NO_IVAL -95684275 /* Used by GetIntegerOption */
#define NO_IVAL -95684275 /* Used by GetIntegerOption */ #define VMLANG 370 /* Size of olf VM lang blocks */
#define VMLANG 370 /* Size of olf VM lang blocks */ #define MAX_JUMP 24 /* Maximum jump level number */
#define MAX_JUMP 24 /* Maximum jump level number */ #define MAX_STR 1024 /* Maximum string length */
#define MAX_STR 1024 /* Maximum string length */ #define STR_SIZE 501 /* Length of char strings. */
#define STR_SIZE 501 /* Length of char strings. */ #define STD_INPUT 0 /* Standard language input */
#define STD_INPUT 0 /* Standard language input */ #define STD_OUTPUT 1 /* Standard language output */
#define STD_OUTPUT 1 /* Standard language output */ #define ERROR_OUTPUT 2 /* Error message output */
#define ERROR_OUTPUT 2 /* Error message output */ #define DEBUG_OUTPUT 3 /* Debug info output */
#define DEBUG_OUTPUT 3 /* Debug info output */ #define PROMPT_OUTPUT 4 /* Prompt message output */
#define PROMPT_OUTPUT 4 /* Prompt message output */ #define COPY_OUTPUT 5 /* Copy of language input */
#define COPY_OUTPUT 5 /* Copy of language input */ #define STD_MSG 6 /* System message file */
#define STD_MSG 6 /* System message file */ #define DEBUG_MSG 7 /* Debug message file */
#define DEBUG_MSG 7 /* Debug message file */ #define DUMMY 0 /* Dummy file index in Ldm block */
#define DUMMY 0 /* Dummy file index in Ldm block */ #define STDIN 1 /* stdin file index in Ldm block */
#define STDIN 1 /* stdin file index in Ldm block */ #define STDOUT 2 /* stdout file index in Ldm block */
#define STDOUT 2 /* stdout file index in Ldm block */ #define STDERR 3 /* stderr file index in Ldm block */
#define STDERR 3 /* stderr file index in Ldm block */ #define STDEBUG 4 /* debug file index in Ldm block */
#define STDEBUG 4 /* debug file index in Ldm block */ #define STDPRN 5 /* stdprn file index in Ldm block */
#define STDPRN 5 /* stdprn file index in Ldm block */ #define STDFREE 6 /* Free file index in Ldm block */
#define STDFREE 6 /* Free file index in Ldm block */
#define TYPE_SEM -2 /* Returned semantic function */
#define TYPE_SEM -2 /* Returned semantic function */ #define TYPE_DFONC -2 /* Indirect sem ref in FPARM */
#define TYPE_DFONC -2 /* Indirect sem ref in FPARM */ #define TYPE_VOID -1
#define TYPE_VOID -1 #define TYPE_SBPAR -1 /* Phrase reference in FPARM */
#define TYPE_SBPAR -1 /* Phrase reference in FPARM */ #define TYPE_SEMX 0 /* Initial semantic function type? */
#define TYPE_SEMX 0 /* Initial semantic function type? */ #define TYPE_ERROR 0
#define TYPE_ERROR 0 #define TYPE_STRING 1
#define TYPE_STRING 1 #define TYPE_FLOAT 2
#define TYPE_FLOAT 2 #define TYPE_SHORT 3
#define TYPE_SHORT 3 #define TYPE_BIGINT 5
#define TYPE_BIGINT 5 #define TYPE_LIST 6
#define TYPE_LIST 6 #define TYPE_INT 7
#define TYPE_INT 7
#if defined(OS32)
#if defined(OS32) #define SYS_STAMP "OS32"
#define SYS_STAMP "OS32" #elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
#elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX) #define SYS_STAMP "UNIX"
#define SYS_STAMP "UNIX" #elif defined(OS16)
#elif defined(OS16) #define SYS_STAMP "OS16"
#define SYS_STAMP "OS16" #elif defined(DOSR)
#elif defined(DOSR) #define SYS_STAMP "DOSR"
#define SYS_STAMP "DOSR" #elif defined(WIN)
#elif defined(WIN) #define SYS_STAMP "WIN1"
#define SYS_STAMP "WIN1" #elif defined(WIN32)
#elif defined(WIN32) #define SYS_STAMP "WIN2"
#define SYS_STAMP "WIN2" #else
#else #define SYS_STAMP "XXXX"
#define SYS_STAMP "XXXX" #endif
#endif
#if defined(__cplusplus)
#if defined(__cplusplus) extern "C" {
extern "C" { #endif
#endif
/***********************************************************************/
/***********************************************************************/ /* Static variables */
/* Static variables */ /***********************************************************************/
/***********************************************************************/ #if defined(STORAGE)
#if defined(STORAGE) char sys_stamp[4] = SYS_STAMP;
char sys_stamp[4] = SYS_STAMP; #else
#else extern char sys_stamp[];
extern char sys_stamp[]; #endif
#endif
/***********************************************************************/
/***********************************************************************/ /* File-Selection Indicators */
/* File-Selection Indicators */ /***********************************************************************/
/***********************************************************************/ #define PAT_LOG "log"
#define PAT_LOG "log"
#if defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
#if defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX) /*********************************************************************/
/*********************************************************************/ /* printf does not accept null pointer for %s target. */
/* printf does not accept null pointer for %s target. */ /*********************************************************************/
/*********************************************************************/ #define SVP(S) ((S) ? S : "<null>")
#define SVP(S) ((S) ? S : "<null>") #else
#else /*********************************************************************/
/*********************************************************************/ /* printf accepts null pointer for %s target. */
/* printf accepts null pointer for %s target. */ /*********************************************************************/
/*********************************************************************/ #define SVP(S) S
#define SVP(S) S #endif
#endif
#if defined(STORAGE)
#if defined(STORAGE) FILE *debug;
FILE *debug; #else
#else extern FILE *debug;
extern FILE *debug; #endif
#endif
/***********************************************************************/
/***********************************************************************/ /* General purpose type definitions. */
/* General purpose type definitions. */ /***********************************************************************/
/***********************************************************************/ #include "os.h"
#include "os.h"
typedef uint OFFSET;
typedef uint OFFSET; typedef char NAME[9];
typedef char NAME[9];
typedef struct {
typedef struct { ushort Length;
ushort Length; char String[2];
char String[2]; } VARSTR;
} VARSTR;
#if !defined(PGLOBAL_DEFINED)
#if !defined(PGLOBAL_DEFINED) typedef struct _global *PGLOBAL;
typedef struct _global *PGLOBAL; #define PGLOBAL_DEFINED
#define PGLOBAL_DEFINED #endif
#endif typedef struct _globplg *PGS;
typedef struct _globplg *PGS; typedef struct _activity *PACTIVITY;
typedef struct _activity *PACTIVITY; typedef struct _parm *PPARM;
typedef struct _parm *PPARM;
/***********************************************************************/
/***********************************************************************/ /* Segment Sub-Allocation block structure declares. */
/* Segment Sub-Allocation block structure declares. */ /* Next block is an implementation dependent segment suballoc save */
/* Next block is an implementation dependent segment suballoc save */ /* structure used to keep the suballocation system offsets and to */
/* structure used to keep the suballocation system offsets and to */ /* restore them if needed. This scheme implies that no SubFree be used */
/* restore them if needed. This scheme implies that no SubFree be used */ /***********************************************************************/
/***********************************************************************/ typedef struct { /* Plug Area SubAlloc header */
typedef struct { /* Plug Area SubAlloc header */ OFFSET To_Free; /* Offset of next free block */
OFFSET To_Free; /* Offset of next free block */ uint FreeBlk; /* Size of remaining free memory */
uint FreeBlk; /* Size of remaining free memory */ } POOLHEADER, *PPOOLHEADER;
} POOLHEADER, *PPOOLHEADER;
/***********************************************************************/
/***********************************************************************/ /* Language block. Containing all global information for the language */
/* Language block. Containing all global information for the language */ /* this block is saved and retrieved with the language. Information */
/* this block is saved and retrieved with the language. Information */ /* in this block can be set and modified under Grammar editing. */
/* in this block can be set and modified under Grammar editing. */ /***********************************************************************/
/***********************************************************************/ #if defined(BIT64)
#if defined(BIT64) typedef int TIME_T; /* Lang block size must not change */
typedef int TIME_T; /* Lang block size must not change */ #else // BIT32
#else // BIT32 typedef time_t TIME_T; /* time_t */
typedef time_t TIME_T; /* time_t */ #endif // BIT32
#endif // BIT32
typedef struct {
typedef struct { uint Memsize;
uint Memsize; uint Size;
uint Size; } AREADEF;
} AREADEF;
typedef struct Lang_block {
typedef struct Lang_block { NAME LangName; /* Language name */
NAME LangName; /* Language name */ NAME Application; /* Application name */
NAME Application; /* Application name */ } LANG, *PLANG;
} LANG, *PLANG;
/***********************************************************************/
/***********************************************************************/ /* Application block. It contains all global information for the */
/* Application block. It contains all global information for the */ /* current parse and execution using the corresponding language. */
/* current parse and execution using the corresponding language. */ /* This block is dynamically allocated and set at language init. */
/* This block is dynamically allocated and set at language init. */ /***********************************************************************/
/***********************************************************************/ typedef struct _activity { /* Describes activity and language */
typedef struct _activity { /* Describes activity and language */ void *Aptr; /* Points to user work area(s) */
void *Aptr; /* Points to user work area(s) */ NAME Ap_Name; /* Current application name */
NAME Ap_Name; /* Current application name */ } ACTIVITY;
} ACTIVITY;
/*---------------- UNIT ?????????? VERSION ? ----------------------*/
/*---------------- UNIT ?????????? VERSION ? ----------------------*/ typedef struct _parm {
typedef struct _parm { void *Value;
void *Value; short Type, Domain;
short Type, Domain; PPARM Next;
PPARM Next; } PARM;
} PARM;
/***********************************************************************/
/***********************************************************************/ /* Global Structure Block. This block contains, or points to, all */
/* Global Structure Block. This block contains, or points to, all */ /* information used by CONNECT tables. Passed as an argument */
/* information used by CONNECT tables. Passed as an argument */ /* to any routine allows it to have access to the entire information */
/* to any routine allows it to have access to the entire information */ /* currently available for the whole set of loaded languages. */
/* currently available for the whole set of loaded languages. */ /***********************************************************************/
/***********************************************************************/ typedef struct _global { /* Global structure */
typedef struct _global { /* Global structure */ void *Sarea; /* Points to work area */
void *Sarea; /* Points to work area */ uint Sarea_Size; /* Work area size */
uint Sarea_Size; /* Work area size */ PACTIVITY Activityp, ActivityStart;
PACTIVITY Activityp, ActivityStart; char Message[MAX_STR];
char Message[MAX_STR]; short Trace;
short Trace; int jump_level;
int jump_level; jmp_buf jumper[MAX_JUMP + 2];
jmp_buf jumper[MAX_JUMP + 2]; } GLOBAL;
} GLOBAL;
/***********************************************************************/
/***********************************************************************/ /* Exported routine declarations. */
/* Exported routine declarations. */ /***********************************************************************/
/***********************************************************************/ #if defined(XMSG)
#if defined(XMSG) DllExport char *PlugReadMessage(PGLOBAL, int, char *);
DllExport char *PlugReadMessage(PGLOBAL, int, char *); #elif defined(NEWMSG)
#elif defined(NEWMSG) DllExport char *PlugGetMessage(PGLOBAL, int);
DllExport char *PlugGetMessage(PGLOBAL, int); #endif // XMSG || NEWMSG
#endif // XMSG || NEWMSG #if defined(WIN32)
#if defined(WIN32) DllExport short GetLineLength(PGLOBAL); // Console line length
DllExport short GetLineLength(PGLOBAL); // Console line length #endif // WIN32
#endif // WIN32 DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization
DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization DllExport int PlugExit(PGLOBAL); // Plug global termination
DllExport int PlugExit(PGLOBAL); // Plug global termination DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); DllExport LPCSTR PlugSetPath(LPSTR, LPCSTR, LPCSTR);
DllExport LPCSTR PlugSetPath(LPSTR, LPCSTR, LPCSTR); DllExport void *PlugAllocMem(PGLOBAL, uint);
DllExport void *PlugAllocMem(PGLOBAL, uint); DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); DllExport void *MakePtr(void *, OFFSET);
DllExport void *MakePtr(void *, OFFSET); DllExport void htrc(char const *fmt, ...);
DllExport void htrc(char const *fmt, ...);
#if defined(__cplusplus)
#if defined(__cplusplus) } // extern "C"
} // extern "C" #endif
#endif
/*-------------------------- End of Global.H --------------------------*/
/*-------------------------- 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 /* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/** @file ha_connect.h /** @file ha_connect.h
@brief @brief
The ha_connect engine is a prototype storage engine to access external data. The ha_connect engine is a prototype storage engine to access external data.
@see @see
/sql/handler.h and /storage/connect/ha_connect.cc /sql/handler.h and /storage/connect/ha_connect.cc
*/ */
#ifdef USE_PRAGMA_INTERFACE #ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */ #pragma interface /* gcc class implementation */
#endif #endif
/****************************************************************************/ /****************************************************************************/
/* Structures used to pass info between CONNECT and ha_connect. */ /* Structures used to pass info between CONNECT and ha_connect. */
/****************************************************************************/ /****************************************************************************/
typedef struct _create_xinfo { typedef struct _create_xinfo {
char *Type; /* Retrieved from table comment */ char *Type; /* Retrieved from table comment */
char *Filename; /* Set if not standard */ char *Filename; /* Set if not standard */
char *IndexFN; /* Set if not standard */ char *IndexFN; /* Set if not standard */
ulonglong Maxrows; /* Estimated max nb of rows */ ulonglong Maxrows; /* Estimated max nb of rows */
ulong Lrecl; /* Set if not default */ ulong Lrecl; /* Set if not default */
ulong Elements; /* Number of lines in blocks */ ulong Elements; /* Number of lines in blocks */
bool Fixed; /* False for DOS type */ bool Fixed; /* False for DOS type */
void *Pcf; /* To list of columns */ void *Pcf; /* To list of columns */
void *Pxdf; /* To list of indexes */ void *Pxdf; /* To list of indexes */
} CRXINFO, *PCXF; } CRXINFO, *PCXF;
typedef struct _xinfo { typedef struct _xinfo {
ulonglong data_file_length; /* Length of data file */ ulonglong data_file_length; /* Length of data file */
ha_rows records; /* Records in table */ ha_rows records; /* Records in table */
ulong mean_rec_length; /* Physical record length */ ulong mean_rec_length; /* Physical record length */
char *data_file_name; /* Physical file name */ char *data_file_name; /* Physical file name */
} XINFO, *PXF; } XINFO, *PXF;
typedef class user_connect *PCONNECT; typedef class user_connect *PCONNECT;
typedef struct ha_table_option_struct TOS, *PTOS; typedef struct ha_table_option_struct TOS, *PTOS;
typedef struct ha_field_option_struct FOS, *PFOS; typedef struct ha_field_option_struct FOS, *PFOS;
/** @brief /** @brief
CONNECT_SHARE is a structure that will be shared among all open handlers. CONNECT_SHARE is a structure that will be shared among all open handlers.
This example implements the minimum of what you will probably need. This example implements the minimum of what you will probably need.
*/ */
typedef struct st_connect_share { typedef struct st_connect_share {
char *table_name; char *table_name;
uint table_name_length, use_count; uint table_name_length, use_count;
mysql_mutex_t mutex; mysql_mutex_t mutex;
THR_LOCK lock; THR_LOCK lock;
#if !defined(MARIADB) #if !defined(MARIADB)
PTOS table_options; PTOS table_options;
PFOS field_options; PFOS field_options;
#endif // !MARIADB #endif // !MARIADB
} CONNECT_SHARE; } CONNECT_SHARE;
typedef class ha_connect *PHC; typedef class ha_connect *PHC;
/** @brief /** @brief
Class definition for the storage engine Class definition for the storage engine
*/ */
class ha_connect: public handler class ha_connect: public handler
{ {
THR_LOCK_DATA lock; ///< MySQL lock THR_LOCK_DATA lock; ///< MySQL lock
CONNECT_SHARE *share; ///< Shared lock info CONNECT_SHARE *share; ///< Shared lock info
public: public:
ha_connect(handlerton *hton, TABLE_SHARE *table_arg); ha_connect(handlerton *hton, TABLE_SHARE *table_arg);
~ha_connect(); ~ha_connect();
// CONNECT Implementation // CONNECT Implementation
static bool connect_init(void); static bool connect_init(void);
static bool connect_end(void); static bool connect_end(void);
char *GetStringOption(char *opname, char *sdef= NULL); char *GetStringOption(char *opname, char *sdef= NULL);
PTOS GetTableOptionStruct(TABLE *table_arg); PTOS GetTableOptionStruct(TABLE *table_arg);
bool GetBooleanOption(char *opname, bool bdef); bool GetBooleanOption(char *opname, bool bdef);
int GetIntegerOption(char *opname); int GetIntegerOption(char *opname);
bool SetIntegerOption(char *opname, int n); bool SetIntegerOption(char *opname, int n);
PFOS GetFieldOptionStruct(Field *fp); PFOS GetFieldOptionStruct(Field *fp);
void *GetColumnOption(void *field, PCOLINFO pcf); void *GetColumnOption(void *field, PCOLINFO pcf);
PIXDEF GetIndexInfo(int n); PIXDEF GetIndexInfo(int n);
const char *GetDBName(const char *name); const char *GetDBName(const char *name);
const char *GetTableName(void); const char *GetTableName(void);
int GetColNameLen(Field *fp); int GetColNameLen(Field *fp);
char *GetColName(Field *fp); char *GetColName(Field *fp);
void AddColName(char *cp, Field *fp); void AddColName(char *cp, Field *fp);
TABLE *GetTable(void) {return table;} TABLE *GetTable(void) {return table;}
PCONNECT GetUser(THD *thd); PCONNECT GetUser(THD *thd);
PGLOBAL GetPlug(THD *thd); PGLOBAL GetPlug(THD *thd);
PTDB GetTDB(PGLOBAL g); PTDB GetTDB(PGLOBAL g);
bool OpenTable(PGLOBAL g, bool del= false); bool OpenTable(PGLOBAL g, bool del= false);
bool IsOpened(void); bool IsOpened(void);
int CloseTable(PGLOBAL g); int CloseTable(PGLOBAL g);
int MakeRecord(char *buf); int MakeRecord(char *buf);
int ScanRecord(PGLOBAL g, uchar *buf); int ScanRecord(PGLOBAL g, uchar *buf);
int CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf); int CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf);
int ReadIndexed(uchar *buf, OPVAL op, const uchar* key= NULL, int ReadIndexed(uchar *buf, OPVAL op, const uchar* key= NULL,
uint key_len= 0); uint key_len= 0);
/** @brief /** @brief
The name that will be used for display purposes. The name that will be used for display purposes.
*/ */
const char *table_type() const {return "CONNECT";} const char *table_type() const {return "CONNECT";}
/** @brief /** @brief
The name of the index type that will be used for display. The name of the index type that will be used for display.
Don't implement this method unless you really have indexes. Don't implement this method unless you really have indexes.
*/ */
const char *index_type(uint inx) { return "XPLUG"; } const char *index_type(uint inx) { return "XPLUG"; }
/** @brief /** @brief
The file extensions. The file extensions.
*/ */
const char **bas_ext() const; const char **bas_ext() const;
/** @brief /** @brief
This is a list of flags that indicate what functionality the storage engine This is a list of flags that indicate what functionality the storage engine
implements. The current table flags are documented in handler.h implements. The current table flags are documented in handler.h
*/ */
ulonglong table_flags() const ulonglong table_flags() const
{ {
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_HAS_RECORDS | return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_HAS_RECORDS |
/*HA_NO_AUTO_INCREMENT |*/ HA_NO_PREFIX_CHAR_KEYS | /*HA_NO_AUTO_INCREMENT |*/ HA_NO_PREFIX_CHAR_KEYS |
#if defined(MARIADB) #if defined(MARIADB)
HA_CAN_VIRTUAL_COLUMNS | HA_CAN_VIRTUAL_COLUMNS |
#endif // MARIADB #endif // MARIADB
HA_NULL_IN_KEY | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE); HA_NULL_IN_KEY | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE);
} }
/** @brief /** @brief
This is a bitmap of flags that indicates how the storage engine This is a bitmap of flags that indicates how the storage engine
implements indexes. The current index flags are documented in implements indexes. The current index flags are documented in
handler.h. If you do not implement indexes, just return zero here. handler.h. If you do not implement indexes, just return zero here.
@details @details
part is the key part to check. First key part is 0. 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 If all_parts is set, MySQL wants to know the flags for the combined
index, up to and including 'part'. index, up to and including 'part'.
*/ */
ulong index_flags(uint inx, uint part, bool all_parts) const ulong index_flags(uint inx, uint part, bool all_parts) const
{ {
return HA_READ_NEXT | HA_READ_RANGE; return HA_READ_NEXT | HA_READ_RANGE;
} }
/** @brief /** @brief
unireg.cc will call max_supported_record_length(), max_supported_keys(), unireg.cc will call max_supported_record_length(), max_supported_keys(),
max_supported_key_parts(), uint max_supported_key_length() max_supported_key_parts(), uint max_supported_key_length()
to make sure that the storage engine can handle the data it is about to 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 send. Return *real* limits of your storage engine here; MySQL will do
min(your_limits, MySQL_limits) automatically. min(your_limits, MySQL_limits) automatically.
*/ */
uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; } uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
/** @brief /** @brief
unireg.cc will call this to make sure that the storage engine can handle 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 the data it is about to send. Return *real* limits of your storage engine
here; MySQL will do min(your_limits, MySQL_limits) automatically. here; MySQL will do min(your_limits, MySQL_limits) automatically.
@details @details
There is no need to implement ..._key_... methods if your engine doesn't There is no need to implement ..._key_... methods if your engine doesn't
support indexes. support indexes.
*/ */
uint max_supported_keys() const { return 10; } uint max_supported_keys() const { return 10; }
/** @brief /** @brief
unireg.cc will call this to make sure that the storage engine can handle 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 the data it is about to send. Return *real* limits of your storage engine
here; MySQL will do min(your_limits, MySQL_limits) automatically. here; MySQL will do min(your_limits, MySQL_limits) automatically.
@details @details
There is no need to implement ..._key_... methods if your engine doesn't There is no need to implement ..._key_... methods if your engine doesn't
support indexes. support indexes.
*/ */
uint max_supported_key_parts() const { return 10; } uint max_supported_key_parts() const { return 10; }
/** @brief /** @brief
unireg.cc will call this to make sure that the storage engine can handle 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 the data it is about to send. Return *real* limits of your storage engine
here; MySQL will do min(your_limits, MySQL_limits) automatically. here; MySQL will do min(your_limits, MySQL_limits) automatically.
@details @details
There is no need to implement ..._key_... methods if your engine doesn't There is no need to implement ..._key_... methods if your engine doesn't
support indexes. support indexes.
*/ */
uint max_supported_key_length() const { return 255; } uint max_supported_key_length() const { return 255; }
/** @brief /** @brief
Called in test_quick_select to determine if indexes should be used. 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; } virtual double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; }
/** @brief /** @brief
This method will never be called if you do not implement indexes. This method will never be called if you do not implement indexes.
*/ */
virtual double read_time(uint, uint, ha_rows rows) virtual double read_time(uint, uint, ha_rows rows)
{ return (double) rows / 20.0+1; } { return (double) rows / 20.0+1; }
/* /*
Everything below are methods that we implement in ha_connect.cc. Everything below are methods that we implement in ha_connect.cc.
Most of these methods are not obligatory, skip them and Most of these methods are not obligatory, skip them and
MySQL will treat them as not implemented MySQL will treat them as not implemented
*/ */
virtual bool get_error_message(int error, String *buf); virtual bool get_error_message(int error, String *buf);
/** /**
Push condition down to the table handler. Push condition down to the table handler.
@param cond Condition to be pushed. The condition tree must not be @param cond Condition to be pushed. The condition tree must not be
modified by the by the caller. modified by the by the caller.
@return @return
The 'remainder' condition that caller must use to filter out records. The 'remainder' condition that caller must use to filter out records.
NULL means the handler will not return rows that do not match the NULL means the handler will not return rows that do not match the
passed condition. passed condition.
@note @note
The pushed conditions form a stack (from which one can remove the The pushed conditions form a stack (from which one can remove the
last pushed condition using cond_pop). last pushed condition using cond_pop).
The table handler filters out rows using (pushed_cond1 AND pushed_cond2 The table handler filters out rows using (pushed_cond1 AND pushed_cond2
AND ... AND pushed_condN) AND ... AND pushed_condN)
or less restrictive condition, depending on handler's capabilities. or less restrictive condition, depending on handler's capabilities.
handler->ha_reset() call empties the condition stack. handler->ha_reset() call empties the condition stack.
Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the
condition stack. condition stack.
*/ */
virtual const COND *cond_push(const COND *cond); virtual const COND *cond_push(const COND *cond);
PFIL CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond); PFIL CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond);
char *GetValStr(OPVAL vop, bool neg); const char *GetValStr(OPVAL vop, bool neg);
/** /**
Number of rows in table. It will only be called if Number of rows in table. It will only be called if
(table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0 (table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0
*/ */
virtual ha_rows records(); virtual ha_rows records();
/** @brief /** @brief
We implement this in ha_connect.cc; it's a required method. We implement this in ha_connect.cc; it's a required method.
*/ */
int open(const char *name, int mode, uint test_if_locked); // required int open(const char *name, int mode, uint test_if_locked); // required
/** @brief /** @brief
We implement this in ha_connect.cc; it's a required method. We implement this in ha_connect.cc; it's a required method.
*/ */
int close(void); // required int close(void); // required
/** @brief /** @brief
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented. skip it and and MySQL will treat it as not implemented.
*/ */
int write_row(uchar *buf); int write_row(uchar *buf);
/** @brief /** @brief
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented. skip it and and MySQL will treat it as not implemented.
*/ */
int update_row(const uchar *old_data, uchar *new_data); int update_row(const uchar *old_data, uchar *new_data);
/** @brief /** @brief
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented. skip it and and MySQL will treat it as not implemented.
*/ */
int delete_row(const uchar *buf); int delete_row(const uchar *buf);
// Added to the connect handler // Added to the connect handler
int index_init(uint idx, bool sorted); int index_init(uint idx, bool sorted);
int index_end(); int index_end();
int index_read(uchar * buf, const uchar * key, uint key_len, int index_read(uchar * buf, const uchar * key, uint key_len,
enum ha_rkey_function find_flag); enum ha_rkey_function find_flag);
int index_next_same(uchar *buf, const uchar *key, uint keylen); int index_next_same(uchar *buf, const uchar *key, uint keylen);
/** @brief /** @brief
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented. skip it and and MySQL will treat it as not implemented.
*/ */
//int index_read_map(uchar *buf, const uchar *key, //int index_read_map(uchar *buf, const uchar *key,
// key_part_map keypart_map, enum ha_rkey_function find_flag); // key_part_map keypart_map, enum ha_rkey_function find_flag);
/** @brief /** @brief
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented. skip it and and MySQL will treat it as not implemented.
*/ */
int index_next(uchar *buf); int index_next(uchar *buf);
/** @brief /** @brief
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented. skip it and and MySQL will treat it as not implemented.
*/ */
//int index_prev(uchar *buf); //int index_prev(uchar *buf);
/** @brief /** @brief
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented. skip it and and MySQL will treat it as not implemented.
*/ */
int index_first(uchar *buf); int index_first(uchar *buf);
/** @brief /** @brief
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented. skip it and and MySQL will treat it as not implemented.
*/ */
//int index_last(uchar *buf); //int index_last(uchar *buf);
/** @brief /** @brief
Unlike index_init(), rnd_init() can be called two consecutive times 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 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 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 rnd_init() allocates the cursor, the second call should position the
cursor to the start of the table; no need to deallocate and allocate cursor to the start of the table; no need to deallocate and allocate
it again. This is a required method. it again. This is a required method.
*/ */
int rnd_init(bool scan); //required int rnd_init(bool scan); //required
int rnd_end(); int rnd_end();
int rnd_next(uchar *buf); ///< required int rnd_next(uchar *buf); ///< required
int rnd_pos(uchar *buf, uchar *pos); ///< required int rnd_pos(uchar *buf, uchar *pos); ///< required
void position(const uchar *record); ///< required void position(const uchar *record); ///< required
int info(uint); ///< required int info(uint); ///< required
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int external_lock(THD *thd, int lock_type); ///< required int external_lock(THD *thd, int lock_type); ///< required
int delete_all_rows(void); int delete_all_rows(void);
ha_rows records_in_range(uint inx, key_range *min_key, ha_rows records_in_range(uint inx, key_range *min_key,
key_range *max_key); key_range *max_key);
int delete_table(const char *from); int delete_table(const char *from);
bool pre_create(THD *thd, void *crt_info, void *alt_info); bool pre_create(THD *thd, void *crt_info, void *alt_info);
int create(const char *name, TABLE *form, int create(const char *name, TABLE *form,
HA_CREATE_INFO *create_info); ///< required HA_CREATE_INFO *create_info); ///< required
bool check_if_incompatible_data(HA_CREATE_INFO *info, bool check_if_incompatible_data(HA_CREATE_INFO *info,
uint table_changes); uint table_changes);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type); ///< required enum thr_lock_type lock_type); ///< required
int optimize(THD* thd, HA_CHECK_OPT* check_opt); int optimize(THD* thd, HA_CHECK_OPT* check_opt);
protected: protected:
char *GetListOption(char *opname, const char *oplist, char *def= NULL); char *GetListOption(const char *opname, const char *oplist, const char *def= NULL);
char *encode(PGLOBAL g, char *cnm); char *encode(PGLOBAL g, char *cnm);
bool add_fields(THD *thd, void *alter_info, bool add_fields(THD *thd, void *alter_info,
LEX_STRING *field_name, LEX_STRING *field_name,
enum_field_types type, enum_field_types type,
char *length, char *decimals, char *length, char *decimals,
uint type_modifier, uint type_modifier,
// Item *default_value, Item *on_update_value, // Item *default_value, Item *on_update_value,
LEX_STRING *comment, LEX_STRING *comment,
// char *change, // char *change,
// List<String> *interval_list, // List<String> *interval_list,
CHARSET_INFO *cs, CHARSET_INFO *cs,
// uint uint_geom_type, // uint uint_geom_type,
void *vcol_info, void *vcol_info,
engine_option_value *create_options); engine_option_value *create_options);
// Members // Members
static ulong num; // Tracable handler number static ulong num; // Tracable handler number
PCONNECT xp; // To user_connect associated class PCONNECT xp; // To user_connect associated class
ulong hnum; // The number of this handler ulong hnum; // The number of this handler
query_id_t valid_query_id; // The one when tdbp was allocated query_id_t valid_query_id; // The one when tdbp was allocated
query_id_t creat_query_id; // The one when handler was allocated query_id_t creat_query_id; // The one when handler was allocated
PTDB tdbp; // To table class object PTDB tdbp; // To table class object
PVAL sdval; // Used to convert date values PVAL sdval; // Used to convert date values
bool istable; // True for table handler bool istable; // True for table handler
//char tname[64]; // The table name //char tname[64]; // The table name
MODE xmod; // Table mode MODE xmod; // Table mode
XINFO xinfo; // The table info structure XINFO xinfo; // The table info structure
bool valid_info; // True if xinfo is valid bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index bool stop; // Used when creating index
//bool hascond; // Too late for Delete //bool hascond; // Too late for Delete
int indexing; // Type of indexing for CONNECT int indexing; // Type of indexing for CONNECT
#if !defined(MARIADB) #if !defined(MARIADB)
PTOS table_options; PTOS table_options;
PFOS field_options; PFOS field_options;
#endif // !MARIADB #endif // !MARIADB
THR_LOCK_DATA lock_data; THR_LOCK_DATA lock_data;
public: public:
TABLE_SHARE *tshp; // Used by called tables TABLE_SHARE *tshp; // Used by called tables
char *data_file_name; char *data_file_name;
char *index_file_name; char *index_file_name;
uint int_table_flags; // Inherited from MyISAM uint int_table_flags; // Inherited from MyISAM
bool enable_activate_all_index; // Inherited from MyISAM bool enable_activate_all_index; // Inherited from MyISAM
}; // end of ha_connect class definition }; // 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 */ /* Declaration of XML document processing using libxml2 */
/* Author: Olivier Bertrand 2007-2012 */ /* Author: Olivier Bertrand 2007-2012 */
/******************************************************************/ /******************************************************************/
#include "plgxml.h" #include "plgxml.h"
typedef class LIBXMLDOC *PXDOC2; typedef class LIBXMLDOC *PXDOC2;
typedef class XML2NODE *PNODE2; typedef class XML2NODE *PNODE2;
typedef class XML2ATTR *PATTR2; typedef class XML2ATTR *PATTR2;
typedef class XML2NODELIST *PLIST2; typedef class XML2NODELIST *PLIST2;
/******************************************************************/ /******************************************************************/
/* XML2 block. Must have the same layout than FBLOCK up to Type. */ /* XML2 block. Must have the same layout than FBLOCK up to Type. */
/******************************************************************/ /******************************************************************/
typedef struct _x2block { /* Loaded XML file block */ typedef struct _x2block { /* Loaded XML file block */
struct _x2block *Next; struct _x2block *Next;
LPCSTR Fname; /* Point on file name */ LPCSTR Fname; /* Point on file name */
size_t Length; /* Used to tell if read mode */ size_t Length; /* Used to tell if read mode */
short Count; /* Nb of times file is used */ short Count; /* Nb of times file is used */
short Type; /* TYPE_FB_XML */ short Type; /* TYPE_FB_XML */
int Retcode; /* Return code from Load */ int Retcode; /* Return code from Load */
xmlDocPtr Docp; /* Document interface pointer */ xmlDocPtr Docp; /* Document interface pointer */
// xmlXPathContextPtr Ctxp; // xmlXPathContextPtr Ctxp;
// xmlXPathObjectPtr Xop; // xmlXPathObjectPtr Xop;
} X2BLOCK, *PX2BLOCK; } X2BLOCK, *PX2BLOCK;
/******************************************************************/ /******************************************************************/
/* Declaration of libxml2 document. */ /* Declaration of libxml2 document. */
/******************************************************************/ /******************************************************************/
class LIBXMLDOC : public XMLDOCUMENT { class LIBXMLDOC : public XMLDOCUMENT {
friend class XML2NODE; friend class XML2NODE;
friend class XML2ATTR; friend class XML2ATTR;
public: public:
// Constructor // Constructor
LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp); LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp);
// Properties // Properties
virtual short GetDocType(void) {return TYPE_FB_XML2;} virtual short GetDocType(void) {return TYPE_FB_XML2;}
virtual void *GetDocPtr(void) {return Docp;} virtual void *GetDocPtr(void) {return Docp;}
// Methods // Methods
virtual bool Initialize(PGLOBAL g); virtual bool Initialize(PGLOBAL g);
virtual bool ParseFile(char *fn); virtual bool ParseFile(char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver); virtual bool NewDoc(PGLOBAL g, char *ver);
virtual void AddComment(PGLOBAL g, char *com); virtual void AddComment(PGLOBAL g, char *com);
virtual PXNODE GetRoot(PGLOBAL g); virtual PXNODE GetRoot(PGLOBAL g);
virtual PXNODE NewRoot(PGLOBAL g, char *name); virtual PXNODE NewRoot(PGLOBAL g, char *name);
virtual PXNODE NewPnode(PGLOBAL g, char *name); virtual PXNODE NewPnode(PGLOBAL g, char *name);
virtual PXATTR NewPattr(PGLOBAL g); virtual PXATTR NewPattr(PGLOBAL g);
virtual PXLIST NewPlist(PGLOBAL g); virtual PXLIST NewPlist(PGLOBAL g);
virtual int DumpDoc(PGLOBAL g, char *ofn); virtual int DumpDoc(PGLOBAL g, char *ofn);
virtual void CloseDoc(PGLOBAL g, PFBLOCK xp); virtual void CloseDoc(PGLOBAL g, PFBLOCK xp);
virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn); virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn);
protected: protected:
bool CheckDocument(FILE *of, xmlNodePtr np); bool CheckDocument(FILE *of, xmlNodePtr np);
xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp); xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp);
int Decode(xmlChar *cnt, char *buf, int n); int Decode(xmlChar *cnt, char *buf, int n);
xmlChar *Encode(PGLOBAL g, char *txt); xmlChar *Encode(PGLOBAL g, char *txt);
// Members // Members
xmlDocPtr Docp; xmlDocPtr Docp;
xmlNodeSetPtr Nlist; xmlNodeSetPtr Nlist;
xmlXPathContextPtr Ctxp; xmlXPathContextPtr Ctxp;
xmlXPathObjectPtr Xop; xmlXPathObjectPtr Xop;
char *Buf; // Temporary char *Buf; // Temporary
}; // end of class LIBXMLDOC }; // end of class LIBXMLDOC
/******************************************************************/ /******************************************************************/
/* Declaration of libxml2 node. */ /* Declaration of libxml2 node. */
/******************************************************************/ /******************************************************************/
class XML2NODE : public XMLNODE { class XML2NODE : public XMLNODE {
friend class LIBXMLDOC; friend class LIBXMLDOC;
friend class XML2NODELIST; friend class XML2NODELIST;
public: public:
// Properties // Properties
virtual char *GetName(PGLOBAL g) {return (char*)Nodep->name;} virtual char *GetName(PGLOBAL g) {return (char*)Nodep->name;}
virtual int GetType(void); virtual int GetType(void);
virtual PXNODE GetNext(PGLOBAL g); virtual PXNODE GetNext(PGLOBAL g);
virtual PXNODE GetChild(PGLOBAL g); virtual PXNODE GetChild(PGLOBAL g);
// Methods // Methods
virtual char *GetText(char *buf, int len); virtual char *GetText(char *buf, int len);
virtual bool SetContent(PGLOBAL g, char *txtp, int len); virtual bool SetContent(PGLOBAL g, char *txtp, int len);
virtual PXNODE Clone(PGLOBAL g, PXNODE np); virtual PXNODE Clone(PGLOBAL g, PXNODE np);
virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp); virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp);
virtual PXLIST SelectNodes(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 PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap); virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np); virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap); virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
virtual void AddText(PGLOBAL g, char *txtp); virtual void AddText(PGLOBAL g, char *txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp); virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected: protected:
// Constructor // Constructor
XML2NODE(PXDOC dp, xmlNodePtr np); XML2NODE(PXDOC dp, xmlNodePtr np);
// Members // Members
xmlDocPtr Docp; xmlDocPtr Docp;
xmlChar *Content; xmlChar *Content;
xmlNodePtr Nodep; xmlNodePtr Nodep;
}; // end of class XML2NODE }; // end of class XML2NODE
/******************************************************************/ /******************************************************************/
/* Declaration of libxml2 node list. */ /* Declaration of libxml2 node list. */
/******************************************************************/ /******************************************************************/
class XML2NODELIST : public XMLNODELIST { class XML2NODELIST : public XMLNODELIST {
friend class LIBXMLDOC; friend class LIBXMLDOC;
friend class XML2NODE; friend class XML2NODE;
public: public:
// Methods // Methods
virtual int GetLength(void); virtual int GetLength(void);
virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np); virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np);
protected: protected:
// Constructor // Constructor
XML2NODELIST(PXDOC dp, xmlNodeSetPtr lp); XML2NODELIST(PXDOC dp, xmlNodeSetPtr lp);
// Members // Members
xmlNodeSetPtr Listp; xmlNodeSetPtr Listp;
}; // end of class XML2NODELIST }; // end of class XML2NODELIST
/******************************************************************/ /******************************************************************/
/* Declaration of libxml2 attribute. */ /* Declaration of libxml2 attribute. */
/******************************************************************/ /******************************************************************/
class XML2ATTR : public XMLATTRIBUTE { class XML2ATTR : public XMLATTRIBUTE {
friend class LIBXMLDOC; friend class LIBXMLDOC;
friend class XML2NODE; friend class XML2NODE;
public: public:
// Properties // Properties
//virtual char *GetText(void); //virtual char *GetText(void);
// Methods // Methods
virtual bool SetText(PGLOBAL g, char *txtp, int len); virtual bool SetText(PGLOBAL g, char *txtp, int len);
protected: protected:
// Constructor // Constructor
XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np); XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np);
// Members // Members
xmlAttrPtr Atrp; xmlAttrPtr Atrp;
xmlNodePtr Parent; xmlNodePtr Parent;
}; // end of class XML2ATTR }; // end of class XML2ATTR

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,13 +1,13 @@
/**************************************************************************/ /**************************************************************************/
/* NLS messsages definition. */ /* NLS messsages definition. */
/**************************************************************************/ /**************************************************************************/
#if defined(FRENCH) #if defined(FRENCH)
#if defined(CPX) #if defined(CPX)
#include "frmsg1.h" #include "frmsg1.h"
#else /* not CPX */ #else /* not CPX */
#include "frmsg2.h" #include "frmsg2.h"
#endif /* CPX */ #endif /* CPX */
#else /* not FRENCH */ #else /* not FRENCH */
#include "engmsg.h" #include "engmsg.h"
#endif /* FRENCH */ #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 /* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**************** MYCAT H Declares Source Code File (.H) ***************/ /**************** MYCAT H Declares Source Code File (.H) ***************/
/* Name: MYCAT.H Version 2.3 */ /* Name: MYCAT.H Version 2.3 */
/* */ /* */
/* This file contains the CONNECT plugin MYCAT class definitions. */ /* This file contains the CONNECT plugin MYCAT class definitions. */
/***********************************************************************/ /***********************************************************************/
#ifndef __MYCAT__H #ifndef __MYCAT__H
#define __MYCAT__H #define __MYCAT__H
#include "block.h" #include "block.h"
#include "catalog.h" #include "catalog.h"
/***********************************************************************/ char GetTypeID(const char *type);
/* MYCAT: class for managing the CONNECT plugin DB items. */
/***********************************************************************/ /***********************************************************************/
class MYCAT : public CATALOG { /* MYCAT: class for managing the CONNECT plugin DB items. */
public: /***********************************************************************/
MYCAT(PHC hc); // Constructor class MYCAT : public CATALOG {
public:
// Implementation MYCAT(PHC hc); // Constructor
PHC GetHandler(void) {return Hc;}
void SetHandler(PHC hc) {Hc= hc;} // Implementation
PHC GetHandler(void) {return Hc;}
// Methods void SetHandler(PHC hc) {Hc= hc;}
void Reset(void);
void SetDataPath(PGLOBAL g, const char *path) // Methods
{SetPath(g, &DataPath, path);} void Reset(void);
bool GetBoolCatInfo(LPCSTR name, PSZ what, bool bdef); void SetDataPath(PGLOBAL g, const char *path)
bool SetIntCatInfo(LPCSTR name, PSZ what, int ival); {SetPath(g, &DataPath, path);}
int GetIntCatInfo(LPCSTR name, PSZ what, int idef); bool GetBoolCatInfo(LPCSTR name, PSZ what, bool bdef);
int GetSizeCatInfo(LPCSTR name, PSZ what, PSZ sdef); bool SetIntCatInfo(LPCSTR name, PSZ what, int ival);
int GetCharCatInfo(LPCSTR name, PSZ what, PSZ sdef, char *buf, int size); int GetIntCatInfo(LPCSTR name, PSZ what, int idef);
char *GetStringCatInfo(PGLOBAL g, PSZ name, PSZ what, PSZ sdef); int GetSizeCatInfo(LPCSTR name, PSZ what, PSZ sdef);
int GetColCatInfo(PGLOBAL g, PTABDEF defp); int GetCharCatInfo(LPCSTR name, PSZ what, PSZ sdef, char *buf, int size);
bool GetIndexInfo(PGLOBAL g, PTABDEF defp); char *GetStringCatInfo(PGLOBAL g, PSZ name, PSZ what, PSZ sdef);
bool StoreIndex(PGLOBAL g, PTABDEF defp) {return false;} // Temporary int GetColCatInfo(PGLOBAL g, PTABDEF defp);
PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, bool GetIndexInfo(PGLOBAL g, PTABDEF defp);
LPCSTR am, PRELDEF *prp = NULL); bool StoreIndex(PGLOBAL g, PTABDEF defp) {return false;} // Temporary
PTDB GetTable(PGLOBAL g, PTABLE tablep, MODE mode = MODE_READ); PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
void ClearDB(PGLOBAL g); LPCSTR am, PRELDEF *prp = NULL);
PTDB GetTable(PGLOBAL g, PTABLE tablep, MODE mode = MODE_READ);
protected: void ClearDB(PGLOBAL g);
PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path); protected:
PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
// Members void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
ha_connect *Hc; // The Connect handler
}; // end of class MYCAT // Members
ha_connect *Hc; // The Connect handler
#endif __MYCAT__H }; // 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 */ /* MYCONN.H Olivier Bertrand 2007-2012 */
/* */ /* */
/* This is the declaration file for the MySQL connection class and */ /* This is the declaration file for the MySQL connection class and */
/* a few utility functions used to communicate with MySQL. */ /* a few utility functions used to communicate with MySQL. */
/* */ /* */
/* DO NOT define DLL_EXPORT in your application so these items are */ /* DO NOT define DLL_EXPORT in your application so these items are */
/* declared are imported from the Myconn DLL. */ /* declared are imported from the Myconn DLL. */
/***********************************************************************/ /***********************************************************************/
#if defined(WIN32) #if defined(WIN32)
#include <winsock.h> #include <winsock.h>
#else // !WIN32 #else // !WIN32
#include <sys/socket.h> #include <sys/socket.h>
#endif // !WIN32 #endif // !WIN32
#include <mysql.h> #include <mysql.h>
#include <errmsg.h> #include <errmsg.h>
#if defined(WIN32) && defined(MYCONN_EXPORTS) #if defined(WIN32) && defined(MYCONN_EXPORTS)
#if defined(DLL_EXPORT) #if defined(DLL_EXPORT)
#define DllItem _declspec(dllexport) #define DllItem _declspec(dllexport)
#else // !DLL_EXPORT #else // !DLL_EXPORT
#define DllItem _declspec(dllimport) #define DllItem _declspec(dllimport)
#endif // !DLL_EXPORT #endif // !DLL_EXPORT
#else // !WIN32 || !MYCONN_EXPORTS #else // !WIN32 || !MYCONN_EXPORTS
#define DllItem #define DllItem
#endif // !WIN32 #endif // !WIN32
//#define TYPE_AM_MYSQL (AMT)192 //#define TYPE_AM_MYSQL (AMT)192
#define MYSQL_ENABLED 0x00000001 #define MYSQL_ENABLED 0x00000001
#define MYSQL_LOGON 0x00000002 #define MYSQL_LOGON 0x00000002
typedef class MYSQLC *PMYC; typedef class MYSQLC *PMYC;
/***********************************************************************/ /***********************************************************************/
/* Exported/Imported functions. */ /* Exported/Imported functions. */
/***********************************************************************/ /***********************************************************************/
DllItem int MYSQLtoPLG(char *); DllItem int MYSQLtoPLG(char *);
DllItem int MYSQLtoPLG(int); DllItem int MYSQLtoPLG(int);
DllItem enum enum_field_types PLGtoMYSQL(int, bool gdf = FALSE); DllItem enum enum_field_types PLGtoMYSQL(int, bool gdf = FALSE);
DllItem char *MyDateFmt(int); DllItem char *MyDateFmt(int);
DllItem char *MyDateFmt(char *); DllItem char *MyDateFmt(char *);
/* -------------------------- MYCONN class --------------------------- */ /* -------------------------- MYCONN class --------------------------- */
/***********************************************************************/ /***********************************************************************/
/* MYSQLC exported/imported class. A MySQL connection. */ /* MYSQLC exported/imported class. A MySQL connection. */
/***********************************************************************/ /***********************************************************************/
class DllItem MYSQLC { class DllItem MYSQLC {
friend class TDBMYSQL; friend class TDBMYSQL;
// Construction // Construction
public: public:
MYSQLC(void); MYSQLC(void);
// Implementation // Implementation
int GetRows(void) {return m_Rows;} int GetRows(void) {return m_Rows;}
bool Connected(void); bool Connected(void);
// Methods // Methods
// int GetCurPos(void) {return (m_Res) ? N : 0;} // int GetCurPos(void) {return (m_Res) ? N : 0;}
// int GetProgCur(void) {return N;} // int GetProgCur(void) {return N;}
int GetResultSize(PGLOBAL g, PSZ sql); int GetResultSize(PGLOBAL g, PSZ sql);
int Open(PGLOBAL g, PSZ host, PSZ db, PSZ user = "root", int Open(PGLOBAL g, const char *host, const char *db,
PSZ pwd = "*", int pt = 0); const char *user= "root", const char *pwd= "*",
ulong GetThreadID(void); int pt= 0);
ulong ServerVersion(void); ulong GetThreadID(void);
const char *ServerInfo(void); ulong ServerVersion(void);
int KillQuery(ulong id); const char *ServerInfo(void);
int ExecSQL(PGLOBAL g, const char *query, int *w = NULL); int KillQuery(ulong id);
int PrepareSQL(PGLOBAL g, const char *query); int ExecSQL(PGLOBAL g, const char *query, int *w = NULL);
int ExecStmt(PGLOBAL g); int PrepareSQL(PGLOBAL g, const char *query);
int BindParams(PGLOBAL g, MYSQL_BIND *bind); int ExecStmt(PGLOBAL g);
PQRYRES GetResult(PGLOBAL g, bool pdb = FALSE); int BindParams(PGLOBAL g, MYSQL_BIND *bind);
int Fetch(PGLOBAL g, int pos); PQRYRES GetResult(PGLOBAL g, bool pdb = FALSE);
char *GetCharField(int i); int Fetch(PGLOBAL g, int pos);
int GetFieldLength(int i); char *GetCharField(int i);
void Rewind(void); int GetFieldLength(int i);
void FreeResult(void); void Rewind(void);
void Close(void); void FreeResult(void);
void DiscardResults(void); void Close(void);
void DiscardResults(void);
protected:
// Members protected:
MYSQL *m_DB; // The return from MySQL connection // Members
MYSQL_STMT *m_Stmt; // Prepared statement handle MYSQL *m_DB; // The return from MySQL connection
MYSQL_RES *m_Res; // Points to MySQL Result MYSQL_STMT *m_Stmt; // Prepared statement handle
MYSQL_ROW m_Row; // Point to current row MYSQL_RES *m_Res; // Points to MySQL Result
int m_Rows; // The number of rows of the result MYSQL_ROW m_Row; // Point to current row
int N; int m_Rows; // The number of rows of the result
int m_Fields; // The number of result fields int N;
}; // end of class MYSQLC 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) **************/ /************** MyUtil C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: MYUTIL */ /* PROGRAM NAME: MYUTIL */
/* ------------- */ /* ------------- */
/* Version 1.0 */ /* Version 1.0 */
/* */ /* */
/* Author Olivier BERTRAND 2013 */ /* Author Olivier BERTRAND 2013 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
/* It contains utility functions to convert data types. */ /* It contains utility functions to convert data types. */
/* It can optionally use the embedded MySQL library. */ /* It can optionally use the embedded MySQL library. */
/* */ /* */
/************************************************************************/ /************************************************************************/
#include "my_global.h" #include "my_global.h"
#include <mysql.h> #include <mysql.h>
#if defined(WIN32) #if defined(WIN32)
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !WIN32
#include "osutil.h" #include "osutil.h"
#endif // !WIN32 #endif // !WIN32
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
//#include "value.h" //#include "value.h"
//#include "valblk.h" //#include "valblk.h"
#define DLL_EXPORT // Items are exported from this DLL #define DLL_EXPORT // Items are exported from this DLL
/************************************************************************/ /************************************************************************/
/* Convert from MySQL type name to PlugDB type number */ /* Convert from MySQL type name to PlugDB type number */
/************************************************************************/ /************************************************************************/
int MYSQLtoPLG(char *typname) int MYSQLtoPLG(char *typname)
{ {
int type; int type;
if (!stricmp(typname, "int") || !stricmp(typname, "mediumint") || if (!stricmp(typname, "int") || !stricmp(typname, "mediumint") ||
!stricmp(typname, "integer")) !stricmp(typname, "integer"))
type = TYPE_INT; type = TYPE_INT;
else if (!stricmp(typname, "tinyint") || !stricmp(typname, "smallint")) else if (!stricmp(typname, "tinyint") || !stricmp(typname, "smallint"))
type = TYPE_SHORT; type = TYPE_SHORT;
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") || else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") ||
!stricmp(typname, "text") || !stricmp(typname, "blob")) !stricmp(typname, "text") || !stricmp(typname, "blob"))
type = TYPE_STRING; type = TYPE_STRING;
else if (!stricmp(typname, "double") || !stricmp(typname, "float") || else if (!stricmp(typname, "double") || !stricmp(typname, "float") ||
!stricmp(typname, "real") || !stricmp(typname, "bigint") || !stricmp(typname, "real") || !stricmp(typname, "bigint") ||
!stricmp(typname, "decimal") || !stricmp(typname, "numeric")) !stricmp(typname, "decimal") || !stricmp(typname, "numeric"))
type = TYPE_FLOAT; type = TYPE_FLOAT;
else if (!stricmp(typname, "date") || !stricmp(typname, "datetime") || else if (!stricmp(typname, "date") || !stricmp(typname, "datetime") ||
!stricmp(typname, "time") || !stricmp(typname, "timestamp") || !stricmp(typname, "time") || !stricmp(typname, "timestamp") ||
!stricmp(typname, "year")) !stricmp(typname, "year"))
type = TYPE_DATE; type = TYPE_DATE;
else if (!stricmp(typname, "bigint") || !stricmp(typname, "longlong")) else if (!stricmp(typname, "bigint") || !stricmp(typname, "longlong"))
type = TYPE_BIGINT; type = TYPE_BIGINT;
else else
type = TYPE_ERROR; type = TYPE_ERROR;
return type; return type;
} // end of MYSQLtoPLG } // end of MYSQLtoPLG
/************************************************************************/ /************************************************************************/
/* Convert from PlugDB type to MySQL type number */ /* Convert from PlugDB type to MySQL type number */
/************************************************************************/ /************************************************************************/
enum enum_field_types PLGtoMYSQL(int type, bool gdf) enum enum_field_types PLGtoMYSQL(int type, bool gdf)
{ {
enum enum_field_types mytype; enum enum_field_types mytype;
switch (type) { switch (type) {
case TYPE_INT: case TYPE_INT:
mytype = MYSQL_TYPE_LONG; mytype = MYSQL_TYPE_LONG;
break; break;
case TYPE_SHORT: case TYPE_SHORT:
mytype = MYSQL_TYPE_SHORT; mytype = MYSQL_TYPE_SHORT;
break; break;
case TYPE_FLOAT: case TYPE_FLOAT:
mytype = MYSQL_TYPE_DOUBLE; mytype = MYSQL_TYPE_DOUBLE;
break; break;
case TYPE_DATE: case TYPE_DATE:
mytype = (gdf) ? MYSQL_TYPE_DATE : MYSQL_TYPE_DATETIME; mytype = (gdf) ? MYSQL_TYPE_DATE : MYSQL_TYPE_DATETIME;
break; break;
case TYPE_STRING: case TYPE_STRING:
mytype = MYSQL_TYPE_VARCHAR; mytype = MYSQL_TYPE_VARCHAR;
break; break;
case TYPE_BIGINT: case TYPE_BIGINT:
mytype = MYSQL_TYPE_LONGLONG; mytype = MYSQL_TYPE_LONGLONG;
break; break;
default: default:
mytype = MYSQL_TYPE_NULL; mytype = MYSQL_TYPE_NULL;
} // endswitch mytype } // endswitch mytype
return mytype; return mytype;
} // end of PLGtoMYSQL } // end of PLGtoMYSQL
/************************************************************************/ /************************************************************************/
/* Convert from MySQL type to PlugDB type number */ /* Convert from MySQL type to PlugDB type number */
/************************************************************************/ /************************************************************************/
int MYSQLtoPLG(int mytype) int MYSQLtoPLG(int mytype)
{ {
int type; int type;
switch (mytype) { switch (mytype) {
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
type = TYPE_SHORT; type = TYPE_SHORT;
break; break;
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
case MYSQL_TYPE_INT24: case MYSQL_TYPE_INT24:
case MYSQL_TYPE_ENUM: // ??? case MYSQL_TYPE_ENUM: // ???
type = TYPE_INT; type = TYPE_INT;
break; break;
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
type = TYPE_BIGINT; type = TYPE_BIGINT;
break; break;
case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_DECIMAL:
#if !defined(ALPHA) #if !defined(ALPHA)
case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_NEWDECIMAL:
#endif // !ALPHA) #endif // !ALPHA)
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_DOUBLE:
type = TYPE_FLOAT; type = TYPE_FLOAT;
break; break;
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_YEAR: case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
type = TYPE_DATE; type = TYPE_DATE;
break; break;
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
#if !defined(ALPHA) #if !defined(ALPHA)
case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VARCHAR:
#endif // !ALPHA) #endif // !ALPHA)
case MYSQL_TYPE_BLOB: case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
type = TYPE_STRING; type = TYPE_STRING;
break; break;
default: default:
type = TYPE_ERROR; type = TYPE_ERROR;
} // endswitch mytype } // endswitch mytype
return type; return type;
} // end of MYSQLtoPLG } // end of MYSQLtoPLG
/************************************************************************/ /************************************************************************/
/* Returns the format corresponding to a MySQL date type. */ /* Returns the format corresponding to a MySQL date type. */
/************************************************************************/ /************************************************************************/
char *MyDateFmt(int mytype) char *MyDateFmt(int mytype)
{ {
char *fmt; char *fmt;
switch (mytype) { switch (mytype) {
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATETIME:
fmt = "YYYY-MM-DD hh:mm:ss"; fmt = "YYYY-MM-DD hh:mm:ss";
break; break;
case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATE:
fmt = "YYYY-MM-DD"; fmt = "YYYY-MM-DD";
break; break;
case MYSQL_TYPE_YEAR: case MYSQL_TYPE_YEAR:
fmt = "YYYY"; fmt = "YYYY";
break; break;
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
fmt = "hh:mm:ss"; fmt = "hh:mm:ss";
break; break;
default: default:
fmt = NULL; fmt = NULL;
} // endswitch mytype } // endswitch mytype
return fmt; return fmt;
} // end of MyDateFmt } // end of MyDateFmt
/************************************************************************/ /************************************************************************/
/* Returns the format corresponding to a MySQL date type. */ /* Returns the format corresponding to a MySQL date type. */
/************************************************************************/ /************************************************************************/
char *MyDateFmt(char *typname) char *MyDateFmt(char *typname)
{ {
char *fmt; char *fmt;
if (!stricmp(typname, "datetime") || !stricmp(typname, "timestamp")) if (!stricmp(typname, "datetime") || !stricmp(typname, "timestamp"))
fmt = "YYYY-MM-DD hh:mm:ss"; fmt = "YYYY-MM-DD hh:mm:ss";
else if (!stricmp(typname, "date")) else if (!stricmp(typname, "date"))
fmt = "YYYY-MM-DD"; fmt = "YYYY-MM-DD";
else if (!stricmp(typname, "year")) else if (!stricmp(typname, "year"))
fmt = "YYYY"; fmt = "YYYY";
else if (!stricmp(typname, "time")) else if (!stricmp(typname, "time"))
fmt = "hh:mm:ss"; fmt = "hh:mm:ss";
else else
fmt = NULL; fmt = NULL;
return fmt; return fmt;
} // end of MyDateFmt } // 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. */ /* ODBConn.h : header file for the ODBC connection classes. */
/***********************************************************************/ /***********************************************************************/
//nclude <windows.h> /* Windows include file */ //nclude <windows.h> /* Windows include file */
//nclude <windowsx.h> /* Message crackers */ //nclude <windowsx.h> /* Message crackers */
/***********************************************************************/ /***********************************************************************/
/* Included C-definition files required by the interface. */ /* Included C-definition files required by the interface. */
/***********************************************************************/ /***********************************************************************/
#include "block.h" #include "block.h"
/***********************************************************************/ /***********************************************************************/
/* ODBC interface. */ /* ODBC interface. */
/***********************************************************************/ /***********************************************************************/
#include <sql.h> #include <sql.h>
#include <sqlext.h> #include <sqlext.h>
/***********************************************************************/ /***********************************************************************/
/* Constants and defines. */ /* Constants and defines. */
/***********************************************************************/ /***********************************************************************/
// Miscellaneous sizing info // Miscellaneous sizing info
#define MAX_NUM_OF_MSG 10 // Max number of error messages #define MAX_NUM_OF_MSG 10 // Max number of error messages
//efine MAX_CURRENCY 30 // Max size of Currency($) string //efine MAX_CURRENCY 30 // Max size of Currency($) string
#define MAX_TNAME_LEN 32 // Max size of table names #define MAX_TNAME_LEN 32 // Max size of table names
//efine MAX_FNAME_LEN 256 // Max size of field names //efine MAX_FNAME_LEN 256 // Max size of field names
#define MAX_STRING_INFO 256 // Max size of string from SQLGetInfo #define MAX_STRING_INFO 256 // Max size of string from SQLGetInfo
//efine MAX_DNAME_LEN 256 // Max size of Recordset names //efine MAX_DNAME_LEN 256 // Max size of Recordset names
#define MAX_CONNECT_LEN 512 // Max size of Connect string #define MAX_CONNECT_LEN 512 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name //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 #define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type
#if !defined(WIN32) #if !defined(WIN32)
typedef unsigned char *PUCHAR; typedef unsigned char *PUCHAR;
#endif // !WIN32 #endif // !WIN32
// Timeout and net wait defaults // Timeout and net wait defaults
#define DEFAULT_LOGIN_TIMEOUT 15 // seconds to before fail on connect #define DEFAULT_LOGIN_TIMEOUT 15 // seconds to before fail on connect
#define DEFAULT_QUERY_TIMEOUT 15 // seconds to before fail waiting for results #define DEFAULT_QUERY_TIMEOUT 15 // seconds to before fail waiting for results
// Field Flags, used to indicate status of fields // Field Flags, used to indicate status of fields
//efine SQL_FIELD_FLAG_DIRTY 0x1 //efine SQL_FIELD_FLAG_DIRTY 0x1
//efine SQL_FIELD_FLAG_NULL 0x2 //efine SQL_FIELD_FLAG_NULL 0x2
// Update options flags // Update options flags
#define SQL_SETPOSUPDATES 0x0001 #define SQL_SETPOSUPDATES 0x0001
#define SQL_POSITIONEDSQL 0x0002 #define SQL_POSITIONEDSQL 0x0002
//efine SQL_GDBOUND 0x0004 //efine SQL_GDBOUND 0x0004
enum CATINFO {CAT_TAB = 1, /* SQLTables */ enum CATINFO {CAT_TAB = 1, /* SQLTables */
CAT_COL = 2, /* SQLColumns */ CAT_COL = 2, /* SQLColumns */
CAT_KEY = 3, /* SQLPrimaryKeys */ CAT_KEY = 3, /* SQLPrimaryKeys */
CAT_STAT = 4, /* SQLStatistics */ CAT_STAT = 4, /* SQLStatistics */
CAT_SPC = 5}; /* SQLSpecialColumns */ CAT_SPC = 5}; /* SQLSpecialColumns */
/***********************************************************************/ /***********************************************************************/
/* This structure is used to control the catalog functions. */ /* This structure is used to control the catalog functions. */
/***********************************************************************/ /***********************************************************************/
typedef struct tagCATPARM { typedef struct tagCATPARM {
CATINFO Id; // Id to indicate function CATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer PQRYRES Qrp; // Result set pointer
PUCHAR Tab; // Table name or pattern PUCHAR Tab; // Table name or pattern
PUCHAR Pat; // Table type or column pattern PUCHAR Pat; // Table type or column pattern
SQLLEN* *Vlen; // To array of indicator values SQLLEN* *Vlen; // To array of indicator values
UWORD *Status; // To status block UWORD *Status; // To status block
// For SQLStatistics // For SQLStatistics
UWORD Unique; // Index type UWORD Unique; // Index type
UWORD Accuracy; // For Cardinality and Pages UWORD Accuracy; // For Cardinality and Pages
// For SQLSpecialColumns // For SQLSpecialColumns
UWORD ColType; UWORD ColType;
UWORD Scope; UWORD Scope;
UWORD Nullable; UWORD Nullable;
} CATPARM; } CATPARM;
// ODBC connection to a data source // ODBC connection to a data source
class TDBODBC; class TDBODBC;
class ODBCCOL; class ODBCCOL;
class ODBConn; class ODBConn;
/***********************************************************************/ /***********************************************************************/
/* Class DBX (ODBC exception). */ /* Class DBX (ODBC exception). */
/***********************************************************************/ /***********************************************************************/
class DBX : public BLOCK { class DBX : public BLOCK {
friend class ODBConn; friend class ODBConn;
// Construction (by ThrowDBX only) -- destruction // Construction (by ThrowDBX only) -- destruction
protected: protected:
DBX(RETCODE rc); DBX(RETCODE rc);
public: public:
//virtual ~DBX() {} //virtual ~DBX() {}
//void operator delete(void*, PGLOBAL, void*) {}; //void operator delete(void*, PGLOBAL, void*) {};
// Implementation (use ThrowDBX to create) // Implementation (use ThrowDBX to create)
RETCODE GetRC(void) {return m_RC;} RETCODE GetRC(void) {return m_RC;}
PSZ GetErrorMessage(int i) const char *GetErrorMessage(int i)
{return (i >=0 && i < MAX_NUM_OF_MSG) ? m_ErrMsg[i] { return (i >=0 && i < MAX_NUM_OF_MSG) ? m_ErrMsg[i] : "No ODBC error"; }
: "No ODBC error";} protected:
protected: void BuildErrorMessage(ODBConn* pdb, HSTMT hstmt = SQL_NULL_HSTMT);
void BuildErrorMessage(ODBConn* pdb, HSTMT hstmt = SQL_NULL_HSTMT);
// Attributes
// Attributes RETCODE m_RC;
RETCODE m_RC; PSZ m_ErrMsg[MAX_NUM_OF_MSG];
PSZ m_ErrMsg[MAX_NUM_OF_MSG]; }; // end of DBX class definition
}; // end of DBX class definition
/***********************************************************************/
/***********************************************************************/ /* ODBConn class. */
/* ODBConn class. */ /***********************************************************************/
/***********************************************************************/ class ODBConn : public BLOCK {
class ODBConn : public BLOCK { friend class DBX;
friend class DBX; friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&); private:
private: ODBConn(); // Standard (unused) constructor
ODBConn(); // Standard (unused) constructor
public:
public: ODBConn(PGLOBAL g, TDBODBC *tdbp);
ODBConn(PGLOBAL g, TDBODBC *tdbp);
enum DOP { // Db Open oPtions
enum DOP { // Db Open oPtions traceSQL = 0x0001, // Trace SQL calls
traceSQL = 0x0001, // Trace SQL calls openReadOnly = 0x0002, // Open database read only
openReadOnly = 0x0002, // Open database read only useCursorLib = 0x0004, // Use ODBC cursor lib
useCursorLib = 0x0004, // Use ODBC cursor lib noOdbcDialog = 0x0008, // Don't display ODBC Connect dialog
noOdbcDialog = 0x0008, // Don't display ODBC Connect dialog forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog
forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog
int Open(PSZ ConnectString, DWORD Options = 0);
int Open(PSZ ConnectString, DWORD Options = 0); void Close(void);
void Close(void);
// Attributes
// Attributes public:
public: char GetQuoteChar(void) {return m_IDQuoteChar;}
char GetQuoteChar(void) {return m_IDQuoteChar;} // Database successfully opened?
// Database successfully opened? bool IsOpen(void) {return m_hdbc != SQL_NULL_HDBC;}
bool IsOpen(void) {return m_hdbc != SQL_NULL_HDBC;} PSZ GetStringInfo(ushort infotype);
PSZ GetStringInfo(ushort infotype); int GetMaxValue(ushort infotype);
int GetMaxValue(ushort infotype); PSZ GetConnect(void) {return m_Connect;}
PSZ GetConnect(void) {return m_Connect;}
public:
public: // Operations
// Operations void SetLoginTimeout(DWORD sec) {m_LoginTimeout = sec;}
void SetLoginTimeout(DWORD sec) {m_LoginTimeout = sec;} void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;} int GetResultSize(char *sql, ODBCCOL *colp);
int GetResultSize(char *sql, ODBCCOL *colp); int ExecDirectSQL(char *sql, ODBCCOL *tocols);
int ExecDirectSQL(char *sql, ODBCCOL *tocols); int Fetch(void);
int Fetch(void); int PrepareSQL(char *sql);
int PrepareSQL(char *sql); bool ExecuteSQL(void);
bool ExecuteSQL(void); bool BindParam(ODBCCOL *colp);
bool BindParam(ODBCCOL *colp); int GetCatInfo(CATPARM *cap);
int GetCatInfo(CATPARM *cap); bool GetDataSources(PQRYRES qrp);
bool GetDataSources(PQRYRES qrp);
public:
public: // Set special options
// Set special options void OnSetOptions(HSTMT hstmt);
void OnSetOptions(HSTMT hstmt);
// Implementation
// Implementation public:
public: // virtual ~ODBConn();
// virtual ~ODBConn();
// ODBC operations
// ODBC operations protected:
protected: bool Check(RETCODE rc);
bool Check(RETCODE rc); void ThrowDBX(RETCODE rc, HSTMT hstmt = SQL_NULL_HSTMT);
void ThrowDBX(RETCODE rc, HSTMT hstmt = SQL_NULL_HSTMT); void ThrowDBX(PSZ msg);
void ThrowDBX(PSZ msg); void AllocConnect(DWORD dwOptions);
void AllocConnect(DWORD dwOptions); bool Connect(DWORD Options);
bool Connect(DWORD Options); void VerifyConnect(void);
void VerifyConnect(void); void GetConnectInfo(void);
void GetConnectInfo(void); void Free(void);
void Free(void);
protected:
protected: // Static members
// Static members static HENV m_henv;
static HENV m_henv; static int m_nAlloc; // per-Appl reference to HENV above
static int m_nAlloc; // per-Appl reference to HENV above
// Members
// Members PGLOBAL m_G;
PGLOBAL m_G; TDBODBC *m_Tdb;
TDBODBC *m_Tdb; HDBC m_hdbc;
HDBC m_hdbc; HSTMT m_hstmt;
HSTMT m_hstmt; DWORD m_LoginTimeout;
DWORD m_LoginTimeout; DWORD m_QueryTimeout;
DWORD m_QueryTimeout; DWORD m_UpdateOptions;
DWORD m_UpdateOptions; DWORD m_RowsetSize;
DWORD m_RowsetSize; int m_Catver;
int m_Catver; PSZ m_Connect;
PSZ m_Connect; bool m_Updatable;
bool m_Updatable; char m_IDQuoteChar;
char m_IDQuoteChar; }; // end of ODBConn class definition
}; // end of ODBConn class definition

View File

@@ -26,6 +26,7 @@ typedef unsigned char BYTE;
typedef char *LPSTR; typedef char *LPSTR;
typedef char *LPTSTR; typedef char *LPTSTR;
typedef char *PSZ; typedef char *PSZ;
typedef long BOOL;
typedef int INT; typedef int INT;
#if !defined(NODW) #if !defined(NODW)
/* /*
@@ -39,19 +40,15 @@ typedef unsigned long DWORD;
#undef HANDLE #undef HANDLE
typedef int 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 _stricmp strcasecmp #define _stricmp strcasecmp
#define strnicmp strncasecmp #define strnicmp strncasecmp
#define _strnicmp strncasecmp #define _strnicmp strncasecmp
#ifdef PATH_MAX
#define _MAX_PATH PATH_MAX
#else
#define _MAX_PATH 260 #define _MAX_PATH 260
#endif
#define _MAX_DRIVE 3 #define _MAX_DRIVE 3
#define _MAX_DIR 256 #define _MAX_DIR 256
#define _MAX_FNAME 256 #define _MAX_FNAME 256

View File

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

View File

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

View File

@@ -1,218 +1,218 @@
/**************************************************************************/ /**************************************************************************/
/* PLGCNX.H */ /* PLGCNX.H */
/* Copyright to the author: Olivier Bertrand 2000-2012 */ /* Copyright to the author: Olivier Bertrand 2000-2012 */
/* */ /* */
/* This is the connection DLL's declares. */ /* This is the connection DLL's declares. */
/**************************************************************************/ /**************************************************************************/
#if !defined(_PLGCNX_H) #if !defined(_PLGCNX_H)
#define _PLGCNX_H #define _PLGCNX_H
#define MAXMSGLEN 65512 /* Default max length of cnx message */ #define MAXMSGLEN 65512 /* Default max length of cnx message */
#define MAXERRMSG 512 /* Max length of error messages */ #define MAXERRMSG 512 /* Max length of error messages */
#define MAXMESSAGE 256 /* Max length of returned messages */ #define MAXMESSAGE 256 /* Max length of returned messages */
#define MAXDBNAME 128 /* Max length of DB related names */ #define MAXDBNAME 128 /* Max length of DB related names */
/**************************************************************************/ /**************************************************************************/
/* API Function return codes. */ /* API Function return codes. */
/**************************************************************************/ /**************************************************************************/
enum FNRC {RC_LICENSE = 7, /* PLGConnect prompt for license key */ enum FNRC {RC_LICENSE = 7, /* PLGConnect prompt for license key */
RC_PASSWD = 6, /* PLGConnect prompt for User/Pwd */ RC_PASSWD = 6, /* PLGConnect prompt for User/Pwd */
RC_SUCWINFO = 5, /* Succes With Info return code */ RC_SUCWINFO = 5, /* Succes With Info return code */
RC_SOCKET = 4, /* RC from PLGConnect to socket DLL */ RC_SOCKET = 4, /* RC from PLGConnect to socket DLL */
RC_PROMPT = 3, /* Intermediate prompt return */ RC_PROMPT = 3, /* Intermediate prompt return */
RC_CANCEL = 2, /* Command was cancelled by user */ RC_CANCEL = 2, /* Command was cancelled by user */
RC_PROGRESS = 1, /* Intermediate progress info */ RC_PROGRESS = 1, /* Intermediate progress info */
RC_SUCCESS = 0, /* Successful function (must be 0) */ RC_SUCCESS = 0, /* Successful function (must be 0) */
RC_MEMORY = -1, /* Storage allocation error */ RC_MEMORY = -1, /* Storage allocation error */
RC_TRUNCATED = -2, /* Result has been truncated */ RC_TRUNCATED = -2, /* Result has been truncated */
RC_TIMEOUT = -3, /* Connection timeout occured */ RC_TIMEOUT = -3, /* Connection timeout occured */
RC_TOOBIG = -4, /* Data is too big for connection */ RC_TOOBIG = -4, /* Data is too big for connection */
RC_KEY = -5, /* Null ptr to key in Connect */ RC_KEY = -5, /* Null ptr to key in Connect */
/* or bad key in other functions */ /* or bad key in other functions */
RC_MAXCONN = -6, /* Too many conn's for one process */ RC_MAXCONN = -6, /* Too many conn's for one process */
RC_MAXCLIENT = -7, /* Too many clients for one system */ RC_MAXCLIENT = -7, /* Too many clients for one system */
RC_SYNCHRO = -8, /* Synchronization error */ RC_SYNCHRO = -8, /* Synchronization error */
RC_SERVER = -9, /* Error related to the server */ RC_SERVER = -9, /* Error related to the server */
RC_MAXCOL = -10, /* Result has too many columns */ RC_MAXCOL = -10, /* Result has too many columns */
RC_LAST = -10}; /* Other error codes are < this and */ RC_LAST = -10}; /* Other error codes are < this and */
/* are system errors. */ /* are system errors. */
/**************************************************************************/ /**************************************************************************/
/* Standard function return codes. */ /* Standard function return codes. */
/**************************************************************************/ /**************************************************************************/
#if !defined(RC_OK_DEFINED) #if !defined(RC_OK_DEFINED)
#define RC_OK_DEFINED #define RC_OK_DEFINED
enum RCODE {RC_OK = 0, /* No error return code */ enum RCODE {RC_OK = 0, /* No error return code */
RC_NF = 1, /* Not found return code */ RC_NF = 1, /* Not found return code */
RC_EF = 2, /* End of file return code */ RC_EF = 2, /* End of file return code */
RC_FX = 3, /* Error return code */ RC_FX = 3, /* Error return code */
RC_INFO = 4}; /* Success with info */ RC_INFO = 4}; /* Success with info */
#endif // !RC_OK_DEFINED #endif // !RC_OK_DEFINED
/**************************************************************************/ /**************************************************************************/
/* Data types. */ /* Data types. */
/**************************************************************************/ /**************************************************************************/
enum XDBTYPE {DB_ERROR = 0, /* Unknown or wrong type */ enum XDBTYPE {DB_ERROR = 0, /* Unknown or wrong type */
DB_STRING = 1, /* Null terminated string */ DB_STRING = 1, /* Null terminated string */
DB_CHAR = 2, /* Character array */ DB_CHAR = 2, /* Character array */
DB_SHORT = 3, /* Used by some catalog functions */ DB_SHORT = 3, /* Used by some catalog functions */
DB_INT = 4, /* Long integer array */ DB_INT = 4, /* Long integer array */
DB_DOUBLE = 5, /* Double float array */ DB_DOUBLE = 5, /* Double float array */
DB_DATE = 6}; /* Datetime value array */ DB_DATE = 6}; /* Datetime value array */
/**************************************************************************/ /**************************************************************************/
/* Index of info values within the info int integer array. */ /* Index of info values within the info int integer array. */
/**************************************************************************/ /**************************************************************************/
enum INFO {INDX_RC, /* Index of PlugDB return code field */ enum INFO {INDX_RC, /* Index of PlugDB return code field */
INDX_TIME, /* Index of elapsed time in millisec */ INDX_TIME, /* Index of elapsed time in millisec */
INDX_CHG, /* Index of Language or DB changed */ INDX_CHG, /* Index of Language or DB changed */
INDX_RSAV, /* Index of Result Set availability */ INDX_RSAV, /* Index of Result Set availability */
INDX_TYPE, /* Index of returned data type field */ INDX_TYPE, /* Index of returned data type field */
INDX_LINE, /* Index of number of lines field */ INDX_LINE, /* Index of number of lines field */
INDX_LEN, /* Index of line length field */ INDX_LEN, /* Index of line length field */
INDX_SIZE, /* Index of returned data size field */ INDX_SIZE, /* Index of returned data size field */
INDX_MAX}; /* Size of info array */ INDX_MAX}; /* Size of info array */
/**************************************************************************/ /**************************************************************************/
/* Internal message types. */ /* Internal message types. */
/**************************************************************************/ /**************************************************************************/
enum MSGTYP {MST_OPEN = 10, /* Code for old connecting message */ enum MSGTYP {MST_OPEN = 10, /* Code for old connecting message */
MST_COMMAND = 11, /* Code for send command message */ MST_COMMAND = 11, /* Code for send command message */
MST_RESULT = 12, /* Code for get result message */ MST_RESULT = 12, /* Code for get result message */
MST_CLOSE = 13, /* Code for disconnecting message */ MST_CLOSE = 13, /* Code for disconnecting message */
MST_PROGRESS = 14, /* Code for progress message */ MST_PROGRESS = 14, /* Code for progress message */
MST_CANCEL = 15, /* Code for cancel message */ MST_CANCEL = 15, /* Code for cancel message */
MST_PROCESSED = 16, /* Code for already processed msg */ MST_PROCESSED = 16, /* Code for already processed msg */
MST_ERROR = 17, /* Code for get error message */ MST_ERROR = 17, /* Code for get error message */
MST_CHAR = 18, /* Code for get char value message */ MST_CHAR = 18, /* Code for get char value message */
MST_LONG = 19, /* Code for get int value message */ MST_LONG = 19, /* Code for get int value message */
MST_COLUMN = 20, /* Code for get col value message */ MST_COLUMN = 20, /* Code for get col value message */
MST_MESSAGE = 21, /* Code for get message message */ MST_MESSAGE = 21, /* Code for get message message */
MST_HEADER = 22, /* Code for get header message */ MST_HEADER = 22, /* Code for get header message */
MST_SOCKET = 23, /* Code for socket error message */ MST_SOCKET = 23, /* Code for socket error message */
MST_SHUTDOWN = 24, /* Code for shutdown message */ MST_SHUTDOWN = 24, /* Code for shutdown message */
MST_SOCKPROG = 25, /* Code for socket progress message */ MST_SOCKPROG = 25, /* Code for socket progress message */
MST_POST = 26, /* Code for post command message */ MST_POST = 26, /* Code for post command message */
MST_NEW_OPEN = 27, /* Code for new connecting message */ MST_NEW_OPEN = 27, /* Code for new connecting message */
MST_PROG_NUM = 5}; /* Num of integers in progress msg */ MST_PROG_NUM = 5}; /* Num of integers in progress msg */
/**************************************************************************/ /**************************************************************************/
/* Vendors. */ /* Vendors. */
/**************************************************************************/ /**************************************************************************/
enum VENDOR {VDR_UNKNOWN = -2, /* Not known or not connected */ enum VENDOR {VDR_UNKNOWN = -2, /* Not known or not connected */
VDR_PlugDB = -1, /* PlugDB */ VDR_PlugDB = -1, /* PlugDB */
VDR_OTHER = 0}; /* OEM */ VDR_OTHER = 0}; /* OEM */
/**************************************************************************/ /**************************************************************************/
/* Attribute keys of Result Description structure (arranged by type). */ /* Attribute keys of Result Description structure (arranged by type). */
/**************************************************************************/ /**************************************************************************/
enum CKEYS {K_ProgMsg, K_Lang, K_ActiveDB, K_Cmax}; enum CKEYS {K_ProgMsg, K_Lang, K_ActiveDB, K_Cmax};
enum LKEYS {K_NBcol, K_NBlin, K_CurPos, K_RC, K_Result, K_Elapsed, enum LKEYS {K_NBcol, K_NBlin, K_CurPos, K_RC, K_Result, K_Elapsed,
K_Continued, K_Maxsize, K_Lmax, K_Maxcol, K_Continued, K_Maxsize, K_Lmax, K_Maxcol,
K_Maxres, K_Maxlin, K_NBparm}; K_Maxres, K_Maxlin, K_NBparm};
enum NKEYS {K_Type, K_Length, K_Prec, K_DataLen, K_Nmax}; enum NKEYS {K_Type, K_Length, K_Prec, K_DataLen, K_Nmax};
/**************************************************************************/ /**************************************************************************/
/* Result description structures. */ /* Result description structures. */
/**************************************************************************/ /**************************************************************************/
typedef struct _MsgTagAttr { typedef struct _MsgTagAttr {
bool fSupplied; bool fSupplied;
char Attr[MAXMESSAGE]; char Attr[MAXMESSAGE];
} MTAG, *PMTAG; } MTAG, *PMTAG;
typedef struct _CharTagAttr { typedef struct _CharTagAttr {
bool fSupplied; bool fSupplied;
char Attr[MAXDBNAME]; char Attr[MAXDBNAME];
} CTAG, *PCTAG; } CTAG, *PCTAG;
typedef struct _LongTagAttr { typedef struct _LongTagAttr {
bool fSupplied; bool fSupplied;
int Attr; int Attr;
} LTAG, *PLTAG; } LTAG, *PLTAG;
typedef struct _ColVar { typedef struct _ColVar {
LTAG Lat[K_Nmax]; LTAG Lat[K_Nmax];
CTAG Cat; CTAG Cat;
} COLVAR, *LPCOLVAR; } COLVAR, *LPCOLVAR;
typedef struct _ResDesc { typedef struct _ResDesc {
int Maxcol; /* Max number of columns */ int Maxcol; /* Max number of columns */
int Colnum; /* Number of columns */ int Colnum; /* Number of columns */
MTAG Mat; /* Message */ MTAG Mat; /* Message */
CTAG Cat[K_Cmax]; /* Character attributes */ CTAG Cat[K_Cmax]; /* Character attributes */
LTAG Lat[K_Lmax]; /* Long int attributes */ LTAG Lat[K_Lmax]; /* Long int attributes */
COLVAR Col[1]; /* Column attributes */ COLVAR Col[1]; /* Column attributes */
} RDESC, *PRDESC; } RDESC, *PRDESC;
/**************************************************************************/ /**************************************************************************/
/* Exported PlugDB client functions in Plgcnx DLL. */ /* Exported PlugDB client functions in Plgcnx DLL. */
/**************************************************************************/ /**************************************************************************/
#if !defined(CNXFUNC) #if !defined(CNXFUNC)
#if defined(UNIX) || defined(UNIV_LINUX) #if defined(UNIX) || defined(UNIV_LINUX)
#undef __stdcall #undef __stdcall
#define __stdcall #define __stdcall
#endif #endif
#if defined(NOLIB) /* Dynamic link of plgcnx.dll */ #if defined(NOLIB) /* Dynamic link of plgcnx.dll */
#define CNXFUNC(f) (__stdcall *f) #define CNXFUNC(f) (__stdcall *f)
#else /* LIB */ /* Static link with plgcnx.lib */ #else /* LIB */ /* Static link with plgcnx.lib */
#define CNXFUNC(f) __stdcall f #define CNXFUNC(f) __stdcall f
#endif #endif
#endif #endif
#if !defined(CNXKEY) #if !defined(CNXKEY)
#define CNXKEY uint #define CNXKEY uint
#endif #endif
#if !defined(XTRN) #if !defined(XTRN)
#define XTRN #define XTRN
#endif #endif
#ifdef NOT_USED #ifdef NOT_USED
//#if !defined(NO_FUNC) //#if !defined(NO_FUNC)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
XTRN int CNXFUNC(PLGConnect) (CNXKEY *, const char *, bool); XTRN int CNXFUNC(PLGConnect) (CNXKEY *, const char *, bool);
XTRN int CNXFUNC(PLGSendCommand) (CNXKEY, const char *, void *, int, int *); XTRN int CNXFUNC(PLGSendCommand) (CNXKEY, const char *, void *, int, int *);
XTRN int CNXFUNC(PLGGetResult) (CNXKEY, void *, int, int *, bool); XTRN int CNXFUNC(PLGGetResult) (CNXKEY, void *, int, int *, bool);
XTRN int CNXFUNC(PLGDisconnect) (CNXKEY); XTRN int CNXFUNC(PLGDisconnect) (CNXKEY);
XTRN int CNXFUNC(PLGGetErrorMsg) (CNXKEY, char *, int, int *); XTRN int CNXFUNC(PLGGetErrorMsg) (CNXKEY, char *, int, int *);
XTRN bool CNXFUNC(PLGGetCharValue)(CNXKEY, char *, int, int); XTRN bool CNXFUNC(PLGGetCharValue)(CNXKEY, char *, int, int);
XTRN bool CNXFUNC(PLGGetIntValue)(CNXKEY, int *, int); XTRN bool CNXFUNC(PLGGetIntValue)(CNXKEY, int *, int);
XTRN bool CNXFUNC(PLGGetColValue) (CNXKEY, int *, int, int); XTRN bool CNXFUNC(PLGGetColValue) (CNXKEY, int *, int, int);
XTRN bool CNXFUNC(PLGGetMessage) (CNXKEY, char *, int); XTRN bool CNXFUNC(PLGGetMessage) (CNXKEY, char *, int);
XTRN bool CNXFUNC(PLGGetHeader) (CNXKEY, char *, int, int); XTRN bool CNXFUNC(PLGGetHeader) (CNXKEY, char *, int, int);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
//#endif /* !NO_FUNC */ //#endif /* !NO_FUNC */
/**************************************************************************/ /**************************************************************************/
/* Convenience function Definitions */ /* Convenience function Definitions */
/**************************************************************************/ /**************************************************************************/
#define PLGPostCommand(T,C) PLGSendCommand(T,C,NULL,0,NULL) #define PLGPostCommand(T,C) PLGSendCommand(T,C,NULL,0,NULL)
#if defined(FNCMAC) #if defined(FNCMAC)
#define PLGGetProgMsg(T,C,S) PLGGetCharValue(T,C,S,K_ProgMsg) #define PLGGetProgMsg(T,C,S) PLGGetCharValue(T,C,S,K_ProgMsg)
#define PLGGetLangID(T,C,S) PLGGetCharValue(T,C,S,K_Lang) #define PLGGetLangID(T,C,S) PLGGetCharValue(T,C,S,K_Lang)
#define PLGGetActiveDB(T,C,S) PLGGetCharValue(T,C,S,K_ActiveDB) #define PLGGetActiveDB(T,C,S) PLGGetCharValue(T,C,S,K_ActiveDB)
#define PLGGetCursorPos(T,L) PLGGetIntValue(T,L,K_CurPos) #define PLGGetCursorPos(T,L) PLGGetIntValue(T,L,K_CurPos)
#define PLGGetResultType(T,L) PLGGetIntValue(T,L,K_Result) #define PLGGetResultType(T,L) PLGGetIntValue(T,L,K_Result)
#define PLGGetNBcol(T,L) PLGGetIntValue(T,L,K_NBcol) #define PLGGetNBcol(T,L) PLGGetIntValue(T,L,K_NBcol)
#define PLGGetNBlin(T,L) PLGGetIntValue(T,L,K_NBlin) #define PLGGetNBlin(T,L) PLGGetIntValue(T,L,K_NBlin)
#define PLGGetRetCode(T,L) PLGGetIntValue(T,L,K_RC) #define PLGGetRetCode(T,L) PLGGetIntValue(T,L,K_RC)
#define PLGGetElapsed(T,L) PLGGetIntValue(T,L,K_Elapsed) #define PLGGetElapsed(T,L) PLGGetIntValue(T,L,K_Elapsed)
#define PLGGetContinued(T,L) PLGGetIntValue(T,L,K_Continued) #define PLGGetContinued(T,L) PLGGetIntValue(T,L,K_Continued)
#define PLGGetMaxSize(T,L) PLGGetIntValue(T,L,K_Maxsize) #define PLGGetMaxSize(T,L) PLGGetIntValue(T,L,K_Maxsize)
#define PLGGetLength(T,L,C) PLGGetColValue(T,L,K_Length,C) #define PLGGetLength(T,L,C) PLGGetColValue(T,L,K_Length,C)
#define PLGGetDataSize(T,L,C) PLGGetColValue(T,L,K_DataLen,C) #define PLGGetDataSize(T,L,C) PLGGetColValue(T,L,K_DataLen,C)
#define PLGGetDecimal(T,L,C) PLGGetColValue(T,L,K_Prec,C) #define PLGGetDecimal(T,L,C) PLGGetColValue(T,L,K_Prec,C)
#define PLGGetType(T,L,C) PLGGetColValue(T,L,K_Type,C) #define PLGGetType(T,L,C) PLGGetColValue(T,L,K_Type,C)
#endif /* FNCMAC */ #endif /* FNCMAC */
#endif // NOT_USED #endif // NOT_USED
#endif /* !_PLGCNX_H */ #endif /* !_PLGCNX_H */
/* ------------------------- End of 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. */ /* PLGODBC.H - This is the ODBC PlugDB driver include file. */
/***********************************************************************/ /***********************************************************************/
//efine WINVER 0x0300 // prevent Windows 3.1 feature usage //efine WINVER 0x0300 // prevent Windows 3.1 feature usage
#include <windows.h> /* Windows include file */ #include <windows.h> /* Windows include file */
#include <windowsx.h> /* Message crackers */ #include <windowsx.h> /* Message crackers */
#include <commctrl.h> #include <commctrl.h>
/***********************************************************************/ /***********************************************************************/
/* Included C-definition files required by the interface. */ /* Included C-definition files required by the interface. */
/***********************************************************************/ /***********************************************************************/
#include <string.h> /* String manipulation declares */ #include <string.h> /* String manipulation declares */
#include <stdlib.h> /* C standard library */ #include <stdlib.h> /* C standard library */
#include <ctype.h> /* C language specific types */ #include <ctype.h> /* C language specific types */
#include <stdio.h> /* FOPEN_MAX declaration */ #include <stdio.h> /* FOPEN_MAX declaration */
#include <time.h> /* time_t type declaration */ #include <time.h> /* time_t type declaration */
/***********************************************************************/ /***********************************************************************/
/* ODBC interface of PlugDB driver declares. */ /* ODBC interface of PlugDB driver declares. */
/***********************************************************************/ /***********************************************************************/
#include "podbcerr.h" /* Resource ID for PlugDB Driver */ #include "podbcerr.h" /* Resource ID for PlugDB Driver */
#if !defined(WIN32) #if !defined(WIN32)
#include "w16macro.h" #include "w16macro.h"
#endif #endif
#define ODBCVER 0x0300 #define ODBCVER 0x0300
#include "sqltypes.h" #include "sqltypes.h"
#include "sql.h" #include "sql.h"
#include "sqlext.h" #include "sqlext.h"
/***********************************************************************/ /***********************************************************************/
/* Definitions to be used in function prototypes. */ /* Definitions to be used in function prototypes. */
/* The SQL_API is to be used only for those functions exported for */ /* The SQL_API is to be used only for those functions exported for */
/* driver manager use. */ /* driver manager use. */
/* The EXPFUNC is to be used only for those functions exported but */ /* The EXPFUNC is to be used only for those functions exported but */
/* used internally, ie, dialog procs. */ /* used internally, ie, dialog procs. */
/* The INTFUNC is to be used for all other functions. */ /* The INTFUNC is to be used for all other functions. */
/***********************************************************************/ /***********************************************************************/
#if defined(WIN32) #if defined(WIN32)
#define INTFUNC __stdcall #define INTFUNC __stdcall
#define EXPFUNC __stdcall #define EXPFUNC __stdcall
#else #else
#define INTFUNC FAR PASCAL #define INTFUNC FAR PASCAL
#define EXPFUNC __export CALLBACK #define EXPFUNC __export CALLBACK
#endif #endif
/***********************************************************************/ /***********************************************************************/
/* External variables. */ /* External variables. */
/***********************************************************************/ /***********************************************************************/
extern HINSTANCE NEAR s_hModule; // DLL handle. extern HINSTANCE NEAR s_hModule; // DLL handle.
#ifdef DEBTRACE #ifdef DEBTRACE
extern FILE *debug; extern FILE *debug;
#endif #endif
extern bool clearerror; extern bool clearerror;
/***********************************************************************/ /***********************************************************************/
/* Additional values used by PlugDB for ODBC. */ /* Additional values used by PlugDB for ODBC. */
/***********************************************************************/ /***********************************************************************/
#define RES_TYPE_PREPARE 1 /* Result from SQLPrepare */ #define RES_TYPE_PREPARE 1 /* Result from SQLPrepare */
#define RES_TYPE_CATALOG 2 /* Result from catalog funcs */ #define RES_TYPE_CATALOG 2 /* Result from catalog funcs */
#define MAXPATHLEN _MAX_PATH /* Max path length */ #define MAXPATHLEN _MAX_PATH /* Max path length */
#define MAXKEYLEN 16 /* Max keyword length */ #define MAXKEYLEN 16 /* Max keyword length */
#define MAXDESC 256 /* Max description length */ #define MAXDESC 256 /* Max description length */
#define MAXDSNAME 33 /* Max data source name length */ #define MAXDSNAME 33 /* Max data source name length */
#define MAXCRNAME 18 /* Max stmt cursor name length */ #define MAXCRNAME 18 /* Max stmt cursor name length */
#define DEFMAXRES 6300 /* Default MaxRes value */ #define DEFMAXRES 6300 /* Default MaxRes value */
#define NAM_LEN 128 /* Length of col and tab names */ #define NAM_LEN 128 /* Length of col and tab names */
#define MAXRESULT 1000 /* ? */ #define MAXRESULT 1000 /* ? */
#define MAXCOMMAND 200 /* ? */ #define MAXCOMMAND 200 /* ? */
#define RC_ERROR RC_LAST-1 #define RC_ERROR RC_LAST-1
#define RC_FREE 3 #define RC_FREE 3
#if !defined(NOLIB) #if !defined(NOLIB)
#define CNXKEY uint /* C Key returned by Conn DLL */ #define CNXKEY uint /* C Key returned by Conn DLL */
#else #else
typedef struct _conninfo *PCONN; typedef struct _conninfo *PCONN;
#endif /* !NOLIB */ #endif /* !NOLIB */
#if defined(DEBTRACE) #if defined(DEBTRACE)
#define TRACE0(X) fprintf(debug,X); #define TRACE0(X) fprintf(debug,X);
#define TRACE1(X,A) fprintf(debug,X,A); #define TRACE1(X,A) fprintf(debug,X,A);
#define TRACE2(X,A,B) fprintf(debug,X,A,B); #define TRACE2(X,A,B) fprintf(debug,X,A,B);
#define TRACE3(X,A,B,C) fprintf(debug,X,A,B,C); #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 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 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); #define TRACE6(X,A,B,C,D,E,F) fprintf(debug,X,A,B,C,D,E,F);
#else /* !DEBTRACE*/ #else /* !DEBTRACE*/
#define TRACE0(X) #define TRACE0(X)
#define TRACE1(X,A) #define TRACE1(X,A)
#define TRACE2(X,A,B) #define TRACE2(X,A,B)
#define TRACE3(X,A,B,C) #define TRACE3(X,A,B,C)
#define TRACE4(X,A,B,C,D) #define TRACE4(X,A,B,C,D)
#define TRACE5(X,A,B,C,D,E) #define TRACE5(X,A,B,C,D,E)
#define TRACE6(X,A,B,C,D,E,F) #define TRACE6(X,A,B,C,D,E,F)
#endif /* !DEBTRACE*/ #endif /* !DEBTRACE*/
// This definition MUST be identical to the value in plgdbsem.h // This definition MUST be identical to the value in plgdbsem.h
#define XMOD_PREPARE 1 #define XMOD_PREPARE 1
/***********************************************************************/ /***********************************************************************/
/* ODBC.INI keywords (use extern definition in SETUP.C) */ /* ODBC.INI keywords (use extern definition in SETUP.C) */
/***********************************************************************/ /***********************************************************************/
extern char const *EMPTYSTR; /* Empty String */ extern char const *EMPTYSTR; /* Empty String */
extern char const *OPTIONON; extern char const *OPTIONON;
extern char const *OPTIONOFF; extern char const *OPTIONOFF;
extern char const *INI_SDEFAULT; /* Default data source name */ extern char const *INI_SDEFAULT; /* Default data source name */
extern char const *ODBC_INI; /* ODBC initialization file */ extern char const *ODBC_INI; /* ODBC initialization file */
extern char const *INI_KDEFL; /* Is SQL to use by default? */ extern char const *INI_KDEFL; /* Is SQL to use by default? */
extern char const *INI_KLANG; /* Application language */ extern char const *INI_KLANG; /* Application language */
extern char const *INI_KDATA; /* Data description file */ extern char const *INI_KDATA; /* Data description file */
extern char const *INI_KSVR; /* PLG Server */ extern char const *INI_KSVR; /* PLG Server */
/************************************************************************/ /************************************************************************/
/* Attribute key indexes (into an array of Attr structs, see below) */ /* Attribute key indexes (into an array of Attr structs, see below) */
/************************************************************************/ /************************************************************************/
#define KEY_DSN 0 #define KEY_DSN 0
#define KEY_DEFL 1 #define KEY_DEFL 1
#define KEY_LANG 2 #define KEY_LANG 2
#define KEY_DATA 3 #define KEY_DATA 3
#define KEY_SERVER 4 #define KEY_SERVER 4
#define LAST_KEY 5 /* Number of keys in TAG's */ #define LAST_KEY 5 /* Number of keys in TAG's */
#define KEY_DESC 5 #define KEY_DESC 5
#define KEY_TRANSNAME 6 #define KEY_TRANSNAME 6
#define KEY_TRANSOPTION 7 #define KEY_TRANSOPTION 7
#define KEY_TRANSDLL 8 #define KEY_TRANSDLL 8
#define NUMOFKEYS 9 /* Number of keys supported */ #define NUMOFKEYS 9 /* Number of keys supported */
#define FOURYEARS 126230400 // Four years in seconds (1 leap) #define FOURYEARS 126230400 // Four years in seconds (1 leap)
/***********************************************************************/ /***********************************************************************/
/* This is used when an "out of memory" error happens, because this */ /* This is used when an "out of memory" error happens, because this */
/* error recording system allocates memory when it logs an error, */ /* 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 */ /* and it would be bad if it tried to allocate memory when it got an */
/* out of memory error. */ /* out of memory error. */
/***********************************************************************/ /***********************************************************************/
typedef enum _ERRSTAT { typedef enum _ERRSTAT {
errstatOK, errstatOK,
errstatNO_MEMORY, errstatNO_MEMORY,
} ERRSTAT; } ERRSTAT;
/***********************************************************************/ /***********************************************************************/
/* Types */ /* Types */
/***********************************************************************/ /***********************************************************************/
typedef struct TagAttr { typedef struct TagAttr {
bool fSupplied; bool fSupplied;
char Attr[MAXPATHLEN]; char Attr[MAXPATHLEN];
} TAG, *PTAG; } TAG, *PTAG;
typedef struct _parscons { /* Parse constants */ typedef struct _parscons { /* Parse constants */
int Slen; /* String length */ int Slen; /* String length */
int Ntag; /* Number of entries in tags */ int Ntag; /* Number of entries in tags */
int Nlook; /* Number of entries in lookup */ int Nlook; /* Number of entries in lookup */
char Sep; /* Separator */ char Sep; /* Separator */
} PARC, *PPARC; } PARC, *PPARC;
/***********************************************************************/ /***********************************************************************/
/* Attribute string look-up table (maps keys to associated indexes) */ /* Attribute string look-up table (maps keys to associated indexes) */
/***********************************************************************/ /***********************************************************************/
typedef struct _Look { typedef struct _Look {
const char *szKey; const char *szKey;
int iKey; int iKey;
} LOOK, *PLOOK; } LOOK, *PLOOK;
/***********************************************************************/ /***********************************************************************/
/* This is info about a single error. */ /* This is info about a single error. */
/***********************************************************************/ /***********************************************************************/
typedef struct _ERRBLK *PERRBLK; typedef struct _ERRBLK *PERRBLK;
typedef struct _ERRBLK { typedef struct _ERRBLK {
PERRBLK Next; /* Next block in linked list of error blocks */ PERRBLK Next; /* Next block in linked list of error blocks */
DWORD Native_Error; /* Native error */ DWORD Native_Error; /* Native error */
DWORD Stderr; /* SQLC error code */ DWORD Stderr; /* SQLC error code */
PSZ Message; /* Points to text of message */ PSZ Message; /* Points to text of message */
} ERRBLK; } ERRBLK;
/***********************************************************************/ /***********************************************************************/
/* This is a header block, it records information about a list of */ /* This is a header block, it records information about a list of */
/* errors (ERRBLOCK's). */ /* errors (ERRBLOCK's). */
/***********************************************************************/ /***********************************************************************/
typedef struct _ERRINFO { typedef struct _ERRINFO {
PERRBLK First; /* First block in linked list of error blocks. */ PERRBLK First; /* First block in linked list of error blocks. */
PERRBLK Last; /* Last block in above list. */ PERRBLK Last; /* Last block in above list. */
ERRSTAT Errstat; /* Status for special condition out of memory */ ERRSTAT Errstat; /* Status for special condition out of memory */
} ERRINFO, *PERRINFO; } ERRINFO, *PERRINFO;
/***********************************************************************/ /***********************************************************************/
/* Environment information. */ /* Environment information. */
/***********************************************************************/ /***********************************************************************/
typedef struct _env { typedef struct _env {
ERRINFO Errinfo; /* Error list */ ERRINFO Errinfo; /* Error list */
UDWORD ODBCver; UDWORD ODBCver;
UDWORD ODBCdateformat; UDWORD ODBCdateformat;
} ENV, *PENV; } ENV, *PENV;
/***********************************************************************/ /***********************************************************************/
/* Classes used in the PlugDB ODBC Driver. */ /* Classes used in the PlugDB ODBC Driver. */
/***********************************************************************/ /***********************************************************************/
typedef class DBC *PDBC; typedef class DBC *PDBC;
typedef class STMT *PSTMT; typedef class STMT *PSTMT;
typedef class CURSOR *PCURSOR; typedef class CURSOR *PCURSOR;
typedef class RESULT *PRESULT; typedef class RESULT *PRESULT;
typedef class BINDDATA *PBIND; typedef class BINDDATA *PBIND;
typedef class BINDPARM *PBDPARM; typedef class BINDPARM *PBDPARM;
typedef class CPLGdrv *PSCDRV; typedef class CPLGdrv *PSCDRV;
typedef class DESCRIPTOR *PDSC; typedef class DESCRIPTOR *PDSC;
/***********************************************************************/ /***********************************************************************/
/* ODBC Prototypes. */ /* ODBC Prototypes. */
/***********************************************************************/ /***********************************************************************/
void PostSQLError(HENV, HDBC, HSTMT, DWORD, DWORD, PSZ); void PostSQLError(HENV, HDBC, HSTMT, DWORD, DWORD, PSZ);
void ClearSQLError(HENV, HDBC, HSTMT); void ClearSQLError(HENV, HDBC, HSTMT);
short LoadRcString(UWORD, LPSTR, short); short LoadRcString(UWORD, LPSTR, short);
RETCODE RetcodeCopyBytes(HDBC, HSTMT, UCHAR FAR *, SWORD, RETCODE RetcodeCopyBytes(HDBC, HSTMT, UCHAR FAR *, SWORD,
SWORD FAR *, UCHAR FAR *, SWORD, bool); SWORD FAR *, UCHAR FAR *, SWORD, bool);
/***********************************************************************/ /***********************************************************************/
/* Private functions used by the driver. */ /* Private functions used by the driver. */
/***********************************************************************/ /***********************************************************************/
bool EXPFUNC FDriverConnectProc(HWND, WORD, WPARAM, LPARAM); bool EXPFUNC FDriverConnectProc(HWND, WORD, WPARAM, LPARAM);
extern void ParseAttrString(PLOOK, PTAG, UCHAR FAR *, PPARC); extern void ParseAttrString(PLOOK, PTAG, UCHAR FAR *, PPARC);
RETCODE PASCAL StringCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *, RETCODE PASCAL StringCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *,
char FAR *); char FAR *);
RETCODE PASCAL ShortCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *, short); RETCODE PASCAL ShortCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *, short);
RETCODE PASCAL LongCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *, int); RETCODE PASCAL LongCopy(HDBC, HSTMT, PTR, SWORD, SWORD FAR *, int);
RETCODE PASCAL GeneralCopy(HDBC, HSTMT, PTR, SWORD, RETCODE PASCAL GeneralCopy(HDBC, HSTMT, PTR, SWORD,
SWORD FAR *, PTR, SWORD); SWORD FAR *, PTR, SWORD);
/* --------------------- End of PLGODBC.H ---------------------------- */ /* --------------------- End of PLGODBC.H ---------------------------- */

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,107 +1,107 @@
// TABMAC.H Olivier Bertrand 2011-2012 // TABMAC.H Olivier Bertrand 2011-2012
// MAC: virtual table to Get Mac Addresses via GetAdaptersInfo // MAC: virtual table to Get Mac Addresses via GetAdaptersInfo
#if defined(WIN32) #if defined(WIN32)
#include <windows.h> #include <windows.h>
#include <iphlpapi.h> #include <iphlpapi.h>
#else // !WIN32 #else // !WIN32
#error This is a WIN32 only table TYPE #error This is a WIN32 only table TYPE
#endif // !WIN32 #endif // !WIN32
/***********************************************************************/ /***********************************************************************/
/* Definitions. */ /* Definitions. */
/***********************************************************************/ /***********************************************************************/
typedef class MACDEF *PMACDEF; typedef class MACDEF *PMACDEF;
typedef class TDBMAC *PTDBMAC; typedef class TDBMAC *PTDBMAC;
typedef class MACCOL *PMACCOL; typedef class MACCOL *PMACCOL;
/* -------------------------- MAC classes ---------------------------- */ /* -------------------------- MAC classes ---------------------------- */
/***********************************************************************/ /***********************************************************************/
/* MAC: virtual table to get the list of MAC addresses. */ /* MAC: virtual table to get the list of MAC addresses. */
/***********************************************************************/ /***********************************************************************/
class DllExport MACDEF : public TABDEF { /* Logical table description */ class DllExport MACDEF : public TABDEF { /* Logical table description */
friend class TDBMAC; friend class TDBMAC;
public: public:
// Constructor // Constructor
MACDEF(void) {Pseudo = 3;} MACDEF(void) {Pseudo = 3;}
// Implementation // Implementation
virtual const char *GetType(void) {return "MAC";} virtual const char *GetType(void) {return "MAC";}
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g) {return true;} virtual bool DeleteTableFile(PGLOBAL g) {return true;}
protected: protected:
// Members // Members
}; // end of MACDEF }; // end of MACDEF
/***********************************************************************/ /***********************************************************************/
/* This is the class declaration for the MAC table. */ /* This is the class declaration for the MAC table. */
/***********************************************************************/ /***********************************************************************/
class TDBMAC : public TDBASE { class TDBMAC : public TDBASE {
friend class MACCOL; friend class MACCOL;
public: public:
// Constructor // Constructor
TDBMAC(PMACDEF tdp); TDBMAC(PMACDEF tdp);
//TDBMAC(PGLOBAL g, PTDBMAC tdbp); //TDBMAC(PGLOBAL g, PTDBMAC tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MAC;} virtual AMT GetAmType(void) {return TYPE_AM_MAC;}
//virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMAC(g, this);} //virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMAC(g, this);}
// Methods // Methods
//virtual PTDB CopyOne(PTABS t); //virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return N;} virtual int GetRecpos(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;} virtual int RowNumber(PGLOBAL g, bool b = false) {return N;}
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g) {} virtual void CloseDB(PGLOBAL g) {}
protected: protected:
// Specific routines // Specific routines
bool GetMacInfo(PGLOBAL g); bool GetMacInfo(PGLOBAL g);
bool GetFixedInfo(PGLOBAL g); bool GetFixedInfo(PGLOBAL g);
void MakeErrorMsg(PGLOBAL g, DWORD drc); void MakeErrorMsg(PGLOBAL g, DWORD drc);
// Members // Members
FIXED_INFO *FixedInfo; // Points to fixed info structure FIXED_INFO *FixedInfo; // Points to fixed info structure
PIP_ADAPTER_INFO Piaf; // Points on Adapter info array PIP_ADAPTER_INFO Piaf; // Points on Adapter info array
PIP_ADAPTER_INFO Curp; // Points on current Adapt info PIP_ADAPTER_INFO Curp; // Points on current Adapt info
PIP_ADAPTER_INFO Next; // Points on next Adapt info PIP_ADAPTER_INFO Next; // Points on next Adapt info
ULONG Buflen; // Buffer length ULONG Buflen; // Buffer length
bool Fix; // true if FixedInfo is needed bool Fix; // true if FixedInfo is needed
bool Adap; // true if Piaf is needed bool Adap; // true if Piaf is needed
int N; // Row number int N; // Row number
}; // end of class TDBMAC }; // end of class TDBMAC
/***********************************************************************/ /***********************************************************************/
/* Class MACCOL: MAC Address column. */ /* Class MACCOL: MAC Address column. */
/***********************************************************************/ /***********************************************************************/
class MACCOL : public COLBLK { class MACCOL : public COLBLK {
friend class TDBMAC; friend class TDBMAC;
public: public:
// Constructors // Constructors
MACCOL(PCOLDEF cdp, PTDB tdbp, int n); MACCOL(PCOLDEF cdp, PTDB tdbp, int n);
//MACCOL(MACCOL *colp, PTDB tdbp); // Constructor used in copy process //MACCOL(MACCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_MAC;} virtual int GetAmType(void) {return TYPE_AM_MAC;}
// Methods // Methods
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
MACCOL(void) {} // Default constructor not to be used MACCOL(void) {} // Default constructor not to be used
// Members // Members
PTDBMAC Tdbp; // Points to MAC table block PTDBMAC Tdbp; // Points to MAC table block
int Flag; // Indicates what to display int Flag; // Indicates what to display
}; // end of class MACCOL }; // 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) ***************/ /*************** Tabmul H Declares Source Code File (.H) ***************/
/* Name: TABMUL.H Version 1.4 */ /* Name: TABMUL.H Version 1.4 */
/* */ /* */
/* (C) Copyright to PlugDB Software Development 2003-2012 */ /* (C) Copyright to PlugDB Software Development 2003-2012 */
/* Author: Olivier BERTRAND */ /* Author: Olivier BERTRAND */
/* */ /* */
/* This file contains the TDBMUL and TDBDIR classes declares. */ /* This file contains the TDBMUL and TDBDIR classes declares. */
/***********************************************************************/ /***********************************************************************/
#if defined(WIN32) #if defined(WIN32)
#include <io.h> #include <io.h>
#else // !WIN32 #else // !WIN32
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#endif // !WIN32 #endif // !WIN32
//#include "osutil.h" //#include "osutil.h"
#include "block.h" #include "block.h"
typedef class TDBMUL *PTDBMUL; typedef class TDBMUL *PTDBMUL;
typedef class TDBSDR *PTDBSDR; typedef class TDBSDR *PTDBSDR;
/***********************************************************************/ /***********************************************************************/
/* This is the MUL Access Method class declaration for files that are */ /* This is the MUL Access Method class declaration for files that are */
/* physically split in multiple files having the same format. */ /* physically split in multiple files having the same format. */
/***********************************************************************/ /***********************************************************************/
class DllExport TDBMUL : public TDBASE { class DllExport TDBMUL : public TDBASE {
//friend class MULCOL; //friend class MULCOL;
public: public:
// Constructor // Constructor
TDBMUL(PTDBASE tdbp); TDBMUL(PTDBASE tdbp);
TDBMUL(PTDBMUL tdbp); TDBMUL(PTDBMUL tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return Tdbp->GetAmType();} virtual AMT GetAmType(void) {return Tdbp->GetAmType();}
virtual PTDB Duplicate(PGLOBAL g); virtual PTDB Duplicate(PGLOBAL g);
// Methods // Methods
virtual void ResetDB(void); virtual void ResetDB(void);
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
virtual bool IsSame(PTBX tp) {return tp == (PTBX)Tdbp;} virtual bool IsSame(PTBX tp) {return tp == (PTBX)Tdbp;}
virtual PSZ GetFile(PGLOBAL g) {return Tdbp->GetFile(g);} virtual PSZ GetFile(PGLOBAL g) {return Tdbp->GetFile(g);}
virtual int GetRecpos(void) {return 0;} virtual int GetRecpos(void) {return 0;}
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num); virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
bool InitFileNames(PGLOBAL g); bool InitFileNames(PGLOBAL g);
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
{strcpy(g->Message, MSG(MUL_MAKECOL_ERR)); return NULL;} {strcpy(g->Message, MSG(MUL_MAKECOL_ERR)); return NULL;}
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g); virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void); virtual int GetProgCur(void);
virtual int RowNumber(PGLOBAL g, bool b = false); virtual int RowNumber(PGLOBAL g, bool b = false);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
protected: protected:
// Members // Members
TDBASE *Tdbp; // Points to a (file) table class TDBASE *Tdbp; // Points to a (file) table class
char* *Filenames; // Points to file names char* *Filenames; // Points to file names
int Rows; // Total rows of already read files int Rows; // Total rows of already read files
int Mul; // Type of multiple file list int Mul; // Type of multiple file list
int NumFiles; // Number of physical files int NumFiles; // Number of physical files
int iFile; // Index of currently processed file int iFile; // Index of currently processed file
}; // end of class TDBMUL }; // end of class TDBMUL
/***********************************************************************/ /***********************************************************************/
/* Directory listing table. */ /* Directory listing table. */
/***********************************************************************/ /***********************************************************************/
class DllExport DIRDEF : public TABDEF { /* Directory listing table */ class DllExport DIRDEF : public TABDEF { /* Directory listing table */
friend class CATALOG; friend class CATALOG;
friend class TDBDIR; friend class TDBDIR;
public: public:
// Constructor // Constructor
DIRDEF(void) {Fn = NULL; Incl = false; Huge = false;} DIRDEF(void) {Fn = NULL; Incl = false; Huge = false;}
// Implementation // Implementation
virtual const char *GetType(void) {return "DIR";} virtual const char *GetType(void) {return "DIR";}
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
protected: protected:
// Members // Members
PSZ Fn; /* Path/Name of file search */ PSZ Fn; /* Path/Name of file search */
bool Incl; /* true to include sub-directories */ bool Incl; /* true to include sub-directories */
bool Huge; /* true if files can be larger than 2GB */ bool Huge; /* true if files can be larger than 2GB */
}; // end of DIRDEF }; // end of DIRDEF
/***********************************************************************/ /***********************************************************************/
/* This is the DIR Access Method class declaration for tables that */ /* This is the DIR Access Method class declaration for tables that */
/* represent a directory listing. The pathname is given at the create */ /* represent a directory listing. The pathname is given at the create */
/* time and can contain wildcard characters in the file name, and the */ /* time and can contain wildcard characters in the file name, and the */
/* (virtual) table is populated when it is in use. */ /* (virtual) table is populated when it is in use. */
/***********************************************************************/ /***********************************************************************/
class TDBDIR : public TDBASE { class TDBDIR : public TDBASE {
friend class DIRCOL; friend class DIRCOL;
public: public:
// Constructor // Constructor
TDBDIR(PDIRDEF tdp); TDBDIR(PDIRDEF tdp);
TDBDIR(PTDBDIR tdbp); TDBDIR(PTDBDIR tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DIR;} virtual AMT GetAmType(void) {return TYPE_AM_DIR;}
virtual PTDB Duplicate(PGLOBAL g) virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBDIR(this);} {return (PTDB)new(g) TDBDIR(this);}
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return iFile;} virtual int GetRecpos(void) {return iFile;}
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);} virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);}
virtual int GetProgCur(void) {return iFile;} virtual int GetProgCur(void) {return iFile;}
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
protected: protected:
char *Path(PGLOBAL g); char *Path(PGLOBAL g);
// Members // Members
PSZ To_File; // Points to file search pathname PSZ To_File; // Points to file search pathname
int iFile; // Index of currently retrieved file int iFile; // Index of currently retrieved file
#if defined(WIN32) #if defined(WIN32)
_finddata_t FileData; // Find data structure _finddata_t FileData; // Find data structure
int Hsearch; // Search handle int Hsearch; // Search handle
char Drive[_MAX_DRIVE]; // Drive name char Drive[_MAX_DRIVE]; // Drive name
#else // !WIN32 #else // !WIN32
struct stat Fileinfo; // File info structure struct stat Fileinfo; // File info structure
struct dirent *Entry; // Point to directory entry structure struct dirent *Entry; // Point to directory entry structure
DIR *Dir; // To searched directory structure DIR *Dir; // To searched directory structure
bool Done; // true when _splipath is done bool Done; // true when _splipath is done
char Pattern[_MAX_FNAME+_MAX_EXT]; char Pattern[_MAX_FNAME+_MAX_EXT];
#endif // !WIN32 #endif // !WIN32
char Fpath[_MAX_PATH]; // Absolute file search pattern char Fpath[_MAX_PATH]; // Absolute file search pattern
char Direc[_MAX_DIR]; // Search path char Direc[_MAX_DIR]; // Search path
char Fname[_MAX_FNAME]; // File name char Fname[_MAX_FNAME]; // File name
char Ftype[_MAX_EXT]; // File extention char Ftype[_MAX_EXT]; // File extention
}; // end of class TDBDIR }; // end of class TDBDIR
/***********************************************************************/ /***********************************************************************/
/* This is the DIR Access Method class declaration for tables that */ /* This is the DIR Access Method class declaration for tables that */
/* represent a directory listing. The pathname is given at the create */ /* represent a directory listing. The pathname is given at the create */
/* time and can contain wildcard characters in the file name, and the */ /* time and can contain wildcard characters in the file name, and the */
/* (virtual) table is populated when it is in use. In addition, this */ /* (virtual) table is populated when it is in use. In addition, this */
/* class also includes files of included sub-directories. */ /* class also includes files of included sub-directories. */
/***********************************************************************/ /***********************************************************************/
class TDBSDR : public TDBDIR { class TDBSDR : public TDBDIR {
friend class DIRCOL; friend class DIRCOL;
public: public:
// Constructors // Constructors
TDBSDR(PDIRDEF tdp) : TDBDIR(tdp) {Sub = NULL;} TDBSDR(PDIRDEF tdp) : TDBDIR(tdp) {Sub = NULL;}
TDBSDR(PTDBSDR tdbp); TDBSDR(PTDBSDR tdbp);
// Implementation // Implementation
virtual PTDB Duplicate(PGLOBAL g) virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBSDR(this);} {return (PTDB)new(g) TDBSDR(this);}
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
// Database routines // Database routines
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);} virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);}
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
//virtual void CloseDB(PGLOBAL g); //virtual void CloseDB(PGLOBAL g);
protected: protected:
int FindInDir(PGLOBAL g); int FindInDir(PGLOBAL g);
typedef struct _Sub_Dir { typedef struct _Sub_Dir {
struct _Sub_Dir *Next; struct _Sub_Dir *Next;
struct _Sub_Dir *Prev; struct _Sub_Dir *Prev;
#if defined(WIN32) #if defined(WIN32)
int H; // Search handle int H; // Search handle
#else // !WIN32 #else // !WIN32
DIR *D; DIR *D;
#endif // !WIN32 #endif // !WIN32
size_t Len; // Initial directory name length size_t Len; // Initial directory name length
} SUBDIR, *PSUBDIR; } SUBDIR, *PSUBDIR;
// Members // Members
PSUBDIR Sub; // To current Subdir block PSUBDIR Sub; // To current Subdir block
}; // end of class TDBSDR }; // end of class TDBSDR
/***********************************************************************/ /***********************************************************************/
/* Class DIRCOL: DIR access method column descriptor. */ /* Class DIRCOL: DIR access method column descriptor. */
/* This A.M. is used for tables populated by DIR file name list. */ /* This A.M. is used for tables populated by DIR file name list. */
/***********************************************************************/ /***********************************************************************/
class DIRCOL : public COLBLK { class DIRCOL : public COLBLK {
public: public:
// Constructors // Constructors
DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "DIR"); DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "DIR");
DIRCOL(DIRCOL *colp, PTDB tdbp); // Constructor used in copy process DIRCOL(DIRCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_DIR;} virtual int GetAmType(void) {return TYPE_AM_DIR;}
// Methods // Methods
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
// Default constructor not to be used // Default constructor not to be used
DIRCOL(void) {} DIRCOL(void) {}
// Members // Members
int N; // Column number int N; // Column number
}; // end of class DIRCOL }; // 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 // TDBMYSQL.H Olivier Bertrand 2007-2012
#include "myconn.h" // MySQL connection declares #include "myconn.h" // MySQL connection declares
typedef class MYSQLDEF *PMYDEF; typedef class MYSQLDEF *PMYDEF;
typedef class TDBMYSQL *PTDBMY; typedef class TDBMYSQL *PTDBMY;
typedef class MYSQLC *PMYC; typedef class MYSQLC *PMYC;
typedef class MYSQLCOL *PMYCOL; typedef class MYSQLCOL *PMYCOL;
/* ------------------------- MYSQL classes --------------------------- */ /* ------------------------- MYSQL classes --------------------------- */
/***********************************************************************/ /***********************************************************************/
/* MYSQL: table type that are MySQL tables. */ /* MYSQL: table type that are MySQL tables. */
/* Using embedded MySQL library (or optionally calling a MySQL server)*/ /* Using embedded MySQL library (or optionally calling a MySQL server)*/
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* MYSQL table. */ /* MYSQL table. */
/***********************************************************************/ /***********************************************************************/
class MYSQLDEF : public TABDEF {/* Logical table description */ class MYSQLDEF : public TABDEF {/* Logical table description */
friend class TDBMYSQL; friend class TDBMYSQL;
public: public:
// Constructor // Constructor
MYSQLDEF(void); MYSQLDEF(void);
// Implementation // Implementation
virtual const char *GetType(void) {return "MYSQL";} virtual const char *GetType(void) {return "MYSQL";}
inline PSZ GetHostname(void) {return Hostname;}; inline PSZ GetHostname(void) {return Hostname;};
inline PSZ GetDatabase(void) {return Database;}; inline PSZ GetDatabase(void) {return Database;};
inline PSZ GetTabname(void) {return Tabname;} inline PSZ GetTabname(void) {return Tabname;}
inline PSZ GetUsername(void) {return Username;}; inline PSZ GetUsername(void) {return Username;};
inline PSZ GetPassword(void) {return Password;}; inline PSZ GetPassword(void) {return Password;};
inline int GetPortnumber(void) {return Portnumber;} inline int GetPortnumber(void) {return Portnumber;}
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
protected: protected:
// Members // Members
PSZ Hostname; /* Host machine to use */ PSZ Hostname; /* Host machine to use */
PSZ Database; /* Database to be used by server */ PSZ Database; /* Database to be used by server */
PSZ Tabname; /* External table name */ PSZ Tabname; /* External table name */
PSZ Username; /* User logon name */ PSZ Username; /* User logon name */
PSZ Password; /* Password logon info */ PSZ Password; /* Password logon info */
int Portnumber; /* MySQL port number (0 = default) */ int Portnumber; /* MySQL port number (0 = default) */
bool Bind; /* Use prepared statement on insert */ bool Bind; /* Use prepared statement on insert */
bool Delayed; /* Delayed insert */ bool Delayed; /* Delayed insert */
}; // end of MYSQLDEF }; // end of MYSQLDEF
/***********************************************************************/ /***********************************************************************/
/* This is the class declaration for the MYSQL table. */ /* This is the class declaration for the MYSQL table. */
/***********************************************************************/ /***********************************************************************/
class TDBMYSQL : public TDBASE { class TDBMYSQL : public TDBASE {
friend class MYSQLCOL; friend class MYSQLCOL;
public: public:
// Constructor // Constructor
TDBMYSQL(PMYDEF tdp); TDBMYSQL(PMYDEF tdp);
TDBMYSQL(PGLOBAL g, PTDBMY tdbp); TDBMYSQL(PGLOBAL g, PTDBMY tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MYSQL;} virtual AMT GetAmType(void) {return TYPE_AM_MYSQL;}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(g, this);} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBMYSQL(g, this);}
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
virtual int GetAffectedRows(void) {return AftRows;} virtual int GetAffectedRows(void) {return AftRows;}
virtual int GetRecpos(void) {return N;} virtual int GetRecpos(void) {return N;}
virtual int GetProgMax(PGLOBAL g); virtual int GetProgMax(PGLOBAL g);
virtual void ResetDB(void) {N = 0;} virtual void ResetDB(void) {N = 0;}
virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual int RowNumber(PGLOBAL g, bool b = FALSE);
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
protected: protected:
// Internal functions // Internal functions
bool MakeSelect(PGLOBAL g); bool MakeSelect(PGLOBAL g);
bool MakeInsert(PGLOBAL g); bool MakeInsert(PGLOBAL g);
//bool MakeUpdate(PGLOBAL g); //bool MakeUpdate(PGLOBAL g);
//bool MakeDelete(PGLOBAL g); //bool MakeDelete(PGLOBAL g);
int BindColumns(PGLOBAL g); int BindColumns(PGLOBAL g);
// Members // Members
MYSQLC Myc; // MySQL connection class MYSQLC Myc; // MySQL connection class
MYSQL_BIND *Bind; // To the MySQL bind structure array MYSQL_BIND *Bind; // To the MySQL bind structure array
char *Host; // Host machine to use char *Host; // Host machine to use
char *User; // User logon info char *User; // User logon info
char *Pwd; // Password logon info char *Pwd; // Password logon info
char *Database; // Database to be used by server char *Database; // Database to be used by server
char *Tabname; // External table name char *Tabname; // External table name
char *Query; // Points to SQL query char *Query; // Points to SQL query
char *Qbuf; // Used for not prepared insert char *Qbuf; // Used for not prepared insert
bool Fetched; // True when fetch was done bool Fetched; // True when fetch was done
bool Prep; // Use prepared statement on insert bool Prep; // Use prepared statement on insert
bool Delayed; // Use delayed insert bool Delayed; // Use delayed insert
int m_Rc; // Return code from command int m_Rc; // Return code from command
int AftRows; // The number of affected rows int AftRows; // The number of affected rows
int N; // The current table index int N; // The current table index
int Port; // MySQL port number (0 = default) int Port; // MySQL port number (0 = default)
int Nparm; // The number of statement parameters int Nparm; // The number of statement parameters
}; // end of class TDBMYSQL }; // end of class TDBMYSQL
/***********************************************************************/ /***********************************************************************/
/* Class MYSQLCOL: MySQL table column. */ /* Class MYSQLCOL: MySQL table column. */
/***********************************************************************/ /***********************************************************************/
class MYSQLCOL : public COLBLK { class MYSQLCOL : public COLBLK {
friend class TDBMYSQL; friend class TDBMYSQL;
public: public:
// Constructors // Constructors
MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "MYSQL"); MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "MYSQL");
MYSQLCOL(MYSQLCOL *colp, PTDB tdbp); // Constructor used in copy process MYSQLCOL(MYSQLCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_MYSQL;} virtual int GetAmType(void) {return TYPE_AM_MYSQL;}
void InitBind(PGLOBAL g); void InitBind(PGLOBAL g);
// Methods // Methods
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
protected: protected:
// Default constructor not to be used // Default constructor not to be used
MYSQLCOL(void) {} MYSQLCOL(void) {}
// Members // Members
MYSQL_BIND *Bind; // This column bind structure pointer MYSQL_BIND *Bind; // This column bind structure pointer
PVAL To_Val; // To value used for Update/Insert PVAL To_Val; // To value used for Update/Insert
unsigned long Slen; // Bind string lengh unsigned long Slen; // Bind string lengh
int Rank; // Rank (position) number in the query int Rank; // Rank (position) number in the query
}; // end of class MYSQLCOL }; // 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) **************/ /*************** Tabodbc H Declares Source Code File (.H) **************/
/* Name: TABODBC.H Version 1.5 */ /* Name: TABODBC.H Version 1.5 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2000-2013 */
/* */ /* */
/* This file contains the TDBODBC classes declares. */ /* This file contains the TDBODBC classes declares. */
/***********************************************************************/ /***********************************************************************/
#include "colblk.h" #include "colblk.h"
#include "resource.h" #include "resource.h"
typedef class ODBCDEF *PODEF; typedef class ODBCDEF *PODEF;
typedef class TDBODBC *PTDBODBC; typedef class TDBODBC *PTDBODBC;
typedef class ODBCCOL *PODBCCOL; typedef class ODBCCOL *PODBCCOL;
typedef class TDBOIF *PTDBOIF; typedef class TDBOIF *PTDBOIF;
typedef class OIFCOL *POIFCOL; typedef class OIFCOL *POIFCOL;
typedef class TDBSRC *PTDBSRC; typedef class TDBSRC *PTDBSRC;
/***********************************************************************/ /***********************************************************************/
/* ODBC table. */ /* ODBC table. */
/***********************************************************************/ /***********************************************************************/
class DllExport ODBCDEF : public TABDEF { /* Logical table description */ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
public: public:
// Constructor // Constructor
ODBCDEF(void); ODBCDEF(void);
// Implementation // Implementation
virtual const char *GetType(void) {return "ODBC";} virtual const char *GetType(void) {return "ODBC";}
PSZ GetConnect(void) {return Connect;} PSZ GetConnect(void) {return Connect;}
PSZ GetTabname(void) {return Tabname;} PSZ GetTabname(void) {return Tabname;}
PSZ GetTabowner(void) {return Tabowner;} PSZ GetTabowner(void) {return Tabowner;}
PSZ GetTabqual(void) {return Tabqual;} PSZ GetTabqual(void) {return Tabqual;}
PSZ GetQchar(void) {return (Qchar && *Qchar) ? Qchar : NULL;} PSZ GetQchar(void) {return (Qchar && *Qchar) ? Qchar : NULL;}
int GetCatver(void) {return Catver;} int GetCatver(void) {return Catver;}
int GetOptions(void) {return Options;} int GetOptions(void) {return Options;}
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
protected: protected:
// Members // Members
PSZ Connect; /* ODBC connection string */ PSZ Connect; /* ODBC connection string */
PSZ Tabname; /* External table name */ PSZ Tabname; /* External table name */
PSZ Tabowner; /* External table owner */ PSZ Tabowner; /* External table owner */
PSZ Tabqual; /* External table qualifier */ PSZ Tabqual; /* External table qualifier */
PSZ Qchar; /* Identifier quoting character */ PSZ Qchar; /* Identifier quoting character */
PSZ Info; /* Information value */ PSZ Info; /* Information value */
int Catver; /* ODBC version for catalog functions */ int Catver; /* ODBC version for catalog functions */
int Options; /* Open connection options */ int Options; /* Open connection options */
}; // end of ODBCDEF }; // end of ODBCDEF
#if !defined(NODBC) #if !defined(NODBC)
#include "odbconn.h" #include "odbconn.h"
/***********************************************************************/ /***********************************************************************/
/* This is the ODBC Access Method class declaration for files from */ /* This is the ODBC Access Method class declaration for files from */
/* other DB drivers to be accessed via ODBC. */ /* other DB drivers to be accessed via ODBC. */
/***********************************************************************/ /***********************************************************************/
class TDBODBC : public TDBASE { class TDBODBC : public TDBASE {
friend class ODBCCOL; friend class ODBCCOL;
friend class ODBConn; friend class ODBConn;
public: public:
// Constructor // Constructor
TDBODBC(PODEF tdp = NULL); TDBODBC(PODEF tdp = NULL);
TDBODBC(PTDBODBC tdbp); TDBODBC(PTDBODBC tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ODBC;} virtual AMT GetAmType(void) {return TYPE_AM_ODBC;}
virtual PTDB Duplicate(PGLOBAL g) virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBODBC(this);} {return (PTDB)new(g) TDBODBC(this);}
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void); virtual int GetRecpos(void);
virtual PSZ GetFile(PGLOBAL g); virtual PSZ GetFile(PGLOBAL g);
virtual void SetFile(PGLOBAL g, PSZ fn); virtual void SetFile(PGLOBAL g, PSZ fn);
virtual void ResetSize(void); virtual void ResetSize(void);
virtual int GetAffectedRows(void) {return AftRows;} virtual int GetAffectedRows(void) {return AftRows;}
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetProgMax(PGLOBAL g); virtual int GetProgMax(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
protected: protected:
// Internal functions // Internal functions
int Decode(char *utf, char *buf, size_t n); int Decode(char *utf, char *buf, size_t n);
char *MakeSQL(PGLOBAL g, bool cnt); char *MakeSQL(PGLOBAL g, bool cnt);
//bool MakeUpdate(PGLOBAL g, PSELECT selist); //bool MakeUpdate(PGLOBAL g, PSELECT selist);
//bool MakeInsert(PGLOBAL g); //bool MakeInsert(PGLOBAL g);
//bool MakeDelete(PGLOBAL g); //bool MakeDelete(PGLOBAL g);
//bool MakeFilter(PGLOBAL g, bool c); //bool MakeFilter(PGLOBAL g, bool c);
//bool BindParameters(PGLOBAL g); //bool BindParameters(PGLOBAL g);
// Members // Members
ODBConn *Ocp; // Points to an ODBC connection class ODBConn *Ocp; // Points to an ODBC connection class
ODBCCOL *Cnp; // Points to count(*) column ODBCCOL *Cnp; // Points to count(*) column
char *Connect; // Points to connection string char *Connect; // Points to connection string
char *TableName; // Points to ODBC table name char *TableName; // Points to ODBC table name
char *Owner; // Points to ODBC table Owner char *Owner; // Points to ODBC table Owner
char *Qualifier; // Points to ODBC table Qualifier char *Qualifier; // Points to ODBC table Qualifier
char *Query; // Points to SQL statement char *Query; // Points to SQL statement
char *Count; // Points to count(*) SQL statement char *Count; // Points to count(*) SQL statement
//char *Where; // Points to local where clause //char *Where; // Points to local where clause
char *Quote; // The identifier quoting character char *Quote; // The identifier quoting character
char *MulConn; // Used for multiple ODBC tables char *MulConn; // Used for multiple ODBC tables
char *DBQ; // The address part of Connect string char *DBQ; // The address part of Connect string
int Options; // Connect options int Options; // Connect options
int Fpos; // Position of last read record int Fpos; // Position of last read record
int AftRows; // The number of affected rows int AftRows; // The number of affected rows
int Rows; // Rowset size int Rows; // Rowset size
int Catver; // Catalog ODBC version int Catver; // Catalog ODBC version
int CurNum; // Current buffer line number int CurNum; // Current buffer line number
int Rbuf; // Number of lines read in buffer int Rbuf; // Number of lines read in buffer
int BufSize; // Size of connect string buffer int BufSize; // Size of connect string buffer
int Nparm; // The number of statement parameters int Nparm; // The number of statement parameters
}; // end of class TDBODBC }; // end of class TDBODBC
/***********************************************************************/ /***********************************************************************/
/* Class ODBCCOL: DOS access method column descriptor. */ /* Class ODBCCOL: DOS access method column descriptor. */
/* This A.M. is used for ODBC tables. */ /* This A.M. is used for ODBC tables. */
/***********************************************************************/ /***********************************************************************/
class ODBCCOL : public COLBLK { class ODBCCOL : public COLBLK {
friend class TDBODBC; friend class TDBODBC;
public: public:
// Constructors // Constructors
ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "ODBC"); ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "ODBC");
ODBCCOL(ODBCCOL *colp, PTDB tdbp); // Constructor used in copy process ODBCCOL(ODBCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_ODBC;} virtual int GetAmType(void) {return TYPE_AM_ODBC;}
SQLLEN *GetStrLen(void) {return StrLen;} SQLLEN *GetStrLen(void) {return StrLen;}
int GetRank(void) {return Rank;} int GetRank(void) {return Rank;}
// PVBLK GetBlkp(void) {return Blkp;} // PVBLK GetBlkp(void) {return Blkp;}
// Methods // Methods
//virtual bool CheckLocal(PTDB tdbp); //virtual bool CheckLocal(PTDB tdbp);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
void AllocateBuffers(PGLOBAL g, int rows); void AllocateBuffers(PGLOBAL g, int rows);
void *GetBuffer(DWORD rows); void *GetBuffer(DWORD rows);
SWORD GetBuflen(void); SWORD GetBuflen(void);
// void Print(PGLOBAL g, FILE *, uint); // void Print(PGLOBAL g, FILE *, uint);
protected: protected:
// Constructor used by GetMaxSize // Constructor used by GetMaxSize
ODBCCOL(void); ODBCCOL(void);
// Members // Members
TIMESTAMP_STRUCT *Sqlbuf; // To get SQL_TIMESTAMP's TIMESTAMP_STRUCT *Sqlbuf; // To get SQL_TIMESTAMP's
void *Bufp; // To extended buffer void *Bufp; // To extended buffer
PVBLK Blkp; // To Value Block PVBLK Blkp; // To Value Block
//char F_Date[12]; // Internal Date format //char F_Date[12]; // Internal Date format
PVAL To_Val; // To value used for Insert PVAL To_Val; // To value used for Insert
SQLLEN *StrLen; // As returned by ODBC SQLLEN *StrLen; // As returned by ODBC
SQLLEN Slen; // Used with Fetch SQLLEN Slen; // Used with Fetch
int Rank; // Rank (position) number in the query int Rank; // Rank (position) number in the query
}; // end of class ODBCCOL }; // end of class ODBCCOL
/***********************************************************************/ /***********************************************************************/
/* This is the base class declaration for the ODBC info tables. */ /* This is the base class declaration for the ODBC info tables. */
/***********************************************************************/ /***********************************************************************/
class TDBOIF : public TDBASE { class TDBOIF : public TDBASE {
friend class OIFCOL; friend class OIFCOL;
public: public:
// Constructor // Constructor
TDBOIF(PODEF tdp); TDBOIF(PODEF tdp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ODBC;} virtual AMT GetAmType(void) {return TYPE_AM_ODBC;}
// Methods // Methods
virtual int GetRecpos(void) {return N;} virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;} virtual int GetProgCur(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;} virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
protected: protected:
// Specific routines // Specific routines
virtual bool Initialize(PGLOBAL g) = 0; virtual bool Initialize(PGLOBAL g) = 0;
bool InitCol(PGLOBAL g); bool InitCol(PGLOBAL g);
// Members // Members
PQRYRES Qrp; // Result set PQRYRES Qrp;
int ID; // Base of Column names int ID; // Base of Column names
int NC; // Number of valid flags int NC; // Number of valid flags
int N; // Row number int N; // Row number
bool Init; bool Init;
}; // end of class TDBOIF }; // end of class TDBOIF
/***********************************************************************/ /***********************************************************************/
/* Class OIFCOL: ODBC info column. */ /* Class OIFCOL: ODBC info column. */
/***********************************************************************/ /***********************************************************************/
class OIFCOL : public COLBLK { class OIFCOL : public COLBLK {
friend class TDBOIF; friend class TDBOIF;
public: public:
// Constructors // Constructors
OIFCOL(PCOLDEF cdp, PTDB tdbp, int n); OIFCOL(PCOLDEF cdp, PTDB tdbp, int n);
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_ODBC;} virtual int GetAmType(void) {return TYPE_AM_ODBC;}
// Methods // Methods
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
OIFCOL(void) {} // Default constructor not to be used OIFCOL(void) {} // Default constructor not to be used
// Members // Members
PTDBOIF Tdbp; // Points to ODBC table block PTDBOIF Tdbp; // Points to ODBC table block
PCOLRES Crp; // The column data array PCOLRES Crp; // The column data array
int Flag; int Flag;
}; // end of class OIFCOL }; // end of class OIFCOL
/***********************************************************************/ /***********************************************************************/
/* This is the class declaration for the Data Sources info table. */ /* This is the class declaration for the Data Sources info table. */
/***********************************************************************/ /***********************************************************************/
class TDBSRC : public TDBOIF { class TDBSRC : public TDBOIF {
public: public:
// Constructor // Constructor
TDBSRC(PODEF tdp) : TDBOIF(tdp) {ID = IDS_DSRC; NC = 2;} TDBSRC(PODEF tdp) : TDBOIF(tdp) {ID = IDS_DSRC; NC = 2;}
protected: protected:
// Specific routines // Specific routines
virtual bool Initialize(PGLOBAL g); virtual bool Initialize(PGLOBAL g);
}; // end of class TDBSRC }; // end of class TDBSRC
/***********************************************************************/ /***********************************************************************/
/* This is the class declaration for the columns info table. */ /* This is the class declaration for the columns info table. */
/***********************************************************************/ /***********************************************************************/
class TDBOCL : public TDBOIF { class TDBOCL : public TDBOIF {
public: public:
// Constructor // Constructor
TDBOCL(PODEF tdp); TDBOCL(PODEF tdp);
protected: protected:
// Specific routines // Specific routines
virtual bool Initialize(PGLOBAL g); virtual bool Initialize(PGLOBAL g);
// Members // Members
char *Dsn; // Points to connection string char *Dsn; // Points to connection string
char *Tabn; // Points to ODBC table name char *Tabn; // Points to ODBC table name
}; // end of class TDBOCL }; // end of class TDBOCL
#endif // !NODBC #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) **************/ /************** TabPivot H Declares Source Code File (.H) **************/
/* Name: TABPIVOT.H Version 1.3 */ /* Name: TABPIVOT.H Version 1.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the PIVOT classes declares. */ /* This file contains the PIVOT classes declares. */
/***********************************************************************/ /***********************************************************************/
typedef class TDBPIVOT *PTDBPIVOT; typedef class TDBPIVOT *PTDBPIVOT;
typedef class FNCCOL *PFNCCOL; typedef class FNCCOL *PFNCCOL;
typedef class SRCCOL *PSRCCOL; typedef class SRCCOL *PSRCCOL;
typedef class TDBQRS *PTDBQRS; typedef class TDBQRS *PTDBQRS;
typedef class QRSCOL *PQRSCOL; typedef class QRSCOL *PQRSCOL;
/* -------------------------- PIVOT classes -------------------------- */ /* -------------------------- PIVOT classes -------------------------- */
/***********************************************************************/ /***********************************************************************/
/* PIVOT: table that provides a view of a source table where the */ /* PIVOT: table that provides a view of a source table where the */
/* pivot column is expended in as many columns as there are distinct */ /* pivot column is expended in as many columns as there are distinct */
/* values in it and containing the function value matching other cols.*/ /* values in it and containing the function value matching other cols.*/
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* PIVOT table. */ /* PIVOT table. */
/***********************************************************************/ /***********************************************************************/
//ass DllExport PIVOTDEF : public TABDEF {/* Logical table description */ //ass DllExport PIVOTDEF : public TABDEF {/* Logical table description */
class PIVOTDEF : public TABDEF { /* Logical table description */ class PIVOTDEF : public TABDEF { /* Logical table description */
friend class TDBPIVOT; friend class TDBPIVOT;
public: public:
// Constructor // Constructor
PIVOTDEF(void) {Pseudo = 3; PIVOTDEF(void) {Pseudo = 3;
Tabname = Tabsrc = Picol = Fncol = Function = NULL;} Tabname = Tabsrc = Picol = Fncol = Function = NULL;}
// Implementation // Implementation
virtual const char *GetType(void) {return "PIVOT";} virtual const char *GetType(void) {return "PIVOT";}
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
protected: protected:
// Members // Members
char *Host; /* Host machine to use */ char *Host; /* Host machine to use */
char *User; /* User logon info */ char *User; /* User logon info */
char *Pwd; /* Password logon info */ char *Pwd; /* Password logon info */
char *DB; /* Database to be used by server */ char *DB; /* Database to be used by server */
char *Tabname; /* Name of source table */ char *Tabname; /* Name of source table */
char *Tabsrc; /* The source table SQL description */ char *Tabsrc; /* The source table SQL description */
char *Picol; /* The pivot column */ char *Picol; /* The pivot column */
char *Fncol; /* The function column */ char *Fncol; /* The function column */
char *Function; /* The function applying to group by */ char *Function; /* The function applying to group by */
bool GBdone; /* True if tabname as group by format */ bool GBdone; /* True if tabname as group by format */
int Port; /* MySQL port number */ int Port; /* MySQL port number */
}; // end of PIVOTDEF }; // end of PIVOTDEF
/***********************************************************************/ /***********************************************************************/
/* This is the class declaration for the PIVOT table. */ /* This is the class declaration for the PIVOT table. */
/***********************************************************************/ /***********************************************************************/
//ass DllExport TDBPIVOT : public TDBASE, public CSORT { //ass DllExport TDBPIVOT : public TDBASE, public CSORT {
class TDBPIVOT : public TDBASE, public CSORT { class TDBPIVOT : public TDBASE, public CSORT {
friend class FNCCOL; friend class FNCCOL;
friend class SRCCOL; friend class SRCCOL;
public: public:
// Constructor // Constructor
TDBPIVOT(PPIVOTDEF tdp); TDBPIVOT(PPIVOTDEF tdp);
//TDBPIVOT(PTDBPIVOT tdbp); //TDBPIVOT(PTDBPIVOT tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_PIVOT;} virtual AMT GetAmType(void) {return TYPE_AM_PIVOT;}
//virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBPIVOT(this);} //virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBPIVOT(this);}
// void SetTdbp(PTDB tdbp) {Tdbp = tdbp;} // void SetTdbp(PTDB tdbp) {Tdbp = tdbp;}
// Methods // Methods
//virtual PTDB CopyOne(PTABS t); //virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return N;} virtual int GetRecpos(void) {return N;}
virtual void ResetDB(void) {N = 0;} virtual void ResetDB(void) {N = 0;}
virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual int RowNumber(PGLOBAL g, bool b = FALSE);
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
// The sorting function // The sorting function
virtual int Qcompare(int *, int *); virtual int Qcompare(int *, int *);
protected: protected:
PQRYRES GetSourceTable(PGLOBAL g); PQRYRES GetSourceTable(PGLOBAL g);
int MakePivotColumns(PGLOBAL g); int MakePivotColumns(PGLOBAL g);
bool UpdateTableFields(PGLOBAL g, int n); bool UpdateTableFields(PGLOBAL g, int n);
// Members // Members
MYSQLC Myc; // MySQL connection class MYSQLC Myc; // MySQL connection class
PTDBQRS Tqrp; // To the source table result PTDBQRS Tqrp; // To the source table result
char *Host; // Host machine to use char *Host; // Host machine to use
char *User; // User logon info char *User; // User logon info
char *Pwd; // Password logon info char *Pwd; // Password logon info
char *Database; // Database to be used by server char *Database; // Database to be used by server
PQRYRES Qryp; // Points to Query result block PQRYRES Qryp; // Points to Query result block
char *Tabname; // Name of source table char *Tabname; // Name of source table
char *Tabsrc; // SQL of source table char *Tabsrc; // SQL of source table
char *Picol; // Pivot column name char *Picol; // Pivot column name
char *Fncol; // Function column name char *Fncol; // Function column name
char *Function; // The function applying to group by char *Function; // The function applying to group by
PQRSCOL Fcolp; // To the function column in source PQRSCOL Fcolp; // To the function column in source
PQRSCOL Xcolp; // To the pivot column in source PQRSCOL Xcolp; // To the pivot column in source
PCOLRES Xresp; // To the pivot result column PCOLRES Xresp; // To the pivot result column
//PCOLRES To_Sort; // Saved Qryp To_Sort pointer //PCOLRES To_Sort; // Saved Qryp To_Sort pointer
PVBLK Rblkp; // The value block of the pivot column PVBLK Rblkp; // The value block of the pivot column
bool GBdone; // True when subtable is "Group by" bool GBdone; // True when subtable is "Group by"
int Mult; // Multiplication factor int Mult; // Multiplication factor
int Ncol; // The number of generated columns int Ncol; // The number of generated columns
int N; // The current table index int N; // The current table index
int M; // The occurence rank int M; // The occurence rank
int Port; // MySQL port number int Port; // MySQL port number
BYTE FileStatus; // 0: First 1: Rows 2: End-of-File BYTE FileStatus; // 0: First 1: Rows 2: End-of-File
BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip
}; // end of class TDBPIVOT }; // end of class TDBPIVOT
/***********************************************************************/ /***********************************************************************/
/* Class FNCCOL: for the multiple generated column. */ /* Class FNCCOL: for the multiple generated column. */
/***********************************************************************/ /***********************************************************************/
class FNCCOL : public COLBLK { class FNCCOL : public COLBLK {
friend class TDBPIVOT; friend class TDBPIVOT;
public: public:
// Constructor // Constructor
FNCCOL(PCOL colp, PTDBPIVOT tdbp); FNCCOL(PCOL colp, PTDBPIVOT tdbp);
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_FNC;} virtual int GetAmType(void) {return TYPE_AM_FNC;}
// Methods // Methods
virtual void Reset(void) {} virtual void Reset(void) {}
bool InitColumn(PGLOBAL g, PVAL valp); bool InitColumn(PGLOBAL g, PVAL valp);
protected: protected:
// Member // Member
PVAL Hval; // The original value used to generate the header PVAL Hval; // The original value used to generate the header
}; // end of class FNCCOL }; // end of class FNCCOL
/***********************************************************************/ /***********************************************************************/
/* Class SRCCOL: for other source columns. */ /* Class SRCCOL: for other source columns. */
/***********************************************************************/ /***********************************************************************/
class SRCCOL : public COLBLK { class SRCCOL : public COLBLK {
friend class TDBPIVOT; friend class TDBPIVOT;
public: public:
// Constructors // Constructors
//SRCCOL(PCOLDEF cdp, PTDBPIVOT tdbp, int n); //SRCCOL(PCOLDEF cdp, PTDBPIVOT tdbp, int n);
SRCCOL(PCOL cp, PTDBPIVOT tdbp, int n); SRCCOL(PCOL cp, PTDBPIVOT tdbp, int n);
//SRCCOL(SRCCOL *colp, PTDB tdbp); // Constructor used in copy process //SRCCOL(SRCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_SRC;} virtual int GetAmType(void) {return TYPE_AM_SRC;}
// Methods // Methods
virtual void Reset(void) {} virtual void Reset(void) {}
void SetColumn(void); void SetColumn(void);
bool Init(PGLOBAL g, PTDBPIVOT tdbp); bool Init(PGLOBAL g, PTDBPIVOT tdbp);
bool CompareColumn(void); bool CompareColumn(void);
protected: protected:
// Default constructor not to be used // Default constructor not to be used
SRCCOL(void) {} SRCCOL(void) {}
// Members // Members
PQRSCOL Colp; PQRSCOL Colp;
PVAL Cnval; PVAL Cnval;
}; // end of class SRCCOL }; // end of class SRCCOL
/***********************************************************************/ /***********************************************************************/
/* TDBQRS: This is the Access Method class declaration for the Query */ /* TDBQRS: This is the Access Method class declaration for the Query */
/* Result stored in memory in the current work area (volatil). */ /* Result stored in memory in the current work area (volatil). */
/***********************************************************************/ /***********************************************************************/
class DllExport TDBQRS : public TDBASE { class DllExport TDBQRS : public TDBASE {
friend class QRSCOL; friend class QRSCOL;
public: public:
// Constructor // Constructor
TDBQRS(PQRYRES qrp) : TDBASE() {Qrp = qrp; CurPos = 0;} TDBQRS(PQRYRES qrp) : TDBASE() {Qrp = qrp; CurPos = 0;}
TDBQRS(PTDBQRS tdbp); TDBQRS(PTDBQRS tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_QRS;} virtual AMT GetAmType(void) {return TYPE_AM_QRS;}
virtual PTDB Duplicate(PGLOBAL g) virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBQRS(this);} {return (PTDB)new(g) TDBQRS(this);}
PQRYRES GetQrp(void) {return Qrp;} PQRYRES GetQrp(void) {return Qrp;}
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
virtual int RowNumber(PGLOBAL g, BOOL b = FALSE); virtual int RowNumber(PGLOBAL g, BOOL b = FALSE);
virtual int GetRecpos(void); virtual int GetRecpos(void);
//virtual PCATLG GetCat(void); //virtual PCATLG GetCat(void);
//virtual PSZ GetPath(void); //virtual PSZ GetPath(void);
virtual int GetBadLines(void) {return Qrp->BadLines;} virtual int GetBadLines(void) {return Qrp->BadLines;}
// Database routines // Database routines
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num); virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
private: private:
TDBQRS(void) : TDBASE() {} // Standard constructor not to be used TDBQRS(void) : TDBASE() {} // Standard constructor not to be used
protected: protected:
// Members // Members
PQRYRES Qrp; // Points to Query Result block PQRYRES Qrp; // Points to Query Result block
int CurPos; // Current line position int CurPos; // Current line position
}; // end of class TDBQRS }; // end of class TDBQRS
/***********************************************************************/ /***********************************************************************/
/* Class QRSCOL: QRS access method column descriptor. */ /* Class QRSCOL: QRS access method column descriptor. */
/***********************************************************************/ /***********************************************************************/
class DllExport QRSCOL : public COLBLK { class DllExport QRSCOL : public COLBLK {
friend class TDBQRS; friend class TDBQRS;
public: public:
// Constructors // Constructors
QRSCOL(PGLOBAL g, PCOLRES crp, PTDB tdbp, PCOL cprec, int i); QRSCOL(PGLOBAL g, PCOLRES crp, PTDB tdbp, PCOL cprec, int i);
QRSCOL(QRSCOL *colp, PTDB tdbp); // Constructor used in copy process QRSCOL(QRSCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_QRS;} virtual int GetAmType(void) {return TYPE_AM_QRS;}
PCOLRES GetCrp(void) {return Crp;} PCOLRES GetCrp(void) {return Crp;}
void *GetQrsData(void) {return Crp->Kdata;} void *GetQrsData(void) {return Crp->Kdata;}
// Methods // Methods
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, UINT); virtual void Print(PGLOBAL g, FILE *, UINT);
protected: protected:
QRSCOL(void) {} // Default constructor not to be used QRSCOL(void) {} // Default constructor not to be used
// Members // Members
PCOLRES Crp; PCOLRES Crp;
}; // end of class QRSCOL }; // 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) ***************/
/*************** TabSys H Declares Source Code File (.H) ***************/ /* Name: TABSYS.H Version 2.2 */
/* Name: TABSYS.H Version 2.2 */ /* */
/* */ /* (C) Copyright to the author Olivier BERTRAND 2004-2013 */
/* (C) Copyright to the author Olivier BERTRAND 2004-2013 */ /* */
/* */ /* This file contains the XDB system tables classes declares. */
/* This file contains the XDB system tables classes declares. */ /***********************************************************************/
/***********************************************************************/ typedef class INIDEF *PINIDEF;
typedef class INIDEF *PINIDEF; typedef class TDBINI *PTDBINI;
typedef class TDBINI *PTDBINI; typedef class INICOL *PINICOL;
typedef class INICOL *PINICOL; typedef class TDBXIN *PTDBXIN;
typedef class TDBXIN *PTDBXIN; typedef class XINCOL *PXINCOL;
typedef class XINCOL *PXINCOL;
/* --------------------------- INI classes --------------------------- */
/* --------------------------- INI classes --------------------------- */
/***********************************************************************/
/***********************************************************************/ /* INI, XDB and XCL tables. */
/* INI, XDB and XCL tables. */ /***********************************************************************/
/***********************************************************************/ class DllExport INIDEF : public TABDEF { /* INI table description */
class DllExport INIDEF : public TABDEF { /* INI table description */ friend class TDBINI;
friend class TDBINI; friend class TDBXIN;
friend class TDBXIN; friend class TDBXTB;
friend class TDBXTB; friend class TDBRTB;
friend class TDBRTB; friend class TDBXCL;
friend class TDBXCL; public:
public: // Constructor
// Constructor INIDEF(void);
INIDEF(void);
// Implementation
// Implementation virtual const char *GetType(void) {return "INI";}
virtual const char *GetType(void) {return "INI";}
// Methods
// Methods virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual bool DeleteTableFile(PGLOBAL g);
virtual bool DeleteTableFile(PGLOBAL g);
protected:
protected: // Members
// Members char *Fn; /* Path/Name of corresponding file */
char *Fn; /* Path/Name of corresponding file */ char *Xname; /* The eventual table name */
char *Xname; /* The eventual table name */ char Subtype; /* I: INI, T: Table, C: Column */
char Subtype; /* I: INI, T: Table, C: Column */ char Layout; /* R: Row, C: Column */
char Layout; /* R: Row, C: Column */ int Ln; /* Length of section list buffer */
int Ln; /* Length of section list buffer */ }; // end of INIDEF
}; // end of INIDEF
/***********************************************************************/
/***********************************************************************/ /* This is the class declaration for the INI tables. */
/* This is the class declaration for the INI tables. */ /* These are tables represented by a INI like file. */
/* These are tables represented by a INI like file. */ /***********************************************************************/
/***********************************************************************/ class TDBINI : public TDBASE {
class TDBINI : public TDBASE { friend class INICOL;
friend class INICOL; public:
public: // Constructor
// Constructor TDBINI(PINIDEF tdp);
TDBINI(PINIDEF tdp); TDBINI(PTDBINI tdbp);
TDBINI(PTDBINI tdbp);
// Implementation
// Implementation virtual AMT GetAmType(void) {return TYPE_AM_INI;}
virtual AMT GetAmType(void) {return TYPE_AM_INI;} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);}
// Methods
// Methods virtual PTDB CopyOne(PTABS t);
virtual PTDB CopyOne(PTABS t); virtual int GetRecpos(void) {return N;}
virtual int GetRecpos(void) {return N;} virtual int GetProgCur(void) {return N;}
virtual int GetProgCur(void) {return N;} virtual int GetAffectedRows(void) {return 0;}
virtual int GetAffectedRows(void) {return 0;} virtual PSZ GetFile(PGLOBAL g) {return Ifile;}
virtual PSZ GetFile(PGLOBAL g) {return Ifile;} virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;}
virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;} virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;}
virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;} virtual void ResetSize(void) {MaxSize = -1; Seclist = NULL;}
virtual void ResetSize(void) {MaxSize = -1; Seclist = NULL;} virtual int RowNumber(PGLOBAL g, bool b = false) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;} char *GetSeclist(PGLOBAL g);
char *GetSeclist(PGLOBAL g);
// Database routines
// Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual int GetMaxSize(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int DeleteDB(PGLOBAL g, int irc);
virtual int DeleteDB(PGLOBAL g, int irc); virtual void CloseDB(PGLOBAL g);
virtual void CloseDB(PGLOBAL g);
protected:
protected: // Members
// Members char *Ifile; // The INI file
char *Ifile; // The INI file char *Seclist; // The section list
char *Seclist; // The section list char *Section; // The current section
char *Section; // The current section int Seclen; // Length of seclist buffer
int Seclen; // Length of seclist buffer int N; // The current section index
int N; // The current section index }; // end of class TDBINI
}; // end of class TDBINI
/***********************************************************************/
/***********************************************************************/ /* Class INICOL: XDB table access method column descriptor. */
/* Class INICOL: XDB table access method column descriptor. */ /***********************************************************************/
/***********************************************************************/ class INICOL : public COLBLK {
class INICOL : public COLBLK { public:
public: // Constructors
// Constructors INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI");
INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI"); INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process
INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
// Implementation virtual int GetAmType(void) {return TYPE_AM_INI;}
virtual int GetAmType(void) {return TYPE_AM_INI;} virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
// Methods
// Methods virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual void ReadColumn(PGLOBAL g);
virtual void ReadColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void AllocBuf(PGLOBAL g);
virtual void AllocBuf(PGLOBAL g);
protected:
protected: // Default constructor not to be used
// Default constructor not to be used INICOL(void) {}
INICOL(void) {}
// Members
// Members char *Valbuf; // To the key value buffer
char *Valbuf; // To the key value buffer int Flag; // Tells what set in value
int Flag; // Tells what set in value int Long; // Buffer length
int Long; // Buffer length PVAL To_Val; // To value used for Update/Insert
PVAL To_Val; // To value used for Update/Insert }; // end of class INICOL
}; // end of class INICOL
/* --------------------------- XINI class ---------------------------- */
/* --------------------------- XINI class ---------------------------- */
/***********************************************************************/
/***********************************************************************/ /* This is the class declaration for the XINI tables. */
/* This is the class declaration for the XINI tables. */ /* These are tables represented by a INI like file */
/* These are tables represented by a INI like file */ /* having 3 columns Section, Key, and Value. */
/* having 3 columns Section, Key, and Value. */ /***********************************************************************/
/***********************************************************************/ class TDBXIN : public TDBINI {
class TDBXIN : public TDBINI { friend class XINCOL;
friend class XINCOL; public:
public: // Constructor
// Constructor TDBXIN(PINIDEF tdp);
TDBXIN(PINIDEF tdp); TDBXIN(PTDBXIN tdbp);
TDBXIN(PTDBXIN tdbp);
// Implementation
// Implementation virtual AMT GetAmType(void) {return TYPE_AM_INI;}
virtual AMT GetAmType(void) {return TYPE_AM_INI;} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);}
// Methods
// Methods virtual PTDB CopyOne(PTABS t);
virtual PTDB CopyOne(PTABS t); virtual int GetRecpos(void);
virtual int GetRecpos(void); virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual bool SetRecpos(PGLOBAL g, int recpos); virtual void ResetDB(void)
virtual void ResetDB(void) {Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;}
{Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;} char *GetKeylist(PGLOBAL g, char *sec);
char *GetKeylist(PGLOBAL g, char *sec);
// Database routines
// Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual int GetMaxSize(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int DeleteDB(PGLOBAL g, int irc);
virtual int DeleteDB(PGLOBAL g, int irc);
protected:
protected: // Members
// Members char *Keylist; // The key list
char *Keylist; // The key list char *Keycur; // The current key
char *Keycur; // The current key int Keylen; // Length of keylist buffer
int Keylen; // Length of keylist buffer short Oldsec; // Last current section
short Oldsec; // Last current section }; // end of class TDBXIN
}; // end of class TDBXIN
/***********************************************************************/
/***********************************************************************/ /* Class XINCOL: XIN table access method column descriptor. */
/* Class XINCOL: XIN table access method column descriptor. */ /***********************************************************************/
/***********************************************************************/ class XINCOL : public INICOL {
class XINCOL : public INICOL { public:
public: // Constructors
// Constructors XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI");
XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI"); XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process
XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
// Implementation
// Methods
// Methods virtual void ReadColumn(PGLOBAL g);
virtual void ReadColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
protected:
protected: // Default constructor not to be used
// Default constructor not to be used XINCOL(void) {}
XINCOL(void) {}
// Members
// Members }; // end of class XINICOL
}; // 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) ***************/ /*************** TabTbl H Declares Source Code File (.H) ***************/
/* Name: TABTBL.H Version 1.2 */ /* Name: TABTBL.H Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2008-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2008-2012 */
/* */ /* */
/* This file contains the TDBTBL classes declares. */ /* This file contains the TDBTBL classes declares. */
/***********************************************************************/ /***********************************************************************/
//#include "osutil.h" //#include "osutil.h"
#include "block.h" #include "block.h"
#include "colblk.h" #include "colblk.h"
typedef class TBLDEF *PTBLDEF; typedef class TBLDEF *PTBLDEF;
typedef class TDBTBL *PTDBTBL; typedef class TDBTBL *PTDBTBL;
typedef class TBLCOL *PTBLCOL; typedef class TBLCOL *PTBLCOL;
/***********************************************************************/ /***********************************************************************/
/* Defines the structure used for multiple tables. */ /* Defines the structure used for multiple tables. */
/***********************************************************************/ /***********************************************************************/
typedef struct _tablist *PTBL; typedef struct _tablist *PTBL;
typedef struct _tablist { typedef struct _tablist {
PTBL Next; PTBL Next;
char *Name; char *Name;
char *DB; char *DB;
} TBLIST; } TBLIST;
/***********************************************************************/ /***********************************************************************/
/* TBL table. */ /* TBL table. */
/***********************************************************************/ /***********************************************************************/
class DllExport TBLDEF : public TABDEF { /* Logical table description */ class DllExport TBLDEF : public TABDEF { /* Logical table description */
friend class TDBTBL; friend class TDBTBL;
public: public:
// Constructor // Constructor
TBLDEF(void); TBLDEF(void);
// Implementation // Implementation
virtual const char *GetType(void) {return "TBL";} virtual const char *GetType(void) {return "TBL";}
PTBL GetTables(void) {return To_Tables;} PTBL GetTables(void) {return To_Tables;}
//int GetNtables(void) {return Ntables;} //int GetNtables(void) {return Ntables;}
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
protected: protected:
// Members // Members
PTBL To_Tables; /* To the list of tables */ PTBL To_Tables; /* To the list of tables */
bool Accept; /* TRUE if bad tables are accepted */ bool Accept; /* TRUE if bad tables are accepted */
int Maxerr; /* Maximum number of bad tables */ int Maxerr; /* Maximum number of bad tables */
int Ntables; /* Number of tables */ int Ntables; /* Number of tables */
}; // end of TBLDEF }; // end of TBLDEF
/***********************************************************************/ /***********************************************************************/
/* This is the TBL Access Method class declaration. */ /* This is the TBL Access Method class declaration. */
/***********************************************************************/ /***********************************************************************/
class DllExport TDBTBL : public TDBASE { class DllExport TDBTBL : public TDBASE {
friend class TBLCOL; friend class TBLCOL;
friend class TBTBLK; friend class TBTBLK;
friend class TDBPLG; friend class TDBPLG;
public: public:
// Constructor // Constructor
TDBTBL(PTBLDEF tdp = NULL); TDBTBL(PTBLDEF tdp = NULL);
//TDBTBL(PTDBTBL tdbp); //TDBTBL(PTDBTBL tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_TBL;} virtual AMT GetAmType(void) {return TYPE_AM_TBL;}
//virtual PTDB Duplicate(PGLOBAL g) //virtual PTDB Duplicate(PGLOBAL g)
// {return (PTDB)new(g) TDBTBL(this);} // {return (PTDB)new(g) TDBTBL(this);}
// Methods // Methods
virtual void ResetDB(void); virtual void ResetDB(void);
//virtual PTABLE GetTablist(void) {return (PSZ)Tablist;} //virtual PTABLE GetTablist(void) {return (PSZ)Tablist;}
//virtual PTDB CopyOne(PTABS t); //virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return Rows;} virtual int GetRecpos(void) {return Rows;}
virtual int GetBadLines(void) {return (int)Nbf;} virtual int GetBadLines(void) {return (int)Nbf;}
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual int GetProgMax(PGLOBAL g); virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void); virtual int GetProgCur(void);
virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
protected: protected:
// Internal functions // Internal functions
PTDB GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp); PTDB GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp);
bool InitTableList(PGLOBAL g); bool InitTableList(PGLOBAL g);
bool TestFil(PGLOBAL g, PFIL filp, PTBL tblp); bool TestFil(PGLOBAL g, PFIL filp, PTBL tblp);
// Members // Members
PTABLE Tablist; // Points to the table list PTABLE Tablist; // Points to the table list
PTABLE CurTable; // Points to the current table PTABLE CurTable; // Points to the current table
PTDBASE Tdbp; // Current table PTDB PTDBASE Tdbp; // Current table PTDB
bool Accept; // TRUE if bad tables are accepted bool Accept; // TRUE if bad tables are accepted
int Maxerr; // Maximum number of bad tables int Maxerr; // Maximum number of bad tables
int Nbf; // Number of bad connections int Nbf; // Number of bad connections
int Rows; // Used for RowID int Rows; // Used for RowID
int Crp; // Used for CurPos int Crp; // Used for CurPos
}; // end of class TDBTBL }; // end of class TDBTBL
/***********************************************************************/ /***********************************************************************/
/* Class TBLCOL: TBL access method column descriptor. */ /* Class TBLCOL: TBL access method column descriptor. */
/* This A.M. is used for TBL tables. */ /* This A.M. is used for TBL tables. */
/***********************************************************************/ /***********************************************************************/
class DllExport TBLCOL : public COLBLK { class DllExport TBLCOL : public COLBLK {
friend class TDBTBL; friend class TDBTBL;
public: public:
// Constructors // Constructors
TBLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "TBL"); TBLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "TBL");
TBLCOL(TBLCOL *colp, PTDB tdbp); // Constructor used in copy process TBLCOL(TBLCOL *colp, PTDB tdbp); // Constructor used in copy process
//TBLCOL(SPCBLK *colp, PTDB tdbp); // Constructor used for pseudo columns //TBLCOL(SPCBLK *colp, PTDB tdbp); // Constructor used for pseudo columns
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_TBL;} virtual int GetAmType(void) {return TYPE_AM_TBL;}
// Methods // Methods
virtual bool IsSpecial(void) {return Pseudo;} virtual bool IsSpecial(void) {return Pseudo;}
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
//virtual void WriteColumn(PGLOBAL g); //virtual void WriteColumn(PGLOBAL g);
// void Print(PGLOBAL g, FILE *, UINT); // void Print(PGLOBAL g, FILE *, UINT);
bool Init(PGLOBAL g); bool Init(PGLOBAL g);
protected: protected:
// Default constructor not to be used // Default constructor not to be used
TBLCOL(void) {} TBLCOL(void) {}
// Members // Members
PCOL Colp; // Points to matching table column PCOL Colp; // Points to matching table column
PVAL To_Val; // To the matching column value PVAL To_Val; // To the matching column value
bool Pseudo; // TRUE for special columns bool Pseudo; // TRUE for special columns
int Colnum; // Used when retrieving columns by number int Colnum; // Used when retrieving columns by number
}; // end of class TBLCOL }; // end of class TBLCOL
/***********************************************************************/ /***********************************************************************/
/* Class TBTBLK: TDBPLG TABID special column descriptor. */ /* Class TBTBLK: TDBPLG TABID special column descriptor. */
/***********************************************************************/ /***********************************************************************/
class TBTBLK : public TIDBLK { class TBTBLK : public TIDBLK {
public: public:
// The constructor must restore Value because XOBJECT has a void // The constructor must restore Value because XOBJECT has a void
// constructor called by default that set Value to NULL // constructor called by default that set Value to NULL
TBTBLK(PVAL valp) {Value = valp;} TBTBLK(PVAL valp) {Value = valp;}
// Methods // Methods
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
// Fake operator new used to change TIDBLK into SDTBLK // Fake operator new used to change TIDBLK into SDTBLK
void * operator new(size_t size, TIDBLK *sp) {return sp;} void * operator new(size_t size, TIDBLK *sp) {return sp;}
#if !defined(__BORLANDC__) #if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator // Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, TIDBLK*) {} void operator delete(void *, TIDBLK*) {}
#endif #endif
protected: protected:
// Must not have additional members // Must not have additional members
}; // end of class TBTBLK }; // 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) ***************/ /*************** TabVct H Declares Source Code File (.H) ***************/
/* Name: TABVCT.H Version 3.4 */ /* Name: TABVCT.H Version 3.4 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2011 */ /* (C) Copyright to the author Olivier BERTRAND 1999-2011 */
/* */ /* */
/* This file contains the TDBVCT class declares. */ /* This file contains the TDBVCT class declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __TABVCT__ #ifndef __TABVCT__
#define __TABVCT__ #define __TABVCT__
#include "tabfix.h" #include "tabfix.h"
#if defined(UNIX) #if defined(UNIX)
//#include <string.h.SUNWCCh> //#include <string.h.SUNWCCh>
#endif #endif
typedef class TDBVCT *PTDBVCT; typedef class TDBVCT *PTDBVCT;
typedef class VCTCOL *PVCTCOL; typedef class VCTCOL *PVCTCOL;
/***********************************************************************/ /***********************************************************************/
/* VCT table. */ /* VCT table. */
/***********************************************************************/ /***********************************************************************/
class DllExport VCTDEF : public DOSDEF { /* Logical table description */ class DllExport VCTDEF : public DOSDEF { /* Logical table description */
friend class VCTFAM; friend class VCTFAM;
friend class VECFAM; friend class VECFAM;
friend class VMPFAM; friend class VMPFAM;
public: public:
// Constructor // Constructor
VCTDEF(void) {Split = Estimate = Header = 0;} VCTDEF(void) {Split = Estimate = Header = 0;}
// Implementation // Implementation
virtual const char *GetType(void) {return "VCT";} virtual const char *GetType(void) {return "VCT";}
int GetEstimate(void) {return Estimate;} int GetEstimate(void) {return Estimate;}
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode); virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected: protected:
// Specific file erase routine for vertical tables // Specific file erase routine for vertical tables
virtual bool Erase(char *filename); virtual bool Erase(char *filename);
int MakeFnPattern(char *fpat); int MakeFnPattern(char *fpat);
// Members // Members
int Split; /* Columns in separate files */ int Split; /* Columns in separate files */
int Estimate; /* Estimated maximum size of table */ int Estimate; /* Estimated maximum size of table */
int Header; /* 0: no, 1: separate, 2: in data file */ int Header; /* 0: no, 1: separate, 2: in data file */
}; // end of VCTDEF }; // end of VCTDEF
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in blocked vector format. In each block containing "Elements" */ /* in blocked vector format. In each block containing "Elements" */
/* records, values of each columns are consecutively stored (vector). */ /* records, values of each columns are consecutively stored (vector). */
/***********************************************************************/ /***********************************************************************/
class DllExport TDBVCT : public TDBFIX { class DllExport TDBVCT : public TDBFIX {
friend class VCTCOL; friend class VCTCOL;
friend class VCTFAM; friend class VCTFAM;
friend class VCMFAM; friend class VCMFAM;
friend class VECFAM; friend class VECFAM;
friend class VMPFAM; friend class VMPFAM;
public: public:
// Constructors // Constructors
TDBVCT(PVCTDEF tdp, PTXF txfp); TDBVCT(PVCTDEF tdp, PTXF txfp);
TDBVCT(PGLOBAL g, PTDBVCT tdbp); TDBVCT(PGLOBAL g, PTDBVCT tdbp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VCT;} virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
virtual PTDB Duplicate(PGLOBAL g) virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBVCT(g, this);} {return (PTDB)new(g) TDBVCT(g, this);}
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual void CloseDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
protected: protected:
// Members // Members
}; // end of class TDBVCT }; // end of class TDBVCT
/***********************************************************************/ /***********************************************************************/
/* Class VCTCOL: VCT access method column descriptor. */ /* Class VCTCOL: VCT access method column descriptor. */
/* This A.M. is used for file having column wise organization. */ /* This A.M. is used for file having column wise organization. */
/***********************************************************************/ /***********************************************************************/
class DllExport VCTCOL : public DOSCOL { class DllExport VCTCOL : public DOSCOL {
friend class TDBVCT; friend class TDBVCT;
friend class VCTFAM; friend class VCTFAM;
friend class VCMFAM; friend class VCMFAM;
friend class VECFAM; friend class VECFAM;
friend class VMPFAM; friend class VMPFAM;
friend class BGVFAM; friend class BGVFAM;
public: public:
// Constructors // Constructors
VCTCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); VCTCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
VCTCOL(VCTCOL *colp, PTDB tdbp); // Constructor used in copy process VCTCOL(VCTCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_VCT;} virtual int GetAmType(void) {return TYPE_AM_VCT;}
// Methods // Methods
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetOk(void); virtual void SetOk(void);
protected: protected:
virtual void ReadBlock(PGLOBAL g); virtual void ReadBlock(PGLOBAL g);
virtual void WriteBlock(PGLOBAL g); virtual void WriteBlock(PGLOBAL g);
VCTCOL(void) {} // Default constructor not to be used VCTCOL(void) {} // Default constructor not to be used
// Members // Members
PVBLK Blk; // Block buffer PVBLK Blk; // Block buffer
int Clen; // Internal length in table int Clen; // Internal length in table
int ColBlk; // Block pointed by column int ColBlk; // Block pointed by column
int ColPos; // Last position read int ColPos; // Last position read
int Modif; // Number of modified lines in block int Modif; // Number of modified lines in block
}; // end of class VCTCOL }; // end of class VCTCOL
#endif // __TABVCT__ #endif // __TABVCT__

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@@ -1,80 +1,80 @@
/* Copyright (C) Olivier Bertrand 2004 - 2011 /* Copyright (C) Olivier Bertrand 2004 - 2011
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/** @file user_connect.h /** @file user_connect.h
@brief @brief
Declaration of the user_connect class. Declaration of the user_connect class.
@note @note
@see @see
/sql/handler.h and /storage/connect/user_connect.cc /sql/handler.h and /storage/connect/user_connect.cc
*/ */
#ifdef USE_PRAGMA_INTERFACE #ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */ #pragma interface /* gcc class implementation */
#endif #endif
#if defined(WIN32) #if defined(WIN32)
#include <sys\timeb.h> #include <sys\timeb.h>
#else #else
#include <sys/timeb.h> #include <sys/timeb.h>
#endif // UBUNTU #endif // UBUNTU
/*****************************************************************************/ /*****************************************************************************/
/* This is the global structure having all CONNECT information. */ /* This is the global structure having all CONNECT information. */
/*****************************************************************************/ /*****************************************************************************/
//typedef struct _global *PGLOBAL; //typedef struct _global *PGLOBAL;
typedef class user_connect *PCONNECT; typedef class user_connect *PCONNECT;
typedef class ha_connect *PHC; typedef class ha_connect *PHC;
static int connect_done_func(void *); static int connect_done_func(void *);
/*****************************************************************************/ /*****************************************************************************/
/* The CONNECT users. There should be one by connected users. */ /* The CONNECT users. There should be one by connected users. */
/*****************************************************************************/ /*****************************************************************************/
class user_connect class user_connect
{ {
friend class ha_connect; friend class ha_connect;
friend int connect_done_func(void *); friend int connect_done_func(void *);
public: public:
// Constructor // Constructor
user_connect(THD *thd, const char *dbn); user_connect(THD *thd, const char *dbn);
// Destructor // Destructor
virtual ~user_connect(); virtual ~user_connect();
// Implementation // Implementation
bool user_init(ha_connect *hc); bool user_init(ha_connect *hc);
bool CheckCleanup(void); bool CheckCleanup(void);
bool CheckQueryID(void) {return thdp->query_id > last_query_id;} bool CheckQueryID(void) {return thdp->query_id > last_query_id;}
bool CheckQuery(query_id_t vid) {return last_query_id > vid;} bool CheckQuery(query_id_t vid) {return last_query_id > vid;}
protected: protected:
// Members // Members
static PCONNECT to_users; // To the chain of users static PCONNECT to_users; // To the chain of users
THD *thdp; // To the user thread THD *thdp; // To the user thread
PCONNECT next; // Next user in chain PCONNECT next; // Next user in chain
PCONNECT previous; // Previous user in chain PCONNECT previous; // Previous user in chain
PGLOBAL g; // The common handle to CONNECT PGLOBAL g; // The common handle to CONNECT
//char dbname[32]; // The DBCONNECT database //char dbname[32]; // The DBCONNECT database
PTDBDOS tabp; // The table used on create PTDBDOS tabp; // The table used on create
query_id_t last_query_id; // the latest user query id query_id_t last_query_id; // the latest user query id
int count; // if used by several handlers int count; // if used by several handlers
// Statistics // Statistics
ulong nrd, fnd, nfd; ulong nrd, fnd, nfd;
ulonglong tb1; ulonglong tb1;
}; // end of user_connect class definition }; // 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) ***************/ /*************** Valblk H Declares Source Code File (.H) ***************/
/* Name: VALBLK.H Version 1.7 */ /* Name: VALBLK.H Version 1.7 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* */ /* */
/* This file contains the VALBLK and derived classes declares. */ /* This file contains the VALBLK and derived classes declares. */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/* assert.h is header required when using the assert function. */ /* assert.h is header required when using the assert function. */
/* block.h is header containing Block global declarations. */ /* block.h is header containing Block global declarations. */
/***********************************************************************/ /***********************************************************************/
#ifndef __VALBLK__H__ #ifndef __VALBLK__H__
#define __VALBLK__H__ #define __VALBLK__H__
#include "value.h" #include "value.h"
/***********************************************************************/ /***********************************************************************/
/* Utility used to allocate value blocks. */ /* Utility used to allocate value blocks. */
/***********************************************************************/ /***********************************************************************/
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, bool, bool); DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, bool, bool);
/***********************************************************************/ /***********************************************************************/
/* Class VALBLK represent a base class for variable blocks. */ /* Class VALBLK represent a base class for variable blocks. */
/***********************************************************************/ /***********************************************************************/
class VALBLK : public BLOCK { class VALBLK : public BLOCK {
//friend void SemColData(PGLOBAL g, PSEM semp); //friend void SemColData(PGLOBAL g, PSEM semp);
public: public:
// Constructors // Constructors
VALBLK(void *mp, int type, int nval) VALBLK(void *mp, int type, int nval)
{Blkp = mp; Type = type; Nval = nval; Check = true;} {Blkp = mp; Type = type; Nval = nval; Check = true;}
// Implementation // Implementation
int GetNval(void) {return Nval;} int GetNval(void) {return Nval;}
void SetNval(int n) {Nval = n;} void SetNval(int n) {Nval = n;}
void *GetValPointer(void) {return Blkp;} void *GetValPointer(void) {return Blkp;}
void SetValPointer(void *mp) {Blkp = mp;} void SetValPointer(void *mp) {Blkp = mp;}
int GetType(void) {return Type;} int GetType(void) {return Type;}
void SetCheck(bool b) {Check = b;} void SetCheck(bool b) {Check = b;}
virtual void Init(PGLOBAL g, bool check) = 0; virtual void Init(PGLOBAL g, bool check) = 0;
virtual int GetVlen(void) = 0; virtual int GetVlen(void) = 0;
virtual PSZ GetCharValue(int n); virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) = 0; virtual short GetShortValue(int n) = 0;
virtual int GetIntValue(int n) = 0; virtual int GetIntValue(int n) = 0;
virtual longlong GetBigintValue(int n) = 0; virtual longlong GetBigintValue(int n) = 0;
virtual double GetFloatValue(int n) = 0; virtual double GetFloatValue(int n) = 0;
virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;} virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;}
virtual void Reset(int n) = 0; virtual void Reset(int n) = 0;
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
virtual void SetPrec(int p) {} virtual void SetPrec(int p) {}
virtual bool IsCi(void) {return false;} virtual bool IsCi(void) {return false;}
// Methods // Methods
virtual void SetValue(short sval, int n) {assert(false);} virtual void SetValue(short sval, int n) {assert(false);}
virtual void SetValue(int lval, 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(longlong lval, int n) {assert(false);}
virtual void SetValue(PSZ sp, int n) {assert(false);} virtual void SetValue(PSZ sp, int n) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0; virtual void SetValue(PVAL valp, int n) = 0;
virtual void SetMin(PVAL valp, int n) = 0; virtual void SetMin(PVAL valp, int n) = 0;
virtual void SetMax(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 SetValue(PVBLK pv, int n1, int n2) = 0;
virtual void SetValues(PVBLK pv, int i, int n) = 0; virtual void SetValues(PVBLK pv, int i, int n) = 0;
virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);} virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);}
virtual void Move(int i, int j) = 0; virtual void Move(int i, int j) = 0;
virtual int CompVal(PVAL vp, int n) = 0; virtual int CompVal(PVAL vp, int n) = 0;
virtual int CompVal(int i1, int i2) = 0; virtual int CompVal(int i1, int i2) = 0;
virtual void *GetValPtr(int n) = 0; virtual void *GetValPtr(int n) = 0;
virtual void *GetValPtrEx(int n) = 0; virtual void *GetValPtrEx(int n) = 0;
virtual int Find(PVAL vp) = 0; virtual int Find(PVAL vp) = 0;
virtual int GetMaxLength(void) = 0; virtual int GetMaxLength(void) = 0;
bool Locate(PVAL vp, int& i); bool Locate(PVAL vp, int& i);
protected: protected:
#if defined(_DEBUG) || defined(DEBTRACE) #if defined(_DEBUG) || defined(DEBTRACE)
void ChkIndx(int n); void ChkIndx(int n);
void ChkPrm(PVAL v, int n); void ChkPrm(PVAL v, int n);
void ChkTyp(PVAL v); void ChkTyp(PVAL v);
void ChkTyp(PVBLK vb); void ChkTyp(PVBLK vb);
#endif // _DEBUG) || DEBTRACE #endif // _DEBUG) || DEBTRACE
// Members // Members
PGLOBAL Global; // Used for messages and allocation PGLOBAL Global; // Used for messages and allocation
void *Blkp; // To value block void *Blkp; // To value block
int Type; // Type of individual values int Type; // Type of individual values
int Nval; // Max number of values in block int Nval; // Max number of values in block
bool Check; // If true SetValue types must match bool Check; // If true SetValue types must match
}; // end of class VALBLK }; // end of class VALBLK
/***********************************************************************/ /***********************************************************************/
/* Class CHRBLK: represent a block of fixed length strings. */ /* Class CHRBLK: represent a block of fixed length strings. */
/***********************************************************************/ /***********************************************************************/
class CHRBLK : public VALBLK { class CHRBLK : public VALBLK {
public: public:
// Constructors // Constructors
CHRBLK(void *mp, int size, int len, int prec, bool b); CHRBLK(void *mp, int size, int len, int prec, bool b);
// Implementation // Implementation
virtual void Init(PGLOBAL g, bool check); virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return Long;} virtual int GetVlen(void) {return Long;}
virtual PSZ GetCharValue(int n); virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n); virtual short GetShortValue(int n);
virtual int GetIntValue(int n); virtual int GetIntValue(int n);
virtual longlong GetBigintValue(int n); virtual longlong GetBigintValue(int n);
virtual double GetFloatValue(int n); virtual double GetFloatValue(int n);
virtual void Reset(int n); virtual void Reset(int n);
virtual void SetPrec(int p) {Ci = (p != 0);} virtual void SetPrec(int p) {Ci = (p != 0);}
virtual bool IsCi(void) {return Ci;} virtual bool IsCi(void) {return Ci;}
// Methods // Methods
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n); virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n); virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n); virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j); virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n); virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n); virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n); virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp); virtual int Find(PVAL vp);
virtual int GetMaxLength(void); virtual int GetMaxLength(void);
protected: protected:
// Members // Members
char* const &Chrp; // Pointer to char buffer char* const &Chrp; // Pointer to char buffer
PSZ Valp; // Used to make a zero ended value PSZ Valp; // Used to make a zero ended value
bool Blanks; // True for right filling with blanks bool Blanks; // True for right filling with blanks
bool Ci; // True if case insensitive bool Ci; // True if case insensitive
int Long; // Length of each string int Long; // Length of each string
}; // end of class CHRBLK }; // end of class CHRBLK
/***********************************************************************/ /***********************************************************************/
/* Class STRBLK: represent a block of string pointers. */ /* Class STRBLK: represent a block of string pointers. */
/* Currently this class is used only by the DECODE scalar function */ /* Currently this class is used only by the DECODE scalar function */
/* and by the MyColumn function to store date formats. */ /* and by the MyColumn function to store date formats. */
/***********************************************************************/ /***********************************************************************/
class STRBLK : public VALBLK { class STRBLK : public VALBLK {
public: public:
// Constructors // Constructors
STRBLK(PGLOBAL g, void *mp, int size); STRBLK(PGLOBAL g, void *mp, int size);
// Implementation // Implementation
virtual void Init(PGLOBAL g, bool check); virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(PSZ);} virtual int GetVlen(void) {return sizeof(PSZ);}
virtual PSZ GetCharValue(int n) {return Strp[n];} virtual PSZ GetCharValue(int n) {return Strp[n];}
virtual short GetShortValue(int n) {return (short)atoi(Strp[n]);} virtual short GetShortValue(int n) {return (short)atoi(Strp[n]);}
virtual int GetIntValue(int n) {return atol(Strp[n]);} virtual int GetIntValue(int n) {return atol(Strp[n]);}
virtual longlong GetBigintValue(int n) {return atoll(Strp[n]);} virtual longlong GetBigintValue(int n) {return atoll(Strp[n]);}
virtual double GetFloatValue(int n) {return atof(Strp[n]);} virtual double GetFloatValue(int n) {return atof(Strp[n]);}
virtual void Reset(int n) {Strp[n] = NULL;} virtual void Reset(int n) {Strp[n] = NULL;}
// Methods // Methods
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n); virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n); virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n); virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j); virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n); virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n); virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n); virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp); virtual int Find(PVAL vp);
virtual int GetMaxLength(void); virtual int GetMaxLength(void);
protected: protected:
// Members // Members
PSZ* const &Strp; // Pointer to PSZ buffer PSZ* const &Strp; // Pointer to PSZ buffer
}; // end of class STRBLK }; // end of class STRBLK
/***********************************************************************/ /***********************************************************************/
/* Class SHRBLK: represents a block of int integer values. */ /* Class SHRBLK: represents a block of int integer values. */
/***********************************************************************/ /***********************************************************************/
class SHRBLK : public VALBLK { class SHRBLK : public VALBLK {
public: public:
// Constructors // Constructors
SHRBLK(void *mp, int size); SHRBLK(void *mp, int size);
// Implementation // Implementation
virtual void Init(PGLOBAL g, bool check); virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(short);} virtual int GetVlen(void) {return sizeof(short);}
//virtual PSZ GetCharValue(int n); //virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return Shrp[n];} virtual short GetShortValue(int n) {return Shrp[n];}
virtual int GetIntValue(int n) {return (int)Shrp[n];} virtual int GetIntValue(int n) {return (int)Shrp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Shrp[n];} virtual longlong GetBigintValue(int n) {return (longlong)Shrp[n];}
virtual double GetFloatValue(int n) {return (double)Shrp[n];} virtual double GetFloatValue(int n) {return (double)Shrp[n];}
virtual void Reset(int n) {Shrp[n] = 0;} virtual void Reset(int n) {Shrp[n] = 0;}
// Methods // Methods
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PSZ sp, int n);
virtual void SetValue(short sval, int n) {Shrp[n] = sval;} virtual void SetValue(short sval, int n) {Shrp[n] = sval;}
virtual void SetValue(int lval, int n) {Shrp[n] = (short)lval;} 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(longlong lval, int n) {Shrp[n] = (short)lval;}
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n); virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n); virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n); virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2); virtual void AddMinus1(PVBLK pv, int n1, int n2);
virtual void Move(int i, int j); virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n); virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n); virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n); virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp); virtual int Find(PVAL vp);
virtual int GetMaxLength(void); virtual int GetMaxLength(void);
protected: protected:
// Members // Members
short* const &Shrp; short* const &Shrp;
}; // end of class SHRBLK }; // end of class SHRBLK
/***********************************************************************/ /***********************************************************************/
/* Class LNGBLK: represents a block of int integer values. */ /* Class LNGBLK: represents a block of int integer values. */
/***********************************************************************/ /***********************************************************************/
class LNGBLK : public VALBLK { class LNGBLK : public VALBLK {
public: public:
// Constructors // Constructors
LNGBLK(void *mp, int size); LNGBLK(void *mp, int size);
// Implementation // Implementation
virtual void Init(PGLOBAL g, bool check); virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(int);} virtual int GetVlen(void) {return sizeof(int);}
//virtual PSZ GetCharValue(int n); //virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Lngp[n];} virtual short GetShortValue(int n) {return (short)Lngp[n];}
virtual int GetIntValue(int n) {return Lngp[n];} virtual int GetIntValue(int n) {return Lngp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Lngp[n];} virtual longlong GetBigintValue(int n) {return (longlong)Lngp[n];}
virtual double GetFloatValue(int n) {return (double)Lngp[n];} virtual double GetFloatValue(int n) {return (double)Lngp[n];}
virtual void Reset(int n) {Lngp[n] = 0;} virtual void Reset(int n) {Lngp[n] = 0;}
// Methods // Methods
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PSZ sp, int n);
virtual void SetValue(short sval, int n) {Lngp[n] = (int)sval;} virtual void SetValue(short sval, int n) {Lngp[n] = (int)sval;}
virtual void SetValue(int lval, int n) {Lngp[n] = lval;} virtual void SetValue(int lval, int n) {Lngp[n] = lval;}
virtual void SetValue(longlong lval, int n) {Lngp[n] = (int)lval;} virtual void SetValue(longlong lval, int n) {Lngp[n] = (int)lval;}
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n); virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n); virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n); virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2); virtual void AddMinus1(PVBLK pv, int n1, int n2);
virtual void Move(int i, int j); virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n); virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n); virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n); virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp); virtual int Find(PVAL vp);
virtual int GetMaxLength(void); virtual int GetMaxLength(void);
protected: protected:
// Members // Members
int* const &Lngp; int* const &Lngp;
}; // end of class LNGBLK }; // end of class LNGBLK
/***********************************************************************/ /***********************************************************************/
/* Class DATBLK: represents a block of time stamp values. */ /* Class DATBLK: represents a block of time stamp values. */
/***********************************************************************/ /***********************************************************************/
class DATBLK : public LNGBLK { class DATBLK : public LNGBLK {
public: public:
// Constructor // Constructor
DATBLK(void *mp, int size); DATBLK(void *mp, int size);
// Implementation // Implementation
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
// Methods // Methods
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PSZ sp, int n);
protected: protected:
// Members // Members
PVAL Dvalp; // Date value used to convert string PVAL Dvalp; // Date value used to convert string
}; // end of class DATBLK }; // end of class DATBLK
/***********************************************************************/ /***********************************************************************/
/* Class BIGBLK: represents a block of big integer values. */ /* Class BIGBLK: represents a block of big integer values. */
/***********************************************************************/ /***********************************************************************/
class BIGBLK : public VALBLK { class BIGBLK : public VALBLK {
public: public:
// Constructors // Constructors
BIGBLK(void *mp, int size); BIGBLK(void *mp, int size);
// Implementation // Implementation
virtual void Init(PGLOBAL g, bool check); virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(longlong);} virtual int GetVlen(void) {return sizeof(longlong);}
//virtual PSZ GetCharValue(int n); //virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Lngp[n];} virtual short GetShortValue(int n) {return (short)Lngp[n];}
virtual int GetIntValue(int n) {return (int)Lngp[n];} virtual int GetIntValue(int n) {return (int)Lngp[n];}
virtual longlong GetBigintValue(int n) {return Lngp[n];} virtual longlong GetBigintValue(int n) {return Lngp[n];}
virtual double GetFloatValue(int n) {return (double)Lngp[n];} virtual double GetFloatValue(int n) {return (double)Lngp[n];}
virtual void Reset(int n) {Lngp[n] = 0LL;} virtual void Reset(int n) {Lngp[n] = 0LL;}
// Methods // Methods
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PSZ sp, int n);
virtual void SetValue(short sval, int n) {Lngp[n] = (longlong)sval;} 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(int lval, int n) {Lngp[n] = (longlong)lval;}
virtual void SetValue(longlong lval, int n) {Lngp[n] = lval;} virtual void SetValue(longlong lval, int n) {Lngp[n] = lval;}
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n); virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n); virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n); virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2); virtual void AddMinus1(PVBLK pv, int n1, int n2);
virtual void Move(int i, int j); virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n); virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n); virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n); virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp); virtual int Find(PVAL vp);
virtual int GetMaxLength(void); virtual int GetMaxLength(void);
protected: protected:
// Members // Members
longlong* const &Lngp; longlong* const &Lngp;
}; // end of class BIGBLK }; // end of class BIGBLK
/***********************************************************************/ /***********************************************************************/
/* Class DBLBLK: represents a block of double float values. */ /* Class DBLBLK: represents a block of double float values. */
/***********************************************************************/ /***********************************************************************/
class DBLBLK : public VALBLK { class DBLBLK : public VALBLK {
public: public:
// Constructors // Constructors
DBLBLK(void *mp, int size, int prec); DBLBLK(void *mp, int size, int prec);
// Implementation // Implementation
virtual void Init(PGLOBAL g, bool check); virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(double);} virtual int GetVlen(void) {return sizeof(double);}
//virtual PSZ GetCharValue(int n); //virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Dblp[n];} virtual short GetShortValue(int n) {return (short)Dblp[n];}
virtual int GetIntValue(int n) {return (int)Dblp[n];} virtual int GetIntValue(int n) {return (int)Dblp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Dblp[n];} virtual longlong GetBigintValue(int n) {return (longlong)Dblp[n];}
virtual double GetFloatValue(int n) {return Dblp[n];} virtual double GetFloatValue(int n) {return Dblp[n];}
virtual void Reset(int n) {Dblp[n] = 0.0;} virtual void Reset(int n) {Dblp[n] = 0.0;}
virtual void SetPrec(int p) {Prec = p;} virtual void SetPrec(int p) {Prec = p;}
// Methods // Methods
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetMin(PVAL valp, int n); virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n); virtual void SetMax(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n); virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j); virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n); virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);
virtual void *GetValPtr(int n); virtual void *GetValPtr(int n);
virtual void *GetValPtrEx(int n); virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp); virtual int Find(PVAL vp);
virtual int GetMaxLength(void); virtual int GetMaxLength(void);
protected: protected:
// Members // Members
double* const &Dblp; double* const &Dblp;
int Prec; int Prec;
}; // end of class DBLBLK }; // end of class DBLBLK
#endif // __VALBLK__H__ #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) ***************/ /*************** Xindex H Declares Source Code File (.H) ***************/
/* Name: XINDEX.H Version 3.4 */ /* Name: XINDEX.H Version 3.4 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2004 - 2012 */ /* (C) Copyright to the author Olivier BERTRAND 2004 - 2012 */
/* */ /* */
/* This file contains the XINDEX class declares. */ /* This file contains the XINDEX class declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __XINDEX_H__ #ifndef __XINDEX_H__
#define __XINDEX_H__ #define __XINDEX_H__
#include "block.h" #include "block.h"
#include "csort.h" /* Base class declares */ #include "csort.h" /* Base class declares */
#include "xtable.h" #include "xtable.h"
#include "valblk.h" #include "valblk.h"
enum IDT {TYPE_IDX_ERROR = 0, /* Type not defined */ enum IDT {TYPE_IDX_ERROR = 0, /* Type not defined */
TYPE_IDX_INDX = 4, /* Permanent standard index */ TYPE_IDX_INDX = 4, /* Permanent standard index */
TYPE_IDX_XROW = 5}; /* Permanent row index */ TYPE_IDX_XROW = 5}; /* Permanent row index */
typedef struct mem_map *MMP; typedef struct mem_map *MMP;
typedef class INDEXDEF *PIXDEF; typedef class INDEXDEF *PIXDEF;
typedef class KPARTDEF *PKPDEF; typedef class KPARTDEF *PKPDEF;
typedef class XINDEX *PXINDEX; typedef class XINDEX *PXINDEX;
typedef class XLOAD *PXLOAD; typedef class XLOAD *PXLOAD;
typedef class KXYCOL *PXCOL; typedef class KXYCOL *PXCOL;
/***********************************************************************/ /***********************************************************************/
/* Structures used when checking for possible indexing */ /* Structures used when checking for possible indexing */
/***********************************************************************/ /***********************************************************************/
typedef struct index_col *PICOL; typedef struct index_col *PICOL;
typedef struct index_val *PIVAL; typedef struct index_val *PIVAL;
typedef struct index_def *PINDX; typedef struct index_def *PINDX;
typedef struct indx_used *PXUSED; typedef struct indx_used *PXUSED;
typedef struct index_val : public BLOCK { typedef struct index_val : public BLOCK {
index_val(PXOB xp) {Next = NULL; Xval = xp; Kp = NULL;} index_val(PXOB xp) {Next = NULL; Xval = xp; Kp = NULL;}
PIVAL Next; // Next value PIVAL Next; // Next value
PXOB Xval; // To value or array PXOB Xval; // To value or array
int *Kp; // The coordonates in a LSTBLK int *Kp; // The coordonates in a LSTBLK
} IVAL; } IVAL;
typedef struct index_col : public BLOCK { typedef struct index_col : public BLOCK {
index_col(PCOL cp) index_col(PCOL cp)
{Next = Nxtgrp = NULL; Colp = cp; Ngrp = N = 0; Vals = NULL;} {Next = Nxtgrp = NULL; Colp = cp; Ngrp = N = 0; Vals = NULL;}
PICOL Next; // Next column PICOL Next; // Next column
PICOL Nxtgrp; // Next group PICOL Nxtgrp; // Next group
PCOL Colp; // The column PCOL Colp; // The column
PIVAL Vals; // To column values PIVAL Vals; // To column values
int Ngrp; // Group number of values int Ngrp; // Group number of values
int N; // Column number of values int N; // Column number of values
} ICOL; } ICOL;
typedef struct index_def : public BLOCK { typedef struct index_def : public BLOCK {
index_def(PIXDEF xdp) index_def(PIXDEF xdp)
{Next = NULL; Pxdf = xdp; Cols = NULL; Alloc = false;} {Next = NULL; Pxdf = xdp; Cols = NULL; Alloc = false;}
PINDX Next; PINDX Next;
PIXDEF Pxdf; PIXDEF Pxdf;
PICOL Cols; PICOL Cols;
bool Alloc; // Must allocate values bool Alloc; // Must allocate values
} INDX; } INDX;
/***********************************************************************/ /***********************************************************************/
/* Index definition block. */ /* Index definition block. */
/***********************************************************************/ /***********************************************************************/
class DllExport INDEXDEF : public BLOCK { /* Index description block */ class DllExport INDEXDEF : public BLOCK { /* Index description block */
friend class PLUGCAT; friend class PLUGCAT;
friend class DOSDEF; friend class DOSDEF;
friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add); friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add);
public: public:
// Constructor // Constructor
INDEXDEF(char *name, bool uniq = false, int n = 0); INDEXDEF(char *name, bool uniq = false, int n = 0);
// Implementation // Implementation
PIXDEF GetNext(void) {return Next;} PIXDEF GetNext(void) {return Next;}
void SetNext(PIXDEF pxdf) {Next = pxdf;} void SetNext(PIXDEF pxdf) {Next = pxdf;}
PSZ GetName(void) {return (PSZ)Name;} PSZ GetName(void) {return (PSZ)Name;}
bool IsUnique(void) {return Unique;} bool IsUnique(void) {return Unique;}
bool IsAuto(void) {return AutoInc;} bool IsAuto(void) {return AutoInc;}
void SetAuto(bool b) {AutoInc = b;} void SetAuto(bool b) {AutoInc = b;}
void SetInvalid(bool b) {Invalid = b;} void SetInvalid(bool b) {Invalid = b;}
int GetNparts(void) {return Nparts;} int GetNparts(void) {return Nparts;}
int GetID(void) {return ID;} int GetID(void) {return ID;}
void SetID(int n) {ID = n;} void SetID(int n) {ID = n;}
PKPDEF GetToKeyParts(void) {return ToKeyParts;} PKPDEF GetToKeyParts(void) {return ToKeyParts;}
void SetToKeyParts(PKPDEF kp) {ToKeyParts = kp;} void SetToKeyParts(PKPDEF kp) {ToKeyParts = kp;}
void SetNParts(uint np) {Nparts = (signed)np;} void SetNParts(uint np) {Nparts = (signed)np;}
void SetMaxSame(int mxs) {MaxSame = mxs;} void SetMaxSame(int mxs) {MaxSame = mxs;}
void SetMxsame(PXINDEX x); void SetMxsame(PXINDEX x);
int GetOffset(void) {return Offset;} int GetOffset(void) {return Offset;}
void SetOffset(int off) {Offset = off;} void SetOffset(int off) {Offset = off;}
int GetOffhigh(void) {return Offhigh;} int GetOffhigh(void) {return Offhigh;}
void SetOffhigh(int hof) {Offhigh = hof;} void SetOffhigh(int hof) {Offhigh = hof;}
int GetSize(void) {return Size;} int GetSize(void) {return Size;}
void SetSize(int size) {Size = size;} void SetSize(int size) {Size = size;}
int GetMaxSame(void) {return MaxSame;} int GetMaxSame(void) {return MaxSame;}
bool Define(PGLOBAL g, void *memp, PTABDEF dfp, LPCSTR p); bool Define(PGLOBAL g, void *memp, PTABDEF dfp, LPCSTR p);
PIXDEF GetIndexOf(PCOL colp, bool hd = false); PIXDEF GetIndexOf(PCOL colp, bool hd = false);
int IsIndexOf(PCOL colp); int IsIndexOf(PCOL colp);
PKXBASE CheckIndexing(PGLOBAL g, PTDBDOS tdbp); PKXBASE CheckIndexing(PGLOBAL g, PTDBDOS tdbp);
PINDX CheckAND(PGLOBAL g, PINDX pix1, PINDX pix2); PINDX CheckAND(PGLOBAL g, PINDX pix1, PINDX pix2);
PINDX CheckOR(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); 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); bool TestEQ(PGLOBAL g, PTDB tdbp, PXOB *arg, int op, bool b = false);
protected: protected:
PIXDEF Next; /* To next block */ PIXDEF Next; /* To next block */
PKPDEF ToKeyParts; /* To the key part definitions */ PKPDEF ToKeyParts; /* To the key part definitions */
char *Name; /* Index name */ char *Name; /* Index name */
bool Unique; /* true if defined as unique */ bool Unique; /* true if defined as unique */
bool Invalid; /* true if marked as Invalid */ bool Invalid; /* true if marked as Invalid */
bool AutoInc; /* true if unique key in auto increment */ bool AutoInc; /* true if unique key in auto increment */
int Nparts; /* Number of key parts */ int Nparts; /* Number of key parts */
int ID; /* Index ID number */ int ID; /* Index ID number */
int Offset; /* Offset in index file */ int Offset; /* Offset in index file */
int Offhigh; /* Offset high in big index file */ int Offhigh; /* Offset high in big index file */
int Size; /* Size of index file */ int Size; /* Size of index file */
int MaxSame; /* Max number of same values */ int MaxSame; /* Max number of same values */
}; // end of INDEXDEF }; // end of INDEXDEF
typedef struct indx_used : public BLOCK { typedef struct indx_used : public BLOCK {
indx_used(PTDB tp, PIXDEF xdp, PCOL *cp, int k) indx_used(PTDB tp, PIXDEF xdp, PCOL *cp, int k)
{Tname = (char*)tp->GetName(); Xname = xdp->GetName(); Cp = cp; K = k;} {Tname = (char*)tp->GetName(); Xname = xdp->GetName(); Cp = cp; K = k;}
PXUSED Next; PXUSED Next;
char *Tname; char *Tname;
PSZ Xname; PSZ Xname;
PCOL *Cp; PCOL *Cp;
int K; int K;
} XUSED; } XUSED;
/***********************************************************************/ /***********************************************************************/
/* Index Key Part definition block. */ /* Index Key Part definition block. */
/***********************************************************************/ /***********************************************************************/
class DllExport KPARTDEF : public BLOCK { /* Index Key Part desc block */ class DllExport KPARTDEF : public BLOCK { /* Index Key Part desc block */
friend class INDEXDEF; friend class INDEXDEF;
friend class XINDEX; friend class XINDEX;
friend class PLUGCAT; friend class PLUGCAT;
friend class DOSDEF; friend class DOSDEF;
friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add); friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add);
public: public:
KPARTDEF(PSZ name, int n); // Constructor KPARTDEF(PSZ name, int n); // Constructor
// Implementation // Implementation
PKPDEF GetNext(void) {return Next;} PKPDEF GetNext(void) {return Next;}
PSZ GetName(void) {return (PSZ)Name;} PSZ GetName(void) {return (PSZ)Name;}
int GetNcol(void) {return Ncol;} int GetNcol(void) {return Ncol;}
void SetNext(PKPDEF pkdf) {Next = pkdf;} void SetNext(PKPDEF pkdf) {Next = pkdf;}
void SetKlen(int len) {Klen = len;} void SetKlen(int len) {Klen = len;}
void SetMxsame(int mxs) {Mxsame = mxs;} void SetMxsame(int mxs) {Mxsame = mxs;}
protected: protected:
PKPDEF Next; /* To next block */ PKPDEF Next; /* To next block */
PSZ Name; /* Field name */ PSZ Name; /* Field name */
int Mxsame; /* Field max same values */ int Mxsame; /* Field max same values */
int Ncol; /* Field number */ int Ncol; /* Field number */
int Klen; /* Key length */ int Klen; /* Key length */
}; // end of KPARTDEF }; // end of KPARTDEF
/***********************************************************************/ /***********************************************************************/
/* This is the XDB Index virtual base class declaration. */ /* This is the XDB Index virtual base class declaration. */
/***********************************************************************/ /***********************************************************************/
class DllExport XXBASE : public CSORT, public BLOCK { class DllExport XXBASE : public CSORT, public BLOCK {
friend class INDEXDEF; friend class INDEXDEF;
friend class KXYCOL; friend class KXYCOL;
public: public:
// Constructor // Constructor
XXBASE(PTDBDOS tbxp, bool b); XXBASE(PTDBDOS tbxp, bool b);
// Implementation // Implementation
virtual IDT GetType(void) = 0; virtual IDT GetType(void) = 0;
virtual void Reset(void) = 0; virtual void Reset(void) = 0;
virtual bool IsMul(void) {return false;} virtual bool IsMul(void) {return false;}
virtual bool IsRandom(void) {return true;} virtual bool IsRandom(void) {return true;}
virtual bool HaveSame(void) {return false;} virtual bool HaveSame(void) {return false;}
virtual int GetCurPos(void) {return Cur_K;} virtual int GetCurPos(void) {return Cur_K;}
virtual void SetNval(int n) {assert(n == 1);} virtual void SetNval(int n) {assert(n == 1);}
virtual void SetOp(OPVAL op) {Op = op;} virtual void SetOp(OPVAL op) {Op = op;}
int GetNdif(void) {return Ndif;} int GetNdif(void) {return Ndif;}
int GetNum_K(void) {return Num_K;} int GetNum_K(void) {return Num_K;}
int GetCur_K(void) {return Cur_K;} int GetCur_K(void) {return Cur_K;}
int GetID(void) {return ID;} int GetID(void) {return ID;}
void SetID(int id) {ID = id;} void SetID(int id) {ID = id;}
void SetNth(int n) {Nth = n;} void SetNth(int n) {Nth = n;}
int *GetPof(void) {return Pof;} int *GetPof(void) {return Pof;}
int *GetPex(void) {return Pex;} int *GetPex(void) {return Pex;}
void FreeIndex(void) {PlgDBfree(Index);} void FreeIndex(void) {PlgDBfree(Index);}
// Methods // Methods
virtual void Print(PGLOBAL g, FILE *f, uint n); virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z); virtual void Print(PGLOBAL g, char *ps, uint z);
virtual bool Init(PGLOBAL g) = 0; virtual bool Init(PGLOBAL g) = 0;
virtual int MaxRange(void) {return 1;} virtual int MaxRange(void) {return 1;}
virtual int Fetch(PGLOBAL g) = 0; virtual int Fetch(PGLOBAL g) = 0;
virtual bool NextVal(bool eq) {return true;} virtual bool NextVal(bool eq) {return true;}
virtual int FastFind(int nk) = 0; virtual int FastFind(int nk) = 0;
virtual bool Reorder(PGLOBAL g) {return true;} virtual bool Reorder(PGLOBAL g) {return true;}
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true) virtual int Range(PGLOBAL g, int limit = 0, bool incl = true)
{return -1;} // Means error {return -1;} // Means error
virtual int Qcompare(int *, int *) = 0; virtual int Qcompare(int *, int *) = 0;
virtual int GroupSize(void) {return 1;} virtual int GroupSize(void) {return 1;}
virtual void Close(void) = 0; virtual void Close(void) = 0;
protected: protected:
// Members // Members
PTDBASE Tbxp; // Points to calling table TDB PTDBASE Tbxp; // Points to calling table TDB
PXCOL To_KeyCol; // To KeyCol class list PXCOL To_KeyCol; // To KeyCol class list
MBLOCK Record; // Record allocation block MBLOCK Record; // Record allocation block
int* &To_Rec; // We are using ftell, fseek int* &To_Rec; // We are using ftell, fseek
int Cur_K; // Index of current record int Cur_K; // Index of current record
int Old_K; // Index of last record int Old_K; // Index of last record
int Num_K; // Size of Rec_K pointer array int Num_K; // Size of Rec_K pointer array
int Ndif; // Number of distinct values int Ndif; // Number of distinct values
int Bot; // Bottom of research index int Bot; // Bottom of research index
int Top; // Top of research index int Top; // Top of research index
int Inf, Sup; // Used for block optimization int Inf, Sup; // Used for block optimization
OPVAL Op; // Search operator OPVAL Op; // Search operator
bool Mul; // true if multiple bool Mul; // true if multiple
bool Srtd; // true for sorted column bool Srtd; // true for sorted column
int Val_K; // Index of current value int Val_K; // Index of current value
int Nblk; // Number of blocks int Nblk; // Number of blocks
int Sblk; // Block size int Sblk; // Block size
int Thresh; // Thresh for sorting join indexes int Thresh; // Thresh for sorting join indexes
int ID; // Index ID number int ID; // Index ID number
int Nth; // Nth constant to fetch int Nth; // Nth constant to fetch
}; // end of class XXBASE }; // end of class XXBASE
/***********************************************************************/ /***********************************************************************/
/* This is the standard (multicolumn) Index class declaration. */ /* This is the standard (multicolumn) Index class declaration. */
/***********************************************************************/ /***********************************************************************/
class DllExport XINDEX : public XXBASE { class DllExport XINDEX : public XXBASE {
friend class KXYCOL; friend class KXYCOL;
public: public:
// Constructor // Constructor
XINDEX(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, XINDEX(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp,
PCOL *cp, PXOB *xp = NULL, int k = 0); PCOL *cp, PXOB *xp = NULL, int k = 0);
// Implementation // Implementation
virtual IDT GetType(void) {return TYPE_IDX_INDX;} virtual IDT GetType(void) {return TYPE_IDX_INDX;}
virtual bool IsMul(void) {return (Nval < Nk) ? true : Mul;} virtual bool IsMul(void) {return (Nval < Nk) ? true : Mul;}
virtual bool HaveSame(void) {return Op == OP_SAME;} virtual bool HaveSame(void) {return Op == OP_SAME;}
virtual int GetCurPos(void) {return (Pex) ? Pex[Cur_K] : Cur_K;} virtual int GetCurPos(void) {return (Pex) ? Pex[Cur_K] : Cur_K;}
virtual void SetNval(int n) {Nval = n;} virtual void SetNval(int n) {Nval = n;}
int GetMaxSame(void) {return MaxSame;} int GetMaxSame(void) {return MaxSame;}
int GetDefoff(void) {return Defoff;} int GetDefoff(void) {return Defoff;}
int GetDefhigh(void) {return Defhigh;} int GetDefhigh(void) {return Defhigh;}
int GetSize(void) {return Size;} int GetSize(void) {return Size;}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual bool Init(PGLOBAL g); virtual bool Init(PGLOBAL g);
virtual int Qcompare(int *, int *); virtual int Qcompare(int *, int *);
virtual int Fetch(PGLOBAL g); virtual int Fetch(PGLOBAL g);
virtual int FastFind(int nk); virtual int FastFind(int nk);
virtual int GroupSize(void); virtual int GroupSize(void);
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true); virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int MaxRange(void) {return MaxSame;} virtual int MaxRange(void) {return MaxSame;}
virtual int ColMaxSame(PXCOL kp); virtual int ColMaxSame(PXCOL kp);
virtual void Close(void); virtual void Close(void);
virtual bool NextVal(bool eq); virtual bool NextVal(bool eq);
virtual bool Make(PGLOBAL g, PIXDEF sxp); virtual bool Make(PGLOBAL g, PIXDEF sxp);
virtual bool SaveIndex(PGLOBAL g, PIXDEF sxp); virtual bool SaveIndex(PGLOBAL g, PIXDEF sxp);
virtual bool Reorder(PGLOBAL g); virtual bool Reorder(PGLOBAL g);
bool GetAllSizes(PGLOBAL g, int &ndif, int &numk); bool GetAllSizes(PGLOBAL g, int &ndif, int &numk);
protected: protected:
bool NextValDif(void); bool NextValDif(void);
// Members // Members
PIXDEF Xdp; // To index definition PIXDEF Xdp; // To index definition
PTDBDOS Tdbp; // Points to calling table TDB PTDBDOS Tdbp; // Points to calling table TDB
PXLOAD X; // To XLOAD class PXLOAD X; // To XLOAD class
PXCOL To_LastCol; // To the last key part block PXCOL To_LastCol; // To the last key part block
PXCOL To_LastVal; // To the last used key part block PXCOL To_LastVal; // To the last used key part block
PCOL *To_Cols; // To array of indexed columns PCOL *To_Cols; // To array of indexed columns
PXOB *To_Vals; // To array of column values PXOB *To_Vals; // To array of column values
int Nk; // The number of indexed columns int Nk; // The number of indexed columns
int Nval; // The number of used columns int Nval; // The number of used columns
int Incr; // Increment of record position int Incr; // Increment of record position
int Defoff; // Offset of definition in index file int Defoff; // Offset of definition in index file
int Defhigh; // High order of offset big value int Defhigh; // High order of offset big value
int Size; // Size of definition in index file int Size; // Size of definition in index file
int MaxSame; // Max number of same values int MaxSame; // Max number of same values
}; // end of class XINDEX }; // end of class XINDEX
/***********************************************************************/ /***********************************************************************/
/* This is the fast single column index class declaration. */ /* This is the fast single column index class declaration. */
/***********************************************************************/ /***********************************************************************/
class DllExport XINDXS : public XINDEX { class DllExport XINDXS : public XINDEX {
friend class KXYCOL; friend class KXYCOL;
public: public:
// Constructor // Constructor
XINDXS(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp = NULL); XINDXS(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp = NULL);
// Implementation // Implementation
virtual void SetNval(int n) {assert(n == 1);} virtual void SetNval(int n) {assert(n == 1);}
// Methods // Methods
virtual int Qcompare(int *, int *); virtual int Qcompare(int *, int *);
virtual int Fetch(PGLOBAL g); virtual int Fetch(PGLOBAL g);
virtual int FastFind(int nk); virtual int FastFind(int nk);
virtual bool NextVal(bool eq); virtual bool NextVal(bool eq);
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true); virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int GroupSize(void); virtual int GroupSize(void);
protected: protected:
// Members // Members
}; // end of class XINDXS }; // end of class XINDXS
/***********************************************************************/ /***********************************************************************/
/* This is the saving/loading index utility base class. */ /* This is the saving/loading index utility base class. */
/***********************************************************************/ /***********************************************************************/
class DllExport XLOAD : public BLOCK { class DllExport XLOAD : public BLOCK {
friend class XBIGEX; friend class XBIGEX;
friend class XBIGXS; friend class XBIGXS;
public: public:
// Constructor // Constructor
XLOAD(void); XLOAD(void);
// Methods // Methods
virtual bool Open(PGLOBAL g, char *filename, MODE mode) = 0; virtual bool Open(PGLOBAL g, char *filename, MODE mode) = 0;
virtual bool GetOff(int& low, int& high, PIXDEF sxp) = 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 Seek(PGLOBAL g, int low, int high, int origin) = 0;
virtual bool Read(PGLOBAL g, void *buf, int n, int size) = 0; virtual bool Read(PGLOBAL g, void *buf, int n, int size) = 0;
virtual int Write(PGLOBAL g, void *buf, int n, virtual int Write(PGLOBAL g, void *buf, int n,
int size, bool& rc) = 0; int size, bool& rc) = 0;
virtual void Close(void); virtual void Close(void);
#if defined(XMAP) #if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff, virtual void *FileView(PGLOBAL g, char *fn, int loff,
int hoff, int size) = 0; int hoff, int size) = 0;
#endif // XMAP #endif // XMAP
protected: protected:
// Members // Members
#if defined(WIN32) #if defined(WIN32)
HANDLE Hfile; // Handle to file or map HANDLE Hfile; // Handle to file or map
#if defined(XMAP) #if defined(XMAP)
void *ViewBase; // Mapped view base address void *ViewBase; // Mapped view base address
#endif // XMAP #endif // XMAP
#else // UNIX #else // UNIX
int Hfile; // Descriptor to file or map int Hfile; // Descriptor to file or map
#endif // UNIX #endif // UNIX
}; // end of class XLOAD }; // end of class XLOAD
/***********************************************************************/ /***********************************************************************/
/* This is the saving/loading indexes utility class. */ /* This is the saving/loading indexes utility class. */
/***********************************************************************/ /***********************************************************************/
class DllExport XFILE : public XLOAD { class DllExport XFILE : public XLOAD {
public: public:
// Constructor // Constructor
XFILE(void); XFILE(void);
// Methods // Methods
virtual bool Open(PGLOBAL g, char *filename, MODE mode); virtual bool Open(PGLOBAL g, char *filename, MODE mode);
virtual bool GetOff(int& low, int& high, PIXDEF sxp); virtual bool GetOff(int& low, int& high, PIXDEF sxp);
virtual bool Seek(PGLOBAL g, int low, int high, int origin); virtual bool Seek(PGLOBAL g, int low, int high, int origin);
virtual bool Read(PGLOBAL g, void *buf, int n, int size); 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 int Write(PGLOBAL g, void *buf, int n, int size, bool& rc);
virtual void Close(void); virtual void Close(void);
#if defined(XMAP) #if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff, virtual void *FileView(PGLOBAL g, char *fn, int loff,
int hoff, int size); int hoff, int size);
#endif // XMAP #endif // XMAP
protected: protected:
// Members // Members
FILE *Xfile; // Index stream file FILE *Xfile; // Index stream file
#if defined(XMAP) && !defined(WIN32) #if defined(XMAP) && !defined(WIN32)
MMP Mmp; // To UNIX mapped index file MMP Mmp; // To UNIX mapped index file
#endif // XMAP #endif // XMAP
}; // end of class XFILE }; // end of class XFILE
/***********************************************************************/ /***********************************************************************/
/* This is the saving/loading huge indexes utility class. */ /* This is the saving/loading huge indexes utility class. */
/***********************************************************************/ /***********************************************************************/
class DllExport XHUGE : public XLOAD { class DllExport XHUGE : public XLOAD {
public: public:
// Constructor // Constructor
XHUGE(void) : XLOAD() {} XHUGE(void) : XLOAD() {}
// Methods // Methods
virtual bool Open(PGLOBAL g, char *filename, MODE mode); virtual bool Open(PGLOBAL g, char *filename, MODE mode);
virtual bool GetOff(int& low, int& high, PIXDEF sxp); virtual bool GetOff(int& low, int& high, PIXDEF sxp);
virtual bool Seek(PGLOBAL g, int low, int high, int origin); virtual bool Seek(PGLOBAL g, int low, int high, int origin);
virtual bool Read(PGLOBAL g, void *buf, int n, int size); 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 int Write(PGLOBAL g, void *buf, int n, int size, bool& rc);
#if defined(XMAP) #if defined(XMAP)
virtual void *FileView(PGLOBAL g, char *fn, int loff, virtual void *FileView(PGLOBAL g, char *fn, int loff,
int hoff, int size); int hoff, int size);
#endif // XMAP #endif // XMAP
protected: protected:
// Members // Members
}; // end of class XHUGE }; // end of class XHUGE
/***********************************************************************/ /***********************************************************************/
/* This is the XDB index for columns containing ROWID values. */ /* This is the XDB index for columns containing ROWID values. */
/***********************************************************************/ /***********************************************************************/
class DllExport XXROW : public XXBASE { class DllExport XXROW : public XXBASE {
friend class KXYCOL; friend class KXYCOL;
public: public:
// Constructor // Constructor
XXROW(PTDBDOS tbxp); XXROW(PTDBDOS tbxp);
// Implementation // Implementation
virtual IDT GetType(void) {return TYPE_IDX_XROW;} virtual IDT GetType(void) {return TYPE_IDX_XROW;}
virtual void Reset(void); virtual void Reset(void);
// Methods // Methods
virtual bool Init(PGLOBAL g); virtual bool Init(PGLOBAL g);
virtual int Fetch(PGLOBAL g); virtual int Fetch(PGLOBAL g);
virtual int FastFind(int nk); virtual int FastFind(int nk);
virtual int MaxRange(void) {return 1;} virtual int MaxRange(void) {return 1;}
virtual int Range(PGLOBAL g, int limit = 0, bool incl = true); virtual int Range(PGLOBAL g, int limit = 0, bool incl = true);
virtual int Qcompare(int *, int *) {assert(false); return 0;} virtual int Qcompare(int *, int *) {assert(false); return 0;}
virtual void Close(void) {} virtual void Close(void) {}
protected: protected:
// Members // Members
PTDBDOS Tdbp; // Points to calling table TDB PTDBDOS Tdbp; // Points to calling table TDB
PVAL Valp; // The value to match in index PVAL Valp; // The value to match in index
}; // end of class XXROW }; // end of class XXROW
/***********************************************************************/ /***********************************************************************/
/* Definition of class KXYCOL used to store values of indexed columns */ /* Definition of class KXYCOL used to store values of indexed columns */
/***********************************************************************/ /***********************************************************************/
class KXYCOL: public BLOCK { class KXYCOL: public BLOCK {
friend class INDEXDEF; friend class INDEXDEF;
friend class XINDEX; friend class XINDEX;
friend class XINDXS; friend class XINDXS;
friend class XBIGEX; friend class XBIGEX;
friend class XBIGXS; friend class XBIGXS;
friend class TDBDOS; friend class TDBDOS;
public: public:
// Constructors // Constructors
KXYCOL(PKXBASE kp); KXYCOL(PKXBASE kp);
// Implementation // Implementation
int GetType(void) {return Type;} int GetType(void) {return Type;}
void SetValue(PCOL colp, int i); void SetValue(PCOL colp, int i);
public: public:
// Methods // Methods
virtual bool Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln); virtual bool Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln);
virtual bool InitFind(PGLOBAL g, PXOB xp); virtual bool InitFind(PGLOBAL g, PXOB xp);
virtual void ReAlloc(PGLOBAL g, int n); virtual void ReAlloc(PGLOBAL g, int n);
virtual void FreeData(void); virtual void FreeData(void);
virtual void FillValue(PVAL valp); virtual void FillValue(PVAL valp);
virtual int CompVal(int i); virtual int CompVal(int i);
void InitBinFind(void *vp); void InitBinFind(void *vp);
bool MakeBlockArray(PGLOBAL g, int nb, int size); bool MakeBlockArray(PGLOBAL g, int nb, int size);
int Compare(int i1, int i2); int Compare(int i1, int i2);
int CompBval(int i); int CompBval(int i);
void Save(int i) {Valp->SetBinValue(Kblp->GetValPtr(i));} void Save(int i) {Valp->SetBinValue(Kblp->GetValPtr(i));}
void Restore(int j) {Kblp->SetValue(Valp, j);} void Restore(int j) {Kblp->SetValue(Valp, j);}
void Move(int j, int k) {Kblp->Move(k, j);} void Move(int j, int k) {Kblp->Move(k, j);}
// Specific functions // Specific functions
#if defined(XMAP) #if defined(XMAP)
BYTE *MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m); BYTE *MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m);
#endif // XMAP #endif // XMAP
int *MakeOffset(PGLOBAL g, int n); int *MakeOffset(PGLOBAL g, int n);
protected: protected:
// Members // Members
PXCOL Next; // To next in the key part list PXCOL Next; // To next in the key part list
PXCOL Previous; // To previous in the key part list PXCOL Previous; // To previous in the key part list
PKXBASE Kxp; // To the INDEX class block PKXBASE Kxp; // To the INDEX class block
PCOL Colp; // To matching object if a column PCOL Colp; // To matching object if a column
bool IsSorted; // true if column is already sorted bool IsSorted; // true if column is already sorted
bool Asc; // true for ascending sort, false for Desc bool Asc; // true for ascending sort, false for Desc
MBLOCK Keys; // Data array allocation block MBLOCK Keys; // Data array allocation block
void* &To_Keys; // To data array void* &To_Keys; // To data array
PVBLK Kblp; // To Valblock of the data array PVBLK Kblp; // To Valblock of the data array
MBLOCK Bkeys; // Block array allocation block MBLOCK Bkeys; // Block array allocation block
void* &To_Bkeys; // To block array void* &To_Bkeys; // To block array
PVBLK Blkp; // To Valblock of the block array PVBLK Blkp; // To Valblock of the block array
PVAL Valp; // Value use by Find PVAL Valp; // Value use by Find
int Klen; // Length of character string or num value int Klen; // Length of character string or num value
int Kprec; // The Value(s) precision or CI int Kprec; // The Value(s) precision or CI
int Type; // The Value(s) type int Type; // The Value(s) type
bool Prefix; // Key on CHAR column prefix bool Prefix; // Key on CHAR column prefix
MBLOCK Koff; // Offset allocation block MBLOCK Koff; // Offset allocation block
CPINT &Kof; // Reference to offset array CPINT &Kof; // Reference to offset array
int Val_K; // Index of current column value int Val_K; // Index of current column value
int Ndf; // Number of stored values int Ndf; // Number of stored values
int Mxs; // Max same for this column int Mxs; // Max same for this column
}; // end of class KXYCOL }; // end of class KXYCOL
#endif // __XINDEX_H__ #endif // __XINDEX_H__

View File

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

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