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

Fix wrong value of JSON column

When null and the column is NOT NULL the value was not reset.
  modified:   storage/connect/tabjson.cpp

Fix converting bstr_t string to set error message
  modified:   storage/connect/domdoc.cpp

Fix MDEV-12768: -Wformat-overflow compile warnings
  modified:   storage/connect/global.h
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/tabvct.cpp

Typo (in external_lock)
  modified:   storage/connect/ha_connect.cc

Remove some warnings
  modified:   storage/connect/odbconn.cpp
  modified:   storage/connect/tabmysql.cpp

Add MEM_RESERVE flag to virtualAlloc
  modified:   storage/connect/plgdbutl.cpp

Fix MDEV-12573:
Accept=1 may show incorrect value for NULL column in CONNECT TBL
  modified:   storage/connect/tabutil.cpp

Fix wrong setting of key size when greater than 2G
 modified:   storage/connect/xindex.cpp

Fixing MDEV-12149: compile errors on Windows with /Zc:strictStrings
Introduce typedef PCSZ and replace PSZ by it where it matters
All done on CONNECT but compile still fails because of an included system file
  modified:   storage/connect/array.cpp
  modified:   storage/connect/catalog.h
  modified:   storage/connect/colblk.cpp
  modified:   storage/connect/colblk.h
  modified:   storage/connect/connect.cc
  modified:   storage/connect/domdoc.cpp
  modified:   storage/connect/domdoc.h
  modified:   storage/connect/filamdbf.cpp
  modified:   storage/connect/filamdbf.h
  modified:   storage/connect/filamfix.cpp
  modified:   storage/connect/filamgz.cpp
  modified:   storage/connect/filamtxt.h
  modified:   storage/connect/filamvct.cpp
  modified:   storage/connect/filamvct.h
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filamzip.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/ha_connect.h
  modified:   storage/connect/jdbccat.h
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jdbconn.h
  modified:   storage/connect/json.cpp
  modified:   storage/connect/json.h
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h
  modified:   storage/connect/libdoc.cpp
  modified:   storage/connect/macutil.cpp
  modified:   storage/connect/myconn.cpp
  modified:   storage/connect/myutil.cpp
  modified:   storage/connect/myutil.h
  modified:   storage/connect/odbccat.h
  modified:   storage/connect/odbconn.cpp
  modified:   storage/connect/odbconn.h
  modified:   storage/connect/os.h
  modified:   storage/connect/plgdbsem.h
  modified:   storage/connect/plgdbutl.cpp
  modified:   storage/connect/plgxml.cpp
  modified:   storage/connect/plgxml.h
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/preparse.h
  modified:   storage/connect/reldef.cpp
  modified:   storage/connect/reldef.h
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabdos.h
  modified:   storage/connect/tabext.cpp
  modified:   storage/connect/tabext.h
  modified:   storage/connect/tabfix.cpp
  modified:   storage/connect/tabfix.h
  modified:   storage/connect/tabfmt.cpp
  modified:   storage/connect/tabfmt.h
  modified:   storage/connect/tabjdbc.cpp
  modified:   storage/connect/tabjdbc.h
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h
  modified:   storage/connect/table.cpp
  modified:   storage/connect/tabmac.cpp
  modified:   storage/connect/tabmul.cpp
  modified:   storage/connect/tabmul.h
  modified:   storage/connect/tabmysql.cpp
  modified:   storage/connect/tabmysql.h
  modified:   storage/connect/tabodbc.cpp
  modified:   storage/connect/tabodbc.h
  modified:   storage/connect/tabpivot.cpp
  modified:   storage/connect/tabpivot.h
  modified:   storage/connect/tabsys.cpp
  modified:   storage/connect/tabsys.h
  modified:   storage/connect/tabutil.cpp
  modified:   storage/connect/tabutil.h
  modified:   storage/connect/tabvir.cpp
  modified:   storage/connect/tabvir.h
  modified:   storage/connect/tabwmi.cpp
  modified:   storage/connect/tabwmi.h
  modified:   storage/connect/tabxml.cpp
  modified:   storage/connect/tabxml.h
  modified:   storage/connect/tabzip.cpp
  modified:   storage/connect/tabzip.h
  modified:   storage/connect/valblk.cpp
  modified:   storage/connect/valblk.h
  modified:   storage/connect/value.cpp
  modified:   storage/connect/value.h
  modified:   storage/connect/xindex.cpp
  modified:   storage/connect/xobject.cpp
  modified:   storage/connect/xobject.h
  modified:   storage/connect/xtable.h

Fix MDEV-12603 Insert replaces values in ZIP file
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filamzip.h

Fix MDEV-12686 Handle null in json
Fix MDEV-12688 Insert does not handle type TINYINT
  modified:   storage/connect/json.cpp
  modified:   storage/connect/tabjson.cpp

Fix MDEV-12653 Cannot add index for ZIP CONNECT table
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabfmt.cpp
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/xindex.cpp
This commit is contained in:
Olivier Bertrand
2017-05-11 21:57:21 +02:00
parent 531698e0da
commit 1c88b9a8d3
99 changed files with 2384 additions and 3391 deletions

View File

@@ -519,11 +519,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
} else if (opc != OP_EXIST) { } else if (opc != OP_EXIST) {
sprintf(g->Message, MSG(MISSING_ARG), opc); sprintf(g->Message, MSG(MISSING_ARG), opc);
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} else // OP_EXIST } else // OP_EXIST
return Nval > 0; return Nval > 0;
@@ -685,22 +681,14 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
{ {
if (Vblp == NULL) { if (Vblp == NULL) {
strcpy(g->Message, MSG(PREC_VBLP_NULL)); strcpy(g->Message, MSG(PREC_VBLP_NULL));
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} // endif Vblp } // endif Vblp
bool was = Vblp->IsCi(); bool was = Vblp->IsCi();
if (was && !p) { if (was && !p) {
strcpy(g->Message, MSG(BAD_SET_CASE)); strcpy(g->Message, MSG(BAD_SET_CASE));
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} // endif Vblp } // endif Vblp
if (was || !p) if (was || !p)
@@ -711,11 +699,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
if (!was && Type == TYPE_STRING) if (!was && Type == TYPE_STRING)
// Must be resorted to eliminate duplicate strings // Must be resorted to eliminate duplicate strings
if (Sort(g)) if (Sort(g))
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} // end of SetPrecision } // end of SetPrecision
@@ -993,7 +977,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
size_t z, len = 2; size_t z, len = 2;
if (Type == TYPE_LIST) if (Type == TYPE_LIST)
return "(?" "?" "?)"; // To be implemented return (PSZ)("(?" "?" "?)"); // To be implemented
z = MY_MAX(24, GetTypeSize(Type, Len) + 4); z = MY_MAX(24, GetTypeSize(Type, Len) + 4);
tp = (char*)PlugSubAlloc(g, NULL, z); tp = (char*)PlugSubAlloc(g, NULL, z);

View File

@@ -595,11 +595,7 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
if (Colp->GetResultType() != Type) { if (Colp->GetResultType() != Type) {
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH)); sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
#if defined(USE_TRY)
throw g->Message; throw g->Message;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 99);
#endif // !USE_TRY
} else if (Colp->GetValue()->IsCi()) } else if (Colp->GetValue()->IsCi())
Arap->SetPrecision(g, 1); // Case insensitive Arap->SetPrecision(g, 1); // Case insensitive

View File

@@ -36,7 +36,7 @@ typedef struct _curtab {
/* Defines the structure used to get column catalog info. */ /* Defines the structure used to get column catalog info. */
/***********************************************************************/ /***********************************************************************/
typedef struct _colinfo { typedef struct _colinfo {
char *Name; PCSZ Name;
int Type; int Type;
int Offset; int Offset;
int Length; int Length;
@@ -45,9 +45,9 @@ typedef struct _colinfo {
int Scale; int Scale;
int Opt; int Opt;
int Freq; int Freq;
char *Remark; PCSZ Remark;
char *Datefmt; PCSZ Datefmt;
char *Fieldfmt; PCSZ Fieldfmt;
ushort Flags; // Used by MariaDB CONNECT handlers ushort Flags; // Used by MariaDB CONNECT handlers
} COLINFO, *PCOLINFO; } COLINFO, *PCOLINFO;
@@ -68,17 +68,15 @@ class DllExport CATALOG {
bool GetDefHuge(void) {return DefHuge;} bool GetDefHuge(void) {return DefHuge;}
void SetDefHuge(bool b) {DefHuge = b;} void SetDefHuge(bool b) {DefHuge = b;}
char *GetCbuf(void) {return Cbuf;} char *GetCbuf(void) {return Cbuf;}
//char *GetDataPath(void) {return (char*)DataPath;}
// Methods // Methods
virtual void Reset(void) {} virtual void Reset(void) {}
//virtual void SetDataPath(PGLOBAL g, const char *path) {}
virtual bool CheckName(PGLOBAL, char*) {return true;} virtual bool CheckName(PGLOBAL, char*) {return true;}
virtual bool ClearName(PGLOBAL, PSZ) {return true;} virtual bool ClearName(PGLOBAL, PSZ) {return true;}
virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;} virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;}
virtual PRELDEF GetTableDescEx(PGLOBAL, PTABLE) {return NULL;} virtual PRELDEF GetTableDescEx(PGLOBAL, PTABLE) {return NULL;}
/*virtual PRELDEF GetTableDesc(PGLOBAL, LPCSTR, LPCSTR, //virtual PRELDEF GetTableDesc(PGLOBAL, LPCSTR, LPCSTR,
PRELDEF* = NULL) {return NULL;}*/ // PRELDEF* = NULL) {return NULL;}
virtual PRELDEF GetFirstTable(PGLOBAL) {return NULL;} virtual PRELDEF GetFirstTable(PGLOBAL) {return NULL;}
virtual PRELDEF GetNextTable(PGLOBAL) {return NULL;} virtual PRELDEF GetNextTable(PGLOBAL) {return NULL;}
virtual bool TestCond(PGLOBAL, const char*, const char*) {return true;} virtual bool TestCond(PGLOBAL, const char*, const char*) {return true;}
@@ -95,14 +93,13 @@ class DllExport CATALOG {
protected: protected:
virtual bool ClearSection(PGLOBAL, const char*, const char*) {return true;} virtual bool ClearSection(PGLOBAL, const char*, const char*) {return true;}
/*virtual PRELDEF MakeTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;}*/ //virtual PRELDEF MakeTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;}
// Members // Members
char *Cbuf; /* Buffer used for col section */ char *Cbuf; /* Buffer used for col section */
int Cblen; /* Length of suballoc. buffer */ int Cblen; /* Length of suballoc. buffer */
CURTAB Ctb; /* Used to enumerate tables */ CURTAB Ctb; /* Used to enumerate tables */
bool DefHuge; /* true: tables default to huge */ bool DefHuge; /* true: tables default to huge */
//LPCSTR DataPath; /* Is the Path of DB data dir */
}; // end of class CATALOG }; // end of class CATALOG
#endif // __CATALOG__H #endif // __CATALOG__H

View File

@@ -197,11 +197,7 @@ int COLBLK::GetLengthEx(void)
void COLBLK::ReadColumn(PGLOBAL g) void COLBLK::ReadColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn"); sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
#if defined(USE_TRY)
throw TYPE_COLBLK; throw TYPE_COLBLK;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
#endif // !USE_TRY
} // end of ReadColumn } // end of ReadColumn
/***********************************************************************/ /***********************************************************************/
@@ -212,11 +208,7 @@ void COLBLK::ReadColumn(PGLOBAL g)
void COLBLK::WriteColumn(PGLOBAL g) void COLBLK::WriteColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn"); sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
#if defined(USE_TRY)
throw TYPE_COLBLK; throw TYPE_COLBLK;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
#endif // !USE_TRY
} // end of WriteColumn } // end of WriteColumn
/***********************************************************************/ /***********************************************************************/
@@ -270,11 +262,7 @@ SPCBLK::SPCBLK(PCOLUMN cp)
void SPCBLK::WriteColumn(PGLOBAL g) void SPCBLK::WriteColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(SPCOL_READONLY), Name); sprintf(g->Message, MSG(SPCOL_READONLY), Name);
#if defined(USE_TRY)
throw TYPE_COLBLK; throw TYPE_COLBLK;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
#endif // !USE_TRY
} // end of WriteColumn } // end of WriteColumn
/***********************************************************************/ /***********************************************************************/
@@ -389,7 +377,7 @@ PRTBLK::PRTBLK(PCOLUMN cp) : SPCBLK(cp)
void PRTBLK::ReadColumn(PGLOBAL g) void PRTBLK::ReadColumn(PGLOBAL g)
{ {
if (Pname == NULL) { if (Pname == NULL) {
char *p; const char *p;
Pname = To_Tdb->GetDef()->GetStringCatInfo(g, "partname", "?"); Pname = To_Tdb->GetDef()->GetStringCatInfo(g, "partname", "?");
p = strrchr(Pname, '#'); p = strrchr(Pname, '#');
@@ -419,7 +407,7 @@ SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp)
void SIDBLK::ReadColumn(PGLOBAL) void SIDBLK::ReadColumn(PGLOBAL)
{ {
//if (Sname == NULL) { //if (Sname == NULL) {
Sname = (char*)To_Tdb->GetServer(); Sname = To_Tdb->GetServer();
Value->SetValue_psz(Sname); Value->SetValue_psz(Sname);
// } // endif Sname // } // endif Sname

View File

@@ -154,7 +154,7 @@ class DllExport FIDBLK : public SPCBLK {
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
PSZ Fn; // The current To_File of the table PCSZ Fn; // The current To_File of the table
OPVAL Op; // The file part operator OPVAL Op; // The file part operator
}; // end of class FIDBLK }; // end of class FIDBLK
@@ -178,7 +178,7 @@ class DllExport TIDBLK : public SPCBLK {
TIDBLK(void) {} TIDBLK(void) {}
// Members // Members
PSZ Tname; // The current table name PCSZ Tname; // The current table name
}; // end of class TIDBLK }; // end of class TIDBLK
/***********************************************************************/ /***********************************************************************/
@@ -201,7 +201,7 @@ class DllExport PRTBLK : public SPCBLK {
PRTBLK(void) {} PRTBLK(void) {}
// Members // Members
PSZ Pname; // The current partition name PCSZ Pname; // The current partition name
}; // end of class PRTBLK }; // end of class PRTBLK
/***********************************************************************/ /***********************************************************************/
@@ -224,7 +224,7 @@ class DllExport SIDBLK : public SPCBLK {
SIDBLK(void) {} SIDBLK(void) {}
// Members // Members
PSZ Sname; // The current server name PCSZ Sname; // The current server name
}; // end of class SIDBLK }; // end of class SIDBLK
#endif // __COLBLK__H #endif // __COLBLK__H

View File

@@ -12,7 +12,7 @@
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/***********************************************************************/ /***********************************************************************/
/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2017 */ /* Author Olivier BERTRAND bertrandop@gmail.com 2004-2017 */
@@ -121,8 +121,6 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
return true; return true;
if (dbuserp->Catalog) { if (dbuserp->Catalog) {
// ((MYCAT *)dbuserp->Catalog)->SetHandler(handler); done later
// ((MYCAT *)dbuserp->Catalog)->SetDataPath(g, pathname);
return false; // Nothing else to do return false; // Nothing else to do
} // endif Catalog } // endif Catalog
@@ -139,9 +137,6 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
if (!(dbuserp->Catalog= new MYCAT(handler))) if (!(dbuserp->Catalog= new MYCAT(handler)))
return true; return true;
//((MYCAT *)dbuserp->Catalog)->SetDataPath(g, pathname);
//dbuserp->UseTemp= TMP_AUTO;
/*********************************************************************/ /*********************************************************************/
/* All is correct. */ /* All is correct. */
/*********************************************************************/ /*********************************************************************/
@@ -173,7 +168,7 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
// info->mean_rec_length= tdbp->GetLrecl(); // info->mean_rec_length= tdbp->GetLrecl();
info->mean_rec_length= 0; info->mean_rec_length= 0;
info->data_file_name= (b) ? NULL : tdbp->GetFile(g); info->data_file_name= (b) ? NULL : (char*)tdbp->GetFile(g);
return true; return true;
} else { } else {
info->data_file_length= 0; info->data_file_length= 0;
@@ -201,21 +196,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
if (!cat) if (!cat)
return NULL; return NULL;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
tdbp = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
// Get table object from the catalog // Get table object from the catalog
tabp = new(g) XTAB(name); tabp = new(g) XTAB(name);
@@ -228,17 +209,12 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
if (!(tdbp = cat->GetTable(g, tabp, mode))) if (!(tdbp = cat->GetTable(g, tabp, mode)))
printf("CntGetTDB: %s\n", g->Message); printf("CntGetTDB: %s\n", g->Message);
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
} catch (const char *msg) { } catch (const char *msg) {
strcpy(g->Message, msg); strcpy(g->Message, msg);
} // end catch } // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
if (trace) if (trace)
printf("Returning tdbp=%p mode=%d\n", tdbp, mode); printf("Returning tdbp=%p mode=%d\n", tdbp, mode);
@@ -268,20 +244,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
return true; return true;
} // endif tdbp } // endif tdbp
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return true;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
goto err;
} // endif rc
#endif // !USE_TRY
if (!c1) { if (!c1) {
if (mode == MODE_INSERT) if (mode == MODE_INSERT)
// Allocate all column blocks for that table // Allocate all column blocks for that table
@@ -299,11 +262,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
if (g->Message[0] == 0) if (g->Message[0] == 0)
sprintf(g->Message, MSG(COL_ISNOT_TABLE), p, tdbp->GetName()); sprintf(g->Message, MSG(COL_ISNOT_TABLE), p, tdbp->GetName());
#if defined(USE_TRY)
throw 1; throw 1;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
} // endif colp } // endif colp
n = strlen(p) + 1; n = strlen(p) + 1;
@@ -311,39 +270,27 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
for (i = 0, colp = tdbp->GetColumns(); colp; i++, colp = colp->GetNext()) { for (i = 0, colp = tdbp->GetColumns(); colp; i++, colp = colp->GetNext()) {
if (colp->InitValue(g)) if (colp->InitValue(g))
#if defined(USE_TRY)
throw 2; throw 2;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
if (mode == MODE_INSERT) if (mode == MODE_INSERT)
// Allow type conversion // Allow type conversion
if (colp->SetBuffer(g, colp->GetValue(), true, false)) if (colp->SetBuffer(g, colp->GetValue(), true, false))
#if defined(USE_TRY)
throw 3; throw 3;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
colp->AddColUse(U_P); // For PLG tables colp->AddColUse(U_P); // For PLG tables
} // endfor colp } // endfor colp
/*********************************************************************/ /*******************************************************************/
/* In Update mode, the updated column blocks must be distinct from */ /* In Update mode, the updated column blocks must be distinct from */
/* the read column blocks. So make a copy of the TDB and allocate */ /* the read column blocks. So make a copy of the TDB and allocate */
/* its column blocks in mode write (required by XML tables). */ /* its column blocks in mode write (required by XML tables). */
/*********************************************************************/ /*******************************************************************/
if (mode == MODE_UPDATE) { if (mode == MODE_UPDATE) {
PTDBASE utp; PTDBASE utp;
if (!(utp = (PTDBASE)tdbp->Duplicate(g))) { if (!(utp = (PTDBASE)tdbp->Duplicate(g))) {
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName()); sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName());
#if defined(USE_TRY)
throw 4; throw 4;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
} // endif tp } // endif tp
if (!c2) if (!c2)
@@ -357,18 +304,10 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
for (i = 0, colp = utp->GetColumns(); colp; i++, colp = colp->GetNext()) { for (i = 0, colp = utp->GetColumns(); colp; i++, colp = colp->GetNext()) {
if (colp->InitValue(g)) if (colp->InitValue(g))
#if defined(USE_TRY)
throw 5; throw 5;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
if (colp->SetBuffer(g, colp->GetValue(), true, false)) if (colp->SetBuffer(g, colp->GetValue(), true, false))
#if defined(USE_TRY)
throw 6; throw 6;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
} // endfor colp } // endfor colp
@@ -400,11 +339,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
if (mode != MODE_ANY && mode != MODE_ALTER) { if (mode != MODE_ANY && mode != MODE_ALTER) {
if (tdbp->OpenDB(g)) { if (tdbp->OpenDB(g)) {
printf("%s\n", g->Message); printf("%s\n", g->Message);
#if defined(USE_TRY)
throw 7; throw 7;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
} else } else
tdbp->SetNext(NULL); tdbp->SetNext(NULL);
@@ -412,17 +347,13 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
rcop = false; rcop = false;
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
} catch (const char *msg) { } catch (const char *msg) {
strcpy(g->Message, msg); strcpy(g->Message, msg);
} // end catch } // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
return rcop; return rcop;
} // end of CntOpenTable } // end of CntOpenTable
@@ -446,28 +377,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
RCODE rc= RC_OK; RCODE rc= RC_OK;
PCOL colp; PCOL colp;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
if (trace) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
printf("EvalColumns: %s\n", g->Message);
} // endif
return RC_FX;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level]) != 0) {
if (trace)
printf("Error reading columns: %s\n", g->Message);
rc = RC_FX;
goto err;
} // endif rc
#endif // !USE_TRY
for (colp = tdbp->GetColumns(); rc == RC_OK && colp; for (colp = tdbp->GetColumns(); rc == RC_OK && colp;
colp = colp->GetNext()) { colp = colp->GetNext()) {
if (reset) if (reset)
@@ -480,7 +390,6 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
} // endfor colp } // endfor colp
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
printf("Error %d reading columns: %s\n", n, g->Message); printf("Error %d reading columns: %s\n", n, g->Message);
@@ -489,10 +398,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
} catch (const char *msg) { } catch (const char *msg) {
strcpy(g->Message, msg); strcpy(g->Message, msg);
} // end catch } // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
return rc; return rc;
} // end of EvalColumns } // end of EvalColumns
@@ -515,21 +421,7 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
((PTDBASE)tdbp)->ResetKindex(g, NULL); ((PTDBASE)tdbp)->ResetKindex(g, NULL);
} // endif index } // endif index
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return RC_FX;
} // endif jump_level
if ((setjmp(g->jumper[++g->jump_level])) != 0) {
rc = RC_FX;
goto err;
} // endif rc
#endif // !USE_TRY
// Do it now to avoid double eval when filtering // Do it now to avoid double eval when filtering
for (PCOL colp = tdbp->GetColumns(); colp; colp = colp->GetNext()) for (PCOL colp = tdbp->GetColumns(); colp; colp = colp->GetNext())
colp->Reset(); colp->Reset();
@@ -544,17 +436,13 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
if (rc == RC_OK) if (rc == RC_OK)
rc = EvalColumns(g, tdbp, false); rc = EvalColumns(g, tdbp, false);
#if defined(USE_TRY)
} catch (int) { } catch (int) {
rc = RC_FX; rc = RC_FX;
} catch (const char *msg) { } catch (const char *msg) {
strcpy(g->Message, msg); strcpy(g->Message, msg);
rc = RC_FX; rc = RC_FX;
} // end catch } // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
return rc; return rc;
} // end of CntReadNext } // end of CntReadNext
@@ -570,22 +458,7 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
if (!tdbp) if (!tdbp)
return RC_FX; return RC_FX;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return RC_FX;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level]) != 0) {
printf("%s\n", g->Message);
rc = RC_FX;
goto err;
} // endif rc
#endif // !USE_TRY
// Store column values in table write buffer(s) // Store column values in table write buffer(s)
for (colp = tdbp->GetSetCols(); colp; colp = colp->GetNext()) for (colp = tdbp->GetSetCols(); colp; colp = colp->GetNext())
if (!colp->GetColUse(U_VIRTUAL)) if (!colp->GetColUse(U_VIRTUAL))
@@ -598,7 +471,6 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
// Return result code from write operation // Return result code from write operation
rc = (RCODE)tdbp->WriteDB(g); rc = (RCODE)tdbp->WriteDB(g);
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
printf("Exception %d: %s\n", n, g->Message); printf("Exception %d: %s\n", n, g->Message);
rc = RC_FX; rc = RC_FX;
@@ -606,10 +478,7 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
strcpy(g->Message, msg); strcpy(g->Message, msg);
rc = RC_FX; rc = RC_FX;
} // end catch } // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
return rc; return rc;
} // end of CntWriteRow } // end of CntWriteRow
@@ -695,22 +564,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
break; break;
} // endswitch rc } // endswitch rc
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
rc = RC_FX;
goto err;
} // endif
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
rc = RC_FX;
goto err;
} // endif
#endif // !USE_TRY
// This will close the table file(s) and also finalize write // This will close the table file(s) and also finalize write
// operations such as Insert, Update, or Delete. // operations such as Insert, Update, or Delete.
tdbp->SetAbort(abort); tdbp->SetAbort(abort);
@@ -734,17 +588,12 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
} // endif nox } // endif nox
#if defined(USE_TRY)
} catch (int) { } catch (int) {
rc = RC_FX; rc = RC_FX;
} catch (const char *msg) { } catch (const char *msg) {
strcpy(g->Message, msg); strcpy(g->Message, msg);
rc = RC_FX; rc = RC_FX;
} // end catch } // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
if (trace > 1) if (trace > 1)
htrc("Done rc=%d\n", rc); htrc("Done rc=%d\n", rc);

View File

@@ -11,7 +11,7 @@
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 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 */

View File

@@ -63,7 +63,9 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all)
xp->Docp->Release(); xp->Docp->Release();
} catch(_com_error e) { } catch(_com_error e) {
sprintf(g->Message, "%s %s", MSG(COM_ERROR), e.Description()); char *p = _com_util::ConvertBSTRToString(e.Description());
sprintf(g->Message, "%s %s", MSG(COM_ERROR), p);
delete[] p;
} catch(...) {} } catch(...) {}
CoUninitialize(); CoUninitialize();
@@ -89,7 +91,7 @@ DOMDOC::DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
/******************************************************************/ /******************************************************************/
/* Initialize XML parser and check library compatibility. */ /* Initialize XML parser and check library compatibility. */
/******************************************************************/ /******************************************************************/
bool DOMDOC::Initialize(PGLOBAL g, char *entry, bool zipped) bool DOMDOC::Initialize(PGLOBAL g, PCSZ entry, bool zipped)
{ {
if (zipped && InitZip(g, entry)) if (zipped && InitZip(g, entry))
return true; return true;
@@ -155,7 +157,7 @@ PFBLOCK DOMDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn)
/******************************************************************/ /******************************************************************/
/* Create the XML node. */ /* Create the XML node. */
/******************************************************************/ /******************************************************************/
bool DOMDOC::NewDoc(PGLOBAL g, char *ver) bool DOMDOC::NewDoc(PGLOBAL g, PCSZ ver)
{ {
char buf[64]; char buf[64];
MSXML2::IXMLDOMProcessingInstructionPtr pip; MSXML2::IXMLDOMProcessingInstructionPtr pip;
@@ -490,9 +492,9 @@ PXATTR DOMNODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap)
/******************************************************************/ /******************************************************************/
/* Add a new element child node to this node and return it. */ /* Add a new element child node to this node and return it. */
/******************************************************************/ /******************************************************************/
PXNODE DOMNODE::AddChildNode(PGLOBAL g, char *name, PXNODE np) PXNODE DOMNODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np)
{ {
char *p, *pn; const char *p, *pn;
// char *p, *pn, *epf, *pf = NULL; // char *p, *pn, *epf, *pf = NULL;
MSXML2::IXMLDOMNodePtr ep; MSXML2::IXMLDOMNodePtr ep;
// _bstr_t uri((wchar_t*)NULL); // _bstr_t uri((wchar_t*)NULL);
@@ -585,7 +587,7 @@ PXATTR DOMNODE::AddProperty(PGLOBAL g, char *name, PXATTR ap)
/******************************************************************/ /******************************************************************/
/* Add a new text node to this node. */ /* Add a new text node to this node. */
/******************************************************************/ /******************************************************************/
void DOMNODE::AddText(PGLOBAL g, char *txtp) void DOMNODE::AddText(PGLOBAL g, PCSZ txtp)
{ {
MSXML2::IXMLDOMTextPtr tp= Docp->createTextNode((_bstr_t)txtp); MSXML2::IXMLDOMTextPtr tp= Docp->createTextNode((_bstr_t)txtp);

View File

@@ -37,9 +37,9 @@ class DOMDOC : public XMLDOCUMENT {
virtual void SetNofree(bool b) {} // Only libxml2 virtual void SetNofree(bool b) {} // Only libxml2
// Methods // Methods
virtual bool Initialize(PGLOBAL g, char *entry, bool zipped); virtual bool Initialize(PGLOBAL g, PCSZ entry, bool zipped);
virtual bool ParseFile(PGLOBAL g, char *fn); virtual bool ParseFile(PGLOBAL g, char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver); virtual bool NewDoc(PGLOBAL g, PCSZ 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);
@@ -78,9 +78,9 @@ class DOMNODE : public XMLNODE {
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, PCSZ 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, PCSZ txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp); virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected: protected:

View File

@@ -128,7 +128,7 @@ typedef struct _descriptor {
/* Moves file pointer to byte 32; fills buffer at buf with */ /* Moves file pointer to byte 32; fills buffer at buf with */
/* first 32 bytes of file. */ /* first 32 bytes of file. */
/****************************************************************************/ /****************************************************************************/
static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf) static int dbfhead(PGLOBAL g, FILE *file, PCSZ fn, DBFHEADER *buf)
{ {
char endmark[2]; char endmark[2];
int dbc = 2, rc = RC_OK; int dbc = 2, rc = RC_OK;
@@ -186,7 +186,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
/* DBFColumns: constructs the result blocks containing the description */ /* DBFColumns: constructs the result blocks containing the description */
/* of all the columns of a DBF file that will be retrieved by #GetData. */ /* of all the columns of a DBF file that will be retrieved by #GetData. */
/****************************************************************************/ /****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info) PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info)
{ {
int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_INT, TYPE_SHORT}; TYPE_INT, TYPE_INT, TYPE_SHORT};
@@ -393,7 +393,7 @@ DBFBASE::DBFBASE(DBFBASE *txfp)
/* and header length. Set Records, check that Reclen is equal to lrecl and */ /* and header length. Set Records, check that Reclen is equal to lrecl and */
/* return the header length or 0 in case of error. */ /* return the header length or 0 in case of error. */
/****************************************************************************/ /****************************************************************************/
int DBFBASE::ScanHeader(PGLOBAL g, PSZ fn, int lrecl, int *rln, char *defpath) int DBFBASE::ScanHeader(PGLOBAL g, PCSZ fn, int lrecl, int *rln, PCSZ defpath)
{ {
int rc; int rc;
char filename[_MAX_PATH]; char filename[_MAX_PATH];

View File

@@ -19,7 +19,7 @@ typedef class DBMFAM *PDBMFAM;
/****************************************************************************/ /****************************************************************************/
/* Functions used externally. */ /* Functions used externally. */
/****************************************************************************/ /****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info); PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info);
/****************************************************************************/ /****************************************************************************/
/* This is the base class for dBASE file access methods. */ /* This is the base class for dBASE file access methods. */
@@ -31,7 +31,7 @@ class DllExport DBFBASE {
DBFBASE(PDBF txfp); DBFBASE(PDBF txfp);
// Implementation // Implementation
int ScanHeader(PGLOBAL g, PSZ fname, int lrecl, int *rlen, char *defpath); int ScanHeader(PGLOBAL g, PCSZ fname, int lrecl, int *rlen, PCSZ defpath);
protected: protected:
// Default constructor, not to be used // Default constructor, not to be used

View File

@@ -761,7 +761,8 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw); htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
if (!brc || nbw != len) { if (!brc || nbw != len) {
char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile"; char buf[256];
PCSZ fn = (h == Hfile) ? To_File : "Tempfile";
if (brc) if (brc)
strcpy(buf, MSG(BAD_BYTE_NUM)); strcpy(buf, MSG(BAD_BYTE_NUM));

View File

@@ -920,7 +920,7 @@ int ZLBFAM::GetFileLength(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
bool ZLBFAM::AllocateBuffer(PGLOBAL g) bool ZLBFAM::AllocateBuffer(PGLOBAL g)
{ {
char *msg; PCSZ msg;
int n, zrc; int n, zrc;
#if 0 #if 0

View File

@@ -71,8 +71,23 @@ TXTFAM::TXTFAM(PDOSDEF tdp)
{ {
Tdbp = NULL; Tdbp = NULL;
To_Fb = NULL; To_Fb = NULL;
if (tdp) {
To_File = tdp->Fn; To_File = tdp->Fn;
Lrecl = tdp->Lrecl; Lrecl = tdp->Lrecl;
Eof = tdp->Eof;
Ending = tdp->Ending;
} else {
To_File = NULL;
Lrecl = 0;
Eof = false;
#if defined(__WIN__)
Ending = 2;
#else
Ending = 1;
#endif
} // endif tdp
Placed = false; Placed = false;
IsRead = true; IsRead = true;
Blocked = false; Blocked = false;
@@ -103,8 +118,6 @@ TXTFAM::TXTFAM(PDOSDEF tdp)
Blksize = 0; Blksize = 0;
Fpos = Spos = Tpos = 0; Fpos = Spos = Tpos = 0;
Padded = false; Padded = false;
Eof = tdp->Eof;
Ending = tdp->Ending;
Abort = false; Abort = false;
CrLf = (char*)(Ending == 1 ? "\n" : "\r\n"); CrLf = (char*)(Ending == 1 ? "\n" : "\r\n");
} // end of TXTFAM standard constructor } // end of TXTFAM standard constructor
@@ -1161,20 +1174,12 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
if (rename(filename, filetemp)) { // Save file for security if (rename(filename, filetemp)) { // Save file for security
sprintf(g->Message, MSG(RENAME_ERROR), sprintf(g->Message, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno)); filename, filetemp, strerror(errno));
#if defined(USE_TRY)
throw 51; throw 51;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 51);
#endif // !USE_TRY
} else if (rename(tempname, filename)) { } else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR), sprintf(g->Message, MSG(RENAME_ERROR),
tempname, filename, strerror(errno)); tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file rc = rename(filetemp, filename); // Restore saved file
#if defined(USE_TRY)
throw 52; throw 52;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 52);
#endif // !USE_TRY
} else if (remove(filetemp)) { } else if (remove(filetemp)) {
sprintf(g->Message, MSG(REMOVE_ERROR), sprintf(g->Message, MSG(REMOVE_ERROR),
filetemp, strerror(errno)); filetemp, strerror(errno));

View File

@@ -80,7 +80,7 @@ class DllExport TXTFAM : public BLOCK {
protected: protected:
// Members // Members
PTDBDOS Tdbp; // To table class PTDBDOS Tdbp; // To table class
PSZ To_File; // Points to table file name PCSZ To_File; // Points to table file name
PFBLOCK To_Fb; // Pointer to file block PFBLOCK To_Fb; // Pointer to file block
PPARM To_Pos; // Pointer to position list PPARM To_Pos; // Pointer to position list
PPARM To_Sos; // Pointer to start position list PPARM To_Sos; // Pointer to start position list

View File

@@ -144,7 +144,7 @@ int VCTFAM::GetFileLength(PGLOBAL g)
if (Split) { if (Split) {
// Get the total file length // Get the total file length
char filename[_MAX_PATH]; char filename[_MAX_PATH];
char *savfile = To_File; PCSZ savfile = To_File;
int i, len = 0; int i, len = 0;
// Initialize the array of file structures // Initialize the array of file structures
@@ -313,7 +313,7 @@ int VCTFAM::Cardinality(PGLOBAL g)
// and Last must be set from the file cardinality. // and Last must be set from the file cardinality.
// Only happens when called by sub classes. // Only happens when called by sub classes.
char filename[_MAX_PATH]; char filename[_MAX_PATH];
PSZ savfn = To_File; PCSZ savfn = To_File;
int len, clen, card = -1; int len, clen, card = -1;
PCOLDEF cdp = Tdbp->GetDef()->GetCols(); PCOLDEF cdp = Tdbp->GetDef()->GetCols();
@@ -368,7 +368,7 @@ int VCTFAM::GetRowID(void)
/***********************************************************************/ /***********************************************************************/
/* VCT Create an empty file for Vector formatted tables. */ /* VCT Create an empty file for Vector formatted tables. */
/***********************************************************************/ /***********************************************************************/
bool VCTFAM::MakeEmptyFile(PGLOBAL g, char *fn) bool VCTFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
{ {
// Vector formatted file: this will create an empty file of the // Vector formatted file: this will create an empty file of the
// required length if it does not exists yet. // required length if it does not exists yet.
@@ -575,26 +575,11 @@ bool VCTFAM::InitInsert(PGLOBAL g)
CurBlk = Block - 1; CurBlk = Block - 1;
CurNum = Last; CurNum = Last;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return true;
} // endif
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
g->jump_level--;
return true;
} // endif
#endif // !USE_TRY
// Last block must be updated by new values // Last block must be updated by new values
for (; cp; cp = (PVCTCOL)cp->Next) for (; cp; cp = (PVCTCOL)cp->Next)
cp->ReadBlock(g); cp->ReadBlock(g);
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -603,9 +588,7 @@ bool VCTFAM::InitInsert(PGLOBAL g)
strcpy(g->Message, msg); strcpy(g->Message, msg);
rc = true; rc = true;
} // end catch } // end catch
#else // !USE_TRY
g->jump_level--;
#endif // !USE_TRY
} // endif Last } // endif Last
if (!rc) if (!rc)
@@ -897,7 +880,8 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/ /***********************************************************************/
bool VCTFAM::OpenTempFile(PGLOBAL g) bool VCTFAM::OpenTempFile(PGLOBAL g)
{ {
char *opmode, tempname[_MAX_PATH]; PCSZ opmode;
char tempname[_MAX_PATH];
bool rc = false; bool rc = false;
/*********************************************************************/ /*********************************************************************/
@@ -1126,11 +1110,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort)
} else if (AddBlock) { } else if (AddBlock) {
// Last block was not written // Last block was not written
rc = ResetTableSize(g, CurBlk, Nrec); rc = ResetTableSize(g, CurBlk, Nrec);
#if defined(USE_TRY)
throw 44; throw 44;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 44);
#endif // !USE_TRY
} // endif } // endif
} else if (mode == MODE_UPDATE) { } else if (mode == MODE_UPDATE) {
@@ -1565,26 +1545,11 @@ bool VCMFAM::InitInsert(PGLOBAL g)
CurNum = Last; CurNum = Last;
} // endif Last } // endif Last
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return true;
} // endif
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
g->jump_level--;
return true;
} // endif
#endif // !USE_TRY
// Initialize the column block pointer // Initialize the column block pointer
for (; cp; cp = (PVCTCOL)cp->Next) for (; cp; cp = (PVCTCOL)cp->Next)
cp->ReadBlock(g); cp->ReadBlock(g);
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -1593,9 +1558,7 @@ bool VCMFAM::InitInsert(PGLOBAL g)
strcpy(g->Message, msg); strcpy(g->Message, msg);
rc = true; rc = true;
} // end catch } // end catch
#else // !USE_TRY
g->jump_level--;
#endif // !USE_TRY
return rc; return rc;
} // end of InitInsert } // end of InitInsert
@@ -2036,7 +1999,7 @@ bool VECFAM::OpenTableFile(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* Open the file corresponding to one column. */ /* Open the file corresponding to one column. */
/***********************************************************************/ /***********************************************************************/
bool VECFAM::OpenColumnFile(PGLOBAL g, char *opmode, int i) bool VECFAM::OpenColumnFile(PGLOBAL g, PCSZ opmode, int i)
{ {
char filename[_MAX_PATH]; char filename[_MAX_PATH];
PDBUSER dup = PlgGetUser(g); PDBUSER dup = PlgGetUser(g);
@@ -2541,11 +2504,7 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort)
if (wrc != RC_FX) if (wrc != RC_FX)
rc = ResetTableSize(g, Block, Last); rc = ResetTableSize(g, Block, Last);
else else
#if defined(USE_TRY)
throw 44; throw 44;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 44);
#endif // !USE_TRY
} else if (mode == MODE_UPDATE) { } else if (mode == MODE_UPDATE) {
if (UseTemp && !InitUpdate && !Abort) { if (UseTemp && !InitUpdate && !Abort) {
@@ -3185,7 +3144,8 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw); htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
if (!brc || nbw != len) { if (!brc || nbw != len) {
char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile"; char buf[256];
PCSZ fn = (h == Hfile) ? To_File : "Tempfile";
if (brc) if (brc)
strcpy(buf, MSG(BAD_BYTE_NUM)); strcpy(buf, MSG(BAD_BYTE_NUM));
@@ -3361,7 +3321,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* VEC Create an empty file for new Vector formatted tables. */ /* VEC Create an empty file for new Vector formatted tables. */
/***********************************************************************/ /***********************************************************************/
bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
{ {
// Vector formatted file this will create an empty file of the // Vector formatted file this will create an empty file of the
// required length if it does not exists yet. // required length if it does not exists yet.
@@ -3371,7 +3331,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
PlugSetPath(filename, fn, Tdbp->GetPath()); PlugSetPath(filename, fn, Tdbp->GetPath());
#if defined(__WIN__) #if defined(__WIN__)
char *p; PCSZ p;
DWORD rc; DWORD rc;
bool brc; bool brc;
LARGE_INTEGER of; LARGE_INTEGER of;
@@ -4206,11 +4166,7 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort)
} else if (AddBlock) { } else if (AddBlock) {
// Last block was not written // Last block was not written
rc = ResetTableSize(g, CurBlk, Nrec); rc = ResetTableSize(g, CurBlk, Nrec);
#if defined(USE_TRY)
throw 44; throw 44;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 44);
#endif // !USE_TRY
} // endif } // endif
} else if (mode == MODE_UPDATE) { } else if (mode == MODE_UPDATE) {

View File

@@ -61,7 +61,7 @@ class DllExport VCTFAM : public FIXFAM {
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, PCSZ 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);
@@ -160,7 +160,7 @@ class DllExport VECFAM : public VCTFAM {
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, PCSZ opmode, int i);
// Members // Members
FILE* *Streams; // Points to Dos file structure array FILE* *Streams; // Points to Dos file structure array
@@ -235,7 +235,7 @@ class BGVFAM : public VCTFAM {
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, PCSZ 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);

View File

@@ -45,12 +45,12 @@
#define WRITEBUFFERSIZE (16384) #define WRITEBUFFERSIZE (16384)
bool ZipLoadFile(PGLOBAL g, char *zfn, char *fn, char *entry, bool append, bool mul); bool ZipLoadFile(PGLOBAL g, PCSZ zfn, PCSZ fn, PCSZ entry, bool append, bool mul);
/***********************************************************************/ /***********************************************************************/
/* Compress a file in zip when creating a table. */ /* Compress a file in zip when creating a table. */
/***********************************************************************/ /***********************************************************************/
static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, char *fn, char *entry, char *buf) static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, PCSZ fn, PCSZ entry, char *buf)
{ {
int rc = RC_OK, size_read, size_buf = WRITEBUFFERSIZE; int rc = RC_OK, size_read, size_buf = WRITEBUFFERSIZE;
FILE *fin; FILE *fin;
@@ -88,7 +88,7 @@ static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, char *fn, char *entry, char *buf)
/***********************************************************************/ /***********************************************************************/
/* Find and Compress several files in zip when creating a table. */ /* Find and Compress several files in zip when creating a table. */
/***********************************************************************/ /***********************************************************************/
static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, char *pat, char *buf) static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf)
{ {
char filename[_MAX_PATH]; char filename[_MAX_PATH];
int rc; int rc;
@@ -203,7 +203,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, char *pat, char *buf)
/***********************************************************************/ /***********************************************************************/
/* Load and Compress a file in zip when creating a table. */ /* Load and Compress a file in zip when creating a table. */
/***********************************************************************/ /***********************************************************************/
bool ZipLoadFile(PGLOBAL g, char *zfn, char *fn, char *entry, bool append, bool mul) bool ZipLoadFile(PGLOBAL g, PCSZ zfn, PCSZ fn, PCSZ entry, bool append, bool mul)
{ {
char *buf; char *buf;
bool err; bool err;
@@ -228,7 +228,7 @@ bool ZipLoadFile(PGLOBAL g, char *zfn, char *fn, char *entry, bool append, bool
/***********************************************************************/ /***********************************************************************/
/* Constructors. */ /* Constructors. */
/***********************************************************************/ /***********************************************************************/
ZIPUTIL::ZIPUTIL(PSZ tgt) ZIPUTIL::ZIPUTIL(PCSZ tgt)
{ {
zipfile = NULL; zipfile = NULL;
target = tgt; target = tgt;
@@ -269,7 +269,7 @@ void ZIPUTIL::getTime(tm_zip& tmZip)
/* append: set true to append the zip file */ /* append: set true to append the zip file */
/* return: true if open, false otherwise. */ /* return: true if open, false otherwise. */
/***********************************************************************/ /***********************************************************************/
bool ZIPUTIL::open(PGLOBAL g, char *filename, bool append) bool ZIPUTIL::open(PGLOBAL g, PCSZ filename, bool append)
{ {
if (!zipfile && !(zipfile = zipOpen64(filename, if (!zipfile && !(zipfile = zipOpen64(filename,
append ? APPEND_STATUS_ADDINZIP append ? APPEND_STATUS_ADDINZIP
@@ -295,7 +295,7 @@ void ZIPUTIL::close()
/***********************************************************************/ /***********************************************************************/
/* OpenTableFile: Open a DOS/UNIX table file from a ZIP file. */ /* OpenTableFile: Open a DOS/UNIX table file from a ZIP file. */
/***********************************************************************/ /***********************************************************************/
bool ZIPUTIL::OpenTable(PGLOBAL g, MODE mode, char *fn, bool append) bool ZIPUTIL::OpenTable(PGLOBAL g, MODE mode, PCSZ fn, bool append)
{ {
/*********************************************************************/ /*********************************************************************/
/* The file will be compressed. */ /* The file will be compressed. */
@@ -338,7 +338,7 @@ bool ZIPUTIL::OpenTable(PGLOBAL g, MODE mode, char *fn, bool append)
/***********************************************************************/ /***********************************************************************/
/* Add target in zip file. */ /* Add target in zip file. */
/***********************************************************************/ /***********************************************************************/
bool ZIPUTIL::addEntry(PGLOBAL g, char *entry) bool ZIPUTIL::addEntry(PGLOBAL g, PCSZ entry)
{ {
//?? we dont need the stinking time //?? we dont need the stinking time
zip_fileinfo zi = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; zip_fileinfo zi = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -382,7 +382,7 @@ void ZIPUTIL::closeEntry()
/***********************************************************************/ /***********************************************************************/
/* Constructors. */ /* Constructors. */
/***********************************************************************/ /***********************************************************************/
UNZIPUTL::UNZIPUTL(PSZ tgt, bool mul) UNZIPUTL::UNZIPUTL(PCSZ tgt, bool mul)
{ {
zipfile = NULL; zipfile = NULL;
target = tgt; target = tgt;
@@ -439,8 +439,8 @@ UNZIPUTL::UNZIPUTL(PZIPUTIL zutp)
/* This code is the copyright property of Alessandro Felice Cantatore. */ /* This code is the copyright property of Alessandro Felice Cantatore. */
/* http://xoomer.virgilio.it/acantato/dev/wildcard/wildmatch.html */ /* http://xoomer.virgilio.it/acantato/dev/wildcard/wildmatch.html */
/***********************************************************************/ /***********************************************************************/
bool UNZIPUTL::WildMatch(PSZ pat, PSZ str) { bool UNZIPUTL::WildMatch(PCSZ pat, PCSZ str) {
PSZ s, p; PCSZ s, p;
bool star = FALSE; bool star = FALSE;
loopStart: loopStart:
@@ -474,7 +474,7 @@ starCheck:
/* param: filename path and the filename of the zip file to open. */ /* param: filename path and the filename of the zip file to open. */
/* return: true if open, false otherwise. */ /* return: true if open, false otherwise. */
/***********************************************************************/ /***********************************************************************/
bool UNZIPUTL::open(PGLOBAL g, char *filename) bool UNZIPUTL::open(PGLOBAL g, PCSZ filename)
{ {
if (!zipfile && !(zipfile = unzOpen64(filename))) if (!zipfile && !(zipfile = unzOpen64(filename)))
sprintf(g->Message, "Zipfile open error on %s", filename); sprintf(g->Message, "Zipfile open error on %s", filename);
@@ -564,7 +564,7 @@ int UNZIPUTL::nextEntry(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* OpenTableFile: Open a DOS/UNIX table file from a ZIP file. */ /* OpenTableFile: Open a DOS/UNIX table file from a ZIP file. */
/***********************************************************************/ /***********************************************************************/
bool UNZIPUTL::OpenTable(PGLOBAL g, MODE mode, char *fn) bool UNZIPUTL::OpenTable(PGLOBAL g, MODE mode, PCSZ fn)
{ {
/*********************************************************************/ /*********************************************************************/
/* The file will be decompressed into virtual memory. */ /* The file will be decompressed into virtual memory. */
@@ -636,7 +636,7 @@ bool UNZIPUTL::OpenTable(PGLOBAL g, MODE mode, char *fn)
/***********************************************************************/ /***********************************************************************/
/* Insert only if the entry does not exist. */ /* Insert only if the entry does not exist. */
/***********************************************************************/ /***********************************************************************/
bool UNZIPUTL::IsInsertOk(PGLOBAL g, char *fn) bool UNZIPUTL::IsInsertOk(PGLOBAL g, PCSZ fn)
{ {
bool ok = true, b = open(g, fn); bool ok = true, b = open(g, fn);

View File

@@ -27,16 +27,13 @@ typedef class ZPXFAM *PZPXFAM;
class DllExport ZIPUTIL : public BLOCK { class DllExport ZIPUTIL : public BLOCK {
public: public:
// Constructor // Constructor
ZIPUTIL(PSZ tgt); ZIPUTIL(PCSZ tgt);
//ZIPUTIL(ZIPUTIL *zutp); //ZIPUTIL(ZIPUTIL *zutp);
// Implementation
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
// Methods // Methods
bool OpenTable(PGLOBAL g, MODE mode, char *fn, bool append); bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn, bool append);
bool open(PGLOBAL g, char *fn, bool append); bool open(PGLOBAL g, PCSZ fn, bool append);
bool addEntry(PGLOBAL g, char *entry); bool addEntry(PGLOBAL g, PCSZ entry);
void close(void); void close(void);
void closeEntry(void); void closeEntry(void);
int writeEntry(PGLOBAL g, char *buf, int len); int writeEntry(PGLOBAL g, char *buf, int len);
@@ -44,16 +41,10 @@ class DllExport ZIPUTIL : public BLOCK {
// Members // Members
zipFile zipfile; // The ZIP container file zipFile zipfile; // The ZIP container file
PSZ target; // The target file name PCSZ target; // The target file name
PSZ pwd; // The ZIP file password PCSZ pwd; // The ZIP file password
//unz_file_info finfo; // The current file info
PFBLOCK fp; PFBLOCK fp;
//char *memory;
//uint size;
//int multiple; // Multiple targets
bool entryopen; // True when open current entry bool entryopen; // True when open current entry
//char fn[FILENAME_MAX]; // The current entry file name
//char mapCaseTable[256];
}; // end of ZIPUTIL }; // end of ZIPUTIL
/***********************************************************************/ /***********************************************************************/
@@ -62,27 +53,27 @@ class DllExport ZIPUTIL : public BLOCK {
class DllExport UNZIPUTL : public BLOCK { class DllExport UNZIPUTL : public BLOCK {
public: public:
// Constructor // Constructor
UNZIPUTL(PSZ tgt, bool mul); UNZIPUTL(PCSZ tgt, bool mul);
UNZIPUTL(PDOSDEF tdp); UNZIPUTL(PDOSDEF tdp);
// Implementation // Implementation
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); } //PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
// Methods // Methods
bool OpenTable(PGLOBAL g, MODE mode, char *fn); bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn);
bool open(PGLOBAL g, char *fn); bool open(PGLOBAL g, PCSZ fn);
bool openEntry(PGLOBAL g); bool openEntry(PGLOBAL g);
void close(void); void close(void);
void closeEntry(void); void closeEntry(void);
bool WildMatch(PSZ pat, PSZ str); bool WildMatch(PCSZ pat, PCSZ str);
int findEntry(PGLOBAL g, bool next); int findEntry(PGLOBAL g, bool next);
int nextEntry(PGLOBAL g); int nextEntry(PGLOBAL g);
bool IsInsertOk(PGLOBAL g, char *fn); bool IsInsertOk(PGLOBAL g, PCSZ fn);
// Members // Members
unzFile zipfile; // The ZIP container file unzFile zipfile; // The ZIP container file
PSZ target; // The target file name PCSZ target; // The target file name
PSZ pwd; // The ZIP file password PCSZ pwd; // The ZIP file password
unz_file_info finfo; // The current file info unz_file_info finfo; // The current file info
PFBLOCK fp; PFBLOCK fp;
char *memory; char *memory;
@@ -123,8 +114,6 @@ class DllExport UNZFAM : public MAPFAM {
// Members // Members
UNZIPUTL *zutp; UNZIPUTL *zutp;
PDOSDEF tdfp; PDOSDEF tdfp;
//PSZ target;
//bool mul;
}; // end of UNZFAM }; // end of UNZFAM
/***********************************************************************/ /***********************************************************************/
@@ -152,8 +141,6 @@ class DllExport UZXFAM : public MPXFAM {
// Members // Members
UNZIPUTL *zutp; UNZIPUTL *zutp;
PDOSDEF tdfp; PDOSDEF tdfp;
//PSZ target;
//bool mul;
}; // end of UZXFAM }; // end of UZXFAM
/***********************************************************************/ /***********************************************************************/
@@ -180,8 +167,9 @@ class DllExport ZIPFAM : public DOSFAM {
protected: protected:
// Members // Members
ZIPUTIL *zutp; ZIPUTIL *zutp;
PSZ target; PCSZ target;
bool append; bool append;
//bool replace;
}; // end of ZIPFAM }; // end of ZIPFAM
/***********************************************************************/ /***********************************************************************/
@@ -205,7 +193,7 @@ class DllExport ZPXFAM : public FIXFAM {
protected: protected:
// Members // Members
ZIPUTIL *zutp; ZIPUTIL *zutp;
PSZ target; PCSZ target;
bool append; bool append;
}; // end of ZPXFAM }; // end of ZPXFAM

View File

@@ -87,11 +87,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
case OP_EXIST: bt = 0x00; break; case OP_EXIST: bt = 0x00; break;
default: default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc); sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
#if defined(USE_TRY)
throw TYPE_ARRAY; throw TYPE_ARRAY;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
#endif // !USE_TRY
} // endswitch opc } // endswitch opc
return bt; return bt;
@@ -1715,11 +1711,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
break; // Remove eventual ending separator(s) break; // Remove eventual ending separator(s)
// if (fp->Convert(g, having)) // if (fp->Convert(g, having))
//#if defined(USE_TRY)
// throw TYPE_ARRAY; // throw TYPE_ARRAY;
//#else // !USE_TRY
// longjmp(g->jumper[g->jump_level], TYPE_FILTER);
//#endif // !USE_TRY
filp = fp; filp = fp;
fp = fp->Next; fp = fp->Next;
@@ -1752,11 +1744,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
// return TRUE; // return TRUE;
if (filp->Eval(g)) if (filp->Eval(g))
#if defined(USE_TRY)
throw TYPE_FILTER; throw TYPE_FILTER;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_FILTER);
#endif // !USE_TRY
if (trace > 1) if (trace > 1)
htrc("PlugFilter filp=%p result=%d\n", htrc("PlugFilter filp=%p result=%d\n",

View File

@@ -59,7 +59,7 @@
#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 4160 /* Maximum message 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 */

View File

@@ -11,7 +11,7 @@
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/** /**
@file ha_connect.cc @file ha_connect.cc
@@ -172,9 +172,9 @@
#define JSONMAX 10 // JSON Default max grp size #define JSONMAX 10 // JSON Default max grp size
extern "C" { extern "C" {
char version[]= "Version 1.05.0003 March 7, 2017"; char version[]= "Version 1.06.0001 April 17, 2017";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.05.0003 " __DATE__ " " __TIME__; char compver[]= "Version 1.06.0001 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
#else // !__WIN__ #else // !__WIN__
char slash= '/'; char slash= '/';
@@ -209,14 +209,15 @@ pthread_mutex_t parmut = PTHREAD_MUTEX_INITIALIZER;
/***********************************************************************/ /***********************************************************************/
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
PQRYRES VirColumns(PGLOBAL g, bool info); PQRYRES VirColumns(PGLOBAL g, bool info);
PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info); PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info);
PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info); PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info);
int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v); int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v);
void PushWarning(PGLOBAL g, THD *thd, int level); void PushWarning(PGLOBAL g, THD *thd, int level);
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host, bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, PCSZ host, PCSZ db,
const char *db, char *tab, const char *src, int port); PCSZ tab, PCSZ src, int port);
bool ZipLoadFile(PGLOBAL, char*, char*, char*, bool, bool); bool ZipLoadFile(PGLOBAL, PCSZ, PCSZ, PCSZ, bool, bool);
bool ExactInfo(void); bool ExactInfo(void);
void mongo_init(bool);
USETEMP UseTemp(void); USETEMP UseTemp(void);
int GetConvSize(void); int GetConvSize(void);
TYPCONV GetTypeConv(void); TYPCONV GetTypeConv(void);
@@ -670,7 +671,7 @@ static int connect_init_func(void *p)
sql_print_information("CONNECT: %s", version); sql_print_information("CONNECT: %s", version);
#endif // !__WIN__ #endif // !__WIN__
#ifdef LIBXML2_SUPPORT #if defined(LIBXML2_SUPPORT)
XmlInitParserLib(); XmlInitParserLib();
#endif // LIBXML2_SUPPORT #endif // LIBXML2_SUPPORT
@@ -1018,15 +1019,14 @@ ulonglong ha_connect::table_flags() const
/****************************************************************************/ /****************************************************************************/
/* Return the value of an option specified in an option list. */ /* Return the value of an option specified in an option list. */
/****************************************************************************/ /****************************************************************************/
char *GetListOption(PGLOBAL g, const char *opname, PCSZ GetListOption(PGLOBAL g, PCSZ opname, PCSZ oplist, PCSZ def)
const char *oplist, const char *def)
{ {
if (!oplist) if (!oplist)
return (char*)def; return (char*)def;
char key[16], val[256]; char key[16], val[256];
char *pk, *pv, *pn; char *pk, *pv, *pn;
char *opval= (char*)def; PCSZ opval= def;
int n; int n;
for (pk= (char*)oplist; pk; pk= ++pn) { for (pk= (char*)oplist; pk; pk= ++pn) {
@@ -1062,9 +1062,9 @@ char *GetListOption(PGLOBAL g, const char *opname,
/****************************************************************************/ /****************************************************************************/
/* Return the value of a string option or NULL if not specified. */ /* Return the value of a string option or NULL if not specified. */
/****************************************************************************/ /****************************************************************************/
char *GetStringTableOption(PGLOBAL g, PTOS options, char *opname, char *sdef) PCSZ GetStringTableOption(PGLOBAL g, PTOS options, PCSZ opname, PCSZ sdef)
{ {
const char *opval= NULL; PCSZ opval= NULL;
if (!options) if (!options)
return sdef; return sdef;
@@ -1107,10 +1107,10 @@ char *GetStringTableOption(PGLOBAL g, PTOS options, char *opname, char *sdef)
/****************************************************************************/ /****************************************************************************/
/* Return the value of a Boolean option or bdef if not specified. */ /* Return the value of a Boolean option or bdef if not specified. */
/****************************************************************************/ /****************************************************************************/
bool GetBooleanTableOption(PGLOBAL g, PTOS options, char *opname, bool bdef) bool GetBooleanTableOption(PGLOBAL g, PTOS options, PCSZ opname, bool bdef)
{ {
bool opval= bdef; bool opval= bdef;
char *pv; PCSZ pv;
if (!options) if (!options)
return bdef; return bdef;
@@ -1138,7 +1138,7 @@ bool GetBooleanTableOption(PGLOBAL g, PTOS options, char *opname, bool bdef)
/****************************************************************************/ /****************************************************************************/
/* Return the value of an integer option or NO_IVAL if not specified. */ /* Return the value of an integer option or NO_IVAL if not specified. */
/****************************************************************************/ /****************************************************************************/
int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef) int GetIntegerTableOption(PGLOBAL g, PTOS options, PCSZ opname, int idef)
{ {
ulonglong opval= (ulonglong) NO_IVAL; ulonglong opval= (ulonglong) NO_IVAL;
@@ -1160,10 +1160,10 @@ int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef)
opval= (options->compressed); opval= (options->compressed);
if ((ulonglong) opval == (ulonglong)NO_IVAL) { if ((ulonglong) opval == (ulonglong)NO_IVAL) {
char *pv; PCSZ pv;
if ((pv= GetListOption(g, opname, options->oplist))) if ((pv= GetListOption(g, opname, options->oplist)))
opval= CharToNumber(pv, strlen(pv), ULONGLONG_MAX, true); opval= CharToNumber((char*)pv, strlen(pv), ULONGLONG_MAX, true);
else else
return idef; return idef;
@@ -1188,7 +1188,7 @@ PTOS ha_connect::GetTableOptionStruct(TABLE_SHARE *s)
/****************************************************************************/ /****************************************************************************/
/* Return the string eventually formatted with partition name. */ /* Return the string eventually formatted with partition name. */
/****************************************************************************/ /****************************************************************************/
char *ha_connect::GetRealString(const char *s) char *ha_connect::GetRealString(PCSZ s)
{ {
char *sv; char *sv;
@@ -1205,9 +1205,9 @@ char *ha_connect::GetRealString(const char *s)
/****************************************************************************/ /****************************************************************************/
/* Return the value of a string option or sdef if not specified. */ /* Return the value of a string option or sdef if not specified. */
/****************************************************************************/ /****************************************************************************/
char *ha_connect::GetStringOption(char *opname, char *sdef) PCSZ ha_connect::GetStringOption(PCSZ opname, PCSZ sdef)
{ {
char *opval= NULL; PCSZ opval= NULL;
PTOS options= GetTableOptionStruct(); PTOS options= GetTableOptionStruct();
if (!stricmp(opname, "Connect")) { if (!stricmp(opname, "Connect")) {
@@ -1267,7 +1267,7 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
/****************************************************************************/ /****************************************************************************/
/* Return the value of a Boolean option or bdef if not specified. */ /* Return the value of a Boolean option or bdef if not specified. */
/****************************************************************************/ /****************************************************************************/
bool ha_connect::GetBooleanOption(char *opname, bool bdef) bool ha_connect::GetBooleanOption(PCSZ opname, bool bdef)
{ {
bool opval; bool opval;
PTOS options= GetTableOptionStruct(); PTOS options= GetTableOptionStruct();
@@ -1284,7 +1284,7 @@ bool ha_connect::GetBooleanOption(char *opname, bool bdef)
/* Set the value of the opname option (does not work for oplist options) */ /* Set the value of the opname option (does not work for oplist options) */
/* Currently used only to set the Sepindex value. */ /* Currently used only to set the Sepindex value. */
/****************************************************************************/ /****************************************************************************/
bool ha_connect::SetBooleanOption(char *opname, bool b) bool ha_connect::SetBooleanOption(PCSZ opname, bool b)
{ {
PTOS options= GetTableOptionStruct(); PTOS options= GetTableOptionStruct();
@@ -1302,7 +1302,7 @@ bool ha_connect::SetBooleanOption(char *opname, bool b)
/****************************************************************************/ /****************************************************************************/
/* Return the value of an integer option or NO_IVAL if not specified. */ /* Return the value of an integer option or NO_IVAL if not specified. */
/****************************************************************************/ /****************************************************************************/
int ha_connect::GetIntegerOption(char *opname) int ha_connect::GetIntegerOption(PCSZ opname)
{ {
int opval; int opval;
PTOS options= GetTableOptionStruct(); PTOS options= GetTableOptionStruct();
@@ -1322,7 +1322,7 @@ int ha_connect::GetIntegerOption(char *opname)
/* Set the value of the opname option (does not work for oplist options) */ /* Set the value of the opname option (does not work for oplist options) */
/* Currently used only to set the Lrecl value. */ /* Currently used only to set the Lrecl value. */
/****************************************************************************/ /****************************************************************************/
bool ha_connect::SetIntegerOption(char *opname, int n) bool ha_connect::SetIntegerOption(PCSZ opname, int n)
{ {
PTOS options= GetTableOptionStruct(); PTOS options= GetTableOptionStruct();
@@ -1522,7 +1522,7 @@ PXOS ha_connect::GetIndexOptionStruct(KEY *kp)
/****************************************************************************/ /****************************************************************************/
/* Return a Boolean index option or false if not specified. */ /* Return a Boolean index option or false if not specified. */
/****************************************************************************/ /****************************************************************************/
bool ha_connect::GetIndexOption(KEY *kp, char *opname) bool ha_connect::GetIndexOption(KEY *kp, PCSZ opname)
{ {
bool opval= false; bool opval= false;
PXOS options= GetIndexOptionStruct(kp); PXOS options= GetIndexOptionStruct(kp);
@@ -1534,7 +1534,7 @@ bool ha_connect::GetIndexOption(KEY *kp, char *opname)
opval= options->mapped; opval= options->mapped;
} else if (kp->comment.str && kp->comment.length) { } else if (kp->comment.str && kp->comment.length) {
char *pv, *oplist= strz(xp->g, kp->comment); PCSZ pv, oplist= strz(xp->g, kp->comment);
if ((pv= GetListOption(xp->g, opname, oplist))) if ((pv= GetListOption(xp->g, opname, oplist)))
opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0); opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0);
@@ -1901,41 +1901,21 @@ bool ha_connect::CheckColumnList(PGLOBAL g)
Field* fp; Field* fp;
MY_BITMAP *map= table->read_set; MY_BITMAP *map= table->read_set;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return true;
} // endif jump_level
if (!setjmp(g->jumper[++g->jump_level])) {
#endif // !USE_TRY
for (field= table->field; fp= *field; field++) for (field= table->field; fp= *field; field++)
if (bitmap_is_set(map, fp->field_index)) { if (bitmap_is_set(map, fp->field_index)) {
if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name, 0))) { if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name, 0))) {
sprintf(g->Message, "Column %s not found in %s", sprintf(g->Message, "Column %s not found in %s",
fp->field_name, tdbp->GetName()); fp->field_name, tdbp->GetName());
#if defined(USE_TRY)
throw 1; throw 1;
#else // !USE_TRY
brc = true;
goto fin;
#endif // !USE_TRY
} // endif colp } // endif colp
if ((brc= colp->InitValue(g))) if ((brc= colp->InitValue(g)))
#if defined(USE_TRY)
throw 2; throw 2;
#else // !USE_TRY
goto fin;
#endif // !USE_TRY
colp->AddColUse(U_P); // For PLG tables colp->AddColUse(U_P); // For PLG tables
} // endif } // endif
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -1944,13 +1924,7 @@ bool ha_connect::CheckColumnList(PGLOBAL g)
strcpy(g->Message, msg); strcpy(g->Message, msg);
brc = true; brc = true;
} // end catch } // end catch
#else // !USE_TRY
} else
brc = true;
fin:
g->jump_level--;
#endif // !USE_TRY
return brc; return brc;
} // end of CheckColumnList } // end of CheckColumnList
@@ -1987,7 +1961,8 @@ int ha_connect::CloseTable(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int ha_connect::MakeRecord(char *buf) int ha_connect::MakeRecord(char *buf)
{ {
char *p, *fmt, val[32]; PCSZ fmt;
char *p, val[32];
int rc= 0; int rc= 0;
Field* *field; Field* *field;
Field *fp; Field *fp;
@@ -2123,7 +2098,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *)
{ {
char attr_buffer[1024]; char attr_buffer[1024];
char data_buffer[1024]; char data_buffer[1024];
char *fmt; PCSZ fmt;
int rc= 0; int rc= 0;
PCOL colp; PCOL colp;
PVAL value, sdvalin; PVAL value, sdvalin;
@@ -2297,7 +2272,7 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
const uchar *ptr; const uchar *ptr;
//uint i, rem, len, klen, stlen; //uint i, rem, len, klen, stlen;
uint i, rem, len, stlen; uint i, rem, len, stlen;
bool nq, both, oom= false; bool nq, both, oom;
OPVAL op; OPVAL op;
Field *fp; Field *fp;
const key_range *ranges[2]; const key_range *ranges[2];
@@ -2325,9 +2300,9 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
continue; continue;
if (both && i > 0) if (both && i > 0)
oom|= qry->Append(") AND ("); qry->Append(") AND (");
else else
oom|= qry->Append(" WHERE ("); qry->Append(" WHERE (");
// klen= len= ranges[i]->length; // klen= len= ranges[i]->length;
len= ranges[i]->length; len= ranges[i]->length;
@@ -2340,14 +2315,14 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
nq= fp->str_needs_quotes(); nq= fp->str_needs_quotes();
if (kpart != kfp->key_part) if (kpart != kfp->key_part)
oom|= qry->Append(" AND "); qry->Append(" AND ");
if (q) { if (q) {
oom|= qry->Append(q); qry->Append(q);
oom|= qry->Append((PSZ)fp->field_name); qry->Append((PSZ)fp->field_name);
oom|= qry->Append(q); qry->Append(q);
} else } else
oom|= qry->Append((PSZ)fp->field_name); qry->Append((PSZ)fp->field_name);
switch (ranges[i]->flag) { switch (ranges[i]->flag) {
case HA_READ_KEY_EXACT: case HA_READ_KEY_EXACT:
@@ -2372,10 +2347,10 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
goto err; goto err;
} // endswitch flag } // endswitch flag
oom|= qry->Append((PSZ)GetValStr(op, false)); qry->Append((PSZ)GetValStr(op, false));
if (nq) if (nq)
oom|= qry->Append('\''); qry->Append('\'');
if (kpart->key_part_flag & HA_VAR_LENGTH_PART) { if (kpart->key_part_flag & HA_VAR_LENGTH_PART) {
String varchar; String varchar;
@@ -2383,17 +2358,17 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
varchar.set_quick((char*)ptr + HA_KEY_BLOB_LENGTH, varchar.set_quick((char*)ptr + HA_KEY_BLOB_LENGTH,
var_length, &my_charset_bin); var_length, &my_charset_bin);
oom|= qry->Append(varchar.ptr(), varchar.length(), nq); qry->Append(varchar.ptr(), varchar.length(), nq);
} else { } else {
char strbuff[MAX_FIELD_WIDTH]; char strbuff[MAX_FIELD_WIDTH];
String str(strbuff, sizeof(strbuff), kpart->field->charset()), *res; String str(strbuff, sizeof(strbuff), kpart->field->charset()), *res;
res= fp->val_str(&str, ptr); res= fp->val_str(&str, ptr);
oom|= qry->Append(res->ptr(), res->length(), nq); qry->Append(res->ptr(), res->length(), nq);
} // endif flag } // endif flag
if (nq) if (nq)
oom |= qry->Append('\''); qry->Append('\'');
if (stlen >= len) if (stlen >= len)
break; break;
@@ -2408,7 +2383,9 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
} // endfor i } // endfor i
if ((oom|= qry->Append(")"))) qry->Append(')');
if ((oom= qry->IsTruncated()))
strcpy(g->Message, "Out of memory"); strcpy(g->Message, "Out of memory");
dbug_tmp_restore_column_map(table->write_set, old_map); dbug_tmp_restore_column_map(table->write_set, old_map);
@@ -3086,28 +3063,16 @@ const COND *ha_connect::cond_push(const COND *cond)
tty == TYPE_AM_PLG || tty == TYPE_AM_JDBC || x); tty == TYPE_AM_PLG || tty == TYPE_AM_JDBC || x);
// This should never happen but is done to avoid crashing // This should never happen but is done to avoid crashing
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
DBUG_RETURN(cond);
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level]))
goto fin;
#endif // !USE_TRY
if (b) { if (b) {
PCFIL filp; PCFIL filp;
int rc; int rc;
if ((filp= tdbp->GetCondFil()) && filp->Cond == cond && if ((filp = tdbp->GetCondFil()) && tdbp->GetCond() == cond &&
filp->Idx == active_index && filp->Type == tty) filp->Idx == active_index && filp->Type == tty)
goto fin; goto fin;
filp= new(g) CONDFIL(cond, active_index, tty); filp = new(g) CONDFIL(active_index, tty);
rc = filp->Init(g, this); rc = filp->Init(g, this);
if (rc == RC_INFO) { if (rc == RC_INFO) {
@@ -3126,6 +3091,8 @@ const COND *ha_connect::cond_push(const COND *cond)
if (trace) if (trace)
htrc("cond_push: %s\n", filp->Body); htrc("cond_push: %s\n", filp->Body);
tdbp->SetCond(cond);
if (!x) if (!x)
PlugSubAlloc(g, NULL, strlen(filp->Body) + 1); PlugSubAlloc(g, NULL, strlen(filp->Body) + 1);
else else
@@ -3135,10 +3102,17 @@ const COND *ha_connect::cond_push(const COND *cond)
} else if (x && cond) } else if (x && cond)
tdbp->SetCondFil(filp); // Wrong filter tdbp->SetCondFil(filp); // Wrong filter
} else if (tty != TYPE_AM_JSN && tty != TYPE_AM_JSON) } else if (tdbp->CanBeFiltered()) {
if (!tdbp->GetCond() || tdbp->GetCond() != cond) {
tdbp->SetFilter(CondFilter(g, (Item *)cond)); tdbp->SetFilter(CondFilter(g, (Item *)cond));
#if defined(USE_TRY) if (tdbp->GetFilter())
tdbp->SetCond(cond);
} // endif cond
} // endif tty
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -3147,10 +3121,6 @@ const COND *ha_connect::cond_push(const COND *cond)
} // end catch } // end catch
fin:; fin:;
#else // !USE_TRY
fin:
g->jump_level--;
#endif // !USE_TRY
} // endif tdbp } // endif tdbp
// Let MySQL do the filtering // Let MySQL do the filtering
@@ -3301,22 +3271,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
PGLOBAL& g= xp->g; PGLOBAL& g= xp->g;
PDBUSER dup= PlgGetUser(g); PDBUSER dup= PlgGetUser(g);
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
rc = HA_ERR_INTERNAL_ERROR;
goto err;
} // endif
if (setjmp(g->jumper[++g->jump_level])) {
rc = HA_ERR_INTERNAL_ERROR;
goto err;
} // endif setjmp
#endif // !USE_TRY
// Ignore error on the opt file // Ignore error on the opt file
dup->Check &= ~CHK_OPT; dup->Check &= ~CHK_OPT;
tdbp = GetTDB(g); tdbp = GetTDB(g);
@@ -3338,7 +3293,6 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
} else if (!tdbp) } else if (!tdbp)
rc = HA_ERR_INTERNAL_ERROR; rc = HA_ERR_INTERNAL_ERROR;
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -3347,10 +3301,6 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
strcpy(g->Message, msg); strcpy(g->Message, msg);
rc = HA_ERR_INTERNAL_ERROR; rc = HA_ERR_INTERNAL_ERROR;
} // end catch } // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
return rc; return rc;
} // end of optimize } // end of optimize
@@ -4045,8 +3995,12 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos)
tdbp->SetFilter(NULL); tdbp->SetFilter(NULL);
rc= rnd_next(buf); rc= rnd_next(buf);
} else } else {
rc= HA_ERR_KEY_NOT_FOUND; PGLOBAL g = GetPlug((table) ? table->in_use : NULL, xp);
strcpy(g->Message, "Not supported by this table type");
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR;
} // endif SetRecpos
DBUG_RETURN(rc); DBUG_RETURN(rc);
} // end of rnd_pos } // end of rnd_pos
@@ -4270,16 +4224,16 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
case TAB_JSON: case TAB_JSON:
if (options->filename && *options->filename) { if (options->filename && *options->filename) {
if (!quick) { if (!quick) {
char *s, path[FN_REFLEN], dbpath[FN_REFLEN]; char path[FN_REFLEN], dbpath[FN_REFLEN];
#if defined(__WIN__)
s= "\\";
#else // !__WIN__
s= "/";
#endif // !__WIN__
strcpy(dbpath, mysql_real_data_home); strcpy(dbpath, mysql_real_data_home);
if (db) if (db)
strcat(strcat(dbpath, db), s); #if defined(__WIN__)
strcat(strcat(dbpath, db), "\\");
#else // !__WIN__
strcat(strcat(dbpath, db), "/");
#endif // !__WIN__
(void)fn_format(path, options->filename, dbpath, "", (void)fn_format(path, options->filename, dbpath, "",
MY_RELATIVE_PATH | MY_UNPACK_FILENAME); MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
@@ -4689,6 +4643,8 @@ int ha_connect::external_lock(THD *thd, int lock_type)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
0, g->Message); 0, g->Message);
rc= 0; rc= 0;
//my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
//rc= HA_ERR_INTERNAL_ERROR;
} // endif MakeIndex } // endif MakeIndex
} else if (tdbp->GetDef()->Indexable() == 3) { } else if (tdbp->GetDef()->Indexable() == 3) {
@@ -4710,9 +4666,12 @@ int ha_connect::external_lock(THD *thd, int lock_type)
// Make it a warning to avoid crash // Make it a warning to avoid crash
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
rc= 0; rc= 0;
//my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
//rc = HA_ERR_INTERNAL_ERROR;
} // endif Close } // endif Close
locked= 0; locked= 0;
// m_lock_type= lock_type;
xmod= MODE_ANY; // For info commands xmod= MODE_ANY; // For info commands
DBUG_RETURN(rc); DBUG_RETURN(rc);
} // endif MODE_ANY } // endif MODE_ANY
@@ -5070,8 +5029,8 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
} // end of records_in_range } // end of records_in_range
// Used to check whether a MYSQL table is created on itself // Used to check whether a MYSQL table is created on itself
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host, bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, PCSZ host,
const char *db, char *tab, const char *src, int port) PCSZ db, PCSZ tab, PCSZ src, int port)
{ {
if (src) if (src)
return false; return false;
@@ -5308,27 +5267,27 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
HA_CREATE_INFO *create_info) HA_CREATE_INFO *create_info)
{ {
char v=0; char v=0;
const char *fncn= "?"; PCSZ fncn= "?";
const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src; PCSZ user, fn, db, host, pwd, sep, tbl, src;
const char *col, *ocl, *rnk, *pic, *fcl, *skc, *zfn; PCSZ col, ocl, rnk, pic, fcl, skc, zfn;
char *tab, *dsn, *shm, *dpath; char *tab, *dsn, *shm, *dpath;
#if defined(__WIN__) #if defined(__WIN__)
char *nsp= NULL, *cls= NULL; PCSZ nsp= NULL, cls= NULL;
#endif // __WIN__ #endif // __WIN__
//int hdr, mxe; //int hdr, mxe;
int port = 0, mxr = 0, rc = 0, mul = 0, lrecl = 0; int port = 0, mxr = 0, rc = 0, mul = 0, lrecl = 0;
#if defined(ODBC_SUPPORT) #if defined(ODBC_SUPPORT)
POPARM sop= NULL; POPARM sop= NULL;
char *ucnc= NULL; PCSZ ucnc= NULL;
bool cnc= false; bool cnc= false;
int cto= -1, qto= -1; int cto= -1, qto= -1;
#endif // ODBC_SUPPORT #endif // ODBC_SUPPORT
#if defined(JDBC_SUPPORT) #if defined(JDBC_SUPPORT)
PJPARM sjp= NULL; PJPARM sjp= NULL;
char *driver= NULL; PCSZ driver= NULL;
char *url= NULL; char *url= NULL;
//char *prop= NULL; //char *prop= NULL;
char *tabtyp= NULL; PCSZ tabtyp= NULL;
#endif // JDBC_SUPPORT #endif // JDBC_SUPPORT
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL); uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
bool bif, ok= false, dbf= false; bool bif, ok= false, dbf= false;
@@ -5409,21 +5368,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
if (!(shm= (char*)db)) if (!(shm= (char*)db))
db= table_s->db.str; // Default value db= table_s->db.str; // Default value
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
goto jer;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level]) != 0) {
rc = HA_ERR_INTERNAL_ERROR;
goto err;
} // endif rc
#endif // !USE_TRY
// Check table type // Check table type
if (ttp == TAB_UNDEF) { if (ttp == TAB_UNDEF) {
topt->type = (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS"; topt->type = (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS";
@@ -5520,7 +5465,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
ok = true; ok = true;
} else if (rc == RC_NF) { } else if (rc == RC_NF) {
if (jdef->GetTabname()) if (jdef->GetTabname())
tab= jdef->GetTabname(); tab = (char*)jdef->GetTabname();
ok = jdef->SetParms(sjp); ok = jdef->SetParms(sjp);
} // endif rc } // endif rc
@@ -5566,7 +5511,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
db = mydef->GetTabschema(); db = mydef->GetTabschema();
if (mydef->GetTabname()) if (mydef->GetTabname())
tab= mydef->GetTabname(); tab = (char*)mydef->GetTabname();
if (mydef->GetPortnumber()) if (mydef->GetPortnumber())
port = mydef->GetPortnumber(); port = mydef->GetPortnumber();
@@ -5612,7 +5557,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case TAB_XML: case TAB_XML:
#endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT #endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT
case TAB_JSON: case TAB_JSON:
if (!fn && !zfn && !mul) dsn = strz(g, create_info->connect_string);
if (!fn && !zfn && !mul && !dsn)
sprintf(g->Message, "Missing %s file name", topt->type); sprintf(g->Message, "Missing %s file name", topt->type);
else else
ok = true; ok = true;
@@ -5639,15 +5586,14 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
} // endif src } // endif src
if (ok) { if (ok) {
char *cnm, *rem, *dft, *xtra, *key, *fmt; const char *cnm, *rem;
char *dft, *xtra, *key, *fmt;
int i, len, prec, dec, typ, flg; int i, len, prec, dec, typ, flg;
// if (cat) if (!(dpath = SetPath(g, table_s->db.str))) {
// cat->SetDataPath(g, table_s->db.str); rc = HA_ERR_INTERNAL_ERROR;
// else goto err;
// return HA_ERR_INTERNAL_ERROR; // Should never happen } // endif dpath
dpath = SetPath(g, table_s->db.str);
if (src && ttp != TAB_PIVOT && ttp != TAB_ODBC && ttp != TAB_JDBC) { if (src && ttp != TAB_PIVOT && ttp != TAB_ODBC && ttp != TAB_JDBC) {
qrp = SrcColumns(g, host, db, user, pwd, src, port); qrp = SrcColumns(g, host, db, user, pwd, src, port);
@@ -5759,7 +5705,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
qrp = VirColumns(g, fnc == FNC_COL); qrp = VirColumns(g, fnc == FNC_COL);
break; break;
case TAB_JSON: case TAB_JSON:
qrp = JSONColumns(g, (char*)db, topt, fnc == FNC_COL); qrp = JSONColumns(g, (char*)db, dsn, topt, fnc == FNC_COL);
break; break;
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT) #if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
case TAB_XML: case TAB_XML:
@@ -6002,7 +5948,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
rc = HA_ERR_UNSUPPORTED; rc = HA_ERR_UNSUPPORTED;
} // endif ok } // endif ok
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -6013,16 +5958,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
} // end catch } // end catch
err: err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
if (rc) if (rc)
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
#if !defined(USE_TRY)
jer:
#endif // !USE_TRY
PopUser(xp); PopUser(xp);
return rc; return rc;
} // end of connect_assisted_discovery } // end of connect_assisted_discovery
@@ -6189,7 +6127,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (!part_info) if (!part_info)
#endif // WITH_PARTITION_STORAGE_ENGINE #endif // WITH_PARTITION_STORAGE_ENGINE
{const char *src= options->srcdef; {const char *src= options->srcdef;
char *host, *db, *tab= (char*)options->tabname; PCSZ host, db, tab= options->tabname;
int port; int port;
host= GetListOption(g, "host", options->oplist, NULL); host= GetListOption(g, "host", options->oplist, NULL);
@@ -6235,7 +6173,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (type == TAB_XML) { if (type == TAB_XML) {
bool dom; // True: MS-DOM, False libxml2 bool dom; // True: MS-DOM, False libxml2
char *xsup= GetListOption(g, "Xmlsup", options->oplist, "*"); PCSZ xsup= GetListOption(g, "Xmlsup", options->oplist, "*");
// Note that if no support is specified, the default is MS-DOM // Note that if no support is specified, the default is MS-DOM
// on Windows and libxml2 otherwise // on Windows and libxml2 otherwise
@@ -6495,14 +6433,14 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (options->zipped) { if (options->zipped) {
// Check whether the zip entry must be made from a file // Check whether the zip entry must be made from a file
char *fn = GetListOption(g, "Load", options->oplist, NULL); PCSZ fn = GetListOption(g, "Load", options->oplist, NULL);
if (fn) { if (fn) {
char zbuf[_MAX_PATH], buf[_MAX_PATH], dbpath[_MAX_PATH]; char zbuf[_MAX_PATH], buf[_MAX_PATH], dbpath[_MAX_PATH];
char *entry = GetListOption(g, "Entry", options->oplist, NULL); PCSZ entry = GetListOption(g, "Entry", options->oplist, NULL);
char *a = GetListOption(g, "Append", options->oplist, "NO"); PCSZ a = GetListOption(g, "Append", options->oplist, "NO");
bool append = *a == '1' || *a == 'Y' || *a == 'y' || !stricmp(a, "ON"); bool append = *a == '1' || *a == 'Y' || *a == 'y' || !stricmp(a, "ON");
char *m = GetListOption(g, "Mulentries", options->oplist, "NO"); PCSZ m = GetListOption(g, "Mulentries", options->oplist, "NO");
bool mul = *m == '1' || *m == 'Y' || *m == 'y' || !stricmp(m, "ON"); bool mul = *m == '1' || *m == 'Y' || *m == 'y' || !stricmp(m, "ON");
if (!entry && !mul) { if (!entry && !mul) {
@@ -6575,8 +6513,6 @@ int ha_connect::create(const char *name, TABLE *table_arg,
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc = HA_ERR_INTERNAL_ERROR; rc = HA_ERR_INTERNAL_ERROR;
} else if (cat) { } else if (cat) {
// cat->SetDataPath(g, table_arg->s->db.str);
#if defined(WITH_PARTITION_STORAGE_ENGINE) #if defined(WITH_PARTITION_STORAGE_ENGINE)
if (part_info) if (part_info)
strncpy(partname, strncpy(partname,
@@ -6632,7 +6568,8 @@ bool ha_connect::FileExists(const char *fn, bool bf)
return true; return true;
if (table) { if (table) {
char *s, tfn[_MAX_PATH], filename[_MAX_PATH], path[_MAX_PATH]; const char *s;
char tfn[_MAX_PATH], filename[_MAX_PATH], path[_MAX_PATH];
bool b= false; bool b= false;
int n; int n;
struct stat info; struct stat info;
@@ -6690,9 +6627,9 @@ bool ha_connect::CheckString(const char *str1, const char *str2)
/** /**
check whether a string option have changed check whether a string option have changed
*/ */
bool ha_connect::SameString(TABLE *tab, char *opn) bool ha_connect::SameString(TABLE *tab, PCSZ opn)
{ {
char *str1, *str2; PCSZ str1, str2;
tshp= tab->s; // The altered table tshp= tab->s; // The altered table
str1= GetStringOption(opn); str1= GetStringOption(opn);
@@ -6704,7 +6641,7 @@ bool ha_connect::SameString(TABLE *tab, char *opn)
/** /**
check whether a Boolean option have changed check whether a Boolean option have changed
*/ */
bool ha_connect::SameBool(TABLE *tab, char *opn) bool ha_connect::SameBool(TABLE *tab, PCSZ opn)
{ {
bool b1, b2; bool b1, b2;
@@ -6718,7 +6655,7 @@ bool ha_connect::SameBool(TABLE *tab, char *opn)
/** /**
check whether an integer option have changed check whether an integer option have changed
*/ */
bool ha_connect::SameInt(TABLE *tab, char *opn) bool ha_connect::SameInt(TABLE *tab, PCSZ opn)
{ {
int i1, i2; int i1, i2;
@@ -6897,7 +6834,7 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
// Conversion to outward table is only allowed for file based // Conversion to outward table is only allowed for file based
// tables whose file does not exist. // tables whose file does not exist.
tshp= altered_table->s; tshp= altered_table->s;
char *fn= GetStringOption("filename"); PCSZ fn= GetStringOption("filename");
tshp= NULL; tshp= NULL;
if (FileExists(fn, false)) { if (FileExists(fn, false)) {
@@ -7142,10 +7079,10 @@ maria_declare_plugin(connect)
PLUGIN_LICENSE_GPL, PLUGIN_LICENSE_GPL,
connect_init_func, /* Plugin Init */ connect_init_func, /* Plugin Init */
connect_done_func, /* Plugin Deinit */ connect_done_func, /* Plugin Deinit */
0x0105, /* version number (1.05) */ 0x0106, /* version number (1.05) */
NULL, /* status variables */ NULL, /* status variables */
connect_system_variables, /* system variables */ connect_system_variables, /* system variables */
"1.05.0003", /* string version */ "1.06.0001", /* string version */
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ MariaDB_PLUGIN_MATURITY_BETA /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;

View File

@@ -11,7 +11,7 @@
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/** @file ha_connect.h /** @file ha_connect.h
@@ -61,7 +61,7 @@ public:
oldopn= newopn= NULL; oldopn= newopn= NULL;
oldpix= newpix= NULL;} oldpix= newpix= NULL;}
inline char *SetName(PGLOBAL g, char *name) {return PlugDup(g, name);} inline char *SetName(PGLOBAL g, PCSZ name) {return PlugDup(g, name);}
bool oldsep; // Sepindex before create/alter bool oldsep; // Sepindex before create/alter
bool newsep; // Sepindex after create/alter bool newsep; // Sepindex after create/alter
@@ -168,18 +168,18 @@ public:
static bool connect_init(void); static bool connect_init(void);
static bool connect_end(void); static bool connect_end(void);
TABTYPE GetRealType(PTOS pos= NULL); TABTYPE GetRealType(PTOS pos= NULL);
char *GetRealString(const char *s); char *GetRealString(PCSZ s);
char *GetStringOption(char *opname, char *sdef= NULL); PCSZ GetStringOption(PCSZ opname, PCSZ sdef= NULL);
PTOS GetTableOptionStruct(TABLE_SHARE *s= NULL); PTOS GetTableOptionStruct(TABLE_SHARE *s= NULL);
bool GetBooleanOption(char *opname, bool bdef); bool GetBooleanOption(PCSZ opname, bool bdef);
bool SetBooleanOption(char *opname, bool b); bool SetBooleanOption(PCSZ opname, bool b);
int GetIntegerOption(char *opname); int GetIntegerOption(PCSZ opname);
bool GetIndexOption(KEY *kp, char *opname); bool GetIndexOption(KEY *kp, PCSZ opname);
bool CheckString(const char *str1, const char *str2); bool CheckString(PCSZ str1, PCSZ str2);
bool SameString(TABLE *tab, char *opn); bool SameString(TABLE *tab, PCSZ opn);
bool SetIntegerOption(char *opname, int n); bool SetIntegerOption(PCSZ opname, int n);
bool SameInt(TABLE *tab, char *opn); bool SameInt(TABLE *tab, PCSZ opn);
bool SameBool(TABLE *tab, char *opn); bool SameBool(TABLE *tab, PCSZ opn);
bool FileExists(const char *fn, bool bf); bool FileExists(const char *fn, bool bf);
bool NoFieldOptionChange(TABLE *tab); bool NoFieldOptionChange(TABLE *tab);
PFOS GetFieldOptionStruct(Field *fp); PFOS GetFieldOptionStruct(Field *fp);
@@ -187,8 +187,8 @@ public:
PXOS GetIndexOptionStruct(KEY *kp); PXOS GetIndexOptionStruct(KEY *kp);
PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL); PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL);
bool CheckVirtualIndex(TABLE_SHARE *s); bool CheckVirtualIndex(TABLE_SHARE *s);
const char *GetDBName(const char *name); PCSZ GetDBName(PCSZ name);
const char *GetTableName(void); PCSZ GetTableName(void);
char *GetPartName(void); char *GetPartName(void);
//int GetColNameLen(Field *fp); //int GetColNameLen(Field *fp);
//char *GetColName(Field *fp); //char *GetColName(Field *fp);
@@ -197,9 +197,9 @@ public:
bool IsSameIndex(PIXDEF xp1, PIXDEF xp2); bool IsSameIndex(PIXDEF xp1, PIXDEF xp2);
bool IsPartitioned(void); bool IsPartitioned(void);
bool IsUnique(uint n); bool IsUnique(uint n);
char *GetDataPath(void) {return (char*)datapath;} PCSZ GetDataPath(void) {return datapath;}
bool SetDataPath(PGLOBAL g, const char *path); bool SetDataPath(PGLOBAL g, PCSZ path);
PTDB GetTDB(PGLOBAL g); PTDB GetTDB(PGLOBAL g);
int OpenTable(PGLOBAL g, bool del= false); int OpenTable(PGLOBAL g, bool del= false);
bool CheckColumnList(PGLOBAL g); bool CheckColumnList(PGLOBAL g);
@@ -513,7 +513,7 @@ protected:
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
char *datapath; // Is the Path of DB data directory PCSZ datapath; // Is the Path of DB data directory
PTDB tdbp; // To table class object PTDB tdbp; // To table class object
PVAL sdvalin1; // Used to convert date values PVAL sdvalin1; // Used to convert date values
PVAL sdvalin2; // Used to convert date values PVAL sdvalin2; // Used to convert date values

View File

@@ -16,7 +16,7 @@
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/ */
#include "my_global.h" #include "my_global.h"

View File

@@ -27,6 +27,7 @@
#include "ioapi.h" #include "ioapi.h"
#include "my_attribute.h"
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
{ {
@@ -92,7 +93,7 @@ static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPO
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) static voidpf ZCALLBACK fopen_file_func (voidpf opaque __attribute__((unused)), const char* filename, int mode)
{ {
FILE* file = NULL; FILE* file = NULL;
const char* mode_fopen = NULL; const char* mode_fopen = NULL;
@@ -110,7 +111,7 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
return file; return file;
} }
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) static voidpf ZCALLBACK fopen64_file_func (voidpf opaque __attribute__((unused)), const void* filename, int mode)
{ {
FILE* file = NULL; FILE* file = NULL;
const char* mode_fopen = NULL; const char* mode_fopen = NULL;
@@ -129,21 +130,21 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
} }
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) static uLong ZCALLBACK fread_file_func (voidpf opaque __attribute__((unused)), voidpf stream, void* buf, uLong size)
{ {
uLong ret; uLong ret;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
return ret; return ret;
} }
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) static uLong ZCALLBACK fwrite_file_func (voidpf opaque __attribute__((unused)), voidpf stream, const void* buf, uLong size)
{ {
uLong ret; uLong ret;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret; return ret;
} }
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) static long ZCALLBACK ftell_file_func (voidpf opaque __attribute__((unused)), voidpf stream)
{ {
long ret; long ret;
ret = ftell((FILE *)stream); ret = ftell((FILE *)stream);
@@ -151,14 +152,14 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
} }
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque __attribute__((unused)), voidpf stream)
{ {
ZPOS64_T ret; ZPOS64_T ret;
ret = FTELLO_FUNC((FILE *)stream); ret = FTELLO_FUNC((FILE *)stream);
return ret; return ret;
} }
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) static long ZCALLBACK fseek_file_func (voidpf opaque __attribute__((unused)), voidpf stream, uLong offset, int origin)
{ {
int fseek_origin=0; int fseek_origin=0;
long ret; long ret;
@@ -181,7 +182,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
return ret; return ret;
} }
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) static long ZCALLBACK fseek64_file_func (voidpf opaque __attribute__((unused)), voidpf stream, ZPOS64_T offset, int origin)
{ {
int fseek_origin=0; int fseek_origin=0;
long ret; long ret;
@@ -207,14 +208,14 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
} }
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) static int ZCALLBACK fclose_file_func (voidpf opaque __attribute__((unused)), voidpf stream)
{ {
int ret; int ret;
ret = fclose((FILE *)stream); ret = fclose((FILE *)stream);
return ret; return ret;
} }
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) static int ZCALLBACK ferror_file_func (voidpf opaque __attribute__((unused)), voidpf stream)
{ {
int ret; int ret;
ret = ferror((FILE *)stream); ret = ferror((FILE *)stream);

View File

@@ -129,8 +129,9 @@ extern "C" {
#endif #endif
#endif #endif
#ifndef OF
#define OF(args) args
#endif
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));

View File

@@ -4,10 +4,10 @@
typedef struct jdbc_parms { typedef struct jdbc_parms {
int CheckSize(int rows); int CheckSize(int rows);
char *Driver; // JDBC driver PCSZ Driver; // JDBC driver
char *Url; // Driver URL PCSZ Url; // Driver URL
char *User; // User connect info PCSZ User; // User connect info
char *Pwd; // Password connect info PCSZ Pwd; // Password connect info
//char *Properties; // Connection property list //char *Properties; // Connection property list
//int Cto; // Connect timeout //int Cto; // Connect timeout
//int Qto; // Query timeout //int Qto; // Query timeout
@@ -19,12 +19,12 @@ typedef struct jdbc_parms {
/* JDBC catalog function prototypes. */ /* JDBC catalog function prototypes. */
/***********************************************************************/ /***********************************************************************/
#if defined(PROMPT_OK) #if defined(PROMPT_OK)
char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop); char *JDBCCheckConnection(PGLOBAL g, PCSZ dsn, int cop);
#endif // PROMPT_OK #endif // PROMPT_OK
//PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info); //PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info);
PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table,
char *colpat, int maxres, bool info, PJPARM sop); PCSZ colpat, int maxres, bool info, PJPARM sop);
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sop); PQRYRES JDBCSrcCols(PGLOBAL g, PCSZ src, PJPARM sop);
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat, PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat,
char *tabtyp, int maxres, bool info, PJPARM sop); PCSZ tabtyp, int maxres, bool info, PJPARM sop);
PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info); PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info);

View File

@@ -189,8 +189,8 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
/***********************************************************************/ /***********************************************************************/
/* Allocate the structure used to refer to the result set. */ /* Allocate the structure used to refer to the result set. */
/***********************************************************************/ /***********************************************************************/
static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, char *db, static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, PCSZ db,
char *tab, PQRYRES qrp) PCSZ tab, PQRYRES qrp)
{ {
JCATPARM *cap; JCATPARM *cap;
@@ -213,7 +213,7 @@ static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, char *db,
/* JDBCColumns: constructs the result blocks containing all columns */ /* JDBCColumns: constructs the result blocks containing all columns */
/* of a JDBC table that will be retrieved by GetData commands. */ /* of a JDBC table that will be retrieved by GetData commands. */
/***********************************************************************/ /***********************************************************************/
PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, char *colpat, PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table, PCSZ colpat,
int maxres, bool info, PJPARM sjp) int maxres, bool info, PJPARM sjp)
{ {
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING,
@@ -316,7 +316,7 @@ PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, char *colpat,
/* JDBCSrcCols: constructs the result blocks containing the */ /* JDBCSrcCols: constructs the result blocks containing the */
/* description of all the columns of a Srcdef option. */ /* description of all the columns of a Srcdef option. */
/**************************************************************************/ /**************************************************************************/
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp) PQRYRES JDBCSrcCols(PGLOBAL g, PCSZ src, PJPARM sjp)
{ {
char *sqry; char *sqry;
PQRYRES qrp; PQRYRES qrp;
@@ -330,7 +330,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
sqry = (char*)PlugSubAlloc(g, NULL, strlen(src) + 2); sqry = (char*)PlugSubAlloc(g, NULL, strlen(src) + 2);
sprintf(sqry, src, "1=1"); // dummy where clause sprintf(sqry, src, "1=1"); // dummy where clause
} else } else
sqry = src; sqry = (char*)src;
qrp = jcp->GetMetaData(g, sqry); qrp = jcp->GetMetaData(g, sqry);
jcp->Close(); jcp->Close();
@@ -341,7 +341,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
/* JDBCTables: constructs the result blocks containing all tables in */ /* JDBCTables: constructs the result blocks containing all tables in */
/* an JDBC database that will be retrieved by GetData commands. */ /* an JDBC database that will be retrieved by GetData commands. */
/**************************************************************************/ /**************************************************************************/
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat, char *tabtyp, PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat, PCSZ tabtyp,
int maxres, bool info, PJPARM sjp) int maxres, bool info, PJPARM sjp)
{ {
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
@@ -1059,7 +1059,7 @@ int JDBConn::Open(PJPARM sop)
/***********************************************************************/ /***********************************************************************/
/* Execute an SQL command. */ /* Execute an SQL command. */
/***********************************************************************/ /***********************************************************************/
int JDBConn::ExecSQLcommand(char *sql) int JDBConn::ExecSQLcommand(PCSZ sql)
{ {
int rc; int rc;
jint n; jint n;
@@ -1142,7 +1142,7 @@ int JDBConn::Fetch(int pos)
/***********************************************************************/ /***********************************************************************/
/* Restart from beginning of result set */ /* Restart from beginning of result set */
/***********************************************************************/ /***********************************************************************/
int JDBConn::Rewind(char *sql) int JDBConn::Rewind(PCSZ sql)
{ {
int rbuf = -1; int rbuf = -1;
@@ -1200,11 +1200,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (rank == 0) if (rank == 0)
if (!name || (jn = env->NewStringUTF(name)) == nullptr) { if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
sprintf(g->Message, "Fail to allocate jstring %s", SVP(name)); sprintf(g->Message, "Fail to allocate jstring %s", SVP(name));
#if defined(USE_TRY)
throw TYPE_AM_JDBC; throw TYPE_AM_JDBC;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
#endif // !USE_TRY
} // endif name } // endif name
// Returns 666 is case of error // Returns 666 is case of error
@@ -1212,11 +1208,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (Check((ctyp == 666) ? -1 : 1)) { if (Check((ctyp == 666) ? -1 : 1)) {
sprintf(g->Message, "Getting ctyp: %s", Msg); sprintf(g->Message, "Getting ctyp: %s", Msg);
#if defined(USE_TRY)
throw TYPE_AM_JDBC; throw TYPE_AM_JDBC;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
#endif // !USE_TRY
} // endif Check } // endif Check
if (val->GetNullable()) if (val->GetNullable())
@@ -1323,11 +1315,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
env->DeleteLocalRef(jn); env->DeleteLocalRef(jn);
sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp); sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp);
#if defined(USE_TRY)
throw TYPE_AM_JDBC; throw TYPE_AM_JDBC;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
#endif // !USE_TRY
} // endif Check } // endif Check
if (rank == 0) if (rank == 0)
@@ -1338,7 +1326,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
/***********************************************************************/ /***********************************************************************/
/* Prepare an SQL statement for insert. */ /* Prepare an SQL statement for insert. */
/***********************************************************************/ /***********************************************************************/
bool JDBConn::PrepareSQL(char *sql) bool JDBConn::PrepareSQL(PCSZ sql)
{ {
bool b = true; bool b = true;
PGLOBAL& g = m_G; PGLOBAL& g = m_G;
@@ -1361,7 +1349,7 @@ bool JDBConn::PrepareSQL(char *sql)
/***********************************************************************/ /***********************************************************************/
/* Execute an SQL query that returns a result set. */ /* Execute an SQL query that returns a result set. */
/***********************************************************************/ /***********************************************************************/
int JDBConn::ExecuteQuery(char *sql) int JDBConn::ExecuteQuery(PCSZ sql)
{ {
int rc = RC_FX; int rc = RC_FX;
jint ncol; jint ncol;
@@ -1389,7 +1377,7 @@ int JDBConn::ExecuteQuery(char *sql)
/***********************************************************************/ /***********************************************************************/
/* Execute an SQL query and get the affected rows. */ /* Execute an SQL query and get the affected rows. */
/***********************************************************************/ /***********************************************************************/
int JDBConn::ExecuteUpdate(char *sql) int JDBConn::ExecuteUpdate(PCSZ sql)
{ {
int rc = RC_FX; int rc = RC_FX;
jint n; jint n;
@@ -1417,7 +1405,7 @@ int JDBConn::ExecuteUpdate(char *sql)
/***********************************************************************/ /***********************************************************************/
/* Get the number of lines of the result set. */ /* Get the number of lines of the result set. */
/***********************************************************************/ /***********************************************************************/
int JDBConn::GetResultSize(char *sql, JDBCCOL *colp) int JDBConn::GetResultSize(PCSZ sql, JDBCCOL *colp)
{ {
int rc, n = 0; int rc, n = 0;
@@ -1655,7 +1643,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
/* GetMetaData: constructs the result blocks containing the */ /* GetMetaData: constructs the result blocks containing the */
/* description of all the columns of an SQL command. */ /* description of all the columns of an SQL command. */
/**************************************************************************/ /**************************************************************************/
PQRYRES JDBConn::GetMetaData(PGLOBAL g, char *src) PQRYRES JDBConn::GetMetaData(PGLOBAL g, PCSZ src)
{ {
static int buftyp[] = {TYPE_STRING, TYPE_INT, TYPE_INT, static int buftyp[] = {TYPE_STRING, TYPE_INT, TYPE_INT,
TYPE_INT, TYPE_INT}; TYPE_INT, TYPE_INT};
@@ -1857,7 +1845,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
PGLOBAL& g = m_G; PGLOBAL& g = m_G;
// void *buffer; // void *buffer;
int i, ncol; int i, ncol;
PSZ fnc = "Unknown"; PCSZ fnc = "Unknown";
uint n; uint n;
short len, tp; short len, tp;
int crow = 0; int crow = 0;

View File

@@ -46,9 +46,9 @@ enum JCATINFO {
typedef struct tagJCATPARM { typedef struct tagJCATPARM {
JCATINFO Id; // Id to indicate function JCATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer PQRYRES Qrp; // Result set pointer
char *DB; // Database (Schema) PCSZ DB; // Database (Schema)
char *Tab; // Table name or pattern PCSZ Tab; // Table name or pattern
char *Pat; // Table type or column pattern PCSZ Pat; // Table type or column pattern
} JCATPARM; } JCATPARM;
typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *); typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *);
@@ -77,7 +77,7 @@ public:
JDBConn(PGLOBAL g, TDBJDBC *tdbp); JDBConn(PGLOBAL g, TDBJDBC *tdbp);
int Open(PJPARM sop); int Open(PJPARM sop);
int Rewind(char *sql); int Rewind(PCSZ sql);
void Close(void); void Close(void);
PQRYRES AllocateResult(PGLOBAL g); PQRYRES AllocateResult(PGLOBAL g);
@@ -96,19 +96,19 @@ public:
//void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;} //void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
//void SetUserName(PSZ user) {m_User = user;} //void SetUserName(PSZ user) {m_User = user;}
//void SetUserPwd(PSZ pwd) {m_Pwd = pwd;} //void SetUserPwd(PSZ pwd) {m_Pwd = pwd;}
int GetResultSize(char *sql, JDBCCOL *colp); int GetResultSize(PCSZ sql, JDBCCOL *colp);
int ExecuteQuery(char *sql); int ExecuteQuery(PCSZ sql);
int ExecuteUpdate(char *sql); int ExecuteUpdate(PCSZ sql);
int Fetch(int pos = 0); int Fetch(int pos = 0);
bool PrepareSQL(char *sql); bool PrepareSQL(PCSZ sql);
int ExecuteSQL(void); int ExecuteSQL(void);
bool SetParam(JDBCCOL *colp); bool SetParam(JDBCCOL *colp);
int ExecSQLcommand(char *sql); int ExecSQLcommand(PCSZ sql);
void SetColumnValue(int rank, PSZ name, PVAL val); void SetColumnValue(int rank, PSZ name, PVAL val);
int GetCatInfo(JCATPARM *cap); int GetCatInfo(JCATPARM *cap);
//bool GetDataSources(PQRYRES qrp); //bool GetDataSources(PQRYRES qrp);
bool GetDrivers(PQRYRES qrp); bool GetDrivers(PQRYRES qrp);
PQRYRES GetMetaData(PGLOBAL g, char *src); PQRYRES GetMetaData(PGLOBAL g, PCSZ src);
public: public:
// Set static variables // Set static variables
@@ -174,16 +174,10 @@ protected:
jmethodID timfldid; // The TimeField method ID jmethodID timfldid; // The TimeField method ID
jmethodID tspfldid; // The TimestampField method ID jmethodID tspfldid; // The TimestampField method ID
jmethodID bigfldid; // The BigintField method ID jmethodID bigfldid; // The BigintField method ID
//DWORD m_LoginTimeout; PCSZ Msg;
//DWORD m_QueryTimeout;
//DWORD m_UpdateOptions;
char *Msg;
char *m_Wrap; char *m_Wrap;
char m_IDQuoteChar[2]; char m_IDQuoteChar[2];
//PSZ m_Driver; PCSZ m_Pwd;
//PSZ m_Url;
//PSZ m_User;
PSZ m_Pwd;
int m_Ncol; int m_Ncol;
int m_Aff; int m_Aff;
int m_Rows; int m_Rows;

View File

@@ -81,64 +81,21 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n'))) if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n')))
pty[0] = false; pty[0] = false;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return NULL;
} // endif jump_level
#if defined(SE_CATCH)
// Let's try to recover from any kind of interrupt
_se_translator_function f = _set_se_translator(trans_func);
try {
#endif // SE_CATCH --------------------- try section --------------------
if (setjmp(g->jumper[++g->jump_level])) {
goto fin;
} // endif rc
#if defined(SE_CATCH) // ------------- end of try section -----------------
} catch (SE_Exception e) {
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
GetExceptionDesc(g, e.nSE), e.nSE);
_set_se_translator(f);
goto err;
} catch (...) {
strcpy(g->Message, "Exception doing setjmp");
_set_se_translator(f);
goto err;
} // end of try-catches
_set_se_translator(f);
#endif // SE_CATCH
#endif // !USE_TRY
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
switch (s[i]) { switch (s[i]) {
case '[': case '[':
if (jsp) if (jsp)
goto tryit; goto tryit;
else if (!(jsp = ParseArray(g, ++i, src, pty))) else if (!(jsp = ParseArray(g, ++i, src, pty)))
#if defined(USE_TRY)
throw 1; throw 1;
#else // !USE_TRY
goto fin;
#endif // !USE_TRY
break; break;
case '{': case '{':
if (jsp) if (jsp)
goto tryit; goto tryit;
else if (!(jsp = ParseObject(g, ++i, src, pty))) else if (!(jsp = ParseObject(g, ++i, src, pty)))
#if defined(USE_TRY)
throw 2; throw 2;
#else // !USE_TRY
goto fin;
#endif // !USE_TRY
break; break;
case ' ': case ' ':
@@ -156,12 +113,7 @@ _set_se_translator(f);
} // endif pretty } // endif pretty
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty); sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty);
#if defined(USE_TRY)
throw 3; throw 3;
#else // !USE_TRY
jsp = NULL;
goto fin;
#endif // !USE_TRY
case '(': case '(':
b = true; b = true;
break; break;
@@ -175,11 +127,7 @@ _set_se_translator(f);
if (jsp) if (jsp)
goto tryit; goto tryit;
else if (!(jsp = ParseValue(g, i, src, pty))) else if (!(jsp = ParseValue(g, i, src, pty)))
#if defined(USE_TRY)
throw 4; throw 4;
#else // !USE_TRY
goto fin;
#endif // !USE_TRY
break; break;
}; // endswitch s[i] }; // endswitch s[i]
@@ -197,7 +145,6 @@ _set_se_translator(f);
} // endif ptyp } // endif ptyp
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -208,20 +155,12 @@ _set_se_translator(f);
} // end catch } // end catch
return jsp; return jsp;
#else // !USE_TRY
fin:
g->jump_level--;
return jsp;
#endif // !USE_TRY
tryit: tryit:
if (pty[0] && (!pretty || pretty > 2)) { if (pty[0] && (!pretty || pretty > 2)) {
if ((jsp = ParseArray(g, (i = 0), src, pty)) && ptyp && pretty == 3) if ((jsp = ParseArray(g, (i = 0), src, pty)) && ptyp && pretty == 3)
*ptyp = (pty[0]) ? 0 : 3; *ptyp = (pty[0]) ? 0 : 3;
#if !defined(USE_TRY)
g->jump_level--;
#endif // !USE_TRY
return jsp; return jsp;
} else } else
strcpy(g->Message, "More than one item in file"); strcpy(g->Message, "More than one item in file");
@@ -626,28 +565,10 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
g->Message[0] = 0; g->Message[0] = 0;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
str = NULL;
goto fin;
} // endif jmp
#endif // !USE_TRY
if (!jsp) { if (!jsp) {
strcpy(g->Message, "Null json tree"); strcpy(g->Message, "Null json tree");
#if defined(USE_TRY)
throw 1; throw 1;
#else // !USE_TRY
goto fin;
#endif // !USE_TRY
} else if (!fn) { } else if (!fn) {
// Serialize to a string // Serialize to a string
jp = new(g) JOUTSTR(g); jp = new(g) JOUTSTR(g);
@@ -657,11 +578,7 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
sprintf(g->Message, MSG(OPEN_MODE_ERROR), sprintf(g->Message, MSG(OPEN_MODE_ERROR),
"w", (int)errno, fn); "w", (int)errno, fn);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
#if defined(USE_TRY)
throw 2; throw 2;
#else // !USE_TRY
goto fin;
#endif // !USE_TRY
} else if (pretty >= 2) { } else if (pretty >= 2) {
// Serialize to a pretty file // Serialize to a pretty file
jp = new(g)JOUTPRT(g, fs); jp = new(g)JOUTPRT(g, fs);
@@ -702,7 +619,6 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
} // endif's } // endif's
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -711,10 +627,7 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
strcpy(g->Message, msg); strcpy(g->Message, msg);
str = NULL; str = NULL;
} // end catch } // end catch
#else // !USE_TRY
fin:
g->jump_level--;
#endif // !USE_TRY
return str; return str;
} // end of Serialize } // end of Serialize
@@ -1023,7 +936,7 @@ return false;
/***********************************************************************/ /***********************************************************************/
/* Add a new pair to an Object. */ /* Add a new pair to an Object. */
/***********************************************************************/ /***********************************************************************/
PJPR JOBJECT::AddPair(PGLOBAL g, PSZ key) PJPR JOBJECT::AddPair(PGLOBAL g, PCSZ key)
{ {
PJPR jpp = new(g) JPAIR(key); PJPR jpp = new(g) JPAIR(key);
@@ -1109,7 +1022,7 @@ bool JOBJECT::Merge(PGLOBAL g, PJSON jsp)
/***********************************************************************/ /***********************************************************************/
/* Set or add a value corresponding to the given key. */ /* Set or add a value corresponding to the given key. */
/***********************************************************************/ /***********************************************************************/
void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key) void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PCSZ key)
{ {
PJPR jp; PJPR jp;
@@ -1129,7 +1042,7 @@ void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key)
/***********************************************************************/ /***********************************************************************/
/* Delete a value corresponding to the given key. */ /* Delete a value corresponding to the given key. */
/***********************************************************************/ /***********************************************************************/
void JOBJECT::DeleteKey(PSZ key) void JOBJECT::DeleteKey(PCSZ key)
{ {
PJPR jp, *pjp = &First; PJPR jp, *pjp = &First;
@@ -1308,10 +1221,10 @@ JVALUE::JVALUE(PGLOBAL g, PVAL valp) : JSON()
/***********************************************************************/ /***********************************************************************/
/* Constructor for a given string. */ /* Constructor for a given string. */
/***********************************************************************/ /***********************************************************************/
JVALUE::JVALUE(PGLOBAL g, PSZ strp) : JSON() JVALUE::JVALUE(PGLOBAL g, PCSZ strp) : JSON()
{ {
Jsp = NULL; Jsp = NULL;
Value = AllocateValue(g, strp, TYPE_STRING); Value = AllocateValue(g, (void*)strp, TYPE_STRING);
Next = NULL; Next = NULL;
Del = false; Del = false;
} // end of JVALUE constructor } // end of JVALUE constructor

View File

@@ -125,14 +125,14 @@ class JPAIR : public BLOCK {
friend PJOB ParseObject(PGLOBAL, int&, STRG&, bool*); friend PJOB ParseObject(PGLOBAL, int&, STRG&, bool*);
friend bool SerializeObject(JOUT *, PJOB); friend bool SerializeObject(JOUT *, PJOB);
public: public:
JPAIR(PSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;} JPAIR(PCSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;}
inline PSZ GetKey(void) {return Key;} inline PCSZ GetKey(void) {return Key;}
inline PJVAL GetVal(void) {return Val;} inline PJVAL GetVal(void) {return Val;}
inline PJPR GetNext(void) {return Next;} inline PJPR GetNext(void) {return Next;}
protected: protected:
PSZ Key; // This pair key name PCSZ Key; // This pair key name
PJVAL Val; // To the value of the pair PJVAL Val; // To the value of the pair
PJPR Next; // To the next pair PJPR Next; // To the next pair
}; // end of class JPAIR }; // end of class JPAIR
@@ -150,7 +150,7 @@ class JSON : public BLOCK {
virtual JTYP GetValType(void) {X return TYPE_JSON;} virtual JTYP GetValType(void) {X return TYPE_JSON;}
virtual void InitArray(PGLOBAL g) {X} virtual void InitArray(PGLOBAL g) {X}
//virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;} //virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;}
virtual PJPR AddPair(PGLOBAL g, PSZ key) {X return NULL;} virtual PJPR AddPair(PGLOBAL g, PCSZ key) {X return NULL;}
virtual PJAR GetKeyList(PGLOBAL g) {X return NULL;} virtual PJAR GetKeyList(PGLOBAL g) {X return NULL;}
virtual PJVAL GetValue(const char *key) {X return NULL;} virtual PJVAL GetValue(const char *key) {X return NULL;}
virtual PJOB GetObject(void) {return NULL;} virtual PJOB GetObject(void) {return NULL;}
@@ -166,13 +166,13 @@ class JSON : public BLOCK {
virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;} virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;}
virtual bool Merge(PGLOBAL g, PJSON jsp) { X return true; } virtual bool Merge(PGLOBAL g, PJSON jsp) { X return true; }
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; } virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; }
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key) {X} virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key) {X}
virtual void SetValue(PVAL valp) {X} virtual void SetValue(PVAL valp) {X}
virtual void SetValue(PJSON jsp) {X} virtual void SetValue(PJSON jsp) {X}
virtual void SetString(PGLOBAL g, PSZ s, short c) {X} virtual void SetString(PGLOBAL g, PSZ s, short c) {X}
virtual void SetInteger(PGLOBAL g, int n) {X} virtual void SetInteger(PGLOBAL g, int n) {X}
virtual void SetFloat(PGLOBAL g, double f) {X} virtual void SetFloat(PGLOBAL g, double f) {X}
virtual void DeleteKey(char *k) {X} virtual void DeleteKey(PCSZ k) {X}
virtual bool DeleteValue(int i) {X return true;} virtual bool DeleteValue(int i) {X return true;}
virtual bool IsNull(void) {X return true;} virtual bool IsNull(void) {X return true;}
@@ -195,14 +195,14 @@ class JOBJECT : public JSON {
virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JOB;} virtual JTYP GetType(void) {return TYPE_JOB;}
virtual PJPR GetFirst(void) {return First;} virtual PJPR GetFirst(void) {return First;}
virtual PJPR AddPair(PGLOBAL g, PSZ key); virtual PJPR AddPair(PGLOBAL g, PCSZ key);
virtual PJOB GetObject(void) {return this;} virtual PJOB GetObject(void) {return this;}
virtual PJVAL GetValue(const char* key); virtual PJVAL GetValue(const char* key);
virtual PJAR GetKeyList(PGLOBAL g); virtual PJAR GetKeyList(PGLOBAL g);
virtual PSZ GetText(PGLOBAL g, PSZ text); virtual PSZ GetText(PGLOBAL g, PSZ text);
virtual bool Merge(PGLOBAL g, PJSON jsp); virtual bool Merge(PGLOBAL g, PJSON jsp);
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key); virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key);
virtual void DeleteKey(char *k); virtual void DeleteKey(PCSZ k);
virtual bool IsNull(void); virtual bool IsNull(void);
protected: protected:
@@ -253,7 +253,7 @@ class JVALUE : public JSON {
JVALUE(PJSON jsp) : JSON() JVALUE(PJSON jsp) : JSON()
{Jsp = jsp; Value = NULL; Next = NULL; Del = false;} {Jsp = jsp; Value = NULL; Next = NULL; Del = false;}
JVALUE(PGLOBAL g, PVAL valp); JVALUE(PGLOBAL g, PVAL valp);
JVALUE(PGLOBAL g, PSZ strp); JVALUE(PGLOBAL g, PCSZ strp);
using JSON::GetValue; using JSON::GetValue;
using JSON::SetValue; using JSON::SetValue;

View File

@@ -1455,7 +1455,7 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
free(g->Sarea); free(g->Sarea);
if (!(g->Sarea = PlugAllocMem(g, ml))) { if (!(g->Sarea = PlugAllocMem(g, ml))) {
char errmsg[256]; char errmsg[MAX_STR];
sprintf(errmsg, MSG(WORK_AREA), g->Message); sprintf(errmsg, MSG(WORK_AREA), g->Message);
strcpy(g->Message, errmsg); strcpy(g->Message, errmsg);
@@ -1496,7 +1496,7 @@ static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i)
/*********************************************************************************/ /*********************************************************************************/
/* Make a valid key from the passed argument. */ /* Make a valid key from the passed argument. */
/*********************************************************************************/ /*********************************************************************************/
static PSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i) static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
{ {
if (args->arg_count > (unsigned)i) { if (args->arg_count > (unsigned)i) {
int j = 0, n = args->attribute_lengths[i]; int j = 0, n = args->attribute_lengths[i];
@@ -2253,7 +2253,8 @@ my_bool json_object_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error)
{ {
char *key, *str = NULL; PCSZ key;
char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
if (g->Xchk) { if (g->Xchk) {
@@ -2358,7 +2359,7 @@ char *json_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif Xchk } // endif Xchk
if (!CheckMemory(g, initid, args, 1, false, true, true)) { if (!CheckMemory(g, initid, args, 1, false, true, true)) {
char *key; PCSZ key;
PJOB jobp; PJOB jobp;
PJSON jsp, top; PJSON jsp, top;
PJVAL jvp = MakeValue(g, args, 0, &top); PJVAL jvp = MakeValue(g, args, 0, &top);
@@ -2921,27 +2922,11 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (g->N) { if (g->N) {
str = (char*)g->Activityp; str = (char*)g->Activityp;
goto fin; goto err;
} else if (initid->const_item) } else if (initid->const_item)
g->N = 1; g->N = 1;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*is_null = 1;
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
str = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) { if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true)) { if (CheckMemory(g, initid, args, 1, true)) {
PUSH_WARNING("CheckMemory error"); PUSH_WARNING("CheckMemory error");
@@ -2983,7 +2968,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function // Keep result of constant function
g->Activityp = (PACTIVITY)str; g->Activityp = (PACTIVITY)str;
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -2996,12 +2980,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // end catch } // end catch
err: err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
fin:
if (!str) { if (!str) {
*is_null = 1; *is_null = 1;
*res_length = 0; *res_length = 0;
@@ -3292,25 +3270,7 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item) } else if (initid->const_item)
g->N = 1; g->N = 1;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*error = 1;
*is_null = 1;
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) { if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, !g->Xchk)) { if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
PUSH_WARNING("CheckMemory error"); PUSH_WARNING("CheckMemory error");
@@ -3348,7 +3308,6 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function // Keep result of constant function
g->Activityp = (PACTIVITY)path; g->Activityp = (PACTIVITY)path;
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -3363,11 +3322,6 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // end catch } // end catch
err: err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
if (!path) { if (!path) {
*res_length = 0; *res_length = 0;
*is_null = 1; *is_null = 1;
@@ -3439,25 +3393,7 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item) } else if (initid->const_item)
g->N = 1; g->N = 1;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*error = 1;
*is_null = 1;
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) { if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true)) { if (CheckMemory(g, initid, args, 1, true)) {
PUSH_WARNING("CheckMemory error"); PUSH_WARNING("CheckMemory error");
@@ -3496,7 +3432,6 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function // Keep result of constant function
g->Activityp = (PACTIVITY)path; g->Activityp = (PACTIVITY)path;
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -3511,11 +3446,6 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // end catch } // end catch
err: err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
if (!path) { if (!path) {
*res_length = 0; *res_length = 0;
*is_null = 1; *is_null = 1;
@@ -3722,42 +3652,17 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
goto fin; goto fin;
} // endelse } // endelse
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*error = 1;
goto fin;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
str = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) { if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true, false, true)) { if (CheckMemory(g, initid, args, 1, true, false, true)) {
PUSH_WARNING("CheckMemory error"); PUSH_WARNING("CheckMemory error");
#if defined(USE_TRY)
throw 1; throw 1;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
} else } else
jvp = MakeValue(g, args, 0); jvp = MakeValue(g, args, 0);
if ((p = jvp->GetString())) { if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) { if (!(jsp = ParseJson(g, p, strlen(p)))) {
#if defined(USE_TRY)
throw 2; throw 2;
#else // !USE_TRY
PUSH_WARNING(g->Message);
goto err;
#endif // !USE_TRY
} // endif jsp } // endif jsp
} else } else
@@ -3801,7 +3706,6 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function // Keep result of constant function
g->Activityp = (PACTIVITY)str; g->Activityp = (PACTIVITY)str;
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -3812,10 +3716,6 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
str = NULL; str = NULL;
} // end catch } // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
fin: fin:
if (!str) { if (!str) {
@@ -4642,7 +4542,7 @@ char *jbin_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif bsp } // endif bsp
if (!CheckMemory(g, initid, args, 2, false, true, true)) { if (!CheckMemory(g, initid, args, 2, false, true, true)) {
char *key; PCSZ key;
PJOB jobp; PJOB jobp;
PJVAL jvp = MakeValue(g, args, 0, &top); PJVAL jvp = MakeValue(g, args, 0, &top);
PJSON jsp = jvp->GetJson(); PJSON jsp = jvp->GetJson();
@@ -4722,7 +4622,7 @@ char *jbin_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif bsp } // endif bsp
if (!CheckMemory(g, initid, args, 1, false, true, true)) { if (!CheckMemory(g, initid, args, 1, false, true, true)) {
char *key; PCSZ key;
PJOB jobp; PJOB jobp;
PJVAL jvp = MakeValue(g, args, 0, &top); PJVAL jvp = MakeValue(g, args, 0, &top);
PJSON jsp = jvp->GetJson(); PJSON jsp = jvp->GetJson();

View File

@@ -232,7 +232,7 @@ extern "C" {
/*********************************************************************************/ /*********************************************************************************/
typedef struct _jpn { typedef struct _jpn {
enum JTYP Type; enum JTYP Type;
PSZ Key; PCSZ Key;
int N; int N;
} JPN, *PJPN; } JPN, *PJPN;

View File

@@ -68,9 +68,9 @@ class LIBXMLDOC : public XMLDOCUMENT {
virtual void SetNofree(bool b) {Nofreelist = b;} virtual void SetNofree(bool b) {Nofreelist = b;}
// Methods // Methods
virtual bool Initialize(PGLOBAL g, char *entry, bool zipped); virtual bool Initialize(PGLOBAL g, PCSZ entry, bool zipped);
virtual bool ParseFile(PGLOBAL g, char *fn); virtual bool ParseFile(PGLOBAL g, char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver); virtual bool NewDoc(PGLOBAL g, PCSZ 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);
@@ -119,9 +119,9 @@ class XML2NODE : public XMLNODE {
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, PCSZ 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, PCSZ txtp);
virtual void DeleteChild(PGLOBAL g, PXNODE dnp); virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
protected: protected:
@@ -373,7 +373,7 @@ LIBXMLDOC::LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
/******************************************************************/ /******************************************************************/
/* Initialize XML parser and check library compatibility. */ /* Initialize XML parser and check library compatibility. */
/******************************************************************/ /******************************************************************/
bool LIBXMLDOC::Initialize(PGLOBAL g, char *entry, bool zipped) bool LIBXMLDOC::Initialize(PGLOBAL g, PCSZ entry, bool zipped)
{ {
if (zipped && InitZip(g, entry)) if (zipped && InitZip(g, entry))
return true; return true;
@@ -434,7 +434,7 @@ PFBLOCK LIBXMLDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn)
/******************************************************************/ /******************************************************************/
/* Construct and add the XML processing instruction node. */ /* Construct and add the XML processing instruction node. */
/******************************************************************/ /******************************************************************/
bool LIBXMLDOC::NewDoc(PGLOBAL g, char *ver) bool LIBXMLDOC::NewDoc(PGLOBAL g, PCSZ ver)
{ {
if (trace) if (trace)
htrc("NewDoc\n"); htrc("NewDoc\n");
@@ -863,14 +863,13 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len)
xmlFree(Content); xmlFree(Content);
if ((Content = xmlNodeGetContent(Nodep))) { if ((Content = xmlNodeGetContent(Nodep))) {
char *extra = " \t\r\n";
char *p1 = (char*)Content, *p2 = buf; char *p1 = (char*)Content, *p2 = buf;
bool b = false; bool b = false;
// Copy content eliminating extra characters // Copy content eliminating extra characters
for (; *p1; p1++) for (; *p1; p1++)
if ((p2 - buf) < len) { if ((p2 - buf) < len) {
if (strchr(extra, *p1)) { if (strchr(" \t\r\n", *p1)) {
if (b) { if (b) {
// This to have one blank between sub-nodes // This to have one blank between sub-nodes
*p2++ = ' '; *p2++ = ' ';
@@ -1020,19 +1019,19 @@ PXATTR XML2NODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap)
/******************************************************************/ /******************************************************************/
/* Add a new child node to this node and return it. */ /* Add a new child node to this node and return it. */
/******************************************************************/ /******************************************************************/
PXNODE XML2NODE::AddChildNode(PGLOBAL g, char *name, PXNODE np) PXNODE XML2NODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np)
{ {
char *p, *pn, *pf = NULL; char *p, *pn, *pf = NULL, *nmp = PlugDup(g, name);
if (trace) if (trace)
htrc("AddChildNode: %s\n", name); htrc("AddChildNode: %s\n", name);
// Is a prefix specified // Is a prefix specified
if ((pn = strchr(name, ':'))) { if ((pn = strchr(nmp, ':'))) {
pf = name; pf = nmp;
*pn++ = '\0'; // Separate name from prefix *pn++ = '\0'; // Separate name from prefix
} else } else
pn = name; pn = nmp;
// If name has the format m[n] only m is taken as node name // If name has the format m[n] only m is taken as node name
if ((p = strchr(pn, '['))) if ((p = strchr(pn, '[')))
@@ -1096,7 +1095,7 @@ PXATTR XML2NODE::AddProperty(PGLOBAL g, char *name, PXATTR ap)
/******************************************************************/ /******************************************************************/
/* Add a new text node to this node. */ /* Add a new text node to this node. */
/******************************************************************/ /******************************************************************/
void XML2NODE::AddText(PGLOBAL g, char *txtp) void XML2NODE::AddText(PGLOBAL g, PCSZ txtp)
{ {
if (trace) if (trace)
htrc("AddText: %s\n", txtp); htrc("AddText: %s\n", txtp);

View File

@@ -192,7 +192,7 @@ bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv)
case 23: case 23:
break; break;
default: default:
p = ""; p = PlugDup(g, "");
} // endswitch flag } // endswitch flag
} else switch (flag) { } else switch (flag) {

View File

@@ -11,7 +11,7 @@
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/*************** Mycat CC Program Source Code File (.CC) ***************/ /*************** Mycat CC Program Source Code File (.CC) ***************/
/* PROGRAM NAME: MYCAT */ /* PROGRAM NAME: MYCAT */
@@ -477,39 +477,6 @@ void MYCAT::Reset(void)
{ {
} // end of Reset } // end of Reset
#if 0
/***********************************************************************/
/* This function sets the current database path. */
/***********************************************************************/
void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path)
{
if (path) {
size_t len= strlen(path) + (*path != '.' ? 4 : 1);
char *buf= (char*)PlugSubAlloc(g, NULL, len);
if (PlugIsAbsolutePath(path))
{
strcpy(buf, path);
*datapath= buf;
return;
}
if (*path != '.') {
#if defined(__WIN__)
char *s= "\\";
#else // !__WIN__
char *s= "/";
#endif // !__WIN__
strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
} else
strcpy(buf, path);
*datapath= buf;
} // endif path
} // end of SetDataPath
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* GetTableDesc: retrieve a table descriptor. */ /* GetTableDesc: retrieve a table descriptor. */
/* Look for a table descriptor matching the name and type. */ /* Look for a table descriptor matching the name and type. */

View File

@@ -11,7 +11,7 @@
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 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 */
@@ -98,10 +98,7 @@ class MYCAT : public CATALOG {
// Methods // Methods
void Reset(void); void Reset(void);
//void SetDataPath(PGLOBAL g, const char *path)
// {SetPath(g, &DataPath, path);}
bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary
// PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
PRELDEF GetTableDesc(PGLOBAL g, PTABLE tablep, PRELDEF GetTableDesc(PGLOBAL g, PTABLE tablep,
LPCSTR type, PRELDEF *prp = NULL); LPCSTR type, PRELDEF *prp = NULL);
PTDB GetTable(PGLOBAL g, PTABLE tablep, PTDB GetTable(PGLOBAL g, PTABLE tablep,
@@ -109,9 +106,7 @@ class MYCAT : public CATALOG {
void ClearDB(PGLOBAL g); void ClearDB(PGLOBAL g);
protected: protected:
// PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
PRELDEF MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am); PRELDEF MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am);
//void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
// Members // Members
ha_connect *Hc; // The Connect handler ha_connect *Hc; // The Connect handler

View File

@@ -137,7 +137,8 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
FLD_CHARSET}; FLD_CHARSET};
//unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0}; //unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
unsigned int length[] = {0, 4, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0}; unsigned int length[] = {0, 4, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
char *fld, *colname, *chset, *fmt, v, buf[128], uns[16], zero[16]; PCSZ fmt;
char *fld, *colname, *chset, v, buf[128], uns[16], zero[16];
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int); int i, n, nf, ncol = sizeof(buftyp) / sizeof(int);
int len, type, prec, rc, k = 0; int len, type, prec, rc, k = 0;
bool b; bool b;
@@ -874,7 +875,8 @@ MYSQL_FIELD *MYSQLC::GetNextField(void)
/***********************************************************************/ /***********************************************************************/
PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
{ {
char *fmt, v; PCSZ fmt;
char *name, v;
int n; int n;
bool uns; bool uns;
PCOLRES *pcrp, crp; PCOLRES *pcrp, crp;
@@ -912,8 +914,9 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
memset(crp, 0, sizeof(COLRES)); memset(crp, 0, sizeof(COLRES));
crp->Ncol = ++qrp->Nbcol; crp->Ncol = ++qrp->Nbcol;
crp->Name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1); name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1);
strcpy(crp->Name, fld->name); strcpy(name, fld->name);
crp->Name = name;
if ((crp->Type = MYSQLtoPLG(fld->type, &v)) == TYPE_ERROR) { if ((crp->Type = MYSQLtoPLG(fld->type, &v)) == TYPE_ERROR) {
sprintf(g->Message, "Type %d not supported for column %s", sprintf(g->Message, "Type %d not supported for column %s",

View File

@@ -269,9 +269,9 @@ int MYSQLtoPLG(int mytype, char *var)
/************************************************************************/ /************************************************************************/
/* Returns the format corresponding to a MySQL date type number. */ /* Returns the format corresponding to a MySQL date type number. */
/************************************************************************/ /************************************************************************/
char *MyDateFmt(int mytype) PCSZ MyDateFmt(int mytype)
{ {
char *fmt; PCSZ fmt;
switch (mytype) { switch (mytype) {
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
@@ -297,9 +297,9 @@ char *MyDateFmt(int mytype)
/************************************************************************/ /************************************************************************/
/* Returns the format corresponding to a MySQL date type name. */ /* Returns the format corresponding to a MySQL date type name. */
/************************************************************************/ /************************************************************************/
char *MyDateFmt(char *typname) PCSZ MyDateFmt(char *typname)
{ {
char *fmt; PCSZ 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";

View File

@@ -8,7 +8,7 @@ enum enum_field_types PLGtoMYSQL(int type, bool dbf, char var = 0);
const char *PLGtoMYSQLtype(int type, bool dbf, char var = 0); const char *PLGtoMYSQLtype(int type, bool dbf, char var = 0);
int MYSQLtoPLG(char *typname, char *var = NULL); int MYSQLtoPLG(char *typname, char *var = NULL);
int MYSQLtoPLG(int mytype, char *var = NULL); int MYSQLtoPLG(int mytype, char *var = NULL);
char *MyDateFmt(int mytype); PCSZ MyDateFmt(int mytype);
char *MyDateFmt(char *typname); PCSZ MyDateFmt(char *typname);
#endif // __MYUTIL__H #endif // __MYUTIL__H

View File

@@ -3,8 +3,8 @@
#define DEFAULT_QUERY_TIMEOUT -1 // means do not set #define DEFAULT_QUERY_TIMEOUT -1 // means do not set
typedef struct odbc_parms { typedef struct odbc_parms {
char *User; // User connect info PCSZ User; // User connect info
char *Pwd; // Password connect info PCSZ Pwd; // Password connect info
int Cto; // Connect timeout int Cto; // Connect timeout
int Qto; // Query timeout int Qto; // Query timeout
bool UseCnc; // Use SQLConnect (!SQLDriverConnect) bool UseCnc; // Use SQLConnect (!SQLDriverConnect)
@@ -17,9 +17,9 @@ typedef struct odbc_parms {
char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop); char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop);
#endif // PROMPT_OK #endif // PROMPT_OK
PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info); PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info);
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table, PQRYRES ODBCColumns(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ table,
char *colpat, int maxres, bool info, POPARM sop); PCSZ colpat, int maxres, bool info, POPARM sop);
PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop); PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop);
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat, PQRYRES ODBCTables(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ tabpat,
char *tabtyp, int maxres, bool info, POPARM sop); PCSZ tabtyp, int maxres, bool info, POPARM sop);
PQRYRES ODBCDrivers(PGLOBAL g, int maxres, bool info); PQRYRES ODBCDrivers(PGLOBAL g, int maxres, bool info);

View File

@@ -239,8 +239,8 @@ char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop)
/***********************************************************************/ /***********************************************************************/
/* Allocate the structure used to refer to the result set. */ /* Allocate the structure used to refer to the result set. */
/***********************************************************************/ /***********************************************************************/
static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db, static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, PCSZ db,
char *tab, PQRYRES qrp) PCSZ tab, PQRYRES qrp)
{ {
size_t i, m, n; size_t i, m, n;
CATPARM *cap; CATPARM *cap;
@@ -249,30 +249,15 @@ static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
assert(qrp); assert(qrp);
#endif #endif
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level]) != 0) {
printf("%s\n", g->Message);
cap = NULL;
goto fin;
} // endif rc
#endif // !USE_TRY
m = (size_t)qrp->Maxres; m = (size_t)qrp->Maxres;
n = (size_t)qrp->Nbcol; n = (size_t)qrp->Nbcol;
cap = (CATPARM *)PlugSubAlloc(g, NULL, sizeof(CATPARM)); cap = (CATPARM *)PlugSubAlloc(g, NULL, sizeof(CATPARM));
memset(cap, 0, sizeof(CATPARM)); memset(cap, 0, sizeof(CATPARM));
cap->Id = fid; cap->Id = fid;
cap->Qrp = qrp; cap->Qrp = qrp;
cap->DB = (PUCHAR)db; cap->DB = db;
cap->Tab = (PUCHAR)tab; cap->Tab = tab;
cap->Vlen = (SQLLEN* *)PlugSubAlloc(g, NULL, n * sizeof(SQLLEN *)); cap->Vlen = (SQLLEN* *)PlugSubAlloc(g, NULL, n * sizeof(SQLLEN *));
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
@@ -280,7 +265,6 @@ static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
cap->Status = (UWORD *)PlugSubAlloc(g, NULL, m * sizeof(UWORD)); cap->Status = (UWORD *)PlugSubAlloc(g, NULL, m * sizeof(UWORD));
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
htrc("Exeption %d: %s\n", n, g->Message); htrc("Exeption %d: %s\n", n, g->Message);
cap = NULL; cap = NULL;
@@ -289,10 +273,7 @@ static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
printf("%s\n", g->Message); printf("%s\n", g->Message);
cap = NULL; cap = NULL;
} // end catch } // end catch
#else // !USE_TRY
fin:
g->jump_level--;
#endif // !USE_TRY
return cap; return cap;
} // end of AllocCatInfo } // end of AllocCatInfo
@@ -324,8 +305,8 @@ static void ResetNullValues(CATPARM *cap)
/* ODBCColumns: constructs the result blocks containing all columns */ /* ODBCColumns: constructs the result blocks containing all columns */
/* of an ODBC table that will be retrieved by GetData commands. */ /* of an ODBC table that will be retrieved by GetData commands. */
/***********************************************************************/ /***********************************************************************/
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table, PQRYRES ODBCColumns(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ table,
char *colpat, int maxres, bool info, POPARM sop) PCSZ colpat, int maxres, bool info, POPARM sop)
{ {
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT,
@@ -398,7 +379,7 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table,
if (!(cap = AllocCatInfo(g, CAT_COL, db, table, qrp))) if (!(cap = AllocCatInfo(g, CAT_COL, db, table, qrp)))
return NULL; return NULL;
cap->Pat = (PUCHAR)colpat; cap->Pat = colpat;
/************************************************************************/ /************************************************************************/
/* Now get the results into blocks. */ /* Now get the results into blocks. */
@@ -633,8 +614,8 @@ PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info)
/* ODBCTables: constructs the result blocks containing all tables in */ /* ODBCTables: constructs the result blocks containing all tables in */
/* an ODBC database that will be retrieved by GetData commands. */ /* an ODBC database that will be retrieved by GetData commands. */
/**************************************************************************/ /**************************************************************************/
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat, PQRYRES ODBCTables(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ tabpat, PCSZ tabtyp,
char *tabtyp, int maxres, bool info, POPARM sop) int maxres, bool info, POPARM sop)
{ {
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_STRING, TYPE_STRING}; TYPE_STRING, TYPE_STRING};
@@ -696,7 +677,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
if (!(cap = AllocCatInfo(g, CAT_TAB, db, tabpat, qrp))) if (!(cap = AllocCatInfo(g, CAT_TAB, db, tabpat, qrp)))
return NULL; return NULL;
cap->Pat = (PUCHAR)tabtyp; cap->Pat = tabtyp;
if (trace) if (trace)
htrc("Getting table results ncol=%d\n", cap->Qrp->Nbcol); htrc("Getting table results ncol=%d\n", cap->Qrp->Nbcol);
@@ -894,7 +875,7 @@ PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat,
/***********************************************************************/ /***********************************************************************/
/* Implementation of DBX class. */ /* Implementation of DBX class. */
/***********************************************************************/ /***********************************************************************/
DBX::DBX(RETCODE rc, PSZ msg) DBX::DBX(RETCODE rc, PCSZ msg)
{ {
m_RC = rc; m_RC = rc;
m_Msg = msg; m_Msg = msg;
@@ -1035,7 +1016,7 @@ bool ODBConn::Check(RETCODE rc)
/***********************************************************************/ /***********************************************************************/
/* DB exception throw routines. */ /* DB exception throw routines. */
/***********************************************************************/ /***********************************************************************/
void ODBConn::ThrowDBX(RETCODE rc, PSZ msg, HSTMT hstmt) void ODBConn::ThrowDBX(RETCODE rc, PCSZ msg, HSTMT hstmt)
{ {
DBX* xp = new(m_G) DBX(rc, msg); DBX* xp = new(m_G) DBX(rc, msg);
@@ -1045,7 +1026,7 @@ void ODBConn::ThrowDBX(RETCODE rc, PSZ msg, HSTMT hstmt)
} // end of ThrowDBX } // end of ThrowDBX
void ODBConn::ThrowDBX(PSZ msg) void ODBConn::ThrowDBX(PCSZ msg)
{ {
DBX* xp = new(m_G) DBX(0, "Error"); DBX* xp = new(m_G) DBX(0, "Error");
@@ -1125,7 +1106,7 @@ void ODBConn::OnSetOptions(HSTMT hstmt)
/***********************************************************************/ /***********************************************************************/
/* Open: connect to a data source. */ /* Open: connect to a data source. */
/***********************************************************************/ /***********************************************************************/
int ODBConn::Open(PSZ ConnectString, POPARM sop, DWORD options) int ODBConn::Open(PCSZ ConnectString, POPARM sop, DWORD options)
{ {
PGLOBAL& g = m_G; PGLOBAL& g = m_G;
//ASSERT_VALID(this); //ASSERT_VALID(this);
@@ -1207,7 +1188,7 @@ void ODBConn::AllocConnect(DWORD Options)
#if defined(_DEBUG) #if defined(_DEBUG)
if (Options & traceSQL) { if (Options & traceSQL) {
SQLSetConnectOption(m_hdbc, SQL_OPT_TRACEFILE, (DWORD)"xodbc.out"); SQLSetConnectOption(m_hdbc, SQL_OPT_TRACEFILE, (SQLULEN)"xodbc.out");
SQLSetConnectOption(m_hdbc, SQL_OPT_TRACE, 1); SQLSetConnectOption(m_hdbc, SQL_OPT_TRACE, 1);
} // endif } // endif
#endif // _DEBUG #endif // _DEBUG
@@ -1230,7 +1211,7 @@ void ODBConn::AllocConnect(DWORD Options)
// Turn on cursor lib support // Turn on cursor lib support
if (Options & useCursorLib) if (Options & useCursorLib)
rc = SQLSetConnectOption(m_hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_ODBC); rc = SQLSetConnectOption(m_hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_DRIVER);
return; return;
} // end of AllocConnect } // end of AllocConnect
@@ -1936,7 +1917,7 @@ bool ODBConn::ExecSQLcommand(char *sql)
/* GetMetaData: constructs the result blocks containing the */ /* GetMetaData: constructs the result blocks containing the */
/* description of all the columns of an SQL command. */ /* description of all the columns of an SQL command. */
/**************************************************************************/ /**************************************************************************/
PQRYRES ODBConn::GetMetaData(PGLOBAL g, char *dsn, char *src) PQRYRES ODBConn::GetMetaData(PGLOBAL g, PCSZ dsn, PCSZ src)
{ {
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_INT, static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_INT,
TYPE_SHORT, TYPE_SHORT}; TYPE_SHORT, TYPE_SHORT};
@@ -2259,7 +2240,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
void *buffer; void *buffer;
int i, irc; int i, irc;
bool b; bool b;
PSZ fnc = "Unknown"; PCSZ fnc = "Unknown";
UWORD n; UWORD n;
SWORD ncol, len, tp; SWORD ncol, len, tp;
SQLULEN crow = 0; SQLULEN crow = 0;
@@ -2298,22 +2279,20 @@ int ODBConn::GetCatInfo(CATPARM *cap)
// Now do call the proper ODBC API // Now do call the proper ODBC API
switch (cap->Id) { switch (cap->Id) {
case CAT_TAB: case CAT_TAB:
// rc = SQLSetStmtAttr(hstmt, SQL_ATTR_METADATA_ID,
// (SQLPOINTER)false, 0);
fnc = "SQLTables"; fnc = "SQLTables";
rc = SQLTables(hstmt, name.ptr(2), name.length(2), rc = SQLTables(hstmt, name.ptr(2), name.length(2),
name.ptr(1), name.length(1), name.ptr(1), name.length(1),
name.ptr(0), name.length(0), name.ptr(0), name.length(0),
cap->Pat, cap->Pat ? SQL_NTS : 0); (SQLCHAR *)cap->Pat,
cap->Pat ? SQL_NTS : 0);
break; break;
case CAT_COL: case CAT_COL:
// rc = SQLSetStmtAttr(hstmt, SQL_ATTR_METADATA_ID,
// (SQLPOINTER)true, 0);
fnc = "SQLColumns"; fnc = "SQLColumns";
rc = SQLColumns(hstmt, name.ptr(2), name.length(2), rc = SQLColumns(hstmt, name.ptr(2), name.length(2),
name.ptr(1), name.length(1), name.ptr(1), name.length(1),
name.ptr(0), name.length(0), name.ptr(0), name.length(0),
cap->Pat, cap->Pat ? SQL_NTS : 0); (SQLCHAR *)cap->Pat,
cap->Pat ? SQL_NTS : 0);
break; break;
case CAT_KEY: case CAT_KEY:
fnc = "SQLPrimaryKeys"; fnc = "SQLPrimaryKeys";

View File

@@ -54,9 +54,9 @@ enum CATINFO {CAT_TAB = 1, /* SQLTables */
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 DB; // Database (Schema) PCSZ DB; // Database (Schema)
PUCHAR Tab; // Table name or pattern PCSZ Tab; // Table name or pattern
PUCHAR Pat; // Table type or column pattern PCSZ 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
@@ -80,23 +80,23 @@ 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, PSZ msg = NULL); DBX(RETCODE rc, PCSZ msg = NULL);
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 GetMsg(void) {return m_Msg;} PCSZ GetMsg(void) {return m_Msg;}
const char *GetErrorMessage(int i); PCSZ GetErrorMessage(int i);
protected: protected:
bool BuildErrorMessage(ODBConn* pdb, HSTMT hstmt = SQL_NULL_HSTMT); bool BuildErrorMessage(ODBConn* pdb, HSTMT hstmt = SQL_NULL_HSTMT);
// Attributes // Attributes
RETCODE m_RC; RETCODE m_RC;
PSZ m_Msg; PCSZ m_Msg;
PSZ m_ErrMsg[MAX_NUM_OF_MSG]; PCSZ m_ErrMsg[MAX_NUM_OF_MSG];
}; // end of DBX class definition }; // end of DBX class definition
/***********************************************************************/ /***********************************************************************/
@@ -119,7 +119,7 @@ class ODBConn : public BLOCK {
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, POPARM sop, DWORD Options = 0); int Open(PCSZ ConnectString, POPARM sop, DWORD Options = 0);
int Rewind(char *sql, ODBCCOL *tocols); int Rewind(char *sql, ODBCCOL *tocols);
void Close(void); void Close(void);
PQRYRES AllocateResult(PGLOBAL g); PQRYRES AllocateResult(PGLOBAL g);
@@ -131,7 +131,7 @@ class ODBConn : public BLOCK {
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;} PCSZ GetConnect(void) {return m_Connect;}
public: public:
// Operations // Operations
@@ -149,7 +149,7 @@ class ODBConn : public BLOCK {
int GetCatInfo(CATPARM *cap); int GetCatInfo(CATPARM *cap);
bool GetDataSources(PQRYRES qrp); bool GetDataSources(PQRYRES qrp);
bool GetDrivers(PQRYRES qrp); bool GetDrivers(PQRYRES qrp);
PQRYRES GetMetaData(PGLOBAL g, char *dsn, char *src); PQRYRES GetMetaData(PGLOBAL g, PCSZ dsn, PCSZ src);
public: public:
// Set special options // Set special options
@@ -162,8 +162,8 @@ class ODBConn : public BLOCK {
// ODBC operations // ODBC operations
protected: protected:
bool Check(RETCODE rc); bool Check(RETCODE rc);
void ThrowDBX(RETCODE rc, PSZ msg, HSTMT hstmt = SQL_NULL_HSTMT); void ThrowDBX(RETCODE rc, PCSZ msg, HSTMT hstmt = SQL_NULL_HSTMT);
void ThrowDBX(PSZ msg); void ThrowDBX(PCSZ msg);
void AllocConnect(DWORD dwOptions); void AllocConnect(DWORD dwOptions);
void Connect(void); void Connect(void);
bool DriverConnect(DWORD Options); bool DriverConnect(DWORD Options);
@@ -187,9 +187,9 @@ class ODBConn : public BLOCK {
DWORD m_UpdateOptions; DWORD m_UpdateOptions;
DWORD m_RowsetSize; DWORD m_RowsetSize;
char m_IDQuoteChar[2]; char m_IDQuoteChar[2];
PSZ m_Connect; PCSZ m_Connect;
PSZ m_User; PCSZ m_User;
PSZ m_Pwd; PCSZ m_Pwd;
int m_Catver; int m_Catver;
int m_Rows; int m_Rows;
int m_Fetch; int m_Fetch;

View File

@@ -17,13 +17,16 @@ typedef off_t off64_t;
#if defined(__WIN__) #if defined(__WIN__)
typedef __int64 BIGINT; typedef __int64 BIGINT;
typedef _Null_terminated_ const char *PCSZ;
#else // !__WIN__ #else // !__WIN__
typedef longlong BIGINT; typedef longlong BIGINT;
#define FILE_BEGIN SEEK_SET #define FILE_BEGIN SEEK_SET
#define FILE_CURRENT SEEK_CUR #define FILE_CURRENT SEEK_CUR
#define FILE_END SEEK_END #define FILE_END SEEK_END
typedef const char *PCSZ;
#endif // !__WIN__ #endif // !__WIN__
#if !defined(__WIN__) #if !defined(__WIN__)
typedef const void *LPCVOID; typedef const void *LPCVOID;
typedef const char *LPCTSTR; typedef const char *LPCTSTR;

View File

@@ -80,7 +80,8 @@ enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */
TAB_DMY = 25, /* DMY Dummy tables NIY */ TAB_DMY = 25, /* DMY Dummy tables NIY */
TAB_JDBC = 26, /* Table accessed via JDBC */ TAB_JDBC = 26, /* Table accessed via JDBC */
TAB_ZIP = 27, /* ZIP file info table */ TAB_ZIP = 27, /* ZIP file info table */
TAB_NIY = 28}; /* Table not implemented yet */ // TAB_MONGO = 28, /* Table retrieved from MongoDB */
TAB_NIY = 30}; /* Table not implemented yet */
enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
TYPE_AM_ROWID = 1, /* ROWID type (special column) */ TYPE_AM_ROWID = 1, /* ROWID type (special column) */
@@ -143,6 +144,7 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
TYPE_AM_MYX = 193, /* MYSQL EXEC access method type */ TYPE_AM_MYX = 193, /* MYSQL EXEC access method type */
TYPE_AM_CAT = 195, /* Catalog access method type no */ TYPE_AM_CAT = 195, /* Catalog access method type no */
TYPE_AM_ZIP = 198, /* ZIP access method type no */ TYPE_AM_ZIP = 198, /* ZIP access method type no */
TYPE_AM_MGO = 199, /* MGO access method type no */
TYPE_AM_OUT = 200}; /* Output relations (storage) */ TYPE_AM_OUT = 200}; /* Output relations (storage) */
enum RECFM {RECFM_NAF = -2, /* Not a file */ enum RECFM {RECFM_NAF = -2, /* Not a file */
@@ -553,7 +555,7 @@ typedef struct _qryres {
typedef struct _colres { typedef struct _colres {
PCOLRES Next; /* To next result column */ PCOLRES Next; /* To next result column */
PCOL Colp; /* To matching column block */ PCOL Colp; /* To matching column block */
PSZ Name; /* Column header */ PCSZ Name; /* Column header */
PVBLK Kdata; /* Column block of values */ PVBLK Kdata; /* Column block of values */
char *Nulls; /* Column null value array */ char *Nulls; /* Column null value array */
int Type; /* Internal type */ int Type; /* Internal type */
@@ -583,7 +585,7 @@ void PlugLineDB(PGLOBAL, PSZ, short, void *, uint);
char *SetPath(PGLOBAL g, const char *path); char *SetPath(PGLOBAL g, const char *path);
char *ExtractFromPath(PGLOBAL, char *, char *, OPVAL); char *ExtractFromPath(PGLOBAL, char *, char *, OPVAL);
void AddPointer(PTABS, void *); void AddPointer(PTABS, void *);
PDTP MakeDateFormat(PGLOBAL, PSZ, bool, bool, int); PDTP MakeDateFormat(PGLOBAL, PCSZ, bool, bool, int);
int ExtractDate(char *, PDTP, int, int val[6]); int ExtractDate(char *, PDTP, int, int val[6]);
/**************************************************************************/ /**************************************************************************/
@@ -615,11 +617,10 @@ DllExport void *PlgDBrealloc(PGLOBAL, void *, MBLOCK&, size_t);
DllExport void NewPointer(PTABS, void *, void *); DllExport void NewPointer(PTABS, void *, void *);
//lExport char *GetIni(int n= 0); // Not used anymore //lExport char *GetIni(int n= 0); // Not used anymore
DllExport void SetTrc(void); DllExport void SetTrc(void);
DllExport char *GetListOption(PGLOBAL, const char *, const char *, DllExport PCSZ GetListOption(PGLOBAL, PCSZ, PCSZ, PCSZ def=NULL);
const char *def=NULL); DllExport PCSZ GetStringTableOption(PGLOBAL, PTOS, PCSZ, PCSZ);
DllExport char *GetStringTableOption(PGLOBAL, PTOS, char *, char *); DllExport bool GetBooleanTableOption(PGLOBAL, PTOS, PCSZ, bool);
DllExport bool GetBooleanTableOption(PGLOBAL, PTOS, char *, bool); DllExport int GetIntegerTableOption(PGLOBAL, PTOS, PCSZ, int);
DllExport int GetIntegerTableOption(PGLOBAL, PTOS, char *, int);
#define MSGID_NONE 0 #define MSGID_NONE 0
#define MSGID_CANNOT_OPEN 1 #define MSGID_CANNOT_OPEN 1

View File

@@ -244,25 +244,10 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
PCOLRES *pcrp, crp; PCOLRES *pcrp, crp;
PQRYRES qrp; PQRYRES qrp;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY /**********************************************************************/
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level]) != 0) {
printf("%s\n", g->Message);
qrp = NULL;
goto fin;
} // endif rc
#endif // !USE_TRY
/************************************************************************/
/* Allocate the structure used to contain the result set. */ /* Allocate the structure used to contain the result set. */
/************************************************************************/ /**********************************************************************/
qrp = (PQRYRES)PlugSubAlloc(g, NULL, sizeof(QRYRES)); qrp = (PQRYRES)PlugSubAlloc(g, NULL, sizeof(QRYRES));
pcrp = &qrp->Colresp; pcrp = &qrp->Colresp;
qrp->Continued = false; qrp->Continued = false;
@@ -320,7 +305,6 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
*pcrp = NULL; *pcrp = NULL;
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
qrp = NULL; qrp = NULL;
@@ -329,10 +313,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
htrc("%s\n", g->Message); htrc("%s\n", g->Message);
qrp = NULL; qrp = NULL;
} // end catch } // end catch
#else // !USE_TRY
fin:
g->jump_level--;
#endif // !USE_TRY
return qrp; return qrp;
} // end of PlgAllocResult } // end of PlgAllocResult
@@ -380,11 +361,7 @@ PCATLG PlgGetCatalog(PGLOBAL g, bool jump)
if (!cat && jump) { if (!cat && jump) {
// Raise exception so caller doesn't have to check return value // Raise exception so caller doesn't have to check return value
strcpy(g->Message, MSG(NO_ACTIVE_DB)); strcpy(g->Message, MSG(NO_ACTIVE_DB));
#if defined(USE_TRY)
throw 1; throw 1;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 1);
#endif // !USE_TRY
} // endif cat } // endif cat
return cat; return cat;
@@ -422,9 +399,9 @@ char *SetPath(PGLOBAL g, const char *path)
if (*path != '.') { if (*path != '.') {
#if defined(__WIN__) #if defined(__WIN__)
char *s= "\\"; const char *s = "\\";
#else // !__WIN__ #else // !__WIN__
char *s= "/"; const char *s = "/";
#endif // !__WIN__ #endif // !__WIN__
strcat(strcat(strcat(strcpy(buf, "."), s), path), s); strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
} else } else
@@ -468,7 +445,7 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op)
static bool PlugCheckPattern(PGLOBAL g, LPCSTR string, LPCSTR pat) static bool PlugCheckPattern(PGLOBAL g, LPCSTR string, LPCSTR pat)
{ {
if (pat && strlen(pat)) { if (pat && strlen(pat)) {
// This leaves 512 bytes (MAX_STR / 2) for each components // This leaves 2048 bytes (MAX_STR / 2) for each components
LPSTR name = g->Message + MAX_STR / 2; LPSTR name = g->Message + MAX_STR / 2;
strlwr(strcpy(name, string)); strlwr(strcpy(name, string));
@@ -496,11 +473,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
tp = g->Message; tp = g->Message;
else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) { else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) {
strcpy(g->Message, MSG(NEW_RETURN_NULL)); strcpy(g->Message, MSG(NEW_RETURN_NULL));
#if defined(USE_TRY)
throw OP_LIKE; throw OP_LIKE;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], OP_LIKE);
#endif // !USE_TRY
} /* endif tp */ } /* endif tp */
sp = tp + strlen(pat) + 1; sp = tp + strlen(pat) + 1;
@@ -511,11 +484,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
tp = g->Message; /* Use this as temporary work space. */ tp = g->Message; /* Use this as temporary work space. */
else if (!(tp = new char[strlen(pat) + 1])) { else if (!(tp = new char[strlen(pat) + 1])) {
strcpy(g->Message, MSG(NEW_RETURN_NULL)); strcpy(g->Message, MSG(NEW_RETURN_NULL));
#if defined(USE_TRY)
throw OP_LIKE; throw OP_LIKE;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], OP_LIKE);
#endif // !USE_TRY
} /* endif tp */ } /* endif tp */
strcpy(tp, pat); /* Make a copy to be worked into */ strcpy(tp, pat); /* Make a copy to be worked into */
@@ -704,7 +673,7 @@ void PlugConvertConstant(PGLOBAL g, void* & value, short& type)
/* format and a Strftime output format. Flag if not 0 indicates that */ /* format and a Strftime output format. Flag if not 0 indicates that */
/* non quoted blanks are not included in the output format. */ /* non quoted blanks are not included in the output format. */
/***********************************************************************/ /***********************************************************************/
PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag) PDTP MakeDateFormat(PGLOBAL g, PCSZ dfmt, bool in, bool out, int flag)
{ {
int rc; int rc;
PDTP pdp = (PDTP)PlugSubAlloc(g, NULL, sizeof(DATPAR)); PDTP pdp = (PDTP)PlugSubAlloc(g, NULL, sizeof(DATPAR));
@@ -713,7 +682,7 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag)
htrc("MakeDateFormat: dfmt=%s\n", dfmt); htrc("MakeDateFormat: dfmt=%s\n", dfmt);
memset(pdp, 0, sizeof(DATPAR)); memset(pdp, 0, sizeof(DATPAR));
pdp->Format = pdp->Curp = dfmt; pdp->Format = pdp->Curp = PlugDup(g, dfmt);
pdp->Outsize = 2 * strlen(dfmt) + 1; pdp->Outsize = 2 * strlen(dfmt) + 1;
if (in) if (in)
@@ -755,7 +724,8 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag)
/***********************************************************************/ /***********************************************************************/
int ExtractDate(char *dts, PDTP pdp, int defy, int val[6]) int ExtractDate(char *dts, PDTP pdp, int defy, int val[6])
{ {
char *fmt, c, d, e, W[8][12]; PCSZ fmt;
char c, d, e, W[8][12];
int i, k, m, numval; int i, k, m, numval;
int n, y = 30; int n, y = 30;
bool b = true; // true for null dates bool b = true; // true for null dates
@@ -1283,7 +1253,7 @@ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp)
// in the area, do allocate from virtual storage. // in the area, do allocate from virtual storage.
#if defined(__WIN__) #if defined(__WIN__)
if (mp.Size >= BIGMEM) if (mp.Size >= BIGMEM)
mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT, PAGE_READWRITE); mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
else else
#endif #endif
mp.Memp = malloc(mp.Size); mp.Memp = malloc(mp.Size);
@@ -1548,11 +1518,7 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
PGLOBAL g = t->G; PGLOBAL g = t->G;
sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR)); sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR));
#if defined(USE_TRY)
throw 3; throw 3;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 3);
#endif // !USE_TRY
} else { } else {
tp->Next = t->P1; tp->Next = t->P1;
tp->Num = 0; tp->Num = 0;
@@ -1589,22 +1555,14 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
sprintf(g->Message, MSG(OPEN_MODE_ERROR), sprintf(g->Message, MSG(OPEN_MODE_ERROR),
"rb", (int)errno, fn[i]); "rb", (int)errno, fn[i]);
strcat(strcat(g->Message, ": "), strerror(errno)); strcat(strcat(g->Message, ": "), strerror(errno));
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
// } else // } else
// len[i] = 0; // File does not exist yet // len[i] = 0; // File does not exist yet
} else { } else {
if ((len[i] = _filelength(h[i])) < 0) { if ((len[i] = _filelength(h[i])) < 0) {
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]); sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]);
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
} // endif len } // endif len
} // endif h } // endif h

View File

@@ -45,7 +45,7 @@ XMLDOCUMENT::XMLDOCUMENT(char *nsl, char *nsdf, char *enc)
/******************************************************************/ /******************************************************************/
/* Initialize zipped file processing. */ /* Initialize zipped file processing. */
/******************************************************************/ /******************************************************************/
bool XMLDOCUMENT::InitZip(PGLOBAL g, char *entry) bool XMLDOCUMENT::InitZip(PGLOBAL g, PCSZ entry)
{ {
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
bool mul = (entry) ? strchr(entry, '*') || strchr(entry, '?') : false; bool mul = (entry) ? strchr(entry, '*') || strchr(entry, '?') : false;
@@ -173,7 +173,7 @@ void XMLNODE::Delete(PXNODE dnp)
/******************************************************************/ /******************************************************************/
/* 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, const char *p, int n)
{ {
if (Len < n) { if (Len < n) {
Len = n; Len = n;

View File

@@ -76,9 +76,9 @@ class XMLDOCUMENT : public BLOCK {
virtual void SetNofree(bool b) = 0; virtual void SetNofree(bool b) = 0;
// Methods // Methods
virtual bool Initialize(PGLOBAL, char *, bool) = 0; virtual bool Initialize(PGLOBAL, PCSZ, bool) = 0;
virtual bool ParseFile(PGLOBAL, char *) = 0; virtual bool ParseFile(PGLOBAL, char *) = 0;
virtual bool NewDoc(PGLOBAL, char *) = 0; virtual bool NewDoc(PGLOBAL, PCSZ) = 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;
@@ -95,7 +95,7 @@ class XMLDOCUMENT : public BLOCK {
// Utility // Utility
bool MakeNSlist(PGLOBAL g); bool MakeNSlist(PGLOBAL g);
bool InitZip(PGLOBAL g, char *entry); bool InitZip(PGLOBAL g, PCSZ entry);
char *GetMemDoc(PGLOBAL g, char *fn); char *GetMemDoc(PGLOBAL g, char *fn);
void CloseZip(void); void CloseZip(void);
@@ -131,15 +131,15 @@ class XMLNODE : public BLOCK {
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, PCSZ, 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, PCSZ) = 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, const char *p, int n);
// Constructor // Constructor
XMLNODE(PXDOC dp); XMLNODE(PXDOC dp);

View File

@@ -139,10 +139,17 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
htrc("PlugInit: Language='%s'\n", htrc("PlugInit: Language='%s'\n",
((!Language) ? "Null" : (char*)Language)); ((!Language) ? "Null" : (char*)Language));
if (!(g = (PGLOBAL)malloc(sizeof(GLOBAL)))) { try {
g = new GLOBAL;
} catch (...) {
fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL)); fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
return NULL; return NULL;
} else { } // end try/catch
//if (!(g = (PGLOBAL)malloc(sizeof(GLOBAL)))) {
// fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
// return NULL;
// } else {
g->Sarea = NULL; g->Sarea = NULL;
g->Createas = 0; g->Createas = 0;
g->Alchecked = 0; g->Alchecked = 0;
@@ -157,14 +164,14 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
/* Allocate the main work segment. */ /* Allocate the main work segment. */
/*******************************************************************/ /*******************************************************************/
if (worksize && !(g->Sarea = PlugAllocMem(g, worksize))) { if (worksize && !(g->Sarea = PlugAllocMem(g, worksize))) {
char errmsg[256]; char errmsg[MAX_STR];
sprintf(errmsg, MSG(WORK_AREA), g->Message); sprintf(errmsg, MSG(WORK_AREA), g->Message);
strcpy(g->Message, errmsg); strcpy(g->Message, errmsg);
g->Sarea_Size = 0; g->Sarea_Size = 0;
} else } else
g->Sarea_Size = worksize; g->Sarea_Size = worksize;
} /* endif g */ //} /* endif g */
g->jump_level = -1; /* New setting to allow recursive call of Plug */ g->jump_level = -1; /* New setting to allow recursive call of Plug */
return(g); return(g);
@@ -183,7 +190,7 @@ int PlugExit(PGLOBAL g)
if (g->Sarea) if (g->Sarea)
free(g->Sarea); free(g->Sarea);
free(g); delete g;
return rc; return rc;
} /* end of PlugExit */ } /* end of PlugExit */
@@ -510,7 +517,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
memp, size, pph->To_Free, pph->FreeBlk); memp, size, pph->To_Free, pph->FreeBlk);
if ((uint)size > pph->FreeBlk) { /* Not enough memory left in pool */ if ((uint)size > pph->FreeBlk) { /* Not enough memory left in pool */
char *pname = "Work"; PCSZ pname = "Work";
sprintf(g->Message, sprintf(g->Message,
"Not enough memory in %s area for request of %u (used=%d free=%d)", "Not enough memory in %s area for request of %u (used=%d free=%d)",
@@ -519,13 +526,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
if (trace) if (trace)
htrc("PlugSubAlloc: %s\n", g->Message); htrc("PlugSubAlloc: %s\n", g->Message);
#if defined(USE_TRY)
throw 1234; throw 1234;
#else // !USE_TRY
/* Nothing we can do if longjmp is not initialized. */
assert(g->jump_level >= 0);
longjmp(g->jumper[g->jump_level], 1);
#endif // !USE_TRY
} /* endif size OS32 code */ } /* endif size OS32 code */
/*********************************************************************/ /*********************************************************************/

View File

@@ -7,7 +7,7 @@
/* 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 const 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

View File

@@ -1,11 +1,11 @@
/************* RelDef CPP Program Source Code File (.CPP) **************/ /************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: RELDEF */ /* PROGRAM NAME: RELDEF */
/* ------------- */ /* ------------- */
/* Version 1.7 */ /* Version 1.6 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2017 */ /* (C) Copyright to the author Olivier BERTRAND 2004-2016 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
@@ -88,7 +88,7 @@ PTOS RELDEF::GetTopt(void)
/***********************************************************************/ /***********************************************************************/
/* This function sets an integer table information. */ /* This function sets an integer table information. */
/***********************************************************************/ /***********************************************************************/
bool RELDEF::SetIntCatInfo(PSZ what, int n) bool RELDEF::SetIntCatInfo(PCSZ what, int n)
{ {
return Hc->SetIntegerOption(what, n); return Hc->SetIntegerOption(what, n);
} // end of SetIntCatInfo } // end of SetIntCatInfo
@@ -96,7 +96,7 @@ bool RELDEF::SetIntCatInfo(PSZ what, int n)
/***********************************************************************/ /***********************************************************************/
/* This function returns integer table information. */ /* This function returns integer table information. */
/***********************************************************************/ /***********************************************************************/
int RELDEF::GetIntCatInfo(PSZ what, int idef) int RELDEF::GetIntCatInfo(PCSZ what, int idef)
{ {
int n= Hc->GetIntegerOption(what); int n= Hc->GetIntegerOption(what);
@@ -106,7 +106,7 @@ int RELDEF::GetIntCatInfo(PSZ what, int idef)
/***********************************************************************/ /***********************************************************************/
/* This function returns Boolean table information. */ /* This function returns Boolean table information. */
/***********************************************************************/ /***********************************************************************/
bool RELDEF::GetBoolCatInfo(PSZ what, bool bdef) bool RELDEF::GetBoolCatInfo(PCSZ what, bool bdef)
{ {
bool b= Hc->GetBooleanOption(what, bdef); bool b= Hc->GetBooleanOption(what, bdef);
@@ -116,9 +116,10 @@ bool RELDEF::GetBoolCatInfo(PSZ what, bool bdef)
/***********************************************************************/ /***********************************************************************/
/* This function returns size catalog information. */ /* This function returns size catalog information. */
/***********************************************************************/ /***********************************************************************/
int RELDEF::GetSizeCatInfo(PSZ what, PSZ sdef) int RELDEF::GetSizeCatInfo(PCSZ what, PCSZ sdef)
{ {
char * s, c; char c;
PCSZ s;
int i, n= 0; int i, n= 0;
if (!(s= Hc->GetStringOption(what))) if (!(s= Hc->GetStringOption(what)))
@@ -138,9 +139,9 @@ int RELDEF::GetSizeCatInfo(PSZ what, PSZ sdef)
/***********************************************************************/ /***********************************************************************/
/* This function sets char table information in buf. */ /* This function sets char table information in buf. */
/***********************************************************************/ /***********************************************************************/
int RELDEF::GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size) int RELDEF::GetCharCatInfo(PCSZ what, PCSZ sdef, char *buf, int size)
{ {
char *s= Hc->GetStringOption(what); PCSZ s= Hc->GetStringOption(what);
strncpy(buf, ((s) ? s : sdef), size); strncpy(buf, ((s) ? s : sdef), size);
return size; return size;
@@ -158,9 +159,10 @@ bool RELDEF::Partitioned(void)
/* This function returns string table information. */ /* This function returns string table information. */
/* Default parameter is "*" to get the handler default. */ /* Default parameter is "*" to get the handler default. */
/***********************************************************************/ /***********************************************************************/
char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) char *RELDEF::GetStringCatInfo(PGLOBAL g, PCSZ what, PCSZ sdef)
{ {
char *name, *sval= NULL, *s= Hc->GetStringOption(what, sdef); char *sval = NULL;
PCSZ name, s= Hc->GetStringOption(what, sdef);
if (s) { if (s) {
if (!Hc->IsPartitioned() || if (!Hc->IsPartitioned() ||
@@ -168,11 +170,11 @@ char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
&& stricmp(what, "connect"))) && stricmp(what, "connect")))
sval= PlugDup(g, s); sval= PlugDup(g, s);
else else
sval= s; sval= (char*)s;
} else if (!stricmp(what, "filename")) { } else if (!stricmp(what, "filename")) {
// Return default file name // Return default file name
char *ftype= Hc->GetStringOption("Type", "*"); PCSZ ftype= Hc->GetStringOption("Type", "*");
int i, n; int i, n;
if (IsFileType(GetTypeID(ftype))) { if (IsFileType(GetTypeID(ftype))) {
@@ -251,9 +253,9 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat,
/***********************************************************************/ /***********************************************************************/
/* This function returns the database data path. */ /* This function returns the database data path. */
/***********************************************************************/ /***********************************************************************/
PSZ TABDEF::GetPath(void) PCSZ TABDEF::GetPath(void)
{ {
return (Database) ? (PSZ)Database : (Hc) ? Hc->GetDataPath() : NULL; return (Database) ? Database : (Hc) ? Hc->GetDataPath() : NULL;
} // end of GetPath } // end of GetPath
/***********************************************************************/ /***********************************************************************/
@@ -615,9 +617,10 @@ bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR, int)
if (!*Module) if (!*Module)
Module = Subtype; Module = Subtype;
Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module) char *desc = (char*)PlugSubAlloc(g, NULL, strlen(Module)
+ strlen(Subtype) + 3); + strlen(Subtype) + 3);
sprintf(Desc, "%s(%s)", Module, Subtype); sprintf(desc, "%s(%s)", Module, Subtype);
Desc = desc;
return false; return false;
} // end of DefineAM } // end of DefineAM

View File

@@ -42,13 +42,13 @@ class DllExport RELDEF : public BLOCK { // Relation definition block
// Methods // Methods
PTOS GetTopt(void); PTOS GetTopt(void);
bool GetBoolCatInfo(PSZ what, bool bdef); bool GetBoolCatInfo(PCSZ what, bool bdef);
bool SetIntCatInfo(PSZ what, int ival); bool SetIntCatInfo(PCSZ what, int ival);
bool Partitioned(void); bool Partitioned(void);
int GetIntCatInfo(PSZ what, int idef); int GetIntCatInfo(PCSZ what, int idef);
int GetSizeCatInfo(PSZ what, PSZ sdef); int GetSizeCatInfo(PCSZ what, PCSZ sdef);
int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size); int GetCharCatInfo(PCSZ what, PCSZ sdef, char *buf, int size);
char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef); char *GetStringCatInfo(PGLOBAL g, PCSZ what, PCSZ sdef);
virtual int Indexable(void) {return 0;} virtual int Indexable(void) {return 0;}
virtual bool Define(PGLOBAL g, PCATLG cat, virtual bool Define(PGLOBAL g, PCATLG cat,
LPCSTR name, LPCSTR schema, LPCSTR am) = 0; LPCSTR name, LPCSTR schema, LPCSTR am) = 0;
@@ -84,7 +84,7 @@ public:
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); PCSZ GetPath(void);
//PSZ GetPath(void) //PSZ GetPath(void)
// {return (Database) ? (PSZ)Database : Cat->GetDataPath();} // {return (Database) ? (PSZ)Database : Cat->GetDataPath();}
bool SepIndex(void) {return GetBoolCatInfo("SepIndex", false);} bool SepIndex(void) {return GetBoolCatInfo("SepIndex", false);}
@@ -105,8 +105,8 @@ public:
protected: protected:
// Members // Members
PSZ Schema; /* Table schema (for ODBC) */ PCSZ Schema; /* Table schema (for ODBC) */
PSZ Desc; /* Table description */ PCSZ Desc; /* Table description */
uint Catfunc; /* Catalog function ID */ uint Catfunc; /* Catalog function ID */
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 */

View File

@@ -132,6 +132,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
bool map = (am && (*am == 'M' || *am == 'm')); bool map = (am && (*am == 'M' || *am == 'm'));
LPCSTR dfm = (am && (*am == 'F' || *am == 'f')) ? "F" LPCSTR dfm = (am && (*am == 'F' || *am == 'f')) ? "F"
: (am && (*am == 'B' || *am == 'b')) ? "B" : (am && (*am == 'B' || *am == 'b')) ? "B"
: (am && (*am == 'X' || *am == 'x')) ? "X"
: (am && !stricmp(am, "DBF")) ? "D" : "V"; : (am && !stricmp(am, "DBF")) ? "D" : "V";
if ((Zipped = GetBoolCatInfo("Zipped", false))) { if ((Zipped = GetBoolCatInfo("Zipped", false))) {
@@ -148,6 +149,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf)); GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf));
Recfm = (toupper(*buf) == 'F') ? RECFM_FIX : Recfm = (toupper(*buf) == 'F') ? RECFM_FIX :
(toupper(*buf) == 'B') ? RECFM_BIN : (toupper(*buf) == 'B') ? RECFM_BIN :
(toupper(*buf) == 'X') ? RECFM_NAF : // MGO
(toupper(*buf) == 'D') ? RECFM_DBF : RECFM_VAR; (toupper(*buf) == 'D') ? RECFM_DBF : RECFM_VAR;
Lrecl = GetIntCatInfo("Lrecl", 0); Lrecl = GetIntCatInfo("Lrecl", 0);
@@ -182,7 +184,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
/***********************************************************************/ /***********************************************************************/
bool DOSDEF::GetOptFileName(PGLOBAL g, char *filename) bool DOSDEF::GetOptFileName(PGLOBAL g, char *filename)
{ {
char *ftype; PCSZ ftype;
switch (Recfm) { switch (Recfm) {
case RECFM_VAR: ftype = ".dop"; break; case RECFM_VAR: ftype = ".dop"; break;
@@ -239,7 +241,7 @@ void DOSDEF::RemoveOptValues(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
{ {
char *ftype; PCSZ ftype;
char filename[_MAX_PATH]; char filename[_MAX_PATH];
bool sep, rc = false; bool sep, rc = false;
@@ -1511,11 +1513,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
if (n == 8 && ctype != TYPE_LIST) { if (n == 8 && ctype != TYPE_LIST) {
// Should never happen // Should never happen
strcpy(g->Message, "Block opt: bad constant"); strcpy(g->Message, "Block opt: bad constant");
#if defined(USE_TRY)
throw 99; throw 99;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 99);
#endif // !USE_TRY
} // endif Conv } // endif Conv
if (type[0] == 1) { if (type[0] == 1) {
@@ -1867,17 +1865,7 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
} else // Column contains same values as ROWID } else // Column contains same values as ROWID
kxp = new(g) XXROW(this); kxp = new(g) XXROW(this);
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return true;
} // endif
if (!setjmp(g->jumper[++g->jump_level])) {
#endif // !USE_TRY
if (dynamic) { if (dynamic) {
ResetBlockFilter(g); ResetBlockFilter(g);
kxp->SetDynamic(dynamic); kxp->SetDynamic(dynamic);
@@ -1902,7 +1890,6 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
} // endif brc } // endif brc
#if defined(USE_TRY)
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -1911,12 +1898,7 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
strcpy(g->Message, msg); strcpy(g->Message, msg);
brc = true; brc = true;
} // end catch } // end catch
#else // !USE_TRY
} else
brc = true;
g->jump_level--;
#endif // !USE_TRY
return brc; return brc;
} // end of InitialyzeIndex } // end of InitialyzeIndex
@@ -2139,7 +2121,8 @@ bool TDBDOS::OpenDB(PGLOBAL g)
return false; return false;
} // endif use } // endif use
if (Mode == MODE_DELETE && !Next && Txfp->GetAmType() != TYPE_AM_DOS) { if (Mode == MODE_DELETE && !Next && Txfp->GetAmType() != TYPE_AM_DOS
&& Txfp->GetAmType() != TYPE_AM_MGO) {
// Delete all lines. Not handled in MAP or block mode // Delete all lines. Not handled in MAP or block mode
Txfp = new(g) DOSFAM((PDOSDEF)To_Def); Txfp = new(g) DOSFAM((PDOSDEF)To_Def);
Txfp->SetTdbp(this); Txfp->SetTdbp(this);
@@ -2327,7 +2310,7 @@ void TDBDOS::CloseDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* DOSCOL public constructor (also called by MAPCOL). */ /* DOSCOL public constructor (also called by MAPCOL). */
/***********************************************************************/ /***********************************************************************/
DOSCOL::DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am) DOSCOL::DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PCSZ am)
: COLBLK(cdp, tp, i) : COLBLK(cdp, tp, i)
{ {
char *p; char *p;
@@ -2358,7 +2341,7 @@ DOSCOL::DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
Dval = NULL; Dval = NULL;
Buf = NULL; Buf = NULL;
if (txfp->Blocked && Opt && (cdp->GetMin() || cdp->GetDval())) { if (txfp && txfp->Blocked && Opt && (cdp->GetMin() || cdp->GetDval())) {
int nblk = txfp->GetBlock(); int nblk = txfp->GetBlock();
Clustered = (cdp->GetXdb2()) ? 2 : 1; Clustered = (cdp->GetXdb2()) ? 2 : 1;
@@ -2537,11 +2520,7 @@ void DOSCOL::ReadColumn(PGLOBAL g)
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); sprintf(g->Message, MSG(INV_DEF_READ), rc);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} // endif } // endif
p = tdbp->To_Line + Deplac; p = tdbp->To_Line + Deplac;
@@ -2597,11 +2576,7 @@ void DOSCOL::ReadColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype); sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype);
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} // endswitch Ftype } // endswitch Ftype
// Set null when applicable // Set null when applicable
@@ -2710,11 +2685,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, "Invalid field format for column %s", Name); sprintf(g->Message, "Invalid field format for column %s", Name);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endswitch BufType } // endswitch BufType
p2 = Buf; p2 = Buf;
@@ -2726,11 +2697,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
if ((len = strlen(p2)) > field) { if ((len = strlen(p2)) > field) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p2, Name, field); sprintf(g->Message, MSG(VALUE_TOO_LONG), p2, Name, field);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Dsp) } else if (Dsp)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
if (p2[i] == '.') if (p2[i] == '.')

View File

@@ -39,9 +39,9 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
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;}
virtual bool IsHuge(void) {return Huge;} virtual bool IsHuge(void) {return Huge;}
PSZ GetFn(void) {return Fn;} PCSZ GetFn(void) {return Fn;}
PSZ GetOfn(void) {return Ofn;} PCSZ GetOfn(void) {return Ofn;}
PSZ GetEntry(void) {return Entry;} PCSZ GetEntry(void) {return Entry;}
bool GetMul(void) {return Mulentries;} bool GetMul(void) {return Mulentries;}
bool GetAppend(void) {return Append;} bool GetAppend(void) {return Append;}
void SetBlock(int block) { Block = block; } void SetBlock(int block) { Block = block; }
@@ -74,10 +74,10 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
//virtual bool Erase(char *filename); //virtual bool Erase(char *filename);
// Members // Members
PSZ Fn; /* Path/Name of corresponding file */ PCSZ Fn; /* Path/Name of corresponding file */
PSZ Ofn; /* Base Path/Name of matching index files*/ PCSZ Ofn; /* Base Path/Name of matching index files*/
PSZ Entry; /* Zip entry name or pattern */ PCSZ Entry; /* Zip entry name or pattern */
PSZ Pwd; /* Zip password */ PCSZ Pwd; /* Zip password */
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 */
@@ -133,8 +133,8 @@ class DllExport TDBDOS : public TDBASE {
// Implementation // Implementation
virtual AMT GetAmType(void) {return Txfp->GetAmType();} virtual AMT GetAmType(void) {return Txfp->GetAmType();}
virtual PSZ GetFile(PGLOBAL) {return Txfp->To_File;} virtual PCSZ GetFile(PGLOBAL) {return Txfp->To_File;}
virtual void SetFile(PGLOBAL, PSZ fn) {Txfp->To_File = fn;} virtual void SetFile(PGLOBAL, PCSZ fn) {Txfp->To_File = fn;}
virtual void SetAbort(bool b) {Abort = b;} virtual void SetAbort(bool b) {Abort = b;}
virtual RECFM GetFtype(void) {return Ftype;} virtual RECFM GetFtype(void) {return Ftype;}
virtual bool SkipHeader(PGLOBAL) {return false;} virtual bool SkipHeader(PGLOBAL) {return false;}
@@ -214,7 +214,7 @@ class DllExport DOSCOL : public COLBLK {
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, PCSZ am = "DOS");
DOSCOL(DOSCOL *colp, PTDB tdbp); // Constructor used in copy process DOSCOL(DOSCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation

View File

@@ -35,9 +35,9 @@
/***********************************************************************/ /***********************************************************************/
/* CONDFIL Constructor. */ /* CONDFIL Constructor. */
/***********************************************************************/ /***********************************************************************/
CONDFIL::CONDFIL(const Item *cond, uint idx, AMT type) CONDFIL::CONDFIL(uint idx, AMT type)
{ {
Cond = cond; //Cond = cond;
Idx = idx; Idx = idx;
Type = type; Type = type;
Op = OP_XX; Op = OP_XX;
@@ -61,7 +61,7 @@ int CONDFIL::Init(PGLOBAL g, PHC hc)
bool h; bool h;
if (options) if (options)
alt = GetListOption(g, "Alias", options->oplist, NULL); alt = (char*)GetListOption(g, "Alias", options->oplist, NULL);
while (alt) { while (alt) {
if (!(p = strchr(alt, '='))) { if (!(p = strchr(alt, '='))) {
@@ -267,7 +267,7 @@ TDBEXT::TDBEXT(PTDBEXT tdbp) : TDB(tdbp)
/******************************************************************/ /******************************************************************/
/* Convert an UTF-8 string to latin characters. */ /* Convert an UTF-8 string to latin characters. */
/******************************************************************/ /******************************************************************/
int TDBEXT::Decode(char *txt, char *buf, size_t n) int TDBEXT::Decode(PCSZ txt, char *buf, size_t n)
{ {
uint dummy_errors; uint dummy_errors;
uint32 len = copy_and_convert(buf, n, &my_charset_latin1, uint32 len = copy_and_convert(buf, n, &my_charset_latin1,
@@ -285,16 +285,17 @@ int TDBEXT::Decode(char *txt, char *buf, size_t n)
/***********************************************************************/ /***********************************************************************/
bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt) bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
{ {
char *schmp = NULL, *catp = NULL, buf[NAM_LEN * 3]; PCSZ schmp = NULL;
char *catp = NULL, buf[NAM_LEN * 3];
int len; int len;
bool oom = false, first = true; bool first = true;
PTABLE tablep = To_Table; PTABLE tablep = To_Table;
PCOL colp; PCOL colp;
if (Srcdef) { if (Srcdef) {
if ((catp = strstr(Srcdef, "%s"))) { if ((catp = strstr(Srcdef, "%s"))) {
char *fil1, *fil2; char *fil1, *fil2;
PSZ ph = ((EXTDEF*)To_Def)->Phpos; PCSZ ph = ((EXTDEF*)To_Def)->Phpos;
if (!ph) if (!ph)
ph = (strstr(catp + 2, "%s")) ? "WH" : "W"; ph = (strstr(catp + 2, "%s")) ? "WH" : "W";
@@ -341,7 +342,7 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
for (colp = Columns; colp; colp = colp->GetNext()) for (colp = Columns; colp; colp = colp->GetNext())
if (!colp->IsSpecial()) { if (!colp->IsSpecial()) {
if (!first) if (!first)
oom |= Query->Append(", "); Query->Append(", ");
else else
first = false; first = false;
@@ -350,11 +351,11 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
if (Quote) { if (Quote) {
// Put column name between identifier quotes in case in contains blanks // Put column name between identifier quotes in case in contains blanks
oom |= Query->Append(Quote); Query->Append(Quote);
oom |= Query->Append(buf); Query->Append(buf);
oom |= Query->Append(Quote); Query->Append(Quote);
} else } else
oom |= Query->Append(buf); Query->Append(buf);
((PEXTCOL)colp)->SetRank(++Ncol); ((PEXTCOL)colp)->SetRank(++Ncol);
} // endif colp } // endif colp
@@ -362,13 +363,13 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
} else } else
// !Columns can occur for queries such that sql count(*) from... // !Columns can occur for queries such that sql count(*) from...
// for which we will count the rows from sql * from... // for which we will count the rows from sql * from...
oom |= Query->Append('*'); Query->Append('*');
} else } else
// SQL statement used to retrieve the size of the result // SQL statement used to retrieve the size of the result
oom |= Query->Append("count(*)"); Query->Append("count(*)");
oom |= Query->Append(" FROM "); Query->Append(" FROM ");
if (Catalog && *Catalog) if (Catalog && *Catalog)
catp = Catalog; catp = Catalog;
@@ -380,17 +381,17 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
schmp = Schema; schmp = Schema;
if (catp) { if (catp) {
oom |= Query->Append(catp); Query->Append(catp);
if (schmp) { if (schmp) {
oom |= Query->Append('.'); Query->Append('.');
oom |= Query->Append(schmp); Query->Append(schmp);
} // endif schmp } // endif schmp
oom |= Query->Append('.'); Query->Append('.');
} else if (schmp) { } else if (schmp) {
oom |= Query->Append(schmp); Query->Append(schmp);
oom |= Query->Append('.'); Query->Append('.');
} // endif schmp } // endif schmp
// Table name can be encoded in UTF-8 // Table name can be encoded in UTF-8
@@ -398,18 +399,18 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
if (Quote) { if (Quote) {
// Put table name between identifier quotes in case in contains blanks // Put table name between identifier quotes in case in contains blanks
oom |= Query->Append(Quote); Query->Append(Quote);
oom |= Query->Append(buf); Query->Append(buf);
oom |= Query->Append(Quote); Query->Append(Quote);
} else } else
oom |= Query->Append(buf); Query->Append(buf);
len = Query->GetLength(); len = Query->GetLength();
if (To_CondFil) { if (To_CondFil) {
if (Mode == MODE_READ) { if (Mode == MODE_READ) {
oom |= Query->Append(" WHERE "); Query->Append(" WHERE ");
oom |= Query->Append(To_CondFil->Body); Query->Append(To_CondFil->Body);
len = Query->GetLength() + 1; len = Query->GetLength() + 1;
} else } else
len += (strlen(To_CondFil->Body) + 256); len += (strlen(To_CondFil->Body) + 256);
@@ -417,10 +418,11 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
} else } else
len += ((Mode == MODE_READX) ? 256 : 1); len += ((Mode == MODE_READX) ? 256 : 1);
if (oom || Query->Resize(len)) { if (Query->IsTruncated()) {
strcpy(g->Message, "MakeSQL: Out of memory"); strcpy(g->Message, "MakeSQL: Out of memory");
return true; return true;
} // endif oom } else
Query->Resize(len);
if (trace) if (trace)
htrc("Query=%s\n", Query->GetStr()); htrc("Query=%s\n", Query->GetStr());
@@ -434,7 +436,8 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
/***********************************************************************/ /***********************************************************************/
bool TDBEXT::MakeCommand(PGLOBAL g) bool TDBEXT::MakeCommand(PGLOBAL g)
{ {
char *p, *stmt, name[132], *body = NULL, *schmp = NULL; PCSZ schmp = NULL;
char *p, *stmt, name[132], *body = NULL;
char *qrystr = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 1); char *qrystr = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 1);
bool qtd = Quoted > 0; bool qtd = Quoted > 0;
char q = qtd ? *Quote : ' '; char q = qtd ? *Quote : ' ';
@@ -562,7 +565,7 @@ int TDBEXT::GetProgMax(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* EXTCOL public constructor. */ /* EXTCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
EXTCOL::EXTCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) EXTCOL::EXTCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: COLBLK(cdp, tdbp, i) : COLBLK(cdp, tdbp, i)
{ {
if (cprec) { if (cprec) {

View File

@@ -28,14 +28,14 @@ class ALIAS : public BLOCK {
class CONDFIL : public BLOCK { class CONDFIL : public BLOCK {
public: public:
// Constructor // Constructor
CONDFIL(const Item *cond, uint idx, AMT type); CONDFIL(uint idx, AMT type);
// Functions // Functions
int Init(PGLOBAL g, PHC hc); int Init(PGLOBAL g, PHC hc);
const char *Chk(const char *cln, bool *h); const char *Chk(const char *cln, bool *h);
// Members // Members
const Item *Cond; //const Item *Cond;
AMT Type; AMT Type;
uint Idx; uint Idx;
OPVAL Op; OPVAL Op;
@@ -60,10 +60,10 @@ public:
// Implementation // Implementation
virtual const char *GetType(void) { return "EXT"; } virtual const char *GetType(void) { return "EXT"; }
inline PSZ GetTabname(void) { return Tabname; } inline PCSZ GetTabname(void) { return Tabname; }
inline PSZ GetTabschema(void) { return Tabschema; } inline PCSZ GetTabschema(void) { return Tabschema; }
inline PSZ GetUsername(void) { return Username; }; inline PCSZ GetUsername(void) { return Username; };
inline PSZ GetPassword(void) { return Password; }; inline PCSZ GetPassword(void) { return Password; };
inline PSZ GetTabcat(void) { return Tabcat; } inline PSZ GetTabcat(void) { return Tabcat; }
inline PSZ GetSrcdef(void) { return Srcdef; } inline PSZ GetSrcdef(void) { return Srcdef; }
inline char GetSep(void) { return (Sep) ? *Sep : 0; } inline char GetSep(void) { return (Sep) ? *Sep : 0; }
@@ -76,10 +76,10 @@ public:
protected: protected:
// Members // Members
PSZ Tabname; /* External table name */ PCSZ Tabname; /* External table name */
PSZ Tabschema; /* External table schema */ PCSZ Tabschema; /* External table schema */
PSZ Username; /* User connect name */ PCSZ Username; /* User connect name */
PSZ Password; /* Password connect info */ PCSZ Password; /* Password connect info */
PSZ Tabcat; /* External table catalog */ PSZ Tabcat; /* External table catalog */
PSZ Tabtyp; /* Catalog table type */ PSZ Tabtyp; /* Catalog table type */
PSZ Colpat; /* Catalog column pattern */ PSZ Colpat; /* Catalog column pattern */
@@ -115,7 +115,7 @@ public:
virtual bool IsRemote(void) { return true; } virtual bool IsRemote(void) { return true; }
// Methods // Methods
virtual PSZ GetServer(void) { return "Remote"; } virtual PCSZ GetServer(void) { return "Remote"; }
virtual int GetRecpos(void); virtual int GetRecpos(void);
// Database routines // Database routines
@@ -127,15 +127,15 @@ protected:
virtual bool MakeSQL(PGLOBAL g, bool cnt); virtual bool MakeSQL(PGLOBAL g, bool cnt);
//virtual bool MakeInsert(PGLOBAL g); //virtual bool MakeInsert(PGLOBAL g);
virtual bool MakeCommand(PGLOBAL g); virtual bool MakeCommand(PGLOBAL g);
int Decode(char *utf, char *buf, size_t n); int Decode(PCSZ utf, char *buf, size_t n);
// Members // Members
PQRYRES Qrp; // Points to storage result PQRYRES Qrp; // Points to storage result
PSTRG Query; // Constructed SQL query PSTRG Query; // Constructed SQL query
char *TableName; // Points to ODBC table name PCSZ TableName; // Points to ODBC table name
char *Schema; // Points to ODBC table Schema PCSZ Schema; // Points to ODBC table Schema
char *User; // User connect info PCSZ User; // User connect info
char *Pwd; // Password connect info PCSZ Pwd; // Password connect info
char *Catalog; // Points to ODBC table Catalog char *Catalog; // Points to ODBC table Catalog
char *Srcdef; // The source table SQL definition char *Srcdef; // The source table SQL definition
char *Count; // Points to count(*) SQL statement char *Count; // Points to count(*) SQL statement
@@ -170,7 +170,7 @@ class DllExport EXTCOL : public COLBLK {
friend class TDBEXT; friend class TDBEXT;
public: public:
// Constructor // Constructor
EXTCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am); EXTCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am);
EXTCOL(PEXTCOL colp, PTDB tdbp); // Constructor used in copy process EXTCOL(PEXTCOL colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation

View File

@@ -373,7 +373,7 @@ int TDBFIX::WriteDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* 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, PCSZ am)
: DOSCOL(g, cdp, tp, cp, i, am) : DOSCOL(g, cdp, tp, cp, i, am)
{ {
char c, *fmt = cdp->GetFmt(); char c, *fmt = cdp->GetFmt();
@@ -411,11 +411,7 @@ BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
case 'D': M = sizeof(double); break; case 'D': M = sizeof(double); break;
default: default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} // endswitch Fmt } // endswitch Fmt
} else if (IsTypeChar(Buf_Type)) } else if (IsTypeChar(Buf_Type))
@@ -490,11 +486,7 @@ void BINCOL::ReadColumn(PGLOBAL g)
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); sprintf(g->Message, MSG(INV_DEF_READ), rc);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} // endif } // endif
p = tdbp->To_Line + Deplac; p = tdbp->To_Line + Deplac;
@@ -553,11 +545,7 @@ void BINCOL::ReadColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} // endswitch Fmt } // endswitch Fmt
// Set null when applicable // Set null when applicable
@@ -607,11 +595,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
} else if (Value->GetBinValue(p, Long, Status)) { } else 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);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif p } // endif p
break; break;
@@ -620,11 +604,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
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);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Status) } else if (Status)
Value->GetValueNonAligned<short>(p, (short)n); Value->GetValueNonAligned<short>(p, (short)n);
@@ -634,11 +614,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
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);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Status) } else if (Status)
*p = (char)n; *p = (char)n;
@@ -648,11 +624,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
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);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Status) } else if (Status)
Value->GetValueNonAligned<int>(p, (int)n); Value->GetValueNonAligned<int>(p, (int)n);
@@ -676,11 +648,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
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, (int) n, Long); sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif n } // endif n
if (Status) { if (Status) {
@@ -692,11 +660,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
break; break;
default: default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name); sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endswitch Fmt } // endswitch Fmt
if (Eds && Status) { if (Eds && Status) {

View File

@@ -65,7 +65,7 @@ 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, PCSZ am = "BIN");
BINCOL(BINCOL *colp, PTDB tdbp); // Constructor used in copy process BINCOL(BINCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
@@ -108,7 +108,7 @@ class TDBDCL : public TDBCAT {
{return DBFColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, false);} {return DBFColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, false);}
// Members // Members
char *Fn; // The DBF file (path) name PCSZ Fn; // The DBF file (path) name
}; // end of class TDBOCL }; // end of class TDBOCL

View File

@@ -81,7 +81,7 @@ USETEMP UseTemp(void);
/* of types (TYPE_STRING < TYPE_DOUBLE < TYPE_INT) (1 < 2 < 7). */ /* of types (TYPE_STRING < TYPE_DOUBLE < TYPE_INT) (1 < 2 < 7). */
/* If these values are changed, this will have to be revisited. */ /* If these values are changed, this will have to be revisited. */
/***********************************************************************/ /***********************************************************************/
PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info) PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
{ {
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_INT, TYPE_SHORT}; TYPE_INT, TYPE_INT, TYPE_SHORT};
@@ -153,7 +153,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
tdp->Lrecl = 4096; tdp->Lrecl = 4096;
tdp->Multiple = GetIntegerTableOption(g, topt, "Multiple", 0); tdp->Multiple = GetIntegerTableOption(g, topt, "Multiple", 0);
p = GetStringTableOption(g, topt, "Separator", ","); p = (char*)GetStringTableOption(g, topt, "Separator", ",");
tdp->Sep = (strlen(p) == 2 && p[0] == '\\' && p[1] == 't') ? '\t' : *p; tdp->Sep = (strlen(p) == 2 && p[0] == '\\' && p[1] == 't') ? '\t' : *p;
#if defined(__WIN__) #if defined(__WIN__)
@@ -167,7 +167,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
sep = tdp->Sep; sep = tdp->Sep;
tdp->Quoted = GetIntegerTableOption(g, topt, "Quoted", -1); tdp->Quoted = GetIntegerTableOption(g, topt, "Quoted", -1);
p = GetStringTableOption(g, topt, "Qchar", ""); p = (char*)GetStringTableOption(g, topt, "Qchar", "");
tdp->Qot = *p; tdp->Qot = *p;
if (tdp->Qot && tdp->Quoted < 0) if (tdp->Qot && tdp->Quoted < 0)
@@ -1435,11 +1435,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); sprintf(g->Message, MSG(INV_DEF_READ), rc);
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} // endif } // endif
if (tdbp->Mode != MODE_UPDATE) { if (tdbp->Mode != MODE_UPDATE) {
@@ -1457,11 +1453,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
Long = colen; // Restore column length Long = colen; // Restore column length
sprintf(g->Message, MSG(FLD_TOO_LNG_FOR), sprintf(g->Message, MSG(FLD_TOO_LNG_FOR),
Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g)); Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g));
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} // endif Long } // endif Long
// Now do the reading // Now do the reading
@@ -1524,11 +1516,7 @@ void CSVCOL::WriteColumn(PGLOBAL g)
if ((signed)strlen(p) > flen) { if ((signed)strlen(p) > flen) {
sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, flen, sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, flen,
tdbp->RowNumber(g), tdbp->GetFile(g)); tdbp->RowNumber(g), tdbp->GetFile(g));
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} else if (Dsp) } else if (Dsp)
for (int i = 0; p[i]; i++) for (int i = 0; p[i]; i++)
if (p[i] == '.') if (p[i] == '.')
@@ -1544,11 +1532,7 @@ void CSVCOL::WriteColumn(PGLOBAL g)
if (Fldnum < 0) { if (Fldnum < 0) {
// This can happen for wrong offset value in XDB files // This can happen for wrong offset value in XDB files
sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name); sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name);
#if defined(USE_TRY)
throw 34; throw 34;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 34);
#endif // !USE_TRY
} else } else
strncpy(tdbp->Field[Fldnum], p, flen); strncpy(tdbp->Field[Fldnum], p, flen);

View File

@@ -13,7 +13,7 @@ typedef class TDBFMT *PTDBFMT;
/***********************************************************************/ /***********************************************************************/
/* Functions used externally. */ /* Functions used externally. */
/***********************************************************************/ /***********************************************************************/
PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info); PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info);
/***********************************************************************/ /***********************************************************************/
/* CSV table. */ /* CSV table. */
@@ -21,7 +21,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info);
class DllExport CSVDEF : public DOSDEF { /* Logical table description */ class DllExport CSVDEF : public DOSDEF { /* Logical table description */
friend class TDBCSV; friend class TDBCSV;
friend class TDBCCL; friend class TDBCCL;
friend PQRYRES CSVColumns(PGLOBAL, char *, PTOS, bool); friend PQRYRES CSVColumns(PGLOBAL, PCSZ, PTOS, bool);
public: public:
// Constructor // Constructor
CSVDEF(void); CSVDEF(void);
@@ -53,7 +53,7 @@ public:
class DllExport TDBCSV : public TDBDOS { class DllExport TDBCSV : public TDBDOS {
friend class CSVCOL; friend class CSVCOL;
friend class MAPFAM; friend class MAPFAM;
friend PQRYRES CSVColumns(PGLOBAL, char *, PTOS, bool); friend PQRYRES CSVColumns(PGLOBAL, PCSZ, PTOS, bool);
public: public:
// Constructor // Constructor
TDBCSV(PCSVDEF tdp, PTXF txfp); TDBCSV(PCSVDEF tdp, PTXF txfp);

View File

@@ -365,10 +365,11 @@ PCOL TDBJDBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/ /***********************************************************************/
bool TDBJDBC::MakeInsert(PGLOBAL g) bool TDBJDBC::MakeInsert(PGLOBAL g)
{ {
char *schmp = NULL, *catp = NULL, buf[NAM_LEN * 3]; PCSZ schmp = NULL;
char *catp = NULL, buf[NAM_LEN * 3];
int len = 0; int len = 0;
uint pos; uint pos;
bool b = false, oom = false; bool b = false;
PTABLE tablep = To_Table; PTABLE tablep = To_Table;
PCOL colp; PCOL colp;
@@ -405,32 +406,32 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
Query = new(g)STRING(g, len, "INSERT INTO "); Query = new(g)STRING(g, len, "INSERT INTO ");
if (catp) { if (catp) {
oom |= Query->Append(catp); Query->Append(catp);
if (schmp) { if (schmp) {
oom |= Query->Append('.'); Query->Append('.');
oom |= Query->Append(schmp); Query->Append(schmp);
} // endif schmp } // endif schmp
oom |= Query->Append('.'); Query->Append('.');
} else if (schmp) { } else if (schmp) {
oom |= Query->Append(schmp); Query->Append(schmp);
oom |= Query->Append('.'); Query->Append('.');
} // endif schmp } // endif schmp
if (Quote) { if (Quote) {
// Put table name between identifier quotes in case in contains blanks // Put table name between identifier quotes in case in contains blanks
oom |= Query->Append(Quote); Query->Append(Quote);
oom |= Query->Append(buf); Query->Append(buf);
oom |= Query->Append(Quote); Query->Append(Quote);
} else } else
oom |= Query->Append(buf); Query->Append(buf);
oom |= Query->Append('('); Query->Append('(');
for (colp = Columns; colp; colp = colp->GetNext()) { for (colp = Columns; colp; colp = colp->GetNext()) {
if (b) if (b)
oom |= Query->Append(", "); Query->Append(", ");
else else
b = true; b = true;
@@ -439,15 +440,15 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
if (Quote) { if (Quote) {
// Put column name between identifier quotes in case in contains blanks // Put column name between identifier quotes in case in contains blanks
oom |= Query->Append(Quote); Query->Append(Quote);
oom |= Query->Append(buf); Query->Append(buf);
oom |= Query->Append(Quote); Query->Append(Quote);
} else } else
oom |= Query->Append(buf); Query->Append(buf);
} // endfor colp } // endfor colp
if ((oom |= Query->Append(") VALUES ("))) { if ((Query->Append(") VALUES ("))) {
strcpy(g->Message, "MakeInsert: Out of memory"); strcpy(g->Message, "MakeInsert: Out of memory");
return true; return true;
} else // in case prepared statement fails } else // in case prepared statement fails
@@ -455,9 +456,9 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
// Make prepared statement // Make prepared statement
for (int i = 0; i < Nparm; i++) for (int i = 0; i < Nparm; i++)
oom |= Query->Append("?,"); Query->Append("?,");
if (oom) { if (Query->IsTruncated()) {
strcpy(g->Message, "MakeInsert: Out of memory"); strcpy(g->Message, "MakeInsert: Out of memory");
return true; return true;
} else } else
@@ -750,7 +751,7 @@ bool TDBJDBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
To_CondFil->Body= (char*)PlugSubAlloc(g, NULL, 0); To_CondFil->Body= (char*)PlugSubAlloc(g, NULL, 0);
*To_CondFil->Body= 0; *To_CondFil->Body= 0;
if ((To_CondFil = hc->CheckCond(g, To_CondFil, To_CondFil->Cond))) if ((To_CondFil = hc->CheckCond(g, To_CondFil, Cond)))
PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1); PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1);
} // endif active_index } // endif active_index
@@ -864,7 +865,6 @@ int TDBJDBC::WriteDB(PGLOBAL g)
// an insert query for each line to insert // an insert query for each line to insert
uint len = Query->GetLength(); uint len = Query->GetLength();
char buf[64]; char buf[64];
bool oom = false;
// Make the Insert command value list // Make the Insert command value list
for (PCOL colp = Columns; colp; colp = colp->GetNext()) { for (PCOL colp = Columns; colp; colp = colp->GetNext()) {
@@ -872,28 +872,28 @@ int TDBJDBC::WriteDB(PGLOBAL g)
char *s = colp->GetValue()->GetCharString(buf); char *s = colp->GetValue()->GetCharString(buf);
if (colp->GetResultType() == TYPE_STRING) if (colp->GetResultType() == TYPE_STRING)
oom |= Query->Append_quoted(s); Query->Append_quoted(s);
else if (colp->GetResultType() == TYPE_DATE) { else if (colp->GetResultType() == TYPE_DATE) {
DTVAL *dtv = (DTVAL*)colp->GetValue(); DTVAL *dtv = (DTVAL*)colp->GetValue();
if (dtv->IsFormatted()) if (dtv->IsFormatted())
oom |= Query->Append_quoted(s); Query->Append_quoted(s);
else else
oom |= Query->Append(s); Query->Append(s);
} else } else
oom |= Query->Append(s); Query->Append(s);
} else } else
oom |= Query->Append("NULL"); Query->Append("NULL");
oom |= Query->Append(','); Query->Append(',');
} // endfor colp } // endfor colp
if (unlikely(oom)) { if (unlikely(Query->IsTruncated())) {
strcpy(g->Message, "WriteDB: Out of memory"); strcpy(g->Message, "WriteDB: Out of memory");
return RC_FX; return RC_FX;
} // endif oom } // endif Query
Query->RepLast(')'); Query->RepLast(')');
@@ -967,7 +967,7 @@ void TDBJDBC::CloseDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* JDBCCOL public constructor. */ /* JDBCCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
JDBCCOL::JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) JDBCCOL::JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: EXTCOL(cdp, tdbp, cprec, i, am) : EXTCOL(cdp, tdbp, cprec, i, am)
{ {
} // end of JDBCCOL constructor } // end of JDBCCOL constructor
@@ -1212,7 +1212,7 @@ int TDBXJDC::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/ /***********************************************************************/
/* JSRCCOL public constructor. */ /* JSRCCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
JSRCCOL::JSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) JSRCCOL::JSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: JDBCCOL(cdp, tdbp, cprec, i, am) : JDBCCOL(cdp, tdbp, cprec, i, am)
{ {
// Set additional JDBC access method information for column. // Set additional JDBC access method information for column.

View File

@@ -67,7 +67,7 @@ public:
virtual PTDB Clone(PTABS t); virtual PTDB Clone(PTABS t);
virtual bool SetRecpos(PGLOBAL g, int recpos); virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual void ResetSize(void); virtual void ResetSize(void);
virtual PSZ GetServer(void) { return "JDBC"; } virtual PCSZ GetServer(void) { return "JDBC"; }
virtual int Indexable(void) { return 2; } virtual int Indexable(void) { return 2; }
// Database routines // Database routines
@@ -103,7 +103,7 @@ class JDBCCOL : public EXTCOL {
friend class TDBJDBC; friend class TDBJDBC;
public: public:
// Constructors // Constructors
JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "JDBC"); JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "JDBC");
JDBCCOL(JDBCCOL *colp, PTDB tdbp); // Constructor used in copy process JDBCCOL(JDBCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
@@ -165,7 +165,7 @@ class JSRCCOL : public JDBCCOL {
friend class TDBXJDC; friend class TDBXJDC;
public: public:
// Constructors // Constructors
JSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "JDBC"); JSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "JDBC");
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_JDBC;} virtual int GetAmType(void) {return TYPE_AM_JDBC;}
@@ -210,9 +210,9 @@ protected:
virtual PQRYRES GetResult(PGLOBAL g); virtual PQRYRES GetResult(PGLOBAL g);
// Members // Members
char *Schema; // Points to schema name or NULL PCSZ Schema; // Points to schema name or NULL
char *Tab; // Points to JDBC table name or pattern PCSZ Tab; // Points to JDBC table name or pattern
char *Tabtype; // Points to JDBC table type PCSZ Tabtype; // Points to JDBC table type
JDBCPARM Ops; // Additional parameters JDBCPARM Ops; // Additional parameters
}; // end of class TDBJTB }; // end of class TDBJTB
@@ -229,7 +229,7 @@ protected:
virtual PQRYRES GetResult(PGLOBAL g); virtual PQRYRES GetResult(PGLOBAL g);
// Members // Members
char *Colpat; // Points to catalog column pattern PCSZ Colpat; // Points to catalog column pattern
}; // end of class TDBJDBCL }; // end of class TDBJDBCL
#endif // !NJDBC #endif // !NJDBC

View File

@@ -63,7 +63,7 @@ typedef struct _jncol {
/* JSONColumns: construct the result blocks containing the description */ /* JSONColumns: construct the result blocks containing the description */
/* of all the columns of a table contained inside a JSON file. */ /* of all the columns of a table contained inside a JSON file. */
/***********************************************************************/ /***********************************************************************/
PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
{ {
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING};
@@ -112,7 +112,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
#endif // ZIP_SUPPORT #endif // ZIP_SUPPORT
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL); tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
if (!tdp->Fn) { if (!tdp->Fn && !dsn) {
strcpy(g->Message, MSG(MISSING_FNAME)); strcpy(g->Message, MSG(MISSING_FNAME));
return NULL; return NULL;
} // endif Fn } // endif Fn
@@ -264,9 +264,14 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
break; break;
if (jcp) { if (jcp) {
if (jcp->Type != jcol.Type) if (jcp->Type != jcol.Type) {
if (jcp->Type == TYPE_UNKNOWN)
jcp->Type = jcol.Type;
else if (jcol.Type != TYPE_UNKNOWN)
jcp->Type = TYPE_STRING; jcp->Type = TYPE_STRING;
} // endif Type
if (*fmt && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) { if (*fmt && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) {
jcp->Fmt = PlugDup(g, fmt); jcp->Fmt = PlugDup(g, fmt);
length[7] = MY_MAX(length[7], strlen(fmt)); length[7] = MY_MAX(length[7], strlen(fmt));
@@ -338,7 +343,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
skipit: skipit:
if (trace) if (trace)
htrc("CSVColumns: n=%d len=%d\n", n, length[0]); htrc("JSONColumns: n=%d len=%d\n", n, length[0]);
/*********************************************************************/ /*********************************************************************/
/* Allocate the structures used to refer to the result set. */ /* Allocate the structures used to refer to the result set. */
@@ -419,7 +424,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
Pretty = GetIntCatInfo("Pretty", 2); Pretty = GetIntCatInfo("Pretty", 2);
Limit = GetIntCatInfo("Limit", 10); Limit = GetIntCatInfo("Limit", 10);
Base = GetIntCatInfo("Base", 0) ? 1 : 0; Base = GetIntCatInfo("Base", 0) ? 1 : 0;
return DOSDEF::DefineAM(g, "DOS", poff); return DOSDEF::DefineAM(g, (Uri ? "XMGO" : "DOS"), poff);
} // end of DefineAM } // end of DefineAM
/***********************************************************************/ /***********************************************************************/
@@ -488,7 +493,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
} else { } else {
if (Zipped) { if (Zipped) {
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
if (m == MODE_READ || m == MODE_UPDATE) { if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
txfp = new(g) UNZFAM(this); txfp = new(g) UNZFAM(this);
} else if (m == MODE_INSERT) { } else if (m == MODE_INSERT) {
strcpy(g->Message, "INSERT supported only for zipped JSON when pretty=0"); strcpy(g->Message, "INSERT supported only for zipped JSON when pretty=0");
@@ -697,6 +702,9 @@ bool TDBJSN::OpenDB(PGLOBAL g)
return true; return true;
} // endswitch Jmode } // endswitch Jmode
if (Xcol && Txfp->GetAmType() != TYPE_AM_MGO)
To_Filter = NULL; // Imcompatible
} // endif Use } // endif Use
return TDBDOS::OpenDB(g); return TDBDOS::OpenDB(g);
@@ -875,9 +883,6 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
int rc = TDBDOS::WriteDB(g); int rc = TDBDOS::WriteDB(g);
#if USE_G #if USE_G
if (rc == RC_FX)
strcpy(g->Message, G->Message);
PlugSubSet(G, G->Sarea, G->Sarea_Size); PlugSubSet(G, G->Sarea, G->Sarea_Size);
#endif #endif
Row->Clear(); Row->Clear();
@@ -1148,6 +1153,56 @@ bool JSONCOL::ParseJpath(PGLOBAL g)
return false; return false;
} // end of ParseJpath } // end of ParseJpath
/***********************************************************************/
/* Get Jpath converted to Mongo path. */
/***********************************************************************/
char *JSONCOL::GetJpath(PGLOBAL g, bool proj)
{
if (Jpath) {
char *p1, *p2, *mgopath;
int i = 0;
if (strcmp(Jpath, "*"))
mgopath = PlugDup(g, Jpath);
else
return NULL;
for (p1 = p2 = mgopath; *p1; p1++)
if (i) { // Inside []
if (isdigit(*p1)) {
if (!proj)
*p2++ = *p1;
i = 2;
} else if (*p1 == ']' && i == 2) {
if (proj && *(p1 + 1) == ':')
p1++;
i = 0;
} else if (proj)
i = 2;
else
return NULL;
} else switch (*p1) {
case ':': *p2++ = '.'; break;
case '[': i = 1; break;
case '*':
if (*(p2 - 1) == '.' && !*(p1 + 1)) {
p2--; // Suppress last :*
break;
} // endif p2
default: *p2++ = *p1; break;
} // endswitch p1;
*p2 = 0;
return mgopath;
} else
return NULL;
} // end of GetJpath
/***********************************************************************/ /***********************************************************************/
/* MakeJson: Serialize the json item and set value to it. */ /* MakeJson: Serialize the json item and set value to it. */
/***********************************************************************/ /***********************************************************************/
@@ -1193,11 +1248,14 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n)
// } // endif Type // } // endif Type
default: default:
vp->Reset();
vp->SetNull(true); vp->SetNull(true);
} // endswitch Type } // endswitch Type
} else } else {
vp->Reset();
vp->SetNull(true); vp->SetNull(true);
} // endif val
} // end of SetJsonValue } // end of SetJsonValue
@@ -1210,8 +1268,8 @@ void JSONCOL::ReadColumn(PGLOBAL g)
Value->SetValue_pval(GetColumnValue(g, Tjp->Row, 0)); Value->SetValue_pval(GetColumnValue(g, Tjp->Row, 0));
// Set null when applicable // Set null when applicable
if (Nullable) if (!Nullable)
Value->SetNull(Value->IsNull()); Value->SetNull(false);
} // end of ReadColumn } // end of ReadColumn
@@ -1292,11 +1350,7 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n)
if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) { if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) {
strcpy(g->Message, "Logical error expanding array"); strcpy(g->Message, "Logical error expanding array");
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
} // endif jvp } // endif jvp
if (n < Nod - 1 && jvp->GetJson()) { if (n < Nod - 1 && jvp->GetJson()) {
@@ -1482,11 +1536,7 @@ void JSONCOL::WriteColumn(PGLOBAL g)
{ {
if (Xpd && Tjp->Pretty < 2) { if (Xpd && Tjp->Pretty < 2) {
strcpy(g->Message, "Cannot write expanded column when Pretty is not 2"); strcpy(g->Message, "Cannot write expanded column when Pretty is not 2");
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
} // endif Xpd } // endif Xpd
/*********************************************************************/ /*********************************************************************/
@@ -1521,11 +1571,7 @@ void JSONCOL::WriteColumn(PGLOBAL g)
if (!(jsp = ParseJson(G, s, (int)strlen(s)))) { if (!(jsp = ParseJson(G, s, (int)strlen(s)))) {
strcpy(g->Message, s); strcpy(g->Message, s);
#if defined(USE_TRY)
throw 666; throw 666;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 666);
#endif // !USE_TRY
} // endif jsp } // endif jsp
if (arp) { if (arp) {
@@ -1876,6 +1922,9 @@ bool TDBJSON::OpenDB(PGLOBAL g)
return true; return true;
} // endswitch Jmode } // endswitch Jmode
if (Xcol)
To_Filter = NULL; // Imcompatible
Use = USE_OPEN; Use = USE_OPEN;
return false; return false;
} // end of OpenDB } // end of OpenDB
@@ -1999,6 +2048,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
{ {
Topt = tdp->GetTopt(); Topt = tdp->GetTopt();
Db = (char*)tdp->GetDB(); Db = (char*)tdp->GetDB();
Dsn = (char*)tdp->Uri;
} // end of TDBJCL constructor } // end of TDBJCL constructor
/***********************************************************************/ /***********************************************************************/
@@ -2006,7 +2056,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBJCL::GetResult(PGLOBAL g) PQRYRES TDBJCL::GetResult(PGLOBAL g)
{ {
return JSONColumns(g, Db, Topt, false); return JSONColumns(g, Db, Dsn, Topt, false);
} // end of GetResult } // end of GetResult
/* --------------------------- End of json --------------------------- */ /* --------------------------- End of json --------------------------- */

View File

@@ -1,7 +1,7 @@
/*************** tabjson H Declares Source Code File (.H) **************/ /*************** tabjson H Declares Source Code File (.H) **************/
/* Name: tabjson.h Version 1.1 */ /* Name: tabjson.h Version 1.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
/* */ /* */
/* This file contains the JSON classes declares. */ /* This file contains the JSON classes declares. */
/***********************************************************************/ /***********************************************************************/
@@ -32,11 +32,11 @@ typedef struct _jnode {
/***********************************************************************/ /***********************************************************************/
/* JSON table. */ /* JSON table. */
/***********************************************************************/ /***********************************************************************/
class JSONDEF : public DOSDEF { /* Table description */ class DllExport JSONDEF : public DOSDEF { /* Table description */
friend class TDBJSON; friend class TDBJSON;
friend class TDBJSN; friend class TDBJSN;
friend class TDBJCL; friend class TDBJCL;
friend PQRYRES JSONColumns(PGLOBAL, char*, PTOS, bool); friend PQRYRES JSONColumns(PGLOBAL, char*, char*, PTOS, bool);
public: public:
// Constructor // Constructor
JSONDEF(void); JSONDEF(void);
@@ -51,13 +51,14 @@ class JSONDEF : public DOSDEF { /* Table description */
protected: protected:
// Members // Members
JMODE Jmode; /* MODE_OBJECT by default */ JMODE Jmode; /* MODE_OBJECT by default */
char *Objname; /* Name of first level object */ PCSZ Objname; /* Name of first level object */
char *Xcol; /* Name of expandable column */ PCSZ Xcol; /* Name of expandable column */
int Limit; /* Limit of multiple values */ int Limit; /* Limit of multiple values */
int Pretty; /* Depends on file structure */ int Pretty; /* Depends on file structure */
int Level; /* Used for catalog table */ int Level; /* Used for catalog table */
int Base; /* Tne array index base */ int Base; /* The array index base */
bool Strict; /* Strict syntax checking */ bool Strict; /* Strict syntax checking */
const char *Uri; /* MongoDB connection URI */
}; // end of JSONDEF }; // end of JSONDEF
/* -------------------------- TDBJSN class --------------------------- */ /* -------------------------- TDBJSN class --------------------------- */
@@ -66,7 +67,7 @@ class JSONDEF : public DOSDEF { /* Table description */
/* This is the JSN Access Method class declaration. */ /* This is the JSN Access Method class declaration. */
/* The table is a DOS file, each record being a JSON object. */ /* The table is a DOS file, each record being a JSON object. */
/***********************************************************************/ /***********************************************************************/
class TDBJSN : public TDBDOS { class DllExport TDBJSN : public TDBDOS {
friend class JSONCOL; friend class JSONCOL;
friend class JSONDEF; friend class JSONDEF;
public: public:
@@ -87,6 +88,8 @@ public:
virtual PCOL InsertSpecialColumn(PCOL colp); virtual PCOL InsertSpecialColumn(PCOL colp);
virtual int RowNumber(PGLOBAL g, bool b = FALSE) virtual int RowNumber(PGLOBAL g, bool b = FALSE)
{return (b) ? M : N;} {return (b) ? M : N;}
virtual bool CanBeFiltered(void)
{return Txfp->GetAmType() == TYPE_AM_MGO || !Xcol;}
// Database routines // Database routines
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
@@ -107,8 +110,8 @@ public:
PJSON Val; // The value of the current row PJSON Val; // The value of the current row
PJCOL Colp; // The multiple column PJCOL Colp; // The multiple column
JMODE Jmode; // MODE_OBJECT by default JMODE Jmode; // MODE_OBJECT by default
char *Objname; // The table object name PCSZ Objname; // The table object name
char *Xcol; // Name of expandable column PCSZ Xcol; // Name of expandable column
int Fpos; // The current row index int Fpos; // The current row index
int N; // The current Rownum int N; // The current Rownum
int M; // Index of multiple value int M; // Index of multiple value
@@ -127,9 +130,10 @@ public:
/***********************************************************************/ /***********************************************************************/
/* Class JSONCOL: JSON access method column descriptor. */ /* Class JSONCOL: JSON access method column descriptor. */
/***********************************************************************/ /***********************************************************************/
class JSONCOL : public DOSCOL { class DllExport JSONCOL : public DOSCOL {
friend class TDBJSN; friend class TDBJSN;
friend class TDBJSON; friend class TDBJSON;
friend class MGOFAM;
public: public:
// Constructors // Constructors
JSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); JSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
@@ -141,6 +145,7 @@ class JSONCOL : public DOSCOL {
// Methods // Methods
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
bool ParseJpath(PGLOBAL g); bool ParseJpath(PGLOBAL g);
char *GetJpath(PGLOBAL g, bool proj);
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
@@ -174,7 +179,7 @@ class JSONCOL : public DOSCOL {
/***********************************************************************/ /***********************************************************************/
/* This is the JSON Access Method class declaration. */ /* This is the JSON Access Method class declaration. */
/***********************************************************************/ /***********************************************************************/
class TDBJSON : public TDBJSN { class DllExport TDBJSON : public TDBJSN {
friend class JSONDEF; friend class JSONDEF;
friend class JSONCOL; friend class JSONCOL;
public: public:
@@ -221,7 +226,7 @@ class TDBJSON : public TDBJSN {
/***********************************************************************/ /***********************************************************************/
/* This is the class declaration for the JSON catalog table. */ /* This is the class declaration for the JSON catalog table. */
/***********************************************************************/ /***********************************************************************/
class TDBJCL : public TDBCAT { class DllExport TDBJCL : public TDBCAT {
public: public:
// Constructor // Constructor
TDBJCL(PJDEF tdp); TDBJCL(PJDEF tdp);
@@ -233,4 +238,5 @@ class TDBJCL : public TDBCAT {
// Members // Members
PTOS Topt; PTOS Topt;
char *Db; char *Db;
char *Dsn;
}; // end of class TDBJCL }; // end of class TDBJCL

View File

@@ -47,6 +47,7 @@ TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
To_Orig = NULL; To_Orig = NULL;
To_Filter = NULL; To_Filter = NULL;
To_CondFil = NULL; To_CondFil = NULL;
Cond = NULL;
Next = NULL; Next = NULL;
Name = (tdp) ? tdp->GetName() : NULL; Name = (tdp) ? tdp->GetName() : NULL;
To_Table = NULL; To_Table = NULL;
@@ -68,6 +69,7 @@ TDB::TDB(PTDB tdbp) : Tdb_No(++Tnum)
To_Orig = tdbp; To_Orig = tdbp;
To_Filter = NULL; To_Filter = NULL;
To_CondFil = NULL; To_CondFil = NULL;
Cond = NULL;
Next = NULL; Next = NULL;
Name = tdbp->Name; Name = tdbp->Name;
To_Table = tdbp->To_Table; To_Table = tdbp->To_Table;
@@ -97,7 +99,7 @@ CHARSET_INFO *TDB::data_charset(void)
/***********************************************************************/ /***********************************************************************/
/* Return the datapath of the DB this table belongs to. */ /* Return the datapath of the DB this table belongs to. */
/***********************************************************************/ /***********************************************************************/
PSZ TDB::GetPath(void) PCSZ TDB::GetPath(void)
{ {
return To_Def->GetPath(); return To_Def->GetPath();
} // end of GetPath } // end of GetPath

View File

@@ -329,7 +329,7 @@ void MACCOL::ReadColumn(PGLOBAL g)
n = 0; n = 0;
break; break;
default: default:
p = ""; p = PlugDup(g, "");
} // endswitch Flag } // endswitch Flag
} else switch (Flag) { } else switch (Flag) {

View File

@@ -924,7 +924,7 @@ void TDBDIR::CloseDB(PGLOBAL)
/***********************************************************************/ /***********************************************************************/
/* DIRCOL public constructor. */ /* DIRCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
DIRCOL::DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ) DIRCOL::DIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ)
: COLBLK(cdp, tdbp, i) : COLBLK(cdp, tdbp, i)
{ {
if (cprec) { if (cprec) {
@@ -1016,11 +1016,7 @@ void DIRCOL::ReadColumn(PGLOBAL g)
#endif // !__WIN__ #endif // !__WIN__
default: default:
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N); sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
#if defined(USE_TRY)
throw GetAmType(); throw GetAmType();
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], GetAmType());
#endif // !USE_TRY
} // endswitch N } // endswitch N
} // end of ReadColumn } // end of ReadColumn
@@ -1548,11 +1544,7 @@ void TDBDHR::CloseDB(PGLOBAL g)
// Close the search handle. // Close the search handle.
if (!FindClose(Hsearch)) { if (!FindClose(Hsearch)) {
strcpy(g->Message, MSG(SRCH_CLOSE_ERR)); strcpy(g->Message, MSG(SRCH_CLOSE_ERR));
#if defined(USE_TRY)
throw GetAmType(); throw GetAmType();
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], GetAmType());
#endif // !USE_TRY
} // endif FindClose } // endif FindClose
iFile = 0; iFile = 0;
@@ -1564,7 +1556,7 @@ void TDBDHR::CloseDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* DHRCOL public constructor. */ /* DHRCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
DHRCOL::DHRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) DHRCOL::DHRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: COLBLK(cdp, tdbp, i) : COLBLK(cdp, tdbp, i)
{ {
if (cprec) { if (cprec) {

View File

@@ -39,7 +39,7 @@ class DllExport TDBMUL : public TDBASE {
virtual void ResetDB(void); virtual void ResetDB(void);
virtual PTDB Clone(PTABS t); virtual PTDB Clone(PTABS t);
virtual bool IsSame(PTDB tp) {return tp == (PTDB)Tdbp;} virtual bool IsSame(PTDB tp) {return tp == (PTDB)Tdbp;}
virtual PSZ GetFile(PGLOBAL g) {return Tdbp->GetFile(g);} virtual PCSZ 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);
@@ -226,7 +226,7 @@ class TDBSDR : public TDBDIR {
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, PCSZ am = "DIR");
DIRCOL(DIRCOL *colp, PTDB tdbp); // Constructor used in copy process DIRCOL(DIRCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation

View File

@@ -68,8 +68,8 @@ void PrintResult(PGLOBAL, PSEM, PQRYRES);
#endif // _CONSOLE #endif // _CONSOLE
// Used to check whether a MYSQL table is created on itself // Used to check whether a MYSQL table is created on itself
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host, bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, PCSZ host, PCSZ db,
const char *db, char *tab, const char *src, int port); PCSZ tab, PCSZ src, int port);
/***********************************************************************/ /***********************************************************************/
/* External function. */ /* External function. */
@@ -125,7 +125,7 @@ bool MYSQLDEF::GetServerInfo(PGLOBAL g, const char *server_name)
} // endif server } // endif server
DBUG_PRINT("info", ("get_server_by_name returned server at %lx", DBUG_PRINT("info", ("get_server_by_name returned server at %lx",
(long unsigned int) server)); (size_t) server));
// TODO: We need to examine which of these can really be NULL // TODO: We need to examine which of these can really be NULL
Hostname = PlugDup(g, server->host); Hostname = PlugDup(g, server->host);
@@ -183,19 +183,22 @@ bool MYSQLDEF::GetServerInfo(PGLOBAL g, const char *server_name)
/***********************************************************************/ /***********************************************************************/
bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b) bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b)
{ {
char *tabn, *pwd, *schema;
if ((!strstr(url, "://") && (!strchr(url, '@')))) { if ((!strstr(url, "://") && (!strchr(url, '@')))) {
// No :// or @ in connection string. Must be a straight // No :// or @ in connection string. Must be a straight
// connection name of either "server" or "server/table" // connection name of either "server" or "server/table"
// ok, so we do a little parsing, but not completely! // ok, so we do a little parsing, but not completely!
if ((Tabname= strchr(url, '/'))) { if ((tabn= strchr(url, '/'))) {
// If there is a single '/' in the connection string, // If there is a single '/' in the connection string,
// this means the user is specifying a table name // this means the user is specifying a table name
*Tabname++= '\0'; *tabn++= '\0';
// there better not be any more '/'s ! // there better not be any more '/'s !
if (strchr(Tabname, '/')) if (strchr(tabn, '/'))
return true; return true;
Tabname = tabn;
} else } else
// Otherwise, straight server name, // Otherwise, straight server name,
Tabname = (b) ? GetStringCatInfo(g, "Tabname", Name) : NULL; Tabname = (b) ? GetStringCatInfo(g, "Tabname", Name) : NULL;
@@ -223,7 +226,7 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b)
Username += 3; Username += 3;
if (!(Hostname = strchr(Username, '@'))) { if (!(Hostname = (char*)strchr(Username, '@'))) {
strcpy(g->Message, "No host specified in URL"); strcpy(g->Message, "No host specified in URL");
return true; return true;
} else { } else {
@@ -231,11 +234,11 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b)
Server = Hostname; Server = Hostname;
} // endif Hostname } // endif Hostname
if ((Password = strchr(Username, ':'))) { if ((pwd = (char*)strchr(Username, ':'))) {
*Password++ = 0; // End username *pwd++ = 0; // End username
// Make sure there isn't an extra / or @ // Make sure there isn't an extra /
if ((strchr(Password, '/') || strchr(Hostname, '@'))) { if (strchr(pwd, '/')) {
strcpy(g->Message, "Syntax error in URL"); strcpy(g->Message, "Syntax error in URL");
return true; return true;
} // endif } // endif
@@ -243,8 +246,10 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b)
// Found that if the string is: // Found that if the string is:
// user:@hostname:port/db/table // user:@hostname:port/db/table
// Then password is a null string, so set to NULL // Then password is a null string, so set to NULL
if ((Password[0] == 0)) if ((pwd[0] == 0))
Password = NULL; Password = NULL;
else
Password = pwd;
} // endif password } // endif password
@@ -254,20 +259,22 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b)
return true; return true;
} // endif } // endif
if ((Tabschema = strchr(Hostname, '/'))) { if ((schema = strchr(Hostname, '/'))) {
*Tabschema++ = 0; *schema++ = 0;
if ((Tabname = strchr(Tabschema, '/'))) { if ((tabn = strchr(schema, '/'))) {
*Tabname++ = 0; *tabn++ = 0;
// Make sure there's not an extra / // Make sure there's not an extra /
if ((strchr(Tabname, '/'))) { if ((strchr(tabn, '/'))) {
strcpy(g->Message, "Syntax error in URL"); strcpy(g->Message, "Syntax error in URL");
return true; return true;
} // endif / } // endif /
Tabname = tabn;
} // endif TableName } // endif TableName
Tabschema = schema;
} // endif database } // endif database
if ((sport = strchr(Hostname, ':'))) if ((sport = strchr(Hostname, ':')))
@@ -349,7 +356,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
Portnumber = GetIntCatInfo("Port", GetDefaultPort()); Portnumber = GetIntCatInfo("Port", GetDefaultPort());
Server = Hostname; Server = Hostname;
} else { } else {
char *locdb = Tabschema; PCSZ locdb = Tabschema;
if (ParseURL(g, url)) if (ParseURL(g, url))
return true; return true;
@@ -499,7 +506,7 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g, bool mx)
//char *tk = "`"; //char *tk = "`";
char tk = '`'; char tk = '`';
int len = 0, rank = 0; int len = 0, rank = 0;
bool b = false, oom = false; bool b = false;
PCOL colp; PCOL colp;
//PDBUSER dup = PlgGetUser(g); //PDBUSER dup = PlgGetUser(g);
@@ -526,13 +533,13 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g, bool mx)
for (colp = Columns; colp; colp = colp->GetNext()) for (colp = Columns; colp; colp = colp->GetNext())
if (!colp->IsSpecial()) { if (!colp->IsSpecial()) {
if (b) if (b)
oom |= Query->Append(", "); Query->Append(", ");
else else
b = true; b = true;
oom |= Query->Append(tk); Query->Append(tk);
oom |= Query->Append(colp->GetName()); Query->Append(colp->GetName());
oom |= Query->Append(tk); Query->Append(tk);
((PMYCOL)colp)->Rank = rank++; ((PMYCOL)colp)->Rank = rank++;
} // endif colp } // endif colp
@@ -542,22 +549,22 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g, bool mx)
// Query '*' from... // Query '*' from...
// (the use of a char constant minimize the result storage) // (the use of a char constant minimize the result storage)
if (Isview) if (Isview)
oom |= Query->Append('*'); Query->Append('*');
else else
oom |= Query->Append("'*'"); Query->Append("'*'");
} // endif ncol } // endif ncol
oom |= Query->Append(" FROM "); Query->Append(" FROM ");
oom |= Query->Append(tk); Query->Append(tk);
oom |= Query->Append(TableName); Query->Append(TableName);
oom |= Query->Append(tk); Query->Append(tk);
len = Query->GetLength(); len = Query->GetLength();
if (To_CondFil) { if (To_CondFil) {
if (!mx) { if (!mx) {
oom |= Query->Append(" WHERE "); Query->Append(" WHERE ");
oom |= Query->Append(To_CondFil->Body); Query->Append(To_CondFil->Body);
len = Query->GetLength() + 1; len = Query->GetLength() + 1;
} else } else
len += (strlen(To_CondFil->Body) + 256); len += (strlen(To_CondFil->Body) + 256);
@@ -565,10 +572,10 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g, bool mx)
} else } else
len += (mx ? 256 : 1); len += (mx ? 256 : 1);
if (oom || Query->Resize(len)) { if (Query->IsTruncated() || Query->Resize(len)) {
strcpy(g->Message, "MakeSelect: Out of memory"); strcpy(g->Message, "MakeSelect: Out of memory");
return true; return true;
} // endif oom } // endif Query
if (trace) if (trace)
htrc("Query=%s\n", Query->GetStr()); htrc("Query=%s\n", Query->GetStr());
@@ -581,9 +588,9 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g, bool mx)
/***********************************************************************/ /***********************************************************************/
bool TDBMYSQL::MakeInsert(PGLOBAL g) bool TDBMYSQL::MakeInsert(PGLOBAL g)
{ {
char *tk = "`"; const char *tk = "`";
uint len = 0; uint len = 0;
bool b = false, oom; bool oom, b = false;
PCOL colp; PCOL colp;
if (Query) if (Query)
@@ -622,38 +629,38 @@ bool TDBMYSQL::MakeInsert(PGLOBAL g)
Query = new(g) STRING(g, len); Query = new(g) STRING(g, len);
if (Delayed) if (Delayed)
oom = Query->Set("INSERT DELAYED INTO "); Query->Set("INSERT DELAYED INTO ");
else else
oom = Query->Set("INSERT INTO "); Query->Set("INSERT INTO ");
oom |= Query->Append(tk); Query->Append(tk);
oom |= Query->Append(TableName); Query->Append(TableName);
oom |= Query->Append("` ("); Query->Append("` (");
for (colp = Columns; colp; colp = colp->GetNext()) { for (colp = Columns; colp; colp = colp->GetNext()) {
if (b) if (b)
oom |= Query->Append(", "); Query->Append(", ");
else else
b = true; b = true;
oom |= Query->Append(tk); Query->Append(tk);
oom |= Query->Append(colp->GetName()); Query->Append(colp->GetName());
oom |= Query->Append(tk); Query->Append(tk);
} // endfor colp } // endfor colp
oom |= Query->Append(") VALUES ("); Query->Append(") VALUES (");
#if defined(MYSQL_PREPARED_STATEMENTS) #if defined(MYSQL_PREPARED_STATEMENTS)
if (Prep) { if (Prep) {
for (int i = 0; i < Nparm; i++) for (int i = 0; i < Nparm; i++)
oom |= Query->Append("?,"); Query->Append("?,");
Query->RepLast(')'); Query->RepLast(')');
Query->Trim(); Query->Trim();
} // endif Prep } // endif Prep
#endif // MYSQL_PREPARED_STATEMENTS #endif // MYSQL_PREPARED_STATEMENTS
if (oom) if ((oom = Query->IsTruncated()))
strcpy(g->Message, "MakeInsert: Out of memory"); strcpy(g->Message, "MakeInsert: Out of memory");
return oom; return oom;
@@ -684,18 +691,18 @@ bool TDBMYSQL::MakeCommand(PGLOBAL g)
strlwr(strcpy(name, Name)); // Not a keyword strlwr(strcpy(name, Name)); // Not a keyword
if ((p = strstr(qrystr, name))) { if ((p = strstr(qrystr, name))) {
bool oom = Query->Set(Qrystr, p - qrystr); Query->Set(Qrystr, p - qrystr);
if (qtd && *(p-1) == ' ') { if (qtd && *(p-1) == ' ') {
oom |= Query->Append('`'); Query->Append('`');
oom |= Query->Append(TableName); Query->Append(TableName);
oom |= Query->Append('`'); Query->Append('`');
} else } else
oom |= Query->Append(TableName); Query->Append(TableName);
oom |= Query->Append(Qrystr + (p - qrystr) + strlen(name)); Query->Append(Qrystr + (p - qrystr) + strlen(name));
if (oom) { if (Query->IsTruncated()) {
strcpy(g->Message, "MakeCommand: Out of memory"); strcpy(g->Message, "MakeCommand: Out of memory");
return true; return true;
} else } else
@@ -1096,7 +1103,7 @@ bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
To_CondFil->Body= (char*)PlugSubAlloc(g, NULL, 0); To_CondFil->Body= (char*)PlugSubAlloc(g, NULL, 0);
*To_CondFil->Body= 0; *To_CondFil->Body= 0;
if ((To_CondFil = hc->CheckCond(g, To_CondFil, To_CondFil->Cond))) if ((To_CondFil = hc->CheckCond(g, To_CondFil, Cond)))
PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1); PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1);
} // endif active_index } // endif active_index
@@ -1161,24 +1168,23 @@ int TDBMYSQL::WriteDB(PGLOBAL g)
int rc; int rc;
uint len = Query->GetLength(); uint len = Query->GetLength();
char buf[64]; char buf[64];
bool oom = false;
// Make the Insert command value list // Make the Insert command value list
for (PCOL colp = Columns; colp; colp = colp->GetNext()) { for (PCOL colp = Columns; colp; colp = colp->GetNext()) {
if (!colp->GetValue()->IsNull()) { if (!colp->GetValue()->IsNull()) {
if (colp->GetResultType() == TYPE_STRING || if (colp->GetResultType() == TYPE_STRING ||
colp->GetResultType() == TYPE_DATE) colp->GetResultType() == TYPE_DATE)
oom |= Query->Append_quoted(colp->GetValue()->GetCharString(buf)); Query->Append_quoted(colp->GetValue()->GetCharString(buf));
else else
oom |= Query->Append(colp->GetValue()->GetCharString(buf)); Query->Append(colp->GetValue()->GetCharString(buf));
} else } else
oom |= Query->Append("NULL"); Query->Append("NULL");
oom |= Query->Append(','); Query->Append(',');
} // endfor colp } // endfor colp
if (unlikely(oom)) { if (unlikely(Query->IsTruncated())) {
strcpy(g->Message, "WriteDB: Out of memory"); strcpy(g->Message, "WriteDB: Out of memory");
rc = RC_FX; rc = RC_FX;
} else { } else {
@@ -1186,7 +1192,7 @@ int TDBMYSQL::WriteDB(PGLOBAL g)
Myc.m_Rows = -1; // To execute the query Myc.m_Rows = -1; // To execute the query
rc = Myc.ExecSQL(g, Query->GetStr()); rc = Myc.ExecSQL(g, Query->GetStr());
Query->Truncate(len); // Restore query Query->Truncate(len); // Restore query
} // endif oom } // endif Query
return (rc == RC_NF) ? RC_OK : rc; // RC_NF is Ok return (rc == RC_NF) ? RC_OK : rc; // RC_NF is Ok
} // end of WriteDB } // end of WriteDB
@@ -1234,7 +1240,7 @@ void TDBMYSQL::CloseDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* MYSQLCOL public constructor. */ /* MYSQLCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
MYSQLCOL::MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) MYSQLCOL::MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: COLBLK(cdp, tdbp, i) : COLBLK(cdp, tdbp, i)
{ {
if (cprec) { if (cprec) {
@@ -1260,7 +1266,7 @@ MYSQLCOL::MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
/***********************************************************************/ /***********************************************************************/
/* MYSQLCOL public constructor. */ /* MYSQLCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
MYSQLCOL::MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am) MYSQLCOL::MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PCSZ am)
: COLBLK(NULL, tdbp, i) : COLBLK(NULL, tdbp, i)
{ {
const char *chset = get_charset_name(fld->charsetnr); const char *chset = get_charset_name(fld->charsetnr);
@@ -1407,11 +1413,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
if (rc == RC_EF) if (rc == RC_EF)
sprintf(g->Message, MSG(INV_DEF_READ), rc); sprintf(g->Message, MSG(INV_DEF_READ), rc);
#if defined(USE_TRY)
throw 11; throw 11;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 11);
#endif // !USE_TRY
} else } else
tdbp->Fetched = true; tdbp->Fetched = true;
@@ -1673,7 +1675,7 @@ int TDBMYEXC::WriteDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* MYXCOL public constructor. */ /* MYXCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
MYXCOL::MYXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) MYXCOL::MYXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: MYSQLCOL(cdp, tdbp, cprec, i, am) : MYSQLCOL(cdp, tdbp, cprec, i, am)
{ {
// Set additional EXEC MYSQL access method information for column. // Set additional EXEC MYSQL access method information for column.
@@ -1683,7 +1685,7 @@ MYXCOL::MYXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
/***********************************************************************/ /***********************************************************************/
/* MYSQLCOL public constructor. */ /* MYSQLCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
MYXCOL::MYXCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am) MYXCOL::MYXCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PCSZ am)
: MYSQLCOL(fld, tdbp, i, am) : MYSQLCOL(fld, tdbp, i, am)
{ {
if (trace) if (trace)

View File

@@ -86,7 +86,7 @@ class TDBMYSQL : public TDBEXT {
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);
virtual bool IsView(void) {return Isview;} virtual bool IsView(void) {return Isview;}
virtual PSZ GetServer(void) {return Server;} virtual PCSZ GetServer(void) {return Server;}
void SetDatabase(LPCSTR db) {Schema = (char*)db;} void SetDatabase(LPCSTR db) {Schema = (char*)db;}
// Schema routines // Schema routines
@@ -109,7 +109,7 @@ class TDBMYSQL : public TDBEXT {
// Internal functions // Internal functions
bool MakeSelect(PGLOBAL g, bool mx); bool MakeSelect(PGLOBAL g, bool mx);
bool MakeInsert(PGLOBAL g); bool MakeInsert(PGLOBAL g);
int BindColumns(PGLOBAL g); int BindColumns(PGLOBAL g __attribute__((unused)));
virtual bool MakeCommand(PGLOBAL g); virtual bool MakeCommand(PGLOBAL g);
//int MakeUpdate(PGLOBAL g); //int MakeUpdate(PGLOBAL g);
//int MakeDelete(PGLOBAL g); //int MakeDelete(PGLOBAL g);
@@ -146,8 +146,8 @@ 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, PCSZ am = "MYSQL");
MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am = "MYSQL"); MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PCSZ am = "MYSQL");
MYSQLCOL(MYSQLCOL *colp, PTDB tdbp); // Constructor used in copy process MYSQLCOL(MYSQLCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
@@ -215,8 +215,8 @@ class MYXCOL : public MYSQLCOL {
friend class TDBMYEXC; friend class TDBMYEXC;
public: public:
// Constructors // Constructors
MYXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "MYSQL"); MYXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "MYSQL");
MYXCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am = "MYSQL"); MYXCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PCSZ am = "MYSQL");
MYXCOL(MYXCOL *colp, PTDB tdbp); // Constructor used in copy process MYXCOL(MYXCOL *colp, PTDB tdbp); // Constructor used in copy process
// Methods // Methods
@@ -242,10 +242,10 @@ class TDBMCL : public TDBCAT {
virtual PQRYRES GetResult(PGLOBAL g); virtual PQRYRES GetResult(PGLOBAL g);
// Members // Members
PSZ Host; // Host machine to use PCSZ Host; // Host machine to use
PSZ Db; // Database to be used by server PCSZ Db; // Database to be used by server
PSZ Tab; // External table name PCSZ Tab; // External table name
PSZ User; // User logon name PCSZ User; // User logon name
PSZ Pwd; // Password logon info PCSZ Pwd; // Password logon info
int Port; // MySQL port number (0 = default) int Port; // MySQL port number (0 = default)
}; // end of class TDBMCL }; // end of class TDBMCL

View File

@@ -1,11 +1,11 @@
/************* Tabodbc C++ Program Source Code File (.CPP) *************/ /************* Tabodbc C++ Program Source Code File (.CPP) *************/
/* PROGRAM NAME: TABODBC */ /* PROGRAM NAME: TABODBC */
/* ------------- */ /* ------------- */
/* Version 3.1 */ /* Version 3.2 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2000-2016 */ /* (C) Copyright to the author Olivier BERTRAND 2000-2017 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
@@ -231,7 +231,7 @@ PCOL TDBODBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/* This used for Multiple(1) tables. Also prepare a connect string */ /* This used for Multiple(1) tables. Also prepare a connect string */
/* with a place holder to be used by SetFile. */ /* with a place holder to be used by SetFile. */
/***********************************************************************/ /***********************************************************************/
PSZ TDBODBC::GetFile(PGLOBAL g) PCSZ TDBODBC::GetFile(PGLOBAL g)
{ {
if (Connect) { if (Connect) {
char *p1, *p2; char *p1, *p2;
@@ -297,9 +297,10 @@ void TDBODBC::SetFile(PGLOBAL g, PSZ fn)
/***********************************************************************/ /***********************************************************************/
bool TDBODBC::MakeInsert(PGLOBAL g) bool TDBODBC::MakeInsert(PGLOBAL g)
{ {
char *schmp = NULL, *catp = NULL, buf[NAM_LEN * 3]; PCSZ schmp = NULL;
char *catp = NULL, buf[NAM_LEN * 3];
int len = 0; int len = 0;
bool b = false, oom = false; bool oom, b = false;
PTABLE tablep = To_Table; PTABLE tablep = To_Table;
PCOL colp; PCOL colp;
@@ -336,32 +337,32 @@ bool TDBODBC::MakeInsert(PGLOBAL g)
Query = new(g) STRING(g, len, "INSERT INTO "); Query = new(g) STRING(g, len, "INSERT INTO ");
if (catp) { if (catp) {
oom |= Query->Append(catp); Query->Append(catp);
if (schmp) { if (schmp) {
oom |= Query->Append('.'); Query->Append('.');
oom |= Query->Append(schmp); Query->Append(schmp);
} // endif schmp } // endif schmp
oom |= Query->Append('.'); Query->Append('.');
} else if (schmp) { } else if (schmp) {
oom |= Query->Append(schmp); Query->Append(schmp);
oom |= Query->Append('.'); Query->Append('.');
} // endif schmp } // endif schmp
if (Quote) { if (Quote) {
// Put table name between identifier quotes in case in contains blanks // Put table name between identifier quotes in case in contains blanks
oom |= Query->Append(Quote); Query->Append(Quote);
oom |= Query->Append(buf); Query->Append(buf);
oom |= Query->Append(Quote); Query->Append(Quote);
} else } else
oom |= Query->Append(buf); Query->Append(buf);
oom |= Query->Append('('); Query->Append('(');
for (colp = Columns; colp; colp = colp->GetNext()) { for (colp = Columns; colp; colp = colp->GetNext()) {
if (b) if (b)
oom |= Query->Append(", "); Query->Append(", ");
else else
b = true; b = true;
@@ -370,20 +371,20 @@ bool TDBODBC::MakeInsert(PGLOBAL g)
if (Quote) { if (Quote) {
// Put column name between identifier quotes in case in contains blanks // Put column name between identifier quotes in case in contains blanks
oom |= Query->Append(Quote); Query->Append(Quote);
oom |= Query->Append(buf); Query->Append(buf);
oom |= Query->Append(Quote); Query->Append(Quote);
} else } else
oom |= Query->Append(buf); Query->Append(buf);
} // endfor colp } // endfor colp
oom |= Query->Append(") VALUES ("); Query->Append(") VALUES (");
for (int i = 0; i < Nparm; i++) for (int i = 0; i < Nparm; i++)
oom |= Query->Append("?,"); Query->Append("?,");
if (oom) if ((oom = Query->IsTruncated()))
strcpy(g->Message, "MakeInsert: Out of memory"); strcpy(g->Message, "MakeInsert: Out of memory");
else else
Query->RepLast(')'); Query->RepLast(')');
@@ -733,7 +734,7 @@ bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
To_CondFil->Body= (char*)PlugSubAlloc(g, NULL, 0); To_CondFil->Body= (char*)PlugSubAlloc(g, NULL, 0);
*To_CondFil->Body= 0; *To_CondFil->Body= 0;
if ((To_CondFil = hc->CheckCond(g, To_CondFil, To_CondFil->Cond))) if ((To_CondFil = hc->CheckCond(g, To_CondFil, Cond)))
PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1); PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1);
} // endif active_index } // endif active_index
@@ -883,7 +884,7 @@ void TDBODBC::CloseDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* ODBCCOL public constructor. */ /* ODBCCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
ODBCCOL::ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) ODBCCOL::ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: EXTCOL(cdp, tdbp, cprec, i, am) : EXTCOL(cdp, tdbp, cprec, i, am)
{ {
// Set additional ODBC access method information for column. // Set additional ODBC access method information for column.
@@ -1301,7 +1302,7 @@ int TDBXDBC::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/ /***********************************************************************/
/* XSRCCOL public constructor. */ /* XSRCCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
XSRCCOL::XSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) XSRCCOL::XSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: ODBCCOL(cdp, tdbp, cprec, i, am) : ODBCCOL(cdp, tdbp, cprec, i, am)
{ {
// Set additional ODBC access method information for column. // Set additional ODBC access method information for column.

View File

@@ -70,10 +70,10 @@ class TDBODBC : public TDBEXT {
// Methods // Methods
virtual PTDB Clone(PTABS t); virtual PTDB Clone(PTABS t);
virtual bool SetRecpos(PGLOBAL g, int recpos); virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual PSZ GetFile(PGLOBAL g); virtual PCSZ 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 PSZ GetServer(void) {return "ODBC";} virtual PCSZ GetServer(void) {return "ODBC";}
virtual int Indexable(void) {return 2;} virtual int Indexable(void) {return 2;}
// Database routines // Database routines
@@ -108,7 +108,7 @@ class ODBCCOL : public EXTCOL {
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, PCSZ am = "ODBC");
ODBCCOL(ODBCCOL *colp, PTDB tdbp); // Constructor used in copy process ODBCCOL(ODBCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
@@ -179,7 +179,7 @@ class XSRCCOL : public ODBCCOL {
friend class TDBXDBC; friend class TDBXDBC;
public: public:
// Constructors // Constructors
XSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "ODBC"); XSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "ODBC");
XSRCCOL(XSRCCOL *colp, PTDB tdbp); // Constructor used in copy process XSRCCOL(XSRCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
@@ -239,10 +239,10 @@ class TDBOTB : public TDBDRV {
virtual PQRYRES GetResult(PGLOBAL g); virtual PQRYRES GetResult(PGLOBAL g);
// Members // Members
char *Dsn; // Points to connection string PCSZ Dsn; // Points to connection string
char *Schema; // Points to schema name or NULL PCSZ Schema; // Points to schema name or NULL
char *Tab; // Points to ODBC table name or pattern PCSZ Tab; // Points to ODBC table name or pattern
char *Tabtyp; // Points to ODBC table type PCSZ Tabtyp; // Points to ODBC table type
ODBCPARM Ops; // Additional parameters ODBCPARM Ops; // Additional parameters
}; // end of class TDBOTB }; // end of class TDBOTB

View File

@@ -114,20 +114,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
PQRYRES qrp; PQRYRES qrp;
PCOLRES *pcrp, crp, fncrp = NULL; PCOLRES *pcrp, crp, fncrp = NULL;
#if defined(USE_TRY)
try { try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
goto err;
} // endif rc
#endif // !USE_TRY
// Are there columns to skip? // Are there columns to skip?
if (Skcol) { if (Skcol) {
uint n = strlen(Skcol); uint n = strlen(Skcol);
@@ -151,7 +138,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
strcpy(g->Message, MSG(SRC_TABLE_UNDEF)); strcpy(g->Message, MSG(SRC_TABLE_UNDEF));
goto err; goto err;
} else } else
query = Tabsrc; query = (char*)Tabsrc;
// Open a MySQL connection for this table // Open a MySQL connection for this table
if (!Myc.Open(g, Host, Database, User, Pwd, Port)) { if (!Myc.Open(g, Host, Database, User, Pwd, Port)) {
@@ -310,9 +297,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
// We added ndif columns and removed 2 (picol and fncol) // We added ndif columns and removed 2 (picol and fncol)
Qryp->Nbcol += (ndif - 2); Qryp->Nbcol += (ndif - 2);
#if defined(USE_TRY)
return Qryp; return Qryp;
} catch (int n) { } catch (int n) {
if (trace) if (trace)
htrc("Exception %d: %s\n", n, g->Message); htrc("Exception %d: %s\n", n, g->Message);
@@ -321,14 +306,6 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // end catch } // end catch
err: err:
#else // !USE_TRY
g->jump_level--;
return Qryp;
err:
g->jump_level--;
#endif // !USE_TRY
if (b) if (b)
Myc.Close(); Myc.Close();

View File

@@ -32,16 +32,16 @@ class PIVAID : public CSORT {
protected: protected:
// Members // Members
MYSQLC Myc; // MySQL connection class MYSQLC Myc; // MySQL connection class
char *Host; // Host machine to use PCSZ Host; // Host machine to use
char *User; // User logon info PCSZ User; // User logon info
char *Pwd; // Password logon info PCSZ Pwd; // Password logon info
char *Database; // Database to be used by server PCSZ 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 PCSZ Tabname; // Name of source table
char *Tabsrc; // SQL of source table PCSZ Tabsrc; // SQL of source table
char *Picol; // Pivot column name PCSZ Picol; // Pivot column name
char *Fncol; // Function column name PCSZ Fncol; // Function column name
char *Skcol; // Skipped columns PCSZ Skcol; // Skipped columns
PVBLK Rblkp; // The value block of the pivot column PVBLK Rblkp; // The value block of the pivot column
int Port; // MySQL port number int Port; // MySQL port number
}; // end of class PIVAID }; // end of class PIVAID

View File

@@ -355,7 +355,7 @@ void TDBINI::CloseDB(PGLOBAL)
/***********************************************************************/ /***********************************************************************/
/* INICOL public constructor. */ /* INICOL public constructor. */
/***********************************************************************/ /***********************************************************************/
INICOL::INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ) INICOL::INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ)
: COLBLK(cdp, tdbp, i) : COLBLK(cdp, tdbp, i)
{ {
if (cprec) { if (cprec) {
@@ -511,19 +511,11 @@ void INICOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Flag == 1) { } else if (Flag == 1) {
if (tdbp->Mode == MODE_UPDATE) { if (tdbp->Mode == MODE_UPDATE) {
strcpy(g->Message, MSG(NO_SEC_UPDATE)); strcpy(g->Message, MSG(NO_SEC_UPDATE));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (*p) { } else if (*p) {
tdbp->Section = p; tdbp->Section = p;
} else } else
@@ -532,11 +524,7 @@ void INICOL::WriteColumn(PGLOBAL g)
return; return;
} else if (!tdbp->Section) { } else if (!tdbp->Section) {
strcpy(g->Message, MSG(SEC_NAME_FIRST)); strcpy(g->Message, MSG(SEC_NAME_FIRST));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif's } // endif's
/*********************************************************************/ /*********************************************************************/
@@ -548,11 +536,7 @@ void INICOL::WriteColumn(PGLOBAL g)
if (!rc) { if (!rc) {
sprintf(g->Message, "Error %d writing to %s", sprintf(g->Message, "Error %d writing to %s",
GetLastError(), tdbp->Ifile); GetLastError(), tdbp->Ifile);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif rc } // endif rc
} // endif Status } // endif Status
@@ -785,7 +769,7 @@ int TDBXIN::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/ /***********************************************************************/
/* XINCOL public constructor. */ /* XINCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
XINCOL::XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) XINCOL::XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: INICOL(cdp, tdbp, cprec, i, am) : INICOL(cdp, tdbp, cprec, i, am)
{ {
} // end of XINCOL constructor } // end of XINCOL constructor
@@ -853,19 +837,11 @@ void XINCOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (Flag == 1) { } else if (Flag == 1) {
if (tdbp->Mode == MODE_UPDATE) { if (tdbp->Mode == MODE_UPDATE) {
strcpy(g->Message, MSG(NO_SEC_UPDATE)); strcpy(g->Message, MSG(NO_SEC_UPDATE));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (*p) { } else if (*p) {
tdbp->Section = p; tdbp->Section = p;
} else } else
@@ -875,11 +851,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
} else if (Flag == 2) { } else if (Flag == 2) {
if (tdbp->Mode == MODE_UPDATE) { if (tdbp->Mode == MODE_UPDATE) {
strcpy(g->Message, MSG(NO_KEY_UPDATE)); strcpy(g->Message, MSG(NO_KEY_UPDATE));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} else if (*p) { } else if (*p) {
tdbp->Keycur = p; tdbp->Keycur = p;
} else } else
@@ -888,11 +860,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
return; return;
} else if (!tdbp->Section || !tdbp->Keycur) { } else if (!tdbp->Section || !tdbp->Keycur) {
strcpy(g->Message, MSG(SEC_KEY_FIRST)); strcpy(g->Message, MSG(SEC_KEY_FIRST));
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif's } // endif's
/*********************************************************************/ /*********************************************************************/
@@ -904,11 +872,7 @@ void XINCOL::WriteColumn(PGLOBAL g)
if (!rc) { if (!rc) {
sprintf(g->Message, "Error %d writing to %s", sprintf(g->Message, "Error %d writing to %s",
GetLastError(), tdbp->Ifile); GetLastError(), tdbp->Ifile);
#if defined(USE_TRY)
throw 31; throw 31;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 31);
#endif // !USE_TRY
} // endif rc } // endif rc
} // endif Status } // endif Status

View File

@@ -61,7 +61,7 @@ class TDBINI : public TDBASE {
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 PCSZ 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;}
@@ -93,7 +93,7 @@ class TDBINI : public TDBASE {
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, PCSZ am = "INI");
INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
@@ -165,7 +165,7 @@ class TDBXIN : public TDBINI {
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, PCSZ am = "INI");
XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation

View File

@@ -119,7 +119,8 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
FLD_LENGTH, FLD_SCALE, FLD_RADIX, FLD_NULL, FLD_LENGTH, FLD_SCALE, FLD_RADIX, FLD_NULL,
FLD_REM, FLD_NO, FLD_CHARSET}; FLD_REM, FLD_NO, FLD_CHARSET};
unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 32, 32}; unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 32, 32};
char *pn, *tn, *fld, *colname, *chset, *fmt, v; PCSZ fmt;
char *pn, *tn, *fld, *colname, *chset, v;
int i, n, ncol = sizeof(buftyp) / sizeof(int); int i, n, ncol = sizeof(buftyp) / sizeof(int);
int prec, len, type, scale; int prec, len, type, scale;
int zconv = GetConvSize(); int zconv = GetConvSize();
@@ -227,7 +228,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
fmt = MyDateFmt(fp->type()); fmt = MyDateFmt(fp->type());
prec = len = strlen(fmt); prec = len = strlen(fmt);
} else { } else {
fmt = (char*)fp->option_struct->dateformat; fmt = (PCSZ)fp->option_struct->dateformat;
prec = len = fp->field_length; prec = len = fp->field_length;
} // endif mysql } // endif mysql
@@ -314,7 +315,7 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR, int)
strcpy(g->Message, "Missing object table definition"); strcpy(g->Message, "Missing object table definition");
return true; return true;
} else } else
tab = "Noname"; tab = PlugDup(g, "Noname");
} else } else
// Analyze the table name, it may have the format: [dbname.]tabname // Analyze the table name, it may have the format: [dbname.]tabname
@@ -626,7 +627,7 @@ void TDBPRX::RemoveNext(PTABLE tp)
/***********************************************************************/ /***********************************************************************/
/* PRXCOL public constructor. */ /* PRXCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
PRXCOL::PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) PRXCOL::PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: COLBLK(cdp, tdbp, i) : COLBLK(cdp, tdbp, i)
{ {
if (cprec) { if (cprec) {
@@ -741,6 +742,13 @@ void PRXCOL::ReadColumn(PGLOBAL g)
if (Nullable) if (Nullable)
Value->SetNull(Value->IsNull()); Value->SetNull(Value->IsNull());
} else {
Value->Reset();
// Set null when applicable
if (Nullable)
Value->SetNull(true);
} // endif Colp } // endif Colp
} // end of ReadColumn } // end of ReadColumn

View File

@@ -71,7 +71,7 @@ class DllExport TDBPRX : public TDBASE {
virtual int GetRecpos(void) {return Tdbp->GetRecpos();} virtual int GetRecpos(void) {return Tdbp->GetRecpos();}
virtual void ResetDB(void) {Tdbp->ResetDB();} virtual void ResetDB(void) {Tdbp->ResetDB();}
virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual PSZ GetServer(void) {return (Tdbp) ? Tdbp->GetServer() : (PSZ)"?";} virtual PCSZ GetServer(void) {return (Tdbp) ? Tdbp->GetServer() : (PSZ)"?";}
// 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);
@@ -101,7 +101,7 @@ class DllExport PRXCOL : public COLBLK {
friend class TDBOCCUR; friend class TDBOCCUR;
public: public:
// Constructors // Constructors
PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "PRX"); PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "PRX");
PRXCOL(PRXCOL *colp, PTDB tdbp); // Constructor used in copy process PRXCOL(PRXCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation

View File

@@ -174,7 +174,7 @@ bool VCTDEF::Erase(char *filename)
/***********************************************************************/ /***********************************************************************/
int VCTDEF::MakeFnPattern(char *fpat) int VCTDEF::MakeFnPattern(char *fpat)
{ {
char pat[8]; char pat[16];
#if defined(__WIN__) #if defined(__WIN__)
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
#else #else
@@ -490,11 +490,7 @@ void VCTCOL::ReadBlock(PGLOBAL g)
#if defined(_DEBUG) #if defined(_DEBUG)
if (!Blk) { if (!Blk) {
strcpy(g->Message, MSG(TO_BLK_IS_NULL)); strcpy(g->Message, MSG(TO_BLK_IS_NULL));
#if defined(USE_TRY)
throw 58; throw 58;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 58);
#endif // !USE_TRY
} // endif } // endif
#endif #endif
@@ -502,11 +498,7 @@ void VCTCOL::ReadBlock(PGLOBAL g)
/* Read column block according to used access method. */ /* Read column block according to used access method. */
/*********************************************************************/ /*********************************************************************/
if (txfp->ReadBlock(g, this)) if (txfp->ReadBlock(g, this))
#if defined(USE_TRY)
throw 6; throw 6;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 6);
#endif // !USE_TRY
ColBlk = txfp->CurBlk; ColBlk = txfp->CurBlk;
ColPos = -1; // Any invalid position ColPos = -1; // Any invalid position
@@ -526,11 +518,7 @@ void VCTCOL::WriteBlock(PGLOBAL g)
#if defined(_DEBUG) #if defined(_DEBUG)
if (!Blk) { if (!Blk) {
strcpy(g->Message, MSG(BLK_IS_NULL)); strcpy(g->Message, MSG(BLK_IS_NULL));
#if defined(USE_TRY)
throw 56; throw 56;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 56);
#endif // !USE_TRY
} // endif } // endif
#endif #endif
@@ -538,11 +526,7 @@ void VCTCOL::WriteBlock(PGLOBAL g)
/* Write column block according to used access method. */ /* Write column block according to used access method. */
/*******************************************************************/ /*******************************************************************/
if (txfp->WriteBlock(g, this)) if (txfp->WriteBlock(g, this))
#if defined(USE_TRY)
throw 6; throw 6;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 6);
#endif // !USE_TRY
Modif = 0; Modif = 0;
} // endif Modif } // endif Modif

View File

@@ -269,7 +269,7 @@ int TDBVIR::DeleteDB(PGLOBAL g, int)
/***********************************************************************/ /***********************************************************************/
/* VIRCOL public constructor. */ /* VIRCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
VIRCOL::VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ) VIRCOL::VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ)
: COLBLK(cdp, tdbp, i) : COLBLK(cdp, tdbp, i)
{ {
if (cprec) { if (cprec) {
@@ -289,11 +289,7 @@ void VIRCOL::ReadColumn(PGLOBAL g)
{ {
// This should never be called // This should never be called
sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name); sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name);
#if defined(USE_TRY)
throw TYPE_COLBLK; throw TYPE_COLBLK;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
#endif // !USE_TRY
} // end of ReadColumn } // end of ReadColumn
/* ---------------------------TDBVICL class -------------------------- */ /* ---------------------------TDBVICL class -------------------------- */

View File

@@ -76,7 +76,7 @@ class VIRCOL : public COLBLK {
friend class TDBVIR; friend class TDBVIR;
public: public:
// Constructors // Constructors
VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "VIRTUAL"); VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "VIRTUAL");
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_VIR;} virtual int GetAmType(void) {return TYPE_AM_VIR;}

View File

@@ -27,7 +27,7 @@
/***********************************************************************/ /***********************************************************************/
/* Initialize WMI operations. */ /* Initialize WMI operations. */
/***********************************************************************/ /***********************************************************************/
PWMIUT InitWMI(PGLOBAL g, char *nsp, char *classname) PWMIUT InitWMI(PGLOBAL g, PCSZ nsp, PCSZ classname)
{ {
IWbemLocator *loc; IWbemLocator *loc;
char *p; char *p;
@@ -132,7 +132,7 @@ PWMIUT InitWMI(PGLOBAL g, char *nsp, char *classname)
/* WMIColumns: constructs the result blocks containing the description */ /* WMIColumns: constructs the result blocks containing the description */
/* of all the columns of a WMI table of a specified class. */ /* of all the columns of a WMI table of a specified class. */
/***********************************************************************/ /***********************************************************************/
PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info) PQRYRES WMIColumns(PGLOBAL g, PCSZ nsp, PCSZ cls, bool info)
{ {
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_INT, TYPE_SHORT}; TYPE_INT, TYPE_INT, TYPE_SHORT};

View File

@@ -27,7 +27,7 @@ typedef struct _WMIutil {
/***********************************************************************/ /***********************************************************************/
/* Functions used externally. */ /* Functions used externally. */
/***********************************************************************/ /***********************************************************************/
PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info); PQRYRES WMIColumns(PGLOBAL g, PCSZ nsp, PCSZ cls, bool info);
/* -------------------------- WMI classes ---------------------------- */ /* -------------------------- WMI classes ---------------------------- */

View File

@@ -118,10 +118,11 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT}; FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT};
static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0}; static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0};
char *fn, *op, colname[65], fmt[129], buf[512]; char colname[65], fmt[129], buf[512];
int i, j, lvl, n = 0; int i, j, lvl, n = 0;
int ncol = sizeof(buftyp) / sizeof(int); int ncol = sizeof(buftyp) / sizeof(int);
bool ok = true; bool ok = true;
PCSZ fn, op;
PXCL xcol, xcp, fxcp = NULL, pxcp = NULL; PXCL xcol, xcp, fxcp = NULL, pxcp = NULL;
PLVL *lvlp, vp; PLVL *lvlp, vp;
PXNODE node = NULL; PXNODE node = NULL;
@@ -362,7 +363,7 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
skipit: skipit:
if (trace) if (trace)
htrc("CSVColumns: n=%d len=%d\n", n, length[0]); htrc("XMLColumns: n=%d len=%d\n", n, length[0]);
/*********************************************************************/ /*********************************************************************/
/* Allocate the structures used to refer to the result set. */ /* Allocate the structures used to refer to the result set. */
@@ -451,7 +452,8 @@ XMLDEF::XMLDEF(void)
/***********************************************************************/ /***********************************************************************/
bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
char *defrow, *defcol, buf[10]; PCSZ defrow, defcol;
char buf[10];
Fn = GetStringCatInfo(g, "Filename", NULL); Fn = GetStringCatInfo(g, "Filename", NULL);
Encoding = GetStringCatInfo(g, "Encoding", "UTF-8"); Encoding = GetStringCatInfo(g, "Encoding", "UTF-8");
@@ -1317,11 +1319,7 @@ void TDBXML::CloseDB(PGLOBAL g)
Docp->CloseDoc(g, To_Xb); Docp->CloseDoc(g, To_Xb);
// This causes a crash in Diagnostics_area::set_error_status // This causes a crash in Diagnostics_area::set_error_status
//#if defined(USE_TRY)
// throw TYPE_AM_XML; // throw TYPE_AM_XML;
//#else // !USE_TRY
// longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
//#endif // !USE_TRY
} // endif DumpDoc } // endif DumpDoc
} // endif Changed } // endif Changed
@@ -1364,7 +1362,7 @@ void TDBXML::CloseDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* XMLCOL public constructor. */ /* XMLCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
XMLCOL::XMLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) XMLCOL::XMLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: COLBLK(cdp, tdbp, i) : COLBLK(cdp, tdbp, i)
{ {
if (cprec) { if (cprec) {
@@ -1644,11 +1642,7 @@ void XMLCOL::ReadColumn(PGLOBAL g)
if (ValNode->GetType() != XML_ELEMENT_NODE && if (ValNode->GetType() != XML_ELEMENT_NODE &&
ValNode->GetType() != XML_ATTRIBUTE_NODE) { ValNode->GetType() != XML_ATTRIBUTE_NODE) {
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name); sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} // endif type } // endif type
// Get the Xname value from the XML file // Get the Xname value from the XML file
@@ -1659,11 +1653,7 @@ void XMLCOL::ReadColumn(PGLOBAL g)
PushWarning(g, Tdbp); PushWarning(g, Tdbp);
break; break;
default: default:
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} // endswitch } // endswitch
Value->SetValue_psz(Valbuf); Value->SetValue_psz(Valbuf);
@@ -1714,11 +1704,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
/* For columns having an Xpath, the Clist must be updated. */ /* For columns having an Xpath, the Clist must be updated. */
/*********************************************************************/ /*********************************************************************/
if (Tdbp->CheckRow(g, Nod || Tdbp->Colname)) if (Tdbp->CheckRow(g, Nod || Tdbp->Colname))
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
/*********************************************************************/ /*********************************************************************/
/* Null values are represented by no node. */ /* Null values are represented by no node. */
@@ -1790,15 +1776,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
if (ColNode == NULL) { if (ColNode == NULL) {
strcpy(g->Message, MSG(COL_ALLOC_ERR)); strcpy(g->Message, MSG(COL_ALLOC_ERR));
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
#if defined(USE_TRY)
throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
#endif // !USE_TRY
} // endif ColNode } // endif ColNode
} // endif ColNode } // endif ColNode
@@ -1827,11 +1805,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} else } else
strcpy(Valbuf, p); strcpy(Valbuf, p);
@@ -1881,11 +1855,7 @@ void XMULCOL::ReadColumn(PGLOBAL g)
if (ValNode->GetType() != XML_ELEMENT_NODE && if (ValNode->GetType() != XML_ELEMENT_NODE &&
ValNode->GetType() != XML_ATTRIBUTE_NODE) { ValNode->GetType() != XML_ATTRIBUTE_NODE) {
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name); sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} // endif type } // endif type
// Get the Xname value from the XML file // Get the Xname value from the XML file
@@ -1971,11 +1941,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
/* For columns having an Xpath, the Clist must be updated. */ /* For columns having an Xpath, the Clist must be updated. */
/*********************************************************************/ /*********************************************************************/
if (Tdbp->CheckRow(g, Nod)) if (Tdbp->CheckRow(g, Nod))
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
/*********************************************************************/ /*********************************************************************/
/* Find the column and value nodes to update or insert. */ /* Find the column and value nodes to update or insert. */
@@ -2024,11 +1990,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
if (len > 1 && !Tdbp->Xpand) { if (len > 1 && !Tdbp->Xpand) {
sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name); sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name);
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} else } else
ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp); ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp);
@@ -2070,11 +2032,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
if (ColNode == NULL) { if (ColNode == NULL) {
strcpy(g->Message, MSG(COL_ALLOC_ERR)); strcpy(g->Message, MSG(COL_ALLOC_ERR));
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} // endif ColNode } // endif ColNode
} // endif ColNode } // endif ColNode
@@ -2103,11 +2061,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} else } else
strcpy(Valbuf, p); strcpy(Valbuf, p);
@@ -2139,11 +2093,7 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
if (Tdbp->Clist == NULL) { if (Tdbp->Clist == NULL) {
strcpy(g->Message, MSG(MIS_TAG_LIST)); strcpy(g->Message, MSG(MIS_TAG_LIST));
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} // endif Clist } // endif Clist
if ((ValNode = Tdbp->Clist->GetItem(g, Rank, Vxnp))) { if ((ValNode = Tdbp->Clist->GetItem(g, Rank, Vxnp))) {
@@ -2155,11 +2105,7 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
PushWarning(g, Tdbp); PushWarning(g, Tdbp);
break; break;
default: default:
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} // endswitch } // endswitch
Value->SetValue_psz(Valbuf); Value->SetValue_psz(Valbuf);
@@ -2210,22 +2156,14 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
/* For all columns the Clist must be updated. */ /* For all columns the Clist must be updated. */
/*********************************************************************/ /*********************************************************************/
if (Tdbp->CheckRow(g, true)) if (Tdbp->CheckRow(g, true))
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
/*********************************************************************/ /*********************************************************************/
/* Find the column and value nodes to update or insert. */ /* Find the column and value nodes to update or insert. */
/*********************************************************************/ /*********************************************************************/
if (Tdbp->Clist == NULL) { if (Tdbp->Clist == NULL) {
strcpy(g->Message, MSG(MIS_TAG_LIST)); strcpy(g->Message, MSG(MIS_TAG_LIST));
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} // endif Clist } // endif Clist
n = Tdbp->Clist->GetLength(); n = Tdbp->Clist->GetLength();
@@ -2250,11 +2188,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
#if defined(USE_TRY)
throw TYPE_AM_XML; throw TYPE_AM_XML;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
#endif // !USE_TRY
} else } else
strcpy(Valbuf, p); strcpy(Valbuf, p);

View File

@@ -31,7 +31,7 @@ class DllExport XMLDEF : public TABDEF { /* Logical table description */
protected: protected:
// Members // Members
char *Fn; /* Path/Name of corresponding file */ PCSZ 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 */
@@ -42,7 +42,7 @@ class DllExport XMLDEF : public TABDEF { /* Logical table description */
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 */
char *Entry; /* Zip entry name or pattern */ PCSZ Entry; /* Zip entry name or pattern */
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 */
@@ -74,7 +74,7 @@ class DllExport TDBXML : public TDBASE {
virtual PTDB Clone(PTABS t); virtual PTDB Clone(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 PCSZ 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;}
@@ -127,7 +127,7 @@ class DllExport TDBXML : public TDBASE {
bool Void; // True if the file does not exist bool Void; // True if the file does not exist
bool Zipped; // True if Zipped XML file(s) bool Zipped; // True if Zipped XML file(s)
bool Mulentries; // True if multiple entries in zip file bool Mulentries; // True if multiple entries in zip file
char *Xfile; // The XML file PCSZ 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
@@ -138,7 +138,7 @@ class DllExport TDBXML : public TDBASE {
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)
char *Entry; // Zip entry name or pattern PCSZ Entry; // Zip entry name or pattern
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
@@ -155,7 +155,7 @@ class DllExport TDBXML : public TDBASE {
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, PCSZ am = "XML");
XMLCOL(XMLCOL *colp, PTDB tdbp); // Constructor used in copy process XMLCOL(XMLCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation

View File

@@ -195,7 +195,7 @@ void TDBZIP::CloseDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* ZIPCOL public constructor. */ /* ZIPCOL public constructor. */
/***********************************************************************/ /***********************************************************************/
ZIPCOL::ZIPCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am) ZIPCOL::ZIPCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: COLBLK(cdp, tdbp, i) : COLBLK(cdp, tdbp, i)
{ {
if (cprec) { if (cprec) {

View File

@@ -34,7 +34,7 @@ public:
protected: protected:
// Members // Members
PSZ target; // The inside file to query PCSZ target; // The inside file to query
}; // end of ZIPDEF }; // end of ZIPDEF
/***********************************************************************/ /***********************************************************************/
@@ -68,7 +68,7 @@ protected:
// Members // Members
unzFile zipfile; // The ZIP container file unzFile zipfile; // The ZIP container file
PSZ zfn; // The ZIP file name PCSZ zfn; // The ZIP file name
//PSZ target; //PSZ target;
unz_file_info64 finfo; // The current file info unz_file_info64 finfo; // The current file info
char fn[FILENAME_MAX]; // The current file name char fn[FILENAME_MAX]; // The current file name
@@ -82,7 +82,7 @@ class DllExport ZIPCOL : public COLBLK {
friend class TDBZIP; friend class TDBZIP;
public: public:
// Constructors // Constructors
ZIPCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "ZIP"); ZIPCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "ZIP");
// Implementation // Implementation
virtual int GetAmType(void) { return TYPE_AM_ZIP; } virtual int GetAmType(void) { return TYPE_AM_ZIP; }

View File

@@ -11,7 +11,7 @@
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/** /**
@file user_connect.cc @file user_connect.cc

View File

@@ -11,7 +11,7 @@
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/** @file user_connect.h /** @file user_connect.h

View File

@@ -1,5 +1,5 @@
/************ Valblk C++ Functions Source Code File (.CPP) *************/ /************ Valblk C++ Functions Source Code File (.CPP) *************/
/* Name: VALBLK.CPP Version 2.2 */ /* Name: VALBLK.CPP Version 2.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
/* */ /* */
@@ -138,18 +138,14 @@ PSZ VALBLK::GetCharValue(int)
assert(g); assert(g);
sprintf(g->Message, MSG(NO_CHAR_FROM), Type); sprintf(g->Message, MSG(NO_CHAR_FROM), Type);
#if defined(USE_TRY)
throw Type; throw Type;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
return NULL; return NULL;
} // end of GetCharValue } // end of GetCharValue
/***********************************************************************/ /***********************************************************************/
/* Set format so formatted dates can be converted on input. */ /* Set format so formatted dates can be converted on input. */
/***********************************************************************/ /***********************************************************************/
bool VALBLK::SetFormat(PGLOBAL g, PSZ, int, int) bool VALBLK::SetFormat(PGLOBAL g, PCSZ, int, int)
{ {
sprintf(g->Message, MSG(NO_DATE_FMT), Type); sprintf(g->Message, MSG(NO_DATE_FMT), Type);
return true; return true;
@@ -210,11 +206,7 @@ void VALBLK::ChkIndx(int n)
if (n < 0 || n >= Nval) { if (n < 0 || n >= Nval) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
strcpy(g->Message, MSG(BAD_VALBLK_INDX)); strcpy(g->Message, MSG(BAD_VALBLK_INDX));
#if defined(USE_TRY)
throw Type; throw Type;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
} // endif n } // endif n
} // end of ChkIndx } // end of ChkIndx
@@ -224,11 +216,7 @@ void VALBLK::ChkTyp(PVAL v)
if (Check && (Type != v->GetType() || Unsigned != v->IsUnsigned())) { if (Check && (Type != v->GetType() || Unsigned != v->IsUnsigned())) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); strcpy(g->Message, MSG(VALTYPE_NOMATCH));
#if defined(USE_TRY)
throw Type; throw Type;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
} // endif Type } // endif Type
} // end of ChkTyp } // end of ChkTyp
@@ -238,11 +226,7 @@ void VALBLK::ChkTyp(PVBLK vb)
if (Check && (Type != vb->GetType() || Unsigned != vb->IsUnsigned())) { if (Check && (Type != vb->GetType() || Unsigned != vb->IsUnsigned())) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); strcpy(g->Message, MSG(VALTYPE_NOMATCH));
#if defined(USE_TRY)
throw Type; throw Type;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
} // endif Type } // endif Type
} // end of ChkTyp } // end of ChkTyp
@@ -351,18 +335,14 @@ uchar TYPBLK<uchar>::GetTypedValue(PVAL valp)
/* Set one value in a block from a zero terminated string. */ /* Set one value in a block from a zero terminated string. */
/***********************************************************************/ /***********************************************************************/
template <class TYPE> template <class TYPE>
void TYPBLK<TYPE>::SetValue(PSZ p, int n) void TYPBLK<TYPE>::SetValue(PCSZ p, int n)
{ {
ChkIndx(n); ChkIndx(n);
if (Check) { if (Check) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
strcpy(g->Message, MSG(BAD_SET_STRING)); strcpy(g->Message, MSG(BAD_SET_STRING));
#if defined(USE_TRY)
throw Type; throw Type;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
} // endif Check } // endif Check
bool minus; bool minus;
@@ -405,18 +385,14 @@ template <>
ulonglong TYPBLK<ulonglong>::MaxVal(void) {return ULONGLONG_MAX;} ulonglong TYPBLK<ulonglong>::MaxVal(void) {return ULONGLONG_MAX;}
template <> template <>
void TYPBLK<double>::SetValue(PSZ p, int n) void TYPBLK<double>::SetValue(PCSZ p, int n)
{ {
ChkIndx(n); ChkIndx(n);
if (Check) { if (Check) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
strcpy(g->Message, MSG(BAD_SET_STRING)); strcpy(g->Message, MSG(BAD_SET_STRING));
#if defined(USE_TRY)
throw Type; throw Type;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
} // endif Check } // endif Check
Typp[n] = atof(p); Typp[n] = atof(p);
@@ -427,7 +403,7 @@ void TYPBLK<double>::SetValue(PSZ p, int n)
/* Set one value in a block from an array of characters. */ /* Set one value in a block from an array of characters. */
/***********************************************************************/ /***********************************************************************/
template <class TYPE> template <class TYPE>
void TYPBLK<TYPE>::SetValue(char *sp, uint len, int n) void TYPBLK<TYPE>::SetValue(PCSZ sp, uint len, int n)
{ {
PGLOBAL& g = Global; PGLOBAL& g = Global;
PSZ spz = (PSZ)PlugSubAlloc(g, NULL, 0); // Temporary PSZ spz = (PSZ)PlugSubAlloc(g, NULL, 0); // Temporary
@@ -802,7 +778,7 @@ void CHRBLK::SetValue(PVAL valp, int n)
/***********************************************************************/ /***********************************************************************/
/* Set one value in a block from a zero terminated string. */ /* Set one value in a block from a zero terminated string. */
/***********************************************************************/ /***********************************************************************/
void CHRBLK::SetValue(PSZ sp, int n) void CHRBLK::SetValue(PCSZ sp, int n)
{ {
uint len = (sp) ? strlen(sp) : 0; uint len = (sp) ? strlen(sp) : 0;
SetValue(sp, len, n); SetValue(sp, len, n);
@@ -811,7 +787,7 @@ void CHRBLK::SetValue(PSZ sp, int n)
/***********************************************************************/ /***********************************************************************/
/* Set one value in a block from an array of characters. */ /* Set one value in a block from an array of characters. */
/***********************************************************************/ /***********************************************************************/
void CHRBLK::SetValue(char *sp, uint len, int n) void CHRBLK::SetValue(const char *sp, uint len, int n)
{ {
char *p = Chrp + n * Long; char *p = Chrp + n * Long;
@@ -819,11 +795,7 @@ void CHRBLK::SetValue(char *sp, uint len, int n)
if (Check && (signed)len > Long) { if (Check && (signed)len > Long) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
strcpy(g->Message, MSG(SET_STR_TRUNC)); strcpy(g->Message, MSG(SET_STR_TRUNC));
#if defined(USE_TRY)
throw Type; throw Type;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
} // endif Check } // endif Check
#endif // _DEBUG #endif // _DEBUG
@@ -851,11 +823,7 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) { if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
strcpy(g->Message, MSG(BLKTYPLEN_MISM)); strcpy(g->Message, MSG(BLKTYPLEN_MISM));
#if defined(USE_TRY)
throw Type; throw Type;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
} // endif Type } // endif Type
if (!(b = pv->IsNull(n2))) if (!(b = pv->IsNull(n2)))
@@ -906,11 +874,7 @@ void CHRBLK::SetValues(PVBLK pv, int k, int n)
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) { if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
strcpy(g->Message, MSG(BLKTYPLEN_MISM)); strcpy(g->Message, MSG(BLKTYPLEN_MISM));
#if defined(USE_TRY)
throw Type; throw Type;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
} // endif Type } // endif Type
#endif // _DEBUG #endif // _DEBUG
char *p = ((CHRBLK*)pv)->Chrp; char *p = ((CHRBLK*)pv)->Chrp;
@@ -1188,7 +1152,7 @@ void STRBLK::SetValue(PVAL valp, int n)
/***********************************************************************/ /***********************************************************************/
/* Set one value in a block from a zero terminated string. */ /* Set one value in a block from a zero terminated string. */
/***********************************************************************/ /***********************************************************************/
void STRBLK::SetValue(PSZ p, int n) void STRBLK::SetValue(PCSZ p, int n)
{ {
if (p) { if (p) {
if (!Sorted || !n || !Strp[n-1] || strcmp(p, Strp[n-1])) if (!Sorted || !n || !Strp[n-1] || strcmp(p, Strp[n-1]))
@@ -1204,7 +1168,7 @@ void STRBLK::SetValue(PSZ p, int n)
/***********************************************************************/ /***********************************************************************/
/* Set one value in a block from an array of characters. */ /* Set one value in a block from an array of characters. */
/***********************************************************************/ /***********************************************************************/
void STRBLK::SetValue(char *sp, uint len, int n) void STRBLK::SetValue(const char *sp, uint len, int n)
{ {
PSZ p; PSZ p;
@@ -1352,7 +1316,7 @@ DATBLK::DATBLK(void *mp, int nval) : TYPBLK<int>(mp, nval, TYPE_INT)
/***********************************************************************/ /***********************************************************************/
/* Set format so formatted dates can be converted on input. */ /* Set format so formatted dates can be converted on input. */
/***********************************************************************/ /***********************************************************************/
bool DATBLK::SetFormat(PGLOBAL g, PSZ fmt, int len, int year) bool DATBLK::SetFormat(PGLOBAL g, PCSZ fmt, int len, int year)
{ {
if (!(Dvalp = AllocateValue(g, TYPE_DATE, len, year, false, fmt))) if (!(Dvalp = AllocateValue(g, TYPE_DATE, len, year, false, fmt)))
return true; return true;
@@ -1379,7 +1343,7 @@ char *DATBLK::GetCharString(char *p, int n)
/***********************************************************************/ /***********************************************************************/
/* Set one value in a block from a char string. */ /* Set one value in a block from a char string. */
/***********************************************************************/ /***********************************************************************/
void DATBLK::SetValue(PSZ p, int n) void DATBLK::SetValue(PCSZ p, int n)
{ {
if (Dvalp) { if (Dvalp) {
// Decode the string according to format // Decode the string according to format

View File

@@ -91,7 +91,7 @@ class VALBLK : public BLOCK {
virtual char *GetCharString(char *p, int n) = 0; virtual char *GetCharString(char *p, 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, PCSZ 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;}
@@ -105,8 +105,8 @@ class VALBLK : public BLOCK {
virtual void SetValue(double, int) {assert(false);} virtual void SetValue(double, int) {assert(false);}
virtual void SetValue(char, int) {assert(false);} virtual void SetValue(char, int) {assert(false);}
virtual void SetValue(uchar, int) {assert(false);} virtual void SetValue(uchar, int) {assert(false);}
virtual void SetValue(PSZ, int) {assert(false);} virtual void SetValue(PCSZ, int) {assert(false);}
virtual void SetValue(char *, uint, int) {assert(false);} virtual void SetValue(const char *, uint, int) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0; virtual void SetValue(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 SetMin(PVAL valp, int n) = 0; virtual void SetMin(PVAL valp, int n) = 0;
@@ -165,8 +165,8 @@ class TYPBLK : public VALBLK {
// Methods // Methods
using VALBLK::SetValue; using VALBLK::SetValue;
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PCSZ sp, int n);
virtual void SetValue(char *sp, uint len, int n); virtual void SetValue(const char *sp, uint len, int n);
virtual void SetValue(short sval, int n) virtual void SetValue(short sval, int n)
{Typp[n] = (TYPE)sval; SetNull(n, false);} {Typp[n] = (TYPE)sval; SetNull(n, false);}
virtual void SetValue(ushort sval, int n) virtual void SetValue(ushort sval, int n)
@@ -236,8 +236,8 @@ class CHRBLK : public VALBLK {
// Methods // Methods
using VALBLK::SetValue; using VALBLK::SetValue;
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PCSZ sp, int n);
virtual void SetValue(char *sp, uint len, int n); virtual void SetValue(const char *sp, uint len, int n);
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetMin(PVAL valp, int n); virtual void SetMin(PVAL valp, int n);
@@ -290,8 +290,8 @@ class STRBLK : public VALBLK {
// Methods // Methods
using VALBLK::SetValue; using VALBLK::SetValue;
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PCSZ sp, int n);
virtual void SetValue(char *sp, uint len, int n); virtual void SetValue(const char *sp, uint len, int n);
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetMin(PVAL valp, int n); virtual void SetMin(PVAL valp, int n);
@@ -322,12 +322,12 @@ class DATBLK : public TYPBLK<int> {
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, PCSZ fmt, int len, int year = 0);
virtual char *GetCharString(char *p, int n); virtual char *GetCharString(char *p, int n);
// Methods // Methods
using TYPBLK<int>::SetValue; using TYPBLK<int>::SetValue;
virtual void SetValue(PSZ sp, int n); virtual void SetValue(PCSZ sp, int n);
protected: protected:
// Members // Members
@@ -352,7 +352,7 @@ class PTRBLK : public STRBLK {
// Methods // Methods
using STRBLK::SetValue; using STRBLK::SetValue;
using STRBLK::CompVal; using STRBLK::CompVal;
virtual void SetValue(PSZ p, int n) {Strp[n] = p;} virtual void SetValue(PCSZ p, int n) {Strp[n] = (char*)p;}
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);
protected: protected:

View File

@@ -1,5 +1,5 @@
/************* Value C++ Functions Source Code File (.CPP) *************/ /************* Value C++ Functions Source Code File (.CPP) *************/
/* Name: VALUE.CPP Version 2.7 */ /* Name: VALUE.CPP Version 2.8 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2017 */ /* (C) Copyright to the author Olivier BERTRAND 2001-2017 */
/* */ /* */
@@ -57,17 +57,10 @@
/* Check macro's. */ /* Check macro's. */
/***********************************************************************/ /***********************************************************************/
#if defined(_DEBUG) #if defined(_DEBUG)
#if defined(USE_TRY)
#define CheckType(V) if (Type != V->GetType()) { \ #define CheckType(V) if (Type != V->GetType()) { \
PGLOBAL& g = Global; \ PGLOBAL& g = Global; \
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \ strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
throw Type; throw Type;
#else // !USE_TRY
#define CheckType(V) if (Type != V->GetType()) { \
PGLOBAL& g = Global; \
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
longjmp(g->jumper[g->jump_level], Type);
#endif // !USE_TRY
#else #else
#define CheckType(V) #define CheckType(V)
#endif #endif
@@ -101,10 +94,10 @@ PSZ strlwr(PSZ s);
/* OUT minus: Set to true if the number is negative */ /* OUT minus: Set to true if the number is negative */
/* Returned val: The resulting number */ /* Returned val: The resulting number */
/***********************************************************************/ /***********************************************************************/
ulonglong CharToNumber(char *p, int n, ulonglong maxval, ulonglong CharToNumber(const char *p, int n, ulonglong maxval,
bool un, bool *minus, bool *rc) bool un, bool *minus, bool *rc)
{ {
char *p2; const char *p2;
uchar c; uchar c;
ulonglong val; ulonglong val;
@@ -145,9 +138,9 @@ ulonglong CharToNumber(char *p, int n, ulonglong maxval,
/***********************************************************************/ /***********************************************************************/
/* GetTypeName: returns the PlugDB internal type name. */ /* GetTypeName: returns the PlugDB internal type name. */
/***********************************************************************/ /***********************************************************************/
PSZ GetTypeName(int type) PCSZ GetTypeName(int type)
{ {
PSZ name; PCSZ name;
switch (type) { switch (type) {
case TYPE_STRING: name = "CHAR"; break; case TYPE_STRING: name = "CHAR"; break;
@@ -191,9 +184,9 @@ int GetTypeSize(int type, int len)
/***********************************************************************/ /***********************************************************************/
/* GetFormatType: returns the FORMAT character(s) according to type. */ /* GetFormatType: returns the FORMAT character(s) according to type. */
/***********************************************************************/ /***********************************************************************/
char *GetFormatType(int type) const char *GetFormatType(int type)
{ {
char *c = "X"; const char *c = "X";
switch (type) { switch (type) {
case TYPE_STRING: c = "C"; break; case TYPE_STRING: c = "C"; break;
@@ -377,7 +370,7 @@ PVAL AllocateValue(PGLOBAL g, void *value, short type, short prec)
/* Allocate a variable Value according to type, length and precision. */ /* Allocate a variable Value according to type, length and precision. */
/***********************************************************************/ /***********************************************************************/
PVAL AllocateValue(PGLOBAL g, int type, int len, int prec, PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
bool uns, PSZ fmt) bool uns, PCSZ fmt)
{ {
PVAL valp; PVAL valp;
@@ -565,6 +558,38 @@ bool VALUE::Compute(PGLOBAL g, PVAL *, int, OPVAL)
return true; return true;
} // end of Compute } // end of Compute
/***********************************************************************/
/* Make file output of an object value. */
/***********************************************************************/
void VALUE::Print(PGLOBAL g, FILE *f, uint n)
{
char m[64], buf[64];
memset(m, ' ', n); /* Make margin string */
m[n] = '\0';
if (Null)
fprintf(f, "%s<null>\n", m);
else
fprintf(f, strcat(strcat(GetCharString(buf), "\n"), m));
} /* end of Print */
/***********************************************************************/
/* Make string output of an object value. */
/***********************************************************************/
void VALUE::Print(PGLOBAL g, char *ps, uint z)
{
char *p, buf[64];
if (Null)
p = strcpy(buf, "<null>");
else
p = GetCharString(buf);
strncpy(ps, p, z);
} // end of Print
/* -------------------------- Class TYPVAL ---------------------------- */ /* -------------------------- Class TYPVAL ---------------------------- */
/***********************************************************************/ /***********************************************************************/
@@ -689,7 +714,7 @@ uchar TYPVAL<uchar>::GetTypedValue(PVAL valp)
/* TYPVAL SetValue: convert chars extracted from a line to TYPE value.*/ /* TYPVAL SetValue: convert chars extracted from a line to TYPE value.*/
/***********************************************************************/ /***********************************************************************/
template <class TYPE> template <class TYPE>
bool TYPVAL<TYPE>::SetValue_char(char *p, int n) bool TYPVAL<TYPE>::SetValue_char(const char *p, int n)
{ {
bool rc, minus; bool rc, minus;
ulonglong maxval = MaxVal(); ulonglong maxval = MaxVal();
@@ -711,7 +736,7 @@ bool TYPVAL<TYPE>::SetValue_char(char *p, int n)
} // end of SetValue } // end of SetValue
template <> template <>
bool TYPVAL<double>::SetValue_char(char *p, int n) bool TYPVAL<double>::SetValue_char(const char *p, int n)
{ {
if (p && n > 0) { if (p && n > 0) {
char buf[64]; char buf[64];
@@ -739,7 +764,7 @@ bool TYPVAL<double>::SetValue_char(char *p, int n)
/* TYPVAL SetValue: fill a typed value from a string. */ /* TYPVAL SetValue: fill a typed value from a string. */
/***********************************************************************/ /***********************************************************************/
template <class TYPE> template <class TYPE>
void TYPVAL<TYPE>::SetValue_psz(PSZ s) void TYPVAL<TYPE>::SetValue_psz(PCSZ s)
{ {
if (s) { if (s) {
SetValue_char(s, (int)strlen(s)); SetValue_char(s, (int)strlen(s));
@@ -1026,19 +1051,11 @@ TYPE TYPVAL<TYPE>::SafeAdd(TYPE n1, TYPE n2)
if ((n2 > 0) && (n < n1)) { if ((n2 > 0) && (n < n1)) {
// Overflow // Overflow
strcpy(g->Message, MSG(FIX_OVFLW_ADD)); strcpy(g->Message, MSG(FIX_OVFLW_ADD));
#if defined(USE_TRY)
throw 138; throw 138;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 138);
#endif // !USE_TRY
} else if ((n2 < 0) && (n > n1)) { } else if ((n2 < 0) && (n > n1)) {
// Underflow // Underflow
strcpy(g->Message, MSG(FIX_UNFLW_ADD)); strcpy(g->Message, MSG(FIX_UNFLW_ADD));
#if defined(USE_TRY)
throw 138; throw 138;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 138);
#endif // !USE_TRY
} // endif's n2 } // endif's n2
return n; return n;
@@ -1062,19 +1079,11 @@ TYPE TYPVAL<TYPE>::SafeMult(TYPE n1, TYPE n2)
if (n > MinMaxVal(true)) { if (n > MinMaxVal(true)) {
// Overflow // Overflow
strcpy(g->Message, MSG(FIX_OVFLW_TIMES)); strcpy(g->Message, MSG(FIX_OVFLW_TIMES));
#if defined(USE_TRY)
throw 138; throw 138;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 138);
#endif // !USE_TRY
} else if (n < MinMaxVal(false)) { } else if (n < MinMaxVal(false)) {
// Underflow // Underflow
strcpy(g->Message, MSG(FIX_UNFLW_TIMES)); strcpy(g->Message, MSG(FIX_UNFLW_TIMES));
#if defined(USE_TRY)
throw 138; throw 138;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 138);
#endif // !USE_TRY
} // endif's n2 } // endif's n2
return (TYPE)n; return (TYPE)n;
@@ -1193,7 +1202,7 @@ bool TYPVAL<TYPE>::Compall(PGLOBAL g, PVAL *vp, int np, OPVAL op)
/* This function assumes that the format matches the value type. */ /* This function assumes that the format matches the value type. */
/***********************************************************************/ /***********************************************************************/
template <class TYPE> template <class TYPE>
bool TYPVAL<TYPE>::FormatValue(PVAL vp, char *fmt) bool TYPVAL<TYPE>::FormatValue(PVAL vp, PCSZ fmt)
{ {
char *buf = (char*)vp->GetTo_Val(); // Should be big enough char *buf = (char*)vp->GetTo_Val(); // Should be big enough
int n = sprintf(buf, fmt, Tval); int n = sprintf(buf, fmt, Tval);
@@ -1215,37 +1224,6 @@ bool TYPVAL<TYPE>::SetConstFormat(PGLOBAL g, FORMAT& fmt)
return false; return false;
} // end of SetConstFormat } // end of SetConstFormat
/***********************************************************************/
/* Make file output of a typed object. */
/***********************************************************************/
template <class TYPE>
void TYPVAL<TYPE>::Print(PGLOBAL g, FILE *f, uint n)
{
char m[64], buf[12];
memset(m, ' ', n); /* Make margin string */
m[n] = '\0';
if (Null)
fprintf(f, "%s<null>\n", m);
else
fprintf(f, strcat(strcat(strcpy(buf, "%s"), Fmt), "\n"), m, Tval);
} /* end of Print */
/***********************************************************************/
/* Make string output of a int object. */
/***********************************************************************/
template <class TYPE>
void TYPVAL<TYPE>::Print(PGLOBAL g, char *ps, uint z)
{
if (Null)
strcpy(ps, "<null>");
else
sprintf(ps, Fmt, Tval);
} /* end of Print */
/* -------------------------- Class STRING --------------------------- */ /* -------------------------- Class STRING --------------------------- */
/***********************************************************************/ /***********************************************************************/
@@ -1384,25 +1362,25 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
/***********************************************************************/ /***********************************************************************/
/* STRING SetValue: fill string with chars extracted from a line. */ /* STRING SetValue: fill string with chars extracted from a line. */
/***********************************************************************/ /***********************************************************************/
bool TYPVAL<PSZ>::SetValue_char(char *p, int n) bool TYPVAL<PSZ>::SetValue_char(const char *cp, int n)
{ {
bool rc = false; bool rc = false;
if (!p || n == 0) { if (!cp || n == 0) {
Reset(); Reset();
Null = Nullable; Null = Nullable;
} else if (p != Strp) { } else if (cp != Strp) {
rc = n > Len; const char *p = cp + n - 1;
if ((n = MY_MIN(n, Len))) { for (p; p >= cp; p--, n--)
strncpy(Strp, p, n);
// for (p = Strp + n - 1; p >= Strp && (*p == ' ' || *p == '\0'); p--) ;
for (p = Strp + n - 1; p >= Strp; p--)
if (*p && *p != ' ') if (*p && *p != ' ')
break; break;
*(++p) = '\0'; rc = n > Len;
if ((n = MY_MIN(n, Len))) {
strncpy(Strp, cp, n);
Strp[n] = '\0';
if (trace > 1) if (trace > 1)
htrc(" Setting string to: '%s'\n", Strp); htrc(" Setting string to: '%s'\n", Strp);
@@ -1419,7 +1397,7 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n)
/***********************************************************************/ /***********************************************************************/
/* STRING SetValue: fill string with another string. */ /* STRING SetValue: fill string with another string. */
/***********************************************************************/ /***********************************************************************/
void TYPVAL<PSZ>::SetValue_psz(PSZ s) void TYPVAL<PSZ>::SetValue_psz(PCSZ s)
{ {
if (!s) { if (!s) {
Reset(); Reset();
@@ -1455,15 +1433,7 @@ void TYPVAL<PSZ>::SetValue(int n)
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
#if defined(USE_TRY)
throw 138; throw 138;
#else // !USE_TRY
#if defined(USE_TRY)
throw 138;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 138);
#endif // !USE_TRY
#endif // !USE_TRY
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1517,11 +1487,7 @@ void TYPVAL<PSZ>::SetValue(longlong n)
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
#if defined(USE_TRY)
throw 138; throw 138;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 138);
#endif // !USE_TRY
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1564,11 +1530,7 @@ void TYPVAL<PSZ>::SetValue(double f)
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
#if defined(USE_TRY)
throw 138; throw 138;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 138);
#endif // !USE_TRY
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1598,7 +1560,7 @@ void TYPVAL<PSZ>::SetValue(uchar c)
/***********************************************************************/ /***********************************************************************/
void TYPVAL<PSZ>::SetBinValue(void *p) void TYPVAL<PSZ>::SetBinValue(void *p)
{ {
SetValue_char((char *)p, Len); SetValue_char((const char *)p, Len);
} // end of SetBinValue } // end of SetBinValue
/***********************************************************************/ /***********************************************************************/
@@ -1728,7 +1690,7 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
/* constructed from its own value formated using the fmt format. */ /* constructed from its own value formated using the fmt format. */
/* This function assumes that the format matches the value type. */ /* This function assumes that the format matches the value type. */
/***********************************************************************/ /***********************************************************************/
bool TYPVAL<PSZ>::FormatValue(PVAL vp, char *fmt) bool TYPVAL<PSZ>::FormatValue(PVAL vp, PCSZ fmt)
{ {
char *buf = (char*)vp->GetTo_Val(); // Should be big enough char *buf = (char*)vp->GetTo_Val(); // Should be big enough
int n = sprintf(buf, fmt, Strp); int n = sprintf(buf, fmt, Strp);
@@ -1747,6 +1709,18 @@ bool TYPVAL<PSZ>::SetConstFormat(PGLOBAL, FORMAT& fmt)
return false; return false;
} // end of SetConstFormat } // end of SetConstFormat
/***********************************************************************/
/* Make string output of an object value. */
/***********************************************************************/
void TYPVAL<PSZ>::Print(PGLOBAL g, char *ps, uint z)
{
if (Null)
strncpy(ps, "null", z);
else
strcat(strncat(strncpy(ps, "\"", z), Strp, z-2), "\"");
} // end of Print
/* -------------------------- Class DECIMAL -------------------------- */ /* -------------------------- Class DECIMAL -------------------------- */
/***********************************************************************/ /***********************************************************************/
@@ -1836,102 +1810,6 @@ bool DECVAL::GetBinValue(void *buf, int buflen, bool go)
return false; return false;
} // end of GetBinValue } // end of GetBinValue
#if 0
/***********************************************************************/
/* DECIMAL SetValue: copy the value of another Value object. */
/***********************************************************************/
bool DECVAL::SetValue_pval(PVAL valp, bool chktype)
{
if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
return true;
char buf[64];
if (!(Null = valp->IsNull() && Nullable))
strncpy(Strp, valp->GetCharString(buf), Len);
else
Reset();
return false;
} // end of SetValue_pval
/***********************************************************************/
/* DECIMAL SetValue: fill string with chars extracted from a line. */
/***********************************************************************/
bool DECVAL::SetValue_char(char *p, int n)
{
bool rc;
if (p && n > 0) {
rc = n > Len;
if ((n = MY_MIN(n, Len))) {
strncpy(Strp, p, n);
// for (p = Strp + n - 1; p >= Strp && (*p == ' ' || *p == '\0'); p--) ;
for (p = Strp + n - 1; p >= Strp; p--)
if (*p && *p != ' ')
break;
*(++p) = '\0';
if (trace > 1)
htrc(" Setting string to: '%s'\n", Strp);
} else
Reset();
Null = false;
} else {
rc = false;
Reset();
Null = Nullable;
} // endif p
return rc;
} // end of SetValue_char
/***********************************************************************/
/* DECIMAL SetValue: fill string with another string. */
/***********************************************************************/
void DECVAL::SetValue_psz(PSZ s)
{
if (s) {
strncpy(Strp, s, Len);
Null = false;
} else {
Reset();
Null = Nullable;
} // endif s
} // end of SetValue_psz
/***********************************************************************/
/* DECIMAL SetValue: fill string with a string extracted from a block.*/
/***********************************************************************/
void DECVAL::SetValue_pvblk(PVBLK blk, int n)
{
// STRBLK's can return a NULL pointer
SetValue_psz(blk->GetCharValue(n));
} // end of SetValue_pvblk
/***********************************************************************/
/* DECIMAL SetBinValue: fill string with chars extracted from a line. */
/***********************************************************************/
void DECVAL::SetBinValue(void *p)
{
SetValue_char((char *)p, Len);
} // end of SetBinValue
/***********************************************************************/
/* DECIMAL GetCharString: get string representation of a char value. */
/***********************************************************************/
char *DECVAL::GetCharString(char *p)
{
return Strp;
} // end of GetCharString
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* DECIMAL compare value with another Value. */ /* DECIMAL compare value with another Value. */
/***********************************************************************/ /***********************************************************************/
@@ -1966,32 +1844,6 @@ int DECVAL::CompareValue(PVAL vp)
return (f > n) ? 1 : (f < n) ? (-1) : 0; return (f > n) ? 1 : (f < n) ? (-1) : 0;
} // end of CompareValue } // end of CompareValue
#if 0
/***********************************************************************/
/* FormatValue: This function set vp (a STRING value) to the string */
/* constructed from its own value formated using the fmt format. */
/* This function assumes that the format matches the value type. */
/***********************************************************************/
bool DECVAL::FormatValue(PVAL vp, char *fmt)
{
char *buf = (char*)vp->GetTo_Val(); // Should be big enough
int n = sprintf(buf, fmt, Strp);
return (n > vp->GetValLen());
} // end of FormatValue
/***********************************************************************/
/* DECIMAL SetFormat function (used to set SELECT output format). */
/***********************************************************************/
bool DECVAL::SetConstFormat(PGLOBAL g, FORMAT& fmt)
{
fmt.Type[0] = 'C';
fmt.Length = Len;
fmt.Prec = 0;
return false;
} // end of SetConstFormat
#endif // 0
/* -------------------------- Class BINVAL --------------------------- */ /* -------------------------- Class BINVAL --------------------------- */
/***********************************************************************/ /***********************************************************************/
@@ -2149,7 +2001,7 @@ bool BINVAL::SetValue_pval(PVAL valp, bool chktype)
/***********************************************************************/ /***********************************************************************/
/* BINVAL SetValue: fill value with chars extracted from a line. */ /* BINVAL SetValue: fill value with chars extracted from a line. */
/***********************************************************************/ /***********************************************************************/
bool BINVAL::SetValue_char(char *p, int n) bool BINVAL::SetValue_char(const char *p, int n)
{ {
bool rc; bool rc;
@@ -2170,7 +2022,7 @@ bool BINVAL::SetValue_char(char *p, int n)
/***********************************************************************/ /***********************************************************************/
/* BINVAL SetValue: fill value with another string. */ /* BINVAL SetValue: fill value with another string. */
/***********************************************************************/ /***********************************************************************/
void BINVAL::SetValue_psz(PSZ s) void BINVAL::SetValue_psz(PCSZ s)
{ {
if (s) { if (s) {
Len = MY_MIN(Clen, (signed)strlen(s)); Len = MY_MIN(Clen, (signed)strlen(s));
@@ -2396,7 +2248,7 @@ bool BINVAL::IsEqual(PVAL vp, bool chktype)
/* constructed from its own value formated using the fmt format. */ /* constructed from its own value formated using the fmt format. */
/* This function assumes that the format matches the value type. */ /* This function assumes that the format matches the value type. */
/***********************************************************************/ /***********************************************************************/
bool BINVAL::FormatValue(PVAL vp, char *fmt) bool BINVAL::FormatValue(PVAL vp, PCSZ fmt)
{ {
char *buf = (char*)vp->GetTo_Val(); // Should be big enough char *buf = (char*)vp->GetTo_Val(); // Should be big enough
int n = sprintf(buf, fmt, Len, Binp); int n = sprintf(buf, fmt, Len, Binp);
@@ -2420,7 +2272,7 @@ bool BINVAL::SetConstFormat(PGLOBAL, FORMAT& fmt)
/***********************************************************************/ /***********************************************************************/
/* DTVAL public constructor for new void values. */ /* DTVAL public constructor for new void values. */
/***********************************************************************/ /***********************************************************************/
DTVAL::DTVAL(PGLOBAL g, int n, int prec, PSZ fmt) DTVAL::DTVAL(PGLOBAL g, int n, int prec, PCSZ fmt)
: TYPVAL<int>((int)0, TYPE_DATE) : TYPVAL<int>((int)0, TYPE_DATE)
{ {
if (!fmt) { if (!fmt) {
@@ -2449,7 +2301,7 @@ DTVAL::DTVAL(int n) : TYPVAL<int>(n, TYPE_DATE)
/***********************************************************************/ /***********************************************************************/
/* Set format so formatted dates can be converted on input/output. */ /* Set format so formatted dates can be converted on input/output. */
/***********************************************************************/ /***********************************************************************/
bool DTVAL::SetFormat(PGLOBAL g, PSZ fmt, int len, int year) bool DTVAL::SetFormat(PGLOBAL g, PCSZ fmt, int len, int year)
{ {
Pdtp = MakeDateFormat(g, fmt, true, true, (year > 9999) ? 1 : 0); Pdtp = MakeDateFormat(g, fmt, true, true, (year > 9999) ? 1 : 0);
Sdate = (char*)PlugSubAlloc(g, NULL, len + 1); Sdate = (char*)PlugSubAlloc(g, NULL, len + 1);
@@ -2707,6 +2559,10 @@ bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
ndv = ExtractDate(valp->GetCharValue(), Pdtp, DefYear, dval); ndv = ExtractDate(valp->GetCharValue(), Pdtp, DefYear, dval);
MakeDate(NULL, dval, ndv); MakeDate(NULL, dval, ndv);
} else if (valp->GetType() == TYPE_BIGINT &&
!(valp->GetBigintValue() % 1000)) {
// Assuming that this timestamp is in milliseconds
Tval = valp->GetBigintValue() / 1000;
} else } else
Tval = valp->GetIntValue(); Tval = valp->GetIntValue();
@@ -2721,12 +2577,12 @@ bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
/***********************************************************************/ /***********************************************************************/
/* SetValue: convert chars extracted from a line to date value. */ /* SetValue: convert chars extracted from a line to date value. */
/***********************************************************************/ /***********************************************************************/
bool DTVAL::SetValue_char(char *p, int n) bool DTVAL::SetValue_char(const char *p, int n)
{ {
bool rc= 0; bool rc= 0;
if (Pdtp) { if (Pdtp) {
char *p2; const char *p2;
int ndv; int ndv;
int dval[6]; int dval[6];
@@ -2760,7 +2616,7 @@ bool DTVAL::SetValue_char(char *p, int n)
/***********************************************************************/ /***********************************************************************/
/* SetValue: convert a char string to date value. */ /* SetValue: convert a char string to date value. */
/***********************************************************************/ /***********************************************************************/
void DTVAL::SetValue_psz(PSZ p) void DTVAL::SetValue_psz(PCSZ p)
{ {
if (Pdtp) { if (Pdtp) {
int ndv; int ndv;
@@ -2854,8 +2710,10 @@ char *DTVAL::ShowValue(char *buf, int len)
strncat(p, "Error", m); strncat(p, "Error", m);
} // endif n } // endif n
} else } else {
p = ""; // DEFAULT VALUE ??? p = buf;
*p = '\0'; // DEFAULT VALUE ???
} // endif Null
return p; return p;
} else } else
@@ -2920,7 +2778,7 @@ bool DTVAL::WeekNum(PGLOBAL g, int& nval)
/* constructed from its own value formated using the fmt format. */ /* constructed from its own value formated using the fmt format. */
/* This function assumes that the format matches the value type. */ /* This function assumes that the format matches the value type. */
/***********************************************************************/ /***********************************************************************/
bool DTVAL::FormatValue(PVAL vp, char *fmt) bool DTVAL::FormatValue(PVAL vp, PCSZ fmt)
{ {
char *buf = (char*)vp->GetTo_Val(); // Should be big enough char *buf = (char*)vp->GetTo_Val(); // Should be big enough
struct tm tm, *ptm = GetGmTime(&tm); struct tm tm, *ptm = GetGmTime(&tm);

View File

@@ -1,7 +1,7 @@
/**************** Value H Declares Source Code File (.H) ***************/ /**************** Value H Declares Source Code File (.H) ***************/
/* Name: VALUE.H Version 2.2 */ /* Name: VALUE.H Version 2.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2016 */ /* (C) Copyright to the author Olivier BERTRAND 2001-2017 */
/* */ /* */
/* This file contains the VALUE and derived classes declares. */ /* This file contains the VALUE and derived classes declares. */
/***********************************************************************/ /***********************************************************************/
@@ -40,14 +40,14 @@ typedef struct _datpar *PDTP; // For DTVAL
/* Utilities used to test types and to allocated values. */ /* Utilities used to test types and to allocated values. */
/***********************************************************************/ /***********************************************************************/
// Exported functions // Exported functions
DllExport PSZ GetTypeName(int); DllExport PCSZ GetTypeName(int);
DllExport int GetTypeSize(int, int); DllExport int GetTypeSize(int, int);
#ifdef ODBC_SUPPORT #ifdef ODBC_SUPPORT
/* This function is exported for use in OEM table type DLLs */ /* This function is exported for use in OEM table type DLLs */
DllExport int TranslateSQLType(int stp, int prec, DllExport int TranslateSQLType(int stp, int prec,
int& len, char& v, bool& w); int& len, char& v, bool& w);
#endif #endif
DllExport char *GetFormatType(int); DllExport const char *GetFormatType(int);
DllExport int GetFormatType(char); DllExport int GetFormatType(char);
DllExport bool IsTypeChar(int type); DllExport bool IsTypeChar(int type);
DllExport bool IsTypeNum(int type); DllExport bool IsTypeNum(int type);
@@ -55,8 +55,8 @@ DllExport int ConvertType(int, int, CONV, bool match = false);
DllExport PVAL AllocateValue(PGLOBAL, void *, short, short = 2); DllExport PVAL AllocateValue(PGLOBAL, void *, short, short = 2);
DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0); DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0);
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0, DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0,
bool uns = false, PSZ fmt = NULL); bool uns = false, PCSZ fmt = NULL);
DllExport ulonglong CharToNumber(char *, int, ulonglong, bool, DllExport ulonglong CharToNumber(PCSZ, int, ulonglong, bool,
bool *minus = NULL, bool *rc = NULL); bool *minus = NULL, bool *rc = NULL);
DllExport BYTE OpBmp(PGLOBAL g, OPVAL opc); DllExport BYTE OpBmp(PGLOBAL g, OPVAL opc);
@@ -100,8 +100,8 @@ class DllExport VALUE : public BLOCK {
// Methods // Methods
virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0; virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0;
virtual bool SetValue_char(char *p, int n) = 0; virtual bool SetValue_char(const char *p, int n) = 0;
virtual void SetValue_psz(PSZ s) = 0; virtual void SetValue_psz(PCSZ s) = 0;
virtual void SetValue_bool(bool) {assert(FALSE);} virtual void SetValue_bool(bool) {assert(FALSE);}
virtual int CompareValue(PVAL vp) = 0; virtual int CompareValue(PVAL vp) = 0;
virtual BYTE TestValue(PVAL vp); virtual BYTE TestValue(PVAL vp);
@@ -121,7 +121,9 @@ class DllExport VALUE : public BLOCK {
virtual char *GetCharString(char *p) = 0; virtual char *GetCharString(char *p) = 0;
virtual bool IsEqual(PVAL vp, bool chktype) = 0; virtual bool IsEqual(PVAL vp, bool chktype) = 0;
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op); virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual bool FormatValue(PVAL vp, char *fmt) = 0; virtual bool FormatValue(PVAL vp, PCSZ fmt) = 0;
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *ps, uint z);
/** /**
Set value from a non-aligned in-memory value in the machine byte order. Set value from a non-aligned in-memory value in the machine byte order.
@@ -211,8 +213,8 @@ class DllExport TYPVAL : public VALUE {
// Methods // Methods
virtual bool SetValue_pval(PVAL valp, bool chktype); virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual bool SetValue_char(char *p, int n); virtual bool SetValue_char(const char *p, int n);
virtual void SetValue_psz(PSZ s); virtual void SetValue_psz(PCSZ s);
virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;} virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;}
virtual int CompareValue(PVAL vp); virtual int CompareValue(PVAL vp);
virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;} virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;}
@@ -232,9 +234,7 @@ class DllExport TYPVAL : public VALUE {
virtual bool IsEqual(PVAL vp, bool chktype); virtual bool IsEqual(PVAL vp, bool chktype);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op); virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual bool SetConstFormat(PGLOBAL, FORMAT&); virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool FormatValue(PVAL vp, char *fmt); virtual bool FormatValue(PVAL vp, PCSZ fmt);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
protected: protected:
static TYPE MinMaxVal(bool b); static TYPE MinMaxVal(bool b);
@@ -287,8 +287,8 @@ class DllExport TYPVAL<PSZ>: public VALUE {
// Methods // Methods
virtual bool SetValue_pval(PVAL valp, bool chktype); virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual bool SetValue_char(char *p, int n); virtual bool SetValue_char(const char *p, int n);
virtual void SetValue_psz(PSZ s); virtual void SetValue_psz(PCSZ s);
virtual void SetValue_pvblk(PVBLK blk, int n); virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetValue(char c); virtual void SetValue(char c);
virtual void SetValue(uchar c); virtual void SetValue(uchar c);
@@ -306,8 +306,9 @@ class DllExport TYPVAL<PSZ>: public VALUE {
virtual char *GetCharString(char *p); virtual char *GetCharString(char *p);
virtual bool IsEqual(PVAL vp, bool chktype); virtual bool IsEqual(PVAL vp, bool chktype);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op); virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual bool FormatValue(PVAL vp, char *fmt); virtual bool FormatValue(PVAL vp, PCSZ fmt);
virtual bool SetConstFormat(PGLOBAL, FORMAT&); virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual void Print(PGLOBAL g, char *ps, uint z);
protected: protected:
// Members // Members
@@ -371,8 +372,8 @@ class DllExport BINVAL: public VALUE {
// Methods // Methods
virtual bool SetValue_pval(PVAL valp, bool chktype); virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual bool SetValue_char(char *p, int n); virtual bool SetValue_char(const char *p, int n);
virtual void SetValue_psz(PSZ s); virtual void SetValue_psz(PCSZ s);
virtual void SetValue_pvblk(PVBLK blk, int n); virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetValue(char c); virtual void SetValue(char c);
virtual void SetValue(uchar c); virtual void SetValue(uchar c);
@@ -389,7 +390,7 @@ class DllExport BINVAL: public VALUE {
virtual char *ShowValue(char *buf, int); virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p); virtual char *GetCharString(char *p);
virtual bool IsEqual(PVAL vp, bool chktype); virtual bool IsEqual(PVAL vp, bool chktype);
virtual bool FormatValue(PVAL vp, char *fmt); virtual bool FormatValue(PVAL vp, PCSZ fmt);
virtual bool SetConstFormat(PGLOBAL, FORMAT&); virtual bool SetConstFormat(PGLOBAL, FORMAT&);
protected: protected:
@@ -405,18 +406,18 @@ class DllExport BINVAL: public VALUE {
class DllExport DTVAL : public TYPVAL<int> { class DllExport DTVAL : public TYPVAL<int> {
public: public:
// Constructors // Constructors
DTVAL(PGLOBAL g, int n, int p, PSZ fmt); DTVAL(PGLOBAL g, int n, int p, PCSZ fmt);
DTVAL(int n); DTVAL(int n);
// Implementation // Implementation
virtual bool SetValue_pval(PVAL valp, bool chktype); virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual bool SetValue_char(char *p, int n); virtual bool SetValue_char(const char *p, int n);
virtual void SetValue_psz(PSZ s); virtual void SetValue_psz(PCSZ s);
virtual void SetValue_pvblk(PVBLK blk, int n); virtual void SetValue_pvblk(PVBLK blk, int n);
virtual char *GetCharString(char *p); virtual char *GetCharString(char *p);
virtual char *ShowValue(char *buf, int); virtual char *ShowValue(char *buf, int);
virtual bool FormatValue(PVAL vp, char *fmt); virtual bool FormatValue(PVAL vp, PCSZ fmt);
bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); bool SetFormat(PGLOBAL g, PCSZ fmt, int len, int year = 0);
bool SetFormat(PGLOBAL g, PVAL valp); bool SetFormat(PGLOBAL g, PVAL valp);
bool IsFormatted(void) {return Pdtp != NULL;} bool IsFormatted(void) {return Pdtp != NULL;}
bool MakeTime(struct tm *ptm); bool MakeTime(struct tm *ptm);

View File

@@ -446,11 +446,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
#if 0 #if 0
if (!dup->Step) { if (!dup->Step) {
strcpy(g->Message, MSG(QUERY_CANCELLED)); strcpy(g->Message, MSG(QUERY_CANCELLED));
#if defined(USE_TRY)
throw 99; throw 99;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], 99);
#endif // !USE_TRY
} // endif Step } // endif Step
#endif // 0 #endif // 0
@@ -823,7 +819,7 @@ bool XINDEX::Reorder(PGLOBAL g __attribute__((unused)))
/***********************************************************************/ /***********************************************************************/
bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
{ {
char *ftype; PCSZ ftype;
char fn[_MAX_PATH]; char fn[_MAX_PATH];
int n[NZ], nof = (Mul) ? (Ndif + 1) : 0; int n[NZ], nof = (Mul) ? (Ndif + 1) : 0;
int id = -1, size = 0; int id = -1, size = 0;
@@ -952,7 +948,7 @@ bool XINDEX::Init(PGLOBAL g)
/* Table will be accessed through an index table. */ /* Table will be accessed through an index table. */
/* If sorting is required, this will be done later. */ /* If sorting is required, this will be done later. */
/*********************************************************************/ /*********************************************************************/
char *ftype; PCSZ ftype;
char fn[_MAX_PATH]; char fn[_MAX_PATH];
int k, n, nv[NZ], id = -1; int k, n, nv[NZ], id = -1;
bool estim = false; bool estim = false;
@@ -1416,7 +1412,7 @@ err:
/***********************************************************************/ /***********************************************************************/
bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk) bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk)
{ {
char *ftype; PCSZ ftype;
char fn[_MAX_PATH]; char fn[_MAX_PATH];
int nv[NZ], id = -1; // n int nv[NZ], id = -1; // n
//bool estim = false; //bool estim = false;
@@ -2324,7 +2320,7 @@ XFILE::XFILE(void) : XLOAD()
/***********************************************************************/ /***********************************************************************/
bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
{ {
char *pmod; PCSZ pmod;
bool rc; bool rc;
IOFF noff[MAX_INDX]; IOFF noff[MAX_INDX];
@@ -3036,7 +3032,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
return true; return true;
Klen = Valp->GetClen(); Klen = Valp->GetClen();
Keys.Size = n * Klen; Keys.Size = (size_t)n * (size_t)Klen;
if (!PlgDBalloc(g, NULL, Keys)) { if (!PlgDBalloc(g, NULL, Keys)) {
sprintf(g->Message, MSG(KEY_ALLOC_ERROR), Klen, n); sprintf(g->Message, MSG(KEY_ALLOC_ERROR), Klen, n);

View File

@@ -84,11 +84,7 @@ double XOBJECT::GetFloatValue(void)
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)))
#if defined(USE_TRY)
throw TYPE_CONST; throw TYPE_CONST;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_CONST);
#endif // !USE_TRY
Constant = true; Constant = true;
} // end of CONSTANT constructor } // end of CONSTANT constructor
@@ -99,11 +95,7 @@ CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
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)))
#if defined(USE_TRY)
throw TYPE_CONST; throw TYPE_CONST;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_CONST);
#endif // !USE_TRY
Constant = true; Constant = true;
} // end of CONSTANT constructor } // end of CONSTANT constructor
@@ -125,11 +117,7 @@ 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)))
#if defined(USE_TRY)
throw TYPE_CONST; throw TYPE_CONST;
#else // !USE_TRY
longjmp(g->jumper[g->jump_level], TYPE_CONST);
#endif // !USE_TRY
} // end of Convert } // end of Convert
@@ -204,7 +192,7 @@ void CONSTANT::Print(PGLOBAL g, char *ps, uint z)
/* STRING public constructor for new char values. Alloc Size must be */ /* STRING public constructor for new char values. Alloc Size must be */
/* calculated because PlugSubAlloc rounds up size to multiple of 8. */ /* calculated because PlugSubAlloc rounds up size to multiple of 8. */
/***********************************************************************/ /***********************************************************************/
STRING::STRING(PGLOBAL g, uint n, char *str) STRING::STRING(PGLOBAL g, uint n, PCSZ str)
{ {
G = g; G = g;
Length = (str) ? strlen(str) : 0; Length = (str) ? strlen(str) : 0;
@@ -217,10 +205,12 @@ STRING::STRING(PGLOBAL g, uint n, char *str)
Next = GetNext(); Next = GetNext();
Size = Next - Strp; Size = Next - Strp;
Trc = false;
} else { } else {
// This should normally never happen // This should normally never happen
Next = NULL; Next = NULL;
Size = 0; Size = 0;
Trc = true;
} // endif Strp } // endif Strp
} // end of STRING constructor } // end of STRING constructor
@@ -241,6 +231,7 @@ char *STRING::Realloc(uint len)
if (!p) { if (!p) {
// No more room in Sarea; this is very unlikely // No more room in Sarea; this is very unlikely
strcpy(G->Message, "No more room in work area"); strcpy(G->Message, "No more room in work area");
Trc = true;
return NULL; return NULL;
} // endif p } // endif p
@@ -255,7 +246,7 @@ char *STRING::Realloc(uint len)
/***********************************************************************/ /***********************************************************************/
/* Set a STRING new PSZ value. */ /* Set a STRING new PSZ value. */
/***********************************************************************/ /***********************************************************************/
bool STRING::Set(PSZ s) bool STRING::Set(PCSZ s)
{ {
if (!s) if (!s)
return false; return false;
@@ -345,9 +336,9 @@ bool STRING::Append(const char *s, uint ln, bool nq)
} // end of Append } // end of Append
/***********************************************************************/ /***********************************************************************/
/* Append a PSZ to a STRING. */ /* Append a PCSZ to a STRING. */
/***********************************************************************/ /***********************************************************************/
bool STRING::Append(PSZ s) bool STRING::Append(PCSZ s)
{ {
if (!s) if (!s)
return false; return false;
@@ -404,11 +395,11 @@ bool STRING::Append(char c)
/***********************************************************************/ /***********************************************************************/
/* Append a quoted PSZ to a STRING. */ /* Append a quoted PSZ to a STRING. */
/***********************************************************************/ /***********************************************************************/
bool STRING::Append_quoted(PSZ s) bool STRING::Append_quoted(PCSZ s)
{ {
bool b = Append('\''); bool b = Append('\'');
if (s) for (char *p = s; !b && *p; p++) if (s) for (const char *p = s; !b && *p; p++)
switch (*p) { switch (*p) {
case '\'': case '\'':
case '\\': case '\\':

View File

@@ -123,24 +123,25 @@ class DllExport CONSTANT : public XOBJECT {
class DllExport STRING : public BLOCK { class DllExport STRING : public BLOCK {
public: public:
// Constructor // Constructor
STRING(PGLOBAL g, uint n, PSZ str = NULL); STRING(PGLOBAL g, uint n, PCSZ str = NULL);
// Implementation // Implementation
inline int GetLength(void) {return (int)Length;} inline int GetLength(void) {return (int)Length;}
inline void SetLength(uint n) {Length = n;} inline void SetLength(uint n) {Length = n;}
inline PSZ GetStr(void) {return Strp;} inline PSZ GetStr(void) {return Strp;}
inline uint32 GetSize(void) {return Size;} inline uint32 GetSize(void) {return Size;}
inline bool IsTruncated(void) {return Trc;}
// Methods // Methods
inline void Reset(void) {*Strp = 0;} inline void Reset(void) {*Strp = 0;}
bool Set(PSZ s); bool Set(PCSZ s);
bool Set(char *s, uint n); bool Set(char *s, uint n);
bool Append(const char *s, uint ln, bool nq = false); bool Append(const char *s, uint ln, bool nq = false);
bool Append(PSZ s); bool Append(PCSZ s);
bool Append(STRING &str); bool Append(STRING &str);
bool Append(char c); bool Append(char c);
bool Resize(uint n); bool Resize(uint n);
bool Append_quoted(PSZ s); bool Append_quoted(PCSZ s);
inline void Trim(void) {(void)Resize(Length + 1);} inline void Trim(void) {(void)Resize(Length + 1);}
inline void Chop(void) {if (Length) Strp[--Length] = 0;} inline void Chop(void) {if (Length) Strp[--Length] = 0;}
inline void RepLast(char c) {if (Length) Strp[Length-1] = c;} inline void RepLast(char c) {if (Length) Strp[Length-1] = c;}
@@ -156,6 +157,7 @@ class DllExport STRING : public BLOCK {
PSZ Strp; // The char string PSZ Strp; // The char string
uint Length; // String length uint Length; // String length
uint Size; // Allocated size uint Size; // Allocated size
bool Trc; // When truncated
char *Next; // Next alloc position char *Next; // Next alloc position
}; // end of class STRING }; // end of class STRING

View File

@@ -33,29 +33,6 @@ class CMD : public BLOCK {
char *Cmd; char *Cmd;
}; // end of class CMD }; // end of class CMD
#if 0
// Condition filter structure
class CONDFIL : public BLOCK {
public:
// Constructor
CONDFIL(const Item *cond, uint idx, AMT type)
{
Cond = cond; Idx = idx; Type = type; Op = OP_XX;
Cmds = NULL; All = true; Body = NULL, Having = NULL;
}
// Members
const Item *Cond;
AMT Type;
uint Idx;
OPVAL Op;
PCMD Cmds;
bool All;
char *Body;
char *Having;
}; // end of class CONDFIL
#endif // 0
typedef class EXTCOL *PEXTCOL; typedef class EXTCOL *PEXTCOL;
typedef class CONDFIL *PCFIL; typedef class CONDFIL *PCFIL;
typedef class TDBCAT *PTDBCAT; typedef class TDBCAT *PTDBCAT;
@@ -84,7 +61,6 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
inline PFIL GetFilter(void) {return To_Filter;} inline PFIL GetFilter(void) {return To_Filter;}
inline PCOL GetSetCols(void) {return To_SetCols;} inline PCOL GetSetCols(void) {return To_SetCols;}
inline void SetSetCols(PCOL colp) {To_SetCols = colp;} inline void SetSetCols(PCOL colp) {To_SetCols = colp;}
inline void SetFilter(PFIL fp) {To_Filter = fp;}
inline void SetOrig(PTDB txp) {To_Orig = txp;} inline void SetOrig(PTDB txp) {To_Orig = txp;}
inline void SetUse(TUSE n) {Use = n;} inline void SetUse(TUSE n) {Use = n;}
inline void SetCondFil(PCFIL cfp) {To_CondFil = cfp;} inline void SetCondFil(PCFIL cfp) {To_CondFil = cfp;}
@@ -94,11 +70,14 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
inline void SetColumns(PCOL colp) {Columns = colp;} inline void SetColumns(PCOL colp) {Columns = colp;}
inline void SetDegree(int degree) {Degree = degree;} inline void SetDegree(int degree) {Degree = degree;}
inline void SetMode(MODE mode) {Mode = mode;} inline void SetMode(MODE mode) {Mode = mode;}
inline const Item *GetCond(void) {return Cond;}
inline void SetCond(const Item *cond) {Cond = cond;}
// Properties // Properties
virtual AMT GetAmType(void) {return TYPE_AM_ERROR;} virtual AMT GetAmType(void) {return TYPE_AM_ERROR;}
virtual bool IsRemote(void) {return false;} virtual bool IsRemote(void) {return false;}
virtual bool IsIndexed(void) {return false;} virtual bool IsIndexed(void) {return false;}
virtual void SetFilter(PFIL fp) {To_Filter = fp;}
virtual int GetTdb_No(void) {return Tdb_No;} virtual int GetTdb_No(void) {return Tdb_No;}
virtual PTDB GetNext(void) {return Next;} virtual PTDB GetNext(void) {return Next;}
virtual PCATLG GetCat(void) {return NULL;} virtual PCATLG GetCat(void) {return NULL;}
@@ -110,7 +89,7 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
virtual bool IsSpecial(PSZ name); virtual bool IsSpecial(PSZ name);
virtual bool IsReadOnly(void) {return Read_Only;} virtual bool IsReadOnly(void) {return Read_Only;}
virtual bool IsView(void) {return FALSE;} virtual bool IsView(void) {return FALSE;}
virtual PSZ GetPath(void); virtual PCSZ GetPath(void);
virtual RECFM GetFtype(void) {return RECFM_NAF;} virtual RECFM GetFtype(void) {return RECFM_NAF;}
virtual bool GetBlockValues(PGLOBAL) { return false; } virtual bool GetBlockValues(PGLOBAL) { return false; }
virtual int Cardinality(PGLOBAL) {return 0;} virtual int Cardinality(PGLOBAL) {return 0;}
@@ -119,11 +98,12 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
virtual int GetMaxSize(PGLOBAL) = 0; virtual int GetMaxSize(PGLOBAL) = 0;
virtual int GetProgMax(PGLOBAL) = 0; virtual int GetProgMax(PGLOBAL) = 0;
virtual int GetProgCur(void) {return GetRecpos();} virtual int GetProgCur(void) {return GetRecpos();}
virtual PSZ GetFile(PGLOBAL) {return "Not a file";} virtual PCSZ GetFile(PGLOBAL) {return "Not a file";}
virtual void SetFile(PGLOBAL, PSZ) {} virtual void SetFile(PGLOBAL, PCSZ) {}
virtual void ResetDB(void) {} virtual void ResetDB(void) {}
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);
virtual bool CanBeFiltered(void) {return true;}
virtual PTDB Duplicate(PGLOBAL) {return NULL;} virtual PTDB Duplicate(PGLOBAL) {return NULL;}
virtual PTDB Clone(PTABS) {return this;} virtual PTDB Clone(PTABS) {return this;}
virtual PTDB Copy(PTABS t); virtual PTDB Copy(PTABS t);
@@ -131,7 +111,7 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
{fprintf(f, "%s AM(%d)\n", m, GetAmType());} {fprintf(f, "%s AM(%d)\n", m, GetAmType());}
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 PSZ GetServer(void) = 0; virtual PCSZ GetServer(void) = 0;
virtual int GetBadLines(void) {return 0;} virtual int GetBadLines(void) {return 0;}
virtual CHARSET_INFO *data_charset(void); virtual CHARSET_INFO *data_charset(void);
@@ -157,6 +137,7 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
TUSE Use; TUSE Use;
PFIL To_Filter; PFIL To_Filter;
PCFIL To_CondFil; // To condition filter structure PCFIL To_CondFil; // To condition filter structure
const Item *Cond; // The condition used to make filters
static int Tnum; // Used to generate Tdb_no's static int Tnum; // Used to generate Tdb_no's
const int Tdb_No; // GetTdb_No() is always 0 for OPJOIN const int Tdb_No; // GetTdb_No() is always 0 for OPJOIN
PTDB Next; // Next in linearized queries PTDB Next; // Next in linearized queries
@@ -187,9 +168,6 @@ class DllExport TDBASE : public TDB {
// Implementation // Implementation
inline int GetKnum(void) {return Knum;} inline int GetKnum(void) {return Knum;}
//inline PTABDEF GetDef(void) {return To_Def;}
//inline PCOL GetSetCols(void) {return To_SetCols;}
//inline void SetSetCols(PCOL colp) {To_SetCols = colp;}
inline void SetKey_Col(PCOL *cpp) {To_Key_Col = cpp;} inline void SetKey_Col(PCOL *cpp) {To_Key_Col = cpp;}
inline void SetXdp(PIXDEF xdp) {To_Xdp = xdp;} inline void SetXdp(PIXDEF xdp) {To_Xdp = xdp;}
inline void SetKindex(PKXBASE kxp) {To_Kindex = kxp;} inline void SetKindex(PKXBASE kxp) {To_Kindex = kxp;}
@@ -201,36 +179,14 @@ class DllExport TDBASE : public TDB {
// Methods // Methods
virtual bool IsUsingTemp(PGLOBAL) {return false;} virtual bool IsUsingTemp(PGLOBAL) {return false;}
//virtual bool IsIndexed(void) {return false;}
//virtual bool IsSpecial(PSZ name);
virtual PCATLG GetCat(void); virtual PCATLG GetCat(void);
//virtual PSZ GetPath(void);
virtual void PrintAM(FILE *f, char *m); virtual void PrintAM(FILE *f, char *m);
//virtual RECFM GetFtype(void) {return RECFM_NAF;}
//virtual int GetAffectedRows(void) {return -1;}
//virtual int GetRecpos(void) = 0;
//virtual bool SetRecpos(PGLOBAL g, int recpos);
//virtual bool IsReadOnly(void) {return Read_Only;}
//virtual bool IsView(void) {return FALSE;}
//virtual CHARSET_INFO *data_charset(void);
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);} virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);}
//virtual int GetProgCur(void) {return GetRecpos();}
//virtual PSZ GetFile(PGLOBAL) {return "Not a file";}
//virtual int GetRemote(void) {return 0;}
//virtual void SetFile(PGLOBAL, PSZ) {}
//virtual void ResetDB(void) {}
//virtual void ResetSize(void) {MaxSize = -1;}
virtual void RestoreNrec(void) {} virtual void RestoreNrec(void) {}
virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox); virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox);
virtual PSZ GetServer(void) {return "Current";} virtual PCSZ GetServer(void) {return "Current";}
// Database routines // Database routines
//virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
//virtual PCOL MakeCol(PGLOBAL, PCOLDEF, PCOL, int)
// {assert(false); return NULL;}
//virtual PCOL InsertSpecialColumn(PCOL colp);
//virtual PCOL InsertSpcBlk(PGLOBAL g, PCOLDEF cdp);
//virtual void MarkDB(PGLOBAL g, PTDB tdb2);
virtual int MakeIndex(PGLOBAL g, PIXDEF, bool) virtual int MakeIndex(PGLOBAL g, PIXDEF, bool)
{strcpy(g->Message, "Remote index"); return RC_INFO;} {strcpy(g->Message, "Remote index"); return RC_INFO;}
virtual bool ReadKey(PGLOBAL, OPVAL, const key_range *) virtual bool ReadKey(PGLOBAL, OPVAL, const key_range *)
@@ -241,18 +197,12 @@ class DllExport TDBASE : public TDB {
"This function should not be called for this table"); return true;} "This function should not be called for this table"); return true;}
// Members // Members
//PTABDEF To_Def; // Points to catalog description block
PXOB *To_Link; // Points to column of previous relations PXOB *To_Link; // Points to column of previous relations
PCOL *To_Key_Col; // Points to key columns in current file PCOL *To_Key_Col; // Points to key columns in current file
PKXBASE To_Kindex; // Points to table key index PKXBASE To_Kindex; // Points to table key index
PIXDEF To_Xdp; // To the index definition block PIXDEF To_Xdp; // To the index definition block
//PCOL To_SetCols; // Points to updated columns
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT) RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT)
//int MaxSize; // Max size in number of lines
int Knum; // Size of key arrays int Knum; // Size of key arrays
//bool Read_Only; // True for read only tables
//const CHARSET_INFO *m_data_charset;
//const char *csname; // Table charset name
}; // end of class TDBASE }; // end of class TDBASE
/***********************************************************************/ /***********************************************************************/

View File

@@ -637,7 +637,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
return relativeOffset; return relativeOffset;
} }
int LoadCentralDirectoryRecord(zip64_internal* pziinit) static int LoadCentralDirectoryRecord(zip64_internal* pziinit)
{ {
int err=ZIP_OK; int err=ZIP_OK;
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
@@ -846,7 +846,7 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
/************************************************************/ /************************************************************/
extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) static zipFile zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def)
{ {
zip64_internal ziinit; zip64_internal ziinit;
zip64_internal* zi; zip64_internal* zi;
@@ -955,7 +955,7 @@ extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append)
return zipOpen3(pathname,append,NULL,NULL); return zipOpen3(pathname,append,NULL,NULL);
} }
int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) static int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)
{ {
/* write the local header */ /* write the local header */
int err; int err;
@@ -1752,7 +1752,7 @@ extern int ZEXPORT zipCloseFileInZip (zipFile file)
return zipCloseFileInZipRaw (file,0,0); return zipCloseFileInZipRaw (file,0,0);
} }
int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) static int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
{ {
int err = ZIP_OK; int err = ZIP_OK;
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset; ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset;
@@ -1774,7 +1774,7 @@ int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eo
return err; return err;
} }
int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) static int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
{ {
int err = ZIP_OK; int err = ZIP_OK;
@@ -1813,7 +1813,7 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra
} }
return err; return err;
} }
int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) static int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
{ {
int err = ZIP_OK; int err = ZIP_OK;
@@ -1861,7 +1861,7 @@ int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir,
return err; return err;
} }
int Write_GlobalComment(zip64_internal* zi, const char* global_comment) static int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
{ {
int err = ZIP_OK; int err = ZIP_OK;
uInt size_global_comment = 0; uInt size_global_comment = 0;