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

Commit changes pulled from ob-10.0

This commit is contained in:
Olivier Bertrand
2015-06-02 10:34:51 +02:00
parent 893631a8c1
commit e8ea671c25
66 changed files with 862 additions and 733 deletions

View File

@@ -19,14 +19,14 @@
#include "sql_class.h" #include "sql_class.h"
//#include "sql_time.h" //#include "sql_time.h"
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdint.h> // for uintprt_h #include <stdint.h> // for uintprt_h
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */

View File

@@ -20,13 +20,13 @@
#include "sql_class.h" #include "sql_class.h"
//#include "sql_time.h" //#include "sql_time.h"
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */

View File

@@ -24,11 +24,11 @@
#if !defined(BLOCK_DEFINED) #if !defined(BLOCK_DEFINED)
#define BLOCK_DEFINED #define BLOCK_DEFINED
#if defined(WIN32) && !defined(NOEX) #if defined(__WIN__) && !defined(NOEX)
#define DllExport __declspec( dllexport ) #define DllExport __declspec( dllexport )
#else // !WIN32 #else // !__WIN__
#define DllExport #define DllExport
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Definition of class BLOCK with its method function new. */ /* Definition of class BLOCK with its method function new. */
@@ -38,7 +38,7 @@ typedef class BLOCK *PBLOCK;
class DllExport BLOCK { class DllExport BLOCK {
public: public:
void * operator new(size_t size, PGLOBAL g, void *p = NULL) { void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
// if (trace > 2) // if (trace > 3)
// htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p); // htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
return (PlugSubAlloc(g, p, size)); return (PlugSubAlloc(g, p, size));

View File

@@ -297,9 +297,9 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op)
Buf_Type = TYPE_STRING; Buf_Type = TYPE_STRING;
*Format.Type = 'C'; *Format.Type = 'C';
Format.Length = Long; Format.Length = Long;
#if defined(WIN32) #if defined(__WIN__)
Format.Prec = 1; // Case insensitive Format.Prec = 1; // Case insensitive
#endif // WIN32 #endif // __WIN__
Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() && Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() &&
To_Tdb->GetAmType() != TYPE_AM_PLG && To_Tdb->GetAmType() != TYPE_AM_PLG &&
To_Tdb->GetAmType() != TYPE_AM_PLM); To_Tdb->GetAmType() != TYPE_AM_PLM);

View File

@@ -4,7 +4,7 @@
/******************************************************************/ /******************************************************************/
#include "my_global.h" #include "my_global.h"
#include <stdio.h> #include <stdio.h>
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#if defined(MSX2) #if defined(MSX2)
#import "msxml2.dll" //Does not exist on Vista #import "msxml2.dll" //Does not exist on Vista

View File

@@ -17,12 +17,12 @@
/* Include relevant sections of the System header files. */ /* Include relevant sections of the System header files. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro #define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__ #endif // __BORLANDC__
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) #if defined(UNIX)
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@@ -30,7 +30,7 @@
#include <io.h> #include <io.h>
#endif // !UNIX #endif // !UNIX
#include <fcntl.h> #include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */
@@ -191,11 +191,11 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
return true; return true;
} // endif Memory } // endif Memory
#if defined(WIN32) #if defined(__WIN__)
if (mode != MODE_DELETE) { if (mode != MODE_DELETE) {
#else // !WIN32 #else // !__WIN__
if (mode == MODE_READ) { if (mode == MODE_READ) {
#endif // !WIN32 #endif // !__WIN__
CloseFileHandle(hFile); // Not used anymore CloseFileHandle(hFile); // Not used anymore
hFile = INVALID_HANDLE_VALUE; // For Fblock hFile = INVALID_HANDLE_VALUE; // For Fblock
} // endif Mode } // endif Mode
@@ -452,7 +452,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/ /*****************************************************************/
n = Tpos - Memory; n = Tpos - Memory;
#if defined(WIN32) #if defined(__WIN__)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
if (drc == 0xFFFFFFFF) { if (drc == 0xFFFFFFFF) {
@@ -482,7 +482,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
#endif // UNIX #endif // UNIX
} // endif Abort } // endif Abort
#if defined(WIN32) #if defined(__WIN__)
CloseHandle(fp->Handle); CloseHandle(fp->Handle);
#else // UNIX #else // UNIX
close(fp->Handle); close(fp->Handle);

View File

@@ -22,12 +22,12 @@
/* Include relevant sections of the System header files. */ /* Include relevant sections of the System header files. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
//#include <errno.h> //#include <errno.h>
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) #if defined(UNIX)
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@@ -35,7 +35,7 @@
//#include <io.h> //#include <io.h>
#endif // !UNIX #endif // !UNIX
//#include <fcntl.h> //#include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -528,7 +528,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen); To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
if (mode == MODE_INSERT) { if (mode == MODE_INSERT) {
#if defined(WIN32) #if defined(__WIN__)
/************************************************************************/ /************************************************************************/
/* Now we can revert to binary mode in particular because the eventual */ /* Now we can revert to binary mode in particular because the eventual */
/* writing of a new header must be done in binary mode to avoid */ /* writing of a new header must be done in binary mode to avoid */
@@ -538,7 +538,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
sprintf(g->Message, MSG(BIN_MODE_FAIL), strerror(errno)); sprintf(g->Message, MSG(BIN_MODE_FAIL), strerror(errno));
return true; return true;
} // endif setmode } // endif setmode
#endif // WIN32 #endif // __WIN__
/************************************************************************/ /************************************************************************/
/* If this is a new file, the header must be generated. */ /* If this is a new file, the header must be generated. */

View File

@@ -17,7 +17,7 @@
/* Include relevant sections of the System header files. */ /* Include relevant sections of the System header files. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
@@ -25,7 +25,7 @@
#define __MFC_COMPAT__ // To define min/max as macro #define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__ #endif // __BORLANDC__
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) #if defined(UNIX)
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@@ -34,7 +34,7 @@
#endif // !UNIX #endif // !UNIX
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */
@@ -338,10 +338,10 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
} else if (feof(Stream)) { } else if (feof(Stream)) {
rc = RC_EF; rc = RC_EF;
} else { } else {
#if defined(UNIX) #if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#endif #endif
if (trace) if (trace)
@@ -678,7 +678,7 @@ BGXFAM::BGXFAM(PBGXFAM txfp) : FIXFAM(txfp)
/***********************************************************************/ /***********************************************************************/
bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org) bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
{ {
#if defined(WIN32) #if defined(__WIN__)
char buf[256]; char buf[256];
DWORD drc; DWORD drc;
LARGE_INTEGER of; LARGE_INTEGER of;
@@ -694,14 +694,14 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
sprintf(g->Message, MSG(SFP_ERROR), buf); sprintf(g->Message, MSG(SFP_ERROR), buf);
return true; return true;
} // endif } // endif
#else // !WIN32 #else // !__WIN__
if (lseek64(h, pos, org) < 0) { if (lseek64(h, pos, org) < 0) {
// sprintf(g->Message, MSG(ERROR_IN_LSK), errno); // sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
sprintf(g->Message, "lseek64: %s", strerror(errno)); sprintf(g->Message, "lseek64: %s", strerror(errno));
printf("%s\n", g->Message); printf("%s\n", g->Message);
return true; return true;
} // endif } // endif
#endif // !WIN32 #endif // !__WIN__
return false; return false;
} // end of BigSeek } // end of BigSeek
@@ -714,7 +714,7 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)),
{ {
int rc; int rc;
#if defined(WIN32) #if defined(__WIN__)
DWORD nbr, drc, len = (DWORD)req; DWORD nbr, drc, len = (DWORD)req;
bool brc = ReadFile(h, inbuf, len, &nbr, NULL); bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
@@ -736,12 +736,12 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)),
rc = -1; rc = -1;
} else } else
rc = (int)nbr; rc = (int)nbr;
#else // !WIN32 #else // !__WIN__
size_t len = (size_t)req; size_t len = (size_t)req;
ssize_t nbr = read(h, inbuf, len); ssize_t nbr = read(h, inbuf, len);
rc = (int)nbr; rc = (int)nbr;
#endif // !WIN32 #endif // !__WIN__
return rc; return rc;
} // end of BigRead } // end of BigRead
@@ -753,7 +753,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
{ {
bool rc = false; bool rc = false;
#if defined(WIN32) #if defined(__WIN__)
DWORD nbw, drc, len = (DWORD)req; DWORD nbw, drc, len = (DWORD)req;
bool brc = WriteFile(h, inbuf, len, &nbw, NULL); bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
@@ -780,7 +780,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true; rc = true;
} // endif brc || nbw } // endif brc || nbw
#else // !WIN32 #else // !__WIN__
size_t len = (size_t)req; size_t len = (size_t)req;
ssize_t nbw = write(h, inbuf, len); ssize_t nbw = write(h, inbuf, len);
@@ -795,7 +795,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true; rc = true;
} // endif nbr } // endif nbr
#endif // !WIN32 #endif // !__WIN__
return rc; return rc;
} // end of BigWrite } // end of BigWrite
@@ -830,7 +830,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
if (trace) if (trace)
htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode); htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
#if defined(WIN32) #if defined(__WIN__)
DWORD rc, access, creation, share = 0; DWORD rc, access, creation, share = 0;
/*********************************************************************/ /*********************************************************************/
@@ -987,7 +987,7 @@ int BGXFAM::Cardinality(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath()); PlugSetPath(filename, To_File, Tdbp->GetPath());
#if defined(WIN32) // OB #if defined(__WIN__) // OB
LARGE_INTEGER len; LARGE_INTEGER len;
DWORD rc = 0; DWORD rc = 0;
@@ -1346,7 +1346,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/ /*****************************************************************/
/* Remove extra records. */ /* Remove extra records. */
/*****************************************************************/ /*****************************************************************/
#if defined(WIN32) #if defined(__WIN__)
if (BigSeek(g, Hfile, (BIGINT)Tpos * (BIGINT)Lrecl)) if (BigSeek(g, Hfile, (BIGINT)Tpos * (BIGINT)Lrecl))
return RC_FX; return RC_FX;
@@ -1356,12 +1356,12 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
sprintf(g->Message, MSG(SETEOF_ERROR), drc); sprintf(g->Message, MSG(SETEOF_ERROR), drc);
return RC_FX; return RC_FX;
} // endif error } // endif error
#else // !WIN32 #else // !__WIN__
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
return RC_FX; return RC_FX;
} // endif } // endif
#endif // !WIN32 #endif // !__WIN__
} // endif UseTemp } // endif UseTemp
@@ -1386,7 +1386,7 @@ bool BGXFAM::OpenTempFile(PGLOBAL g)
strcat(PlugRemoveType(tempname, tempname), ".t"); strcat(PlugRemoveType(tempname, tempname), ".t");
remove(tempname); // Be sure it does not exist yet remove(tempname); // Be sure it does not exist yet
#if defined(WIN32) #if defined(__WIN__)
Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL, Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -1526,7 +1526,7 @@ void BGXFAM::CloseTableFile(PGLOBAL g, bool abort)
void BGXFAM::Rewind(void) void BGXFAM::Rewind(void)
{ {
#if 0 // This is probably unuseful because file is accessed directly #if 0 // This is probably unuseful because file is accessed directly
#if defined(WIN32) //OB #if defined(__WIN__) //OB
SetFilePointer(Hfile, 0, NULL, FILE_BEGIN); SetFilePointer(Hfile, 0, NULL, FILE_BEGIN);
#else // UNIX #else // UNIX
lseek64(Hfile, 0, SEEK_SET); lseek64(Hfile, 0, SEEK_SET);

View File

@@ -17,7 +17,7 @@
/* Include relevant sections of the System header files. */ /* Include relevant sections of the System header files. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
@@ -25,7 +25,7 @@
#define __MFC_COMPAT__ // To define min/max as macro #define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__ #endif // __BORLANDC__
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) || defined(UNIV_LINUX) #if defined(UNIX) || defined(UNIV_LINUX)
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@@ -36,7 +36,7 @@
#include <io.h> #include <io.h>
#endif // !UNIX #endif // !UNIX
#include <fcntl.h> #include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */
@@ -716,10 +716,10 @@ int DOSFAM::SkipRecord(PGLOBAL g, bool header)
if (feof(Stream)) if (feof(Stream))
return RC_EF; return RC_EF;
#if defined(UNIX) || defined(UNIV_LINUX) #if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
#endif #endif
return RC_FX; return RC_FX;
} // endif fgets } // endif fgets
@@ -799,12 +799,12 @@ int DOSFAM::ReadBuffer(PGLOBAL g)
if (trace > 1) if (trace > 1)
htrc(" Read: To_Buf=%p p=%c\n", To_Buf, To_Buf, p); htrc(" Read: To_Buf=%p p=%c\n", To_Buf, To_Buf, p);
#if defined(UNIX) #if defined(__WIN__)
if (true) {
// Data files can be imported from Windows (having CRLF)
#else
if (Bin) { if (Bin) {
// Data file is read in binary so CRLF remains // Data file is read in binary so CRLF remains
#else
if (true) {
// Data files can be imported from Windows (having CRLF)
#endif #endif
if (*p == '\n' || *p == '\r') { if (*p == '\n' || *p == '\r') {
// is this enough for Unix ??? // is this enough for Unix ???
@@ -833,10 +833,10 @@ int DOSFAM::ReadBuffer(PGLOBAL g)
} else if (feof(Stream)) { } else if (feof(Stream)) {
rc = RC_EF; rc = RC_EF;
} else { } else {
#if defined(UNIX) #if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
#endif #endif
if (trace) if (trace)
@@ -1028,15 +1028,15 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/ /*****************************************************************/
/* Remove extra records. */ /* Remove extra records. */
/*****************************************************************/ /*****************************************************************/
#if defined(UNIX) #if defined(__WIN__)
if (ftruncate(h, (off_t)Tpos)) { if (chsize(h, Tpos)) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
#else #else
if (chsize(h, Tpos)) { if (ftruncate(h, (off_t)Tpos)) {
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
close(h); close(h);
return RC_FX; return RC_FX;
} // endif } // endif
@@ -1466,10 +1466,10 @@ int BLKFAM::ReadBuffer(PGLOBAL g)
} else if (feof(Stream)) { } else if (feof(Stream)) {
rc = RC_EF; rc = RC_EF;
} else { } else {
#if defined(UNIX) #if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#endif #endif
if (trace) if (trace)
@@ -1551,11 +1551,11 @@ int BLKFAM::WriteBuffer(PGLOBAL g)
Spos = GetNextPos(); // New start position Spos = GetNextPos(); // New start position
// Prepare the output buffer // Prepare the output buffer
#if defined(WIN32) #if defined(__WIN__)
crlf = "\r\n"; crlf = "\r\n";
#else #else
crlf = "\n"; crlf = "\n";
#endif // WIN32 #endif // __WIN__
strcat(strcpy(OutBuf, Tdbp->GetLine()), crlf); strcat(strcpy(OutBuf, Tdbp->GetLine()), crlf);
len = strlen(OutBuf); len = strlen(OutBuf);
} else { } else {

View File

@@ -21,7 +21,7 @@
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
@@ -29,7 +29,7 @@
#endif // __BORLAND__ #endif // __BORLAND__
//#include <windows.h> //#include <windows.h>
#include <sys/stat.h> #include <sys/stat.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) #if defined(UNIX)
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -40,7 +40,7 @@
#include <io.h> #include <io.h>
#endif // !UNIX #endif // !UNIX
#include <fcntl.h> #include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */
@@ -49,7 +49,7 @@
/* tabdos.h is header containing the TABDOS class declarations. */ /* tabdos.h is header containing the TABDOS class declarations. */
/***********************************************************************/ /***********************************************************************/
#include "global.h" #include "global.h"
#include "osutil.h" // Unuseful for WIN32 #include "osutil.h" // Unuseful for WINDOWS
#include "plgdbsem.h" #include "plgdbsem.h"
#include "valblk.h" #include "valblk.h"
#include "filamfix.h" #include "filamfix.h"
@@ -376,11 +376,11 @@ bool VCTFAM::MakeEmptyFile(PGLOBAL g, char *fn)
int h, n; int h, n;
PlugSetPath(filename, fn, Tdbp->GetPath()); PlugSetPath(filename, fn, Tdbp->GetPath());
#if defined(WIN32) #if defined(__WIN__)
h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, _O_CREAT | _O_WRONLY, S_IREAD | S_IWRITE); h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, _O_CREAT | _O_WRONLY, S_IREAD | S_IWRITE);
#else // !WIN32 #else // !__WIN__
h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE); h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE);
#endif // !WIN32 #endif // !__WIN__
if (h == -1) if (h == -1)
return true; return true;
@@ -1669,7 +1669,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc)
// Remove extra blocks // Remove extra blocks
n = Block * Blksize; n = Block * Blksize;
#if defined(WIN32) #if defined(__WIN__)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
if (drc == 0xFFFFFFFF) { if (drc == 0xFFFFFFFF) {
@@ -2574,11 +2574,11 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
char fn[_MAX_PATH]; char fn[_MAX_PATH];
sprintf(fn, Colfn, colp->Index); sprintf(fn, Colfn, colp->Index);
#if defined(WIN32) #if defined(__WIN__)
if (feof(Streams[i])) if (feof(Streams[i]))
#else // !WIN32 #else // !__WIN__
if (errno == NO_ERROR) if (errno == NO_ERROR)
#endif // !WIN32 #endif // !__WIN__
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn); sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn);
else else
sprintf(g->Message, MSG(READ_ERROR), sprintf(g->Message, MSG(READ_ERROR),
@@ -2969,7 +2969,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/ /*****************************************************************/
n = Tpos * Clens[i]; n = Tpos * Clens[i];
#if defined(WIN32) #if defined(__WIN__)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
if (drc == 0xFFFFFFFF) { if (drc == 0xFFFFFFFF) {
@@ -3049,7 +3049,7 @@ BGVFAM::BGVFAM(PBGVFAM txfp) : VCTFAM(txfp)
/***********************************************************************/ /***********************************************************************/
bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b) bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b)
{ {
#if defined(WIN32) #if defined(__WIN__)
char buf[256]; char buf[256];
DWORD drc, m = (b) ? FILE_END : FILE_BEGIN; DWORD drc, m = (b) ? FILE_END : FILE_BEGIN;
LARGE_INTEGER of; LARGE_INTEGER of;
@@ -3065,12 +3065,12 @@ bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b)
sprintf(g->Message, MSG(SFP_ERROR), buf); sprintf(g->Message, MSG(SFP_ERROR), buf);
return true; return true;
} // endif } // endif
#else // !WIN32 #else // !__WIN__
if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) { if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) {
sprintf(g->Message, MSG(ERROR_IN_LSK), errno); sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
return true; return true;
} // endif } // endif
#endif // !WIN32 #endif // !__WIN__
return false; return false;
} // end of BigSeek } // end of BigSeek
@@ -3082,7 +3082,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
{ {
bool rc = false; bool rc = false;
#if defined(WIN32) #if defined(__WIN__)
DWORD nbr, drc, len = (DWORD)req; DWORD nbr, drc, len = (DWORD)req;
bool brc = ReadFile(h, inbuf, len, &nbr, NULL); bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
@@ -3108,7 +3108,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true; rc = true;
} // endif brc || nbr } // endif brc || nbr
#else // !WIN32 #else // !__WIN__
size_t len = (size_t)req; size_t len = (size_t)req;
ssize_t nbr = read(h, inbuf, len); ssize_t nbr = read(h, inbuf, len);
@@ -3123,7 +3123,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true; rc = true;
} // endif nbr } // endif nbr
#endif // !WIN32 #endif // !__WIN__
return rc; return rc;
} // end of BigRead } // end of BigRead
@@ -3135,7 +3135,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
{ {
bool rc = false; bool rc = false;
#if defined(WIN32) #if defined(__WIN__)
DWORD nbw, drc, len = (DWORD)req; DWORD nbw, drc, len = (DWORD)req;
bool brc = WriteFile(h, inbuf, len, &nbw, NULL); bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
@@ -3162,7 +3162,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true; rc = true;
} // endif brc || nbw } // endif brc || nbw
#else // !WIN32 #else // !__WIN__
size_t len = (size_t)req; size_t len = (size_t)req;
ssize_t nbw = write(h, inbuf, len); ssize_t nbw = write(h, inbuf, len);
@@ -3177,7 +3177,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
rc = true; rc = true;
} // endif nbr } // endif nbr
#endif // !WIN32 #endif // !__WIN__
return rc; return rc;
} // end of BigWrite } // end of BigWrite
@@ -3203,7 +3203,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
if (Header == 2) if (Header == 2)
strcat(PlugRemoveType(filename, filename), ".blk"); strcat(PlugRemoveType(filename, filename), ".blk");
#if defined(WIN32) #if defined(__WIN__)
LARGE_INTEGER len; LARGE_INTEGER len;
h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
@@ -3215,11 +3215,11 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
} // endif h } // endif h
if (h == INVALID_HANDLE_VALUE || !len.QuadPart) { if (h == INVALID_HANDLE_VALUE || !len.QuadPart) {
#else // !WIN32 #else // !__WIN__
h = open64(filename, O_RDONLY, 0); h = open64(filename, O_RDONLY, 0);
if (h == INVALID_HANDLE_VALUE || !_filelength(h)) { if (h == INVALID_HANDLE_VALUE || !_filelength(h)) {
#endif // !WIN32 #endif // !__WIN__
// Consider this is a void table // Consider this is a void table
if (trace) if (trace)
htrc("Void table h=%d\n", h); htrc("Void table h=%d\n", h);
@@ -3280,17 +3280,17 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
strcat(PlugRemoveType(filename, filename), ".blk"); strcat(PlugRemoveType(filename, filename), ".blk");
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
#if defined(WIN32) #if defined(__WIN__)
DWORD creation = (b) ? OPEN_EXISTING : TRUNCATE_EXISTING; DWORD creation = (b) ? OPEN_EXISTING : TRUNCATE_EXISTING;
h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0,
NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL); NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
#else // !WIN32 #else // !__WIN__
int oflag = (b) ? O_RDWR : O_RDWR | O_TRUNC; int oflag = (b) ? O_RDWR : O_RDWR | O_TRUNC;
h = open64(filename, oflag, 0); h = open64(filename, oflag, 0);
#endif // !WIN32 #endif // !__WIN__
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
sprintf(g->Message, "Error opening header file %s", filename); sprintf(g->Message, "Error opening header file %s", filename);
@@ -3328,7 +3328,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
PlugSetPath(filename, fn, Tdbp->GetPath()); PlugSetPath(filename, fn, Tdbp->GetPath());
#if defined(WIN32) #if defined(__WIN__)
char *p; char *p;
DWORD rc; DWORD rc;
bool brc; bool brc;
@@ -3380,7 +3380,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
CloseHandle(h); CloseHandle(h);
return true; return true;
#else // !WIN32 #else // !__WIN__
int h; int h;
BIGINT pos; BIGINT pos;
@@ -3409,7 +3409,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno)); sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
close(h); close(h);
return true; return true;
#endif // !WIN32 #endif // !__WIN__
} // end of MakeEmptyFile } // end of MakeEmptyFile
/***********************************************************************/ /***********************************************************************/
@@ -3440,7 +3440,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
htrc("OpenTableFile: filename=%s mode=%d Last=%d\n", htrc("OpenTableFile: filename=%s mode=%d Last=%d\n",
filename, mode, Last); filename, mode, Last);
#if defined(WIN32) #if defined(__WIN__)
DWORD access, creation, share = 0, rc = 0; DWORD access, creation, share = 0, rc = 0;
/*********************************************************************/ /*********************************************************************/
@@ -3766,7 +3766,7 @@ int BGVFAM::WriteBuffer(PGLOBAL g)
if (!Closing && !MaxBlk) { if (!Closing && !MaxBlk) {
// Close the VCT file and reopen it in mode Insert // Close the VCT file and reopen it in mode Insert
//#if defined(WIN32) //OB //#if defined(__WIN__) //OB
// CloseHandle(Hfile); // CloseHandle(Hfile);
//#else // UNIX //#else // UNIX
// close(Hfile); // close(Hfile);
@@ -3893,7 +3893,7 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc)
/***************************************************************/ /***************************************************************/
/* Remove extra records. */ /* Remove extra records. */
/***************************************************************/ /***************************************************************/
#if defined(WIN32) #if defined(__WIN__)
BIGINT pos = (BIGINT)Block * (BIGINT)Blksize; BIGINT pos = (BIGINT)Block * (BIGINT)Blksize;
if (BigSeek(g, Hfile, pos)) if (BigSeek(g, Hfile, pos))
@@ -3905,12 +3905,12 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc)
sprintf(g->Message, MSG(SETEOF_ERROR), drc); sprintf(g->Message, MSG(SETEOF_ERROR), drc);
return RC_FX; return RC_FX;
} // endif error } // endif error
#else // !WIN32 #else // !__WIN__
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
return RC_FX; return RC_FX;
} // endif } // endif
#endif // !WIN32 #endif // !__WIN__
} else // MaxBlk } else // MaxBlk
// Clean the unused space in the file, this is required when // Clean the unused space in the file, this is required when
// inserting again with a partial column list. // inserting again with a partial column list.
@@ -3947,7 +3947,7 @@ bool BGVFAM::OpenTempFile(PGLOBAL g)
else if (MakeEmptyFile(g, tempname)) else if (MakeEmptyFile(g, tempname))
return true; return true;
#if defined(WIN32) #if defined(__WIN__)
DWORD access = (MaxBlk) ? OPEN_EXISTING : CREATE_NEW; DWORD access = (MaxBlk) ? OPEN_EXISTING : CREATE_NEW;
Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL, Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL,
@@ -4218,7 +4218,7 @@ void BGVFAM::Rewind(void)
CurNum = Nrec - 1; CurNum = Nrec - 1;
#if 0 // This is probably unuseful as the file is directly accessed #if 0 // This is probably unuseful as the file is directly accessed
#if defined(WIN32) //OB #if defined(__WIN__) //OB
SetFilePointer(Hfile, 0, NULL, FILE_BEGIN); SetFilePointer(Hfile, 0, NULL, FILE_BEGIN);
#else // UNIX #else // UNIX
lseek64(Hfile, 0, SEEK_SET); lseek64(Hfile, 0, SEEK_SET);

View File

@@ -17,21 +17,21 @@
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro #define __MFC_COMPAT__ // To define min/max as macro
#endif #endif
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) #if defined(UNIX)
#include <errno.h> #include <errno.h>
#else // !UNIX #else // !UNIX
#include <io.h> #include <io.h>
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */
@@ -89,11 +89,11 @@ int ZIPFAM::Zerror(PGLOBAL g)
strcpy(g->Message, gzerror(Zfile, &errnum)); strcpy(g->Message, gzerror(Zfile, &errnum));
if (errnum == Z_ERRNO) if (errnum == Z_ERRNO)
#if defined(WIN32) #if defined(__WIN__)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(NULL)); sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(NULL));
#else // !WIN32 #else // !__WIN__
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#endif // !WIN32 #endif // !__WIN__
return (errnum == Z_STREAM_END) ? RC_EF : RC_FX; return (errnum == Z_STREAM_END) ? RC_EF : RC_FX;
} // end of Zerror } // end of Zerror
@@ -764,9 +764,9 @@ bool ZIXFAM::AllocateBuffer(PGLOBAL g)
if (Tdbp->GetFtype() < 2) if (Tdbp->GetFtype() < 2)
// if not binary, the file is physically a text file // if not binary, the file is physically a text file
for (int len = Lrecl; len <= Buflen; len += Lrecl) { for (int len = Lrecl; len <= Buflen; len += Lrecl) {
#if defined(WIN32) #if defined(__WIN__)
To_Buf[len - 2] = '\r'; To_Buf[len - 2] = '\r';
#endif // WIN32 #endif // __WIN__
To_Buf[len - 1] = '\n'; To_Buf[len - 1] = '\n';
} // endfor len } // endfor len

View File

@@ -13,13 +13,13 @@
#include "sql_class.h" #include "sql_class.h"
//#include "sql_time.h" //#include "sql_time.h"
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/

View File

@@ -106,7 +106,7 @@ class FILTERX : public FILTER {
// Fake operator new used to change a filter into a derived filter // Fake operator new used to change a filter into a derived filter
void * operator new(size_t, PFIL filp) {return filp;} void * operator new(size_t, PFIL filp) {return filp;}
#if defined(WIN32) #if defined(__WIN__)
// Avoid warning C4291 by defining a matching dummy delete operator // Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, PFIL) {} void operator delete(void *, PFIL) {}
#else #else

View File

@@ -20,11 +20,12 @@
*/ */
#define FLEX_SCANNER #define FLEX_SCANNER
#if WIN32 #ifdef __WIN__
#define __STDC__ 1 #define __STDC__ 1
#define isatty _isatty
#endif #endif
#include <stdio.h> #include <stdio.h>
#ifndef WIN32 #ifndef __WIN__
#include <unistd.h> #include <unistd.h>
#endif #endif

View File

@@ -13,11 +13,11 @@
#include <time.h> /* time_t type declaration */ #include <time.h> /* time_t type declaration */
#include <setjmp.h> /* Long jump declarations */ #include <setjmp.h> /* Long jump declarations */
#if defined(WIN32) && !defined(NOEX) #if defined(__WIN__) && !defined(NOEX)
#define DllExport __declspec( dllexport ) #define DllExport __declspec( dllexport )
#else // !WIN32 #else // !__WIN__
#define DllExport #define DllExport
#endif // !WIN32 #endif // !__WIN__
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT) #if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT)
#define XML_SUPPORT 1 #define XML_SUPPORT 1
@@ -42,11 +42,11 @@
#define STEP(I) MSG_##I #define STEP(I) MSG_##I
#endif // !XMSG and !NEWMSG #endif // !XMSG and !NEWMSG
#if defined(WIN32) #if defined(__WIN__)
#define CRLF 2 #define CRLF 2
#else // !WIN32 #else // !__WIN__
#define CRLF 1 #define CRLF 1
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Define access to the thread based trace value. */ /* Define access to the thread based trace value. */
@@ -104,7 +104,7 @@
#define SYS_STAMP "DOSR" #define SYS_STAMP "DOSR"
#elif defined(WIN) #elif defined(WIN)
#define SYS_STAMP "WIN1" #define SYS_STAMP "WIN1"
#elif defined(WIN32) #elif defined(__WIN__)
#define SYS_STAMP "WIN2" #define SYS_STAMP "WIN2"
#else #else
#define SYS_STAMP "XXXX" #define SYS_STAMP "XXXX"
@@ -248,9 +248,9 @@ DllExport char *PlugReadMessage(PGLOBAL, int, char *);
#elif defined(NEWMSG) #elif defined(NEWMSG)
DllExport char *PlugGetMessage(PGLOBAL, int); DllExport char *PlugGetMessage(PGLOBAL, int);
#endif // XMSG || NEWMSG #endif // XMSG || NEWMSG
#if defined(WIN32) #if defined(__WIN__)
DllExport short GetLineLength(PGLOBAL); // Console line length DllExport short GetLineLength(PGLOBAL); // Console line length
#endif // WIN32 #endif // __WIN__
DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization
DllExport int PlugExit(PGLOBAL); // Plug global termination DllExport int PlugExit(PGLOBAL); // Plug global termination
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);

View File

@@ -138,10 +138,10 @@
#include "reldef.h" #include "reldef.h"
#include "tabcol.h" #include "tabcol.h"
#include "xindex.h" #include "xindex.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include "tabwmi.h" #include "tabwmi.h"
#endif // WIN32 #endif // __WIN__
#include "connect.h" #include "connect.h"
#include "user_connect.h" #include "user_connect.h"
#include "ha_connect.h" #include "ha_connect.h"
@@ -170,12 +170,12 @@
extern "C" { extern "C" {
char version[]= "Version 1.03.0007 April 30, 2015"; char version[]= "Version 1.03.0007 April 30, 2015";
#if defined(WIN32) #if defined(__WIN__)
char compver[]= "Version 1.03.0007 " __DATE__ " " __TIME__; char compver[]= "Version 1.03.0007 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
#else // !WIN32 #else // !__WIN__
char slash= '/'; char slash= '/';
#endif // !WIN32 #endif // !__WIN__
} // extern "C" } // extern "C"
#if defined(XMAP) #if defined(XMAP)
@@ -195,9 +195,8 @@ extern "C" {
/***********************************************************************/ /***********************************************************************/
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 *dp, const char *fn, char *objn, PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info);
int pretty, int lvl, int mxr, bool info); PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info);
PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info);
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, const char *host,
const char *db, char *tab, const char *src, int port); const char *db, char *tab, const char *src, int port);
@@ -630,11 +629,11 @@ static int connect_init_func(void *p)
} }
#endif // 0 (LINUX) #endif // 0 (LINUX)
#if defined(WIN32) #if defined(__WIN__)
sql_print_information("CONNECT: %s", compver); sql_print_information("CONNECT: %s", compver);
#else // !WIN32 #else // !__WIN__
sql_print_information("CONNECT: %s", version); sql_print_information("CONNECT: %s", version);
#endif // !WIN32 #endif // !__WIN__
#ifdef LIBXML2_SUPPORT #ifdef LIBXML2_SUPPORT
XmlInitParserLib(); XmlInitParserLib();
@@ -676,9 +675,9 @@ static int connect_done_func(void *)
XmlCleanupParserLib(); XmlCleanupParserLib();
#endif // LIBXML2_SUPPORT #endif // LIBXML2_SUPPORT
#if !defined(WIN32) #if !defined(__WIN__)
//PROFILE_End(); Causes signal 11 //PROFILE_End(); Causes signal 11
#endif // !WIN32 #endif // !__WIN__
for (pc= user_connect::to_users; pc; pc= pn) { for (pc= user_connect::to_users; pc; pc= pn) {
if (pc->g) if (pc->g)
@@ -745,11 +744,11 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
xp= (table) ? GetUser(ha_thd(), NULL) : NULL; xp= (table) ? GetUser(ha_thd(), NULL) : NULL;
if (xp) if (xp)
xp->SetHandler(this); xp->SetHandler(this);
#if defined(WIN32) #if defined(__WIN__)
datapath= ".\\"; datapath= ".\\";
#else // !WIN32 #else // !__WIN__
datapath= "./"; datapath= "./";
#endif // !WIN32 #endif // !__WIN__
tdbp= NULL; tdbp= NULL;
sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL; sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
sdvalout= NULL; sdvalout= NULL;
@@ -1017,6 +1016,117 @@ char *GetListOption(PGLOBAL g, const char *opname,
return opval; return opval;
} // end of GetListOption } // end of GetListOption
/****************************************************************************/
/* Return the value of a string option or NULL if not specified. */
/****************************************************************************/
char *GetStringTableOption(PGLOBAL g, PTOS options, char *opname, char *sdef)
{
const char *opval= NULL;
if (!options)
return sdef;
else if (!stricmp(opname, "Type"))
opval= options->type;
else if (!stricmp(opname, "Filename"))
opval= options->filename;
else if (!stricmp(opname, "Optname"))
opval= options->optname;
else if (!stricmp(opname, "Tabname"))
opval= options->tabname;
else if (!stricmp(opname, "Tablist"))
opval= options->tablist;
else if (!stricmp(opname, "Database") ||
!stricmp(opname, "DBname"))
opval= options->dbname;
else if (!stricmp(opname, "Separator"))
opval= options->separator;
else if (!stricmp(opname, "Qchar"))
opval= options->qchar;
else if (!stricmp(opname, "Module"))
opval= options->module;
else if (!stricmp(opname, "Subtype"))
opval= options->subtype;
else if (!stricmp(opname, "Catfunc"))
opval= options->catfunc;
else if (!stricmp(opname, "Srcdef"))
opval= options->srcdef;
else if (!stricmp(opname, "Colist"))
opval= options->colist;
else if (!stricmp(opname, "Data_charset"))
opval= options->data_charset;
if (!opval && options && options->oplist)
opval= GetListOption(g, opname, options->oplist);
return opval ? (char*)opval : sdef;
} // end of GetStringTableOption
/****************************************************************************/
/* Return the value of a Boolean option or bdef if not specified. */
/****************************************************************************/
bool GetBooleanTableOption(PGLOBAL g, PTOS options, char *opname, bool bdef)
{
bool opval= bdef;
char *pv;
if (!options)
return bdef;
else if (!stricmp(opname, "Mapped"))
opval= options->mapped;
else if (!stricmp(opname, "Huge"))
opval= options->huge;
else if (!stricmp(opname, "Split"))
opval= options->split;
else if (!stricmp(opname, "Readonly"))
opval= options->readonly;
else if (!stricmp(opname, "SepIndex"))
opval= options->sepindex;
else if (!stricmp(opname, "Header"))
opval= (options->header != 0); // Is Boolean for some table types
else if (options->oplist)
if ((pv= GetListOption(g, opname, options->oplist)))
opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0);
return opval;
} // end of GetBooleanTableOption
/****************************************************************************/
/* Return the value of an integer option or NO_IVAL if not specified. */
/****************************************************************************/
int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef)
{
ulonglong opval= NO_IVAL;
if (!options)
return idef;
else if (!stricmp(opname, "Lrecl"))
opval= options->lrecl;
else if (!stricmp(opname, "Elements"))
opval= options->elements;
else if (!stricmp(opname, "Multiple"))
opval= options->multiple;
else if (!stricmp(opname, "Header"))
opval= options->header;
else if (!stricmp(opname, "Quoted"))
opval= options->quoted;
else if (!stricmp(opname, "Ending"))
opval= options->ending;
else if (!stricmp(opname, "Compressed"))
opval= (options->compressed);
if (opval == NO_IVAL) {
char *pv;
if ((pv= GetListOption(g, opname, options->oplist)))
opval= CharToNumber(pv, strlen(pv), ULONGLONG_MAX, true);
else
return idef;
} // endif opval
return (int)opval;
} // end of GetIntegerTableOption
/****************************************************************************/ /****************************************************************************/
/* Return the table option structure. */ /* Return the table option structure. */
/****************************************************************************/ /****************************************************************************/
@@ -1035,9 +1145,6 @@ char *ha_connect::GetRealString(const char *s)
char *sv; char *sv;
if (IsPartitioned() && s) { if (IsPartitioned() && s) {
// sv= (char*)PlugSubAlloc(xp->g, NULL, strlen(s) + strlen(partname));
// With wrong string pattern, the size of the constructed string
// can be more than strlen(s) + strlen(partname)
sv= (char*)PlugSubAlloc(xp->g, NULL, 0); sv= (char*)PlugSubAlloc(xp->g, NULL, 0);
sprintf(sv, s, partname); sprintf(sv, s, partname);
PlugSubAlloc(xp->g, NULL, strlen(sv) + 1); PlugSubAlloc(xp->g, NULL, strlen(sv) + 1);
@@ -1048,7 +1155,7 @@ char *ha_connect::GetRealString(const char *s)
} // end of GetRealString } // end of GetRealString
/****************************************************************************/ /****************************************************************************/
/* Return the value of a string option or NULL if not specified. */ /* Return the value of a string option or sdef if not specified. */
/****************************************************************************/ /****************************************************************************/
char *ha_connect::GetStringOption(char *opname, char *sdef) char *ha_connect::GetStringOption(char *opname, char *sdef)
{ {
@@ -1066,37 +1173,6 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
opval= thd_query_string(table->in_use)->str; opval= thd_query_string(table->in_use)->str;
else if (!stricmp(opname, "Partname")) else if (!stricmp(opname, "Partname"))
opval= partname; opval= partname;
else if (!options)
;
else if (!stricmp(opname, "Type"))
opval= (char*)options->type;
else if (!stricmp(opname, "Filename"))
opval= GetRealString(options->filename);
else if (!stricmp(opname, "Optname"))
opval= (char*)options->optname;
else if (!stricmp(opname, "Tabname"))
opval= GetRealString(options->tabname);
else if (!stricmp(opname, "Tablist"))
opval= (char*)options->tablist;
else if (!stricmp(opname, "Database") ||
!stricmp(opname, "DBname"))
opval= (char*)options->dbname;
else if (!stricmp(opname, "Separator"))
opval= (char*)options->separator;
else if (!stricmp(opname, "Qchar"))
opval= (char*)options->qchar;
else if (!stricmp(opname, "Module"))
opval= (char*)options->module;
else if (!stricmp(opname, "Subtype"))
opval= (char*)options->subtype;
else if (!stricmp(opname, "Catfunc"))
opval= (char*)options->catfunc;
else if (!stricmp(opname, "Srcdef"))
opval= (char*)options->srcdef;
else if (!stricmp(opname, "Colist"))
opval= (char*)options->colist;
else if (!stricmp(opname, "Data_charset"))
opval= (char*)options->data_charset;
else if (!stricmp(opname, "Table_charset")) { else if (!stricmp(opname, "Table_charset")) {
const CHARSET_INFO *chif= (tshp) ? tshp->table_charset const CHARSET_INFO *chif= (tshp) ? tshp->table_charset
: table->s->table_charset; : table->s->table_charset;
@@ -1104,17 +1180,13 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
if (chif) if (chif)
opval= (char*)chif->csname; opval= (char*)chif->csname;
} // endif Table_charset } else
opval= GetStringTableOption(xp->g, options, opname, NULL);
if (!opval && options && options->oplist) { if (opval && (!stricmp(opname, "connect")
opval= GetListOption(xp->g, opname, options->oplist); || !stricmp(opname, "tabname")
|| !stricmp(opname, "filename")))
if (opval && (!stricmp(opname, "connect") opval = GetRealString(opval);
|| !stricmp(opname, "tabname")
|| !stricmp(opname, "filename")))
opval = GetRealString(opval);
} // endif opval
if (!opval) { if (!opval) {
if (sdef && !strcmp(sdef, "*")) { if (sdef && !strcmp(sdef, "*")) {
@@ -1145,31 +1217,13 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
/****************************************************************************/ /****************************************************************************/
bool ha_connect::GetBooleanOption(char *opname, bool bdef) bool ha_connect::GetBooleanOption(char *opname, bool bdef)
{ {
bool opval= bdef; bool opval;
char *pv;
PTOS options= GetTableOptionStruct(); PTOS options= GetTableOptionStruct();
if (!stricmp(opname, "View")) if (!stricmp(opname, "View"))
opval= (tshp) ? tshp->is_view : table_share->is_view; opval= (tshp) ? tshp->is_view : table_share->is_view;
else if (!options) else
; opval= GetBooleanTableOption(xp->g, options, opname, bdef);
else if (!stricmp(opname, "Mapped"))
opval= options->mapped;
else if (!stricmp(opname, "Huge"))
opval= options->huge;
//else if (!stricmp(opname, "Compressed"))
// opval= options->compressed;
else if (!stricmp(opname, "Split"))
opval= options->split;
else if (!stricmp(opname, "Readonly"))
opval= options->readonly;
else if (!stricmp(opname, "SepIndex"))
opval= options->sepindex;
else if (!stricmp(opname, "Header"))
opval= (options->header != 0); // Is Boolean for some table types
else if (options->oplist)
if ((pv= GetListOption(xp->g, opname, options->oplist)))
opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0);
return opval; return opval;
} // end of GetBooleanOption } // end of GetBooleanOption
@@ -1198,37 +1252,18 @@ bool ha_connect::SetBooleanOption(char *opname, bool b)
/****************************************************************************/ /****************************************************************************/
int ha_connect::GetIntegerOption(char *opname) int ha_connect::GetIntegerOption(char *opname)
{ {
ulonglong opval= NO_IVAL; int opval;
char *pv;
PTOS options= GetTableOptionStruct(); PTOS options= GetTableOptionStruct();
TABLE_SHARE *tsp= (tshp) ? tshp : table_share; TABLE_SHARE *tsp= (tshp) ? tshp : table_share;
if (!stricmp(opname, "Avglen")) if (!stricmp(opname, "Avglen"))
opval= (ulonglong)tsp->avg_row_length; opval= (int)tsp->avg_row_length;
else if (!stricmp(opname, "Estimate")) else if (!stricmp(opname, "Estimate"))
opval= (ulonglong)tsp->max_rows; opval= (int)tsp->max_rows;
else if (!options) else
; opval= GetIntegerTableOption(xp->g, options, opname, NO_IVAL);
else if (!stricmp(opname, "Lrecl"))
opval= options->lrecl;
else if (!stricmp(opname, "Elements"))
opval= options->elements;
else if (!stricmp(opname, "Multiple"))
opval= options->multiple;
else if (!stricmp(opname, "Header"))
opval= options->header;
else if (!stricmp(opname, "Quoted"))
opval= options->quoted;
else if (!stricmp(opname, "Ending"))
opval= options->ending;
else if (!stricmp(opname, "Compressed"))
opval= (options->compressed);
if (opval == (ulonglong)NO_IVAL && options && options->oplist) return opval;
if ((pv= GetListOption(xp->g, opname, options->oplist)))
opval= CharToNumber(pv, strlen(pv), ULONGLONG_MAX, true);
return (int)opval;
} // end of GetIntegerOption } // end of GetIntegerOption
/****************************************************************************/ /****************************************************************************/
@@ -3957,11 +3992,11 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn)
case TAB_JSON: case TAB_JSON:
if (options->filename && *options->filename) { if (options->filename && *options->filename) {
char *s, path[FN_REFLEN], dbpath[FN_REFLEN]; char *s, path[FN_REFLEN], dbpath[FN_REFLEN];
#if defined(WIN32) #if defined(__WIN__)
s= "\\"; s= "\\";
#else // !WIN32 #else // !__WIN__
s= "/"; s= "/";
#endif // !WIN32 #endif // !__WIN__
strcpy(dbpath, mysql_real_data_home); strcpy(dbpath, mysql_real_data_home);
if (db) if (db)
@@ -4720,6 +4755,9 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
else else
rows= HA_POS_ERROR; rows= HA_POS_ERROR;
if (trace)
htrc("records_in_range: rows=%llu\n", rows);
DBUG_RETURN(rows); DBUG_RETURN(rows);
} // end of records_in_range } // end of records_in_range
@@ -4965,12 +5003,12 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
const char *fncn= "?"; const char *fncn= "?";
const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src; const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src;
const char *col, *ocl, *rnk, *pic, *fcl, *skc; const char *col, *ocl, *rnk, *pic, *fcl, *skc;
char *tab, *dsn, *shm, *dpath, *objn; char *tab, *dsn, *shm, *dpath;
#if defined(WIN32) #if defined(__WIN__)
char *nsp= NULL, *cls= NULL; char *nsp= NULL, *cls= NULL;
#endif // WIN32 #endif // __WIN__
int port= 0, hdr= 0, mxr= 0, mxe= 0, rc= 0, lvl= 0; int port= 0, hdr= 0, mxr= 0, mxe= 0, rc= 0;
int cop __attribute__((unused))= 0, pty= 2, lrecl= 0; int cop __attribute__((unused))= 0, lrecl= 0;
#if defined(ODBC_SUPPORT) #if defined(ODBC_SUPPORT)
POPARM sop = NULL; POPARM sop = NULL;
char *ucnc = NULL; char *ucnc = NULL;
@@ -5000,7 +5038,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
if (!g) if (!g)
return HA_ERR_INTERNAL_ERROR; return HA_ERR_INTERNAL_ERROR;
user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= objn= NULL; user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= NULL;
// Get the useful create options // Get the useful create options
ttp= GetTypeID(topt->type); ttp= GetTypeID(topt->type);
@@ -5031,11 +5069,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
skc= GetListOption(g, "skipcol", topt->oplist, NULL); skc= GetListOption(g, "skipcol", topt->oplist, NULL);
rnk= GetListOption(g, "rankcol", topt->oplist, NULL); rnk= GetListOption(g, "rankcol", topt->oplist, NULL);
pwd= GetListOption(g, "password", topt->oplist); pwd= GetListOption(g, "password", topt->oplist);
objn= GetListOption(g, "Object", topt->oplist, NULL); #if defined(__WIN__)
#if defined(WIN32)
nsp= GetListOption(g, "namespace", topt->oplist); nsp= GetListOption(g, "namespace", topt->oplist);
cls= GetListOption(g, "class", topt->oplist); cls= GetListOption(g, "class", topt->oplist);
#endif // WIN32 #endif // __WIN__
port= atoi(GetListOption(g, "port", topt->oplist, "0")); port= atoi(GetListOption(g, "port", topt->oplist, "0"));
#if defined(ODBC_SUPPORT) #if defined(ODBC_SUPPORT)
mxr= atoi(GetListOption(g,"maxres", topt->oplist, "0")); mxr= atoi(GetListOption(g,"maxres", topt->oplist, "0"));
@@ -5049,8 +5086,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#if defined(PROMPT_OK) #if defined(PROMPT_OK)
cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0")); cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0"));
#endif // PROMPT_OK #endif // PROMPT_OK
pty= atoi(GetListOption(g,"Pretty", topt->oplist, "2"));
lvl= atoi(GetListOption(g,"Level", topt->oplist, "0"));
} else { } else {
host= "localhost"; host= "localhost";
user= (ttp == TAB_ODBC ? NULL : "root"); user= (ttp == TAB_ODBC ? NULL : "root");
@@ -5194,11 +5229,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
ok= false; ok= false;
break; break;
#if defined(WIN32) #if defined(__WIN__)
case TAB_WMI: case TAB_WMI:
ok= true; ok= true;
break; break;
#endif // WIN32 #endif // __WIN__
#if defined(PIVOT_SUPPORT) #if defined(PIVOT_SUPPORT)
case TAB_PIVOT: case TAB_PIVOT:
supfnc= FNC_NO; supfnc= FNC_NO;
@@ -5311,11 +5346,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case TAB_CSV: case TAB_CSV:
qrp= CSVColumns(g, dpath, fn, spc, qch, hdr, mxe, fnc == FNC_COL); qrp= CSVColumns(g, dpath, fn, spc, qch, hdr, mxe, fnc == FNC_COL);
break; break;
#if defined(WIN32) #if defined(__WIN__)
case TAB_WMI: case TAB_WMI:
qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL); qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL);
break; break;
#endif // WIN32 #endif // __WIN__
case TAB_PRX: case TAB_PRX:
case TAB_TBL: case TAB_TBL:
case TAB_XCL: case TAB_XCL:
@@ -5342,7 +5377,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, fn, objn, pty, lrecl, lvl, fnc == FNC_COL); qrp= JSONColumns(g, (char*)db, 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:
@@ -5491,10 +5526,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#if defined(ODBC_SUPPORT) #if defined(ODBC_SUPPORT)
if (ttp == TAB_ODBC) { if (ttp == TAB_ODBC) {
int plgtyp; int plgtyp;
bool w= false; // Wide character type
// typ must be PLG type, not SQL type // typ must be PLG type, not SQL type
if (!(plgtyp= TranslateSQLType(typ, dec, prec, v))) { if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) {
if (GetTypeConv() == TPC_SKIP) { if (GetTypeConv() == TPC_SKIP) {
// Skip this column // Skip this column
sprintf(g->Message, "Column %s skipped (unsupported type %d)", sprintf(g->Message, "Column %s skipped (unsupported type %d)",
@@ -5511,6 +5547,13 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
typ= plgtyp; typ= plgtyp;
switch (typ) { switch (typ) {
case TYPE_STRING:
if (w) {
sprintf(g->Message, "Column %s is wide characters", cnm);
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
} // endif w
break;
case TYPE_DOUBLE: case TYPE_DOUBLE:
// Some data sources do not count dec in length (prec) // Some data sources do not count dec in length (prec)
prec += (dec + 2); // To be safe prec += (dec + 2); // To be safe
@@ -5769,11 +5812,11 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// on Windows and libxml2 otherwise // on Windows and libxml2 otherwise
switch (*xsup) { switch (*xsup) {
case '*': case '*':
#if defined(WIN32) #if defined(__WIN__)
dom= true; dom= true;
#else // !WIN32 #else // !__WIN__
dom= false; dom= false;
#endif // !WIN32 #endif // !__WIN__
break; break;
case 'M': case 'M':
case 'D': case 'D':
@@ -6120,11 +6163,11 @@ bool ha_connect::FileExists(const char *fn, bool bf)
NULL, NULL, 0, 0)) NULL, NULL, 0, 0))
return true; return true;
#if defined(WIN32) #if defined(__WIN__)
s= "\\"; s= "\\";
#else // !WIN32 #else // !__WIN__
s= "/"; s= "/";
#endif // !WIN32 #endif // !__WIN__
if (IsPartitioned()) { if (IsPartitioned()) {
sprintf(tfn, fn, GetPartName()); sprintf(tfn, fn, GetPartName());
@@ -6608,7 +6651,7 @@ maria_declare_plugin(connect)
0x0103, /* version number (1.03) */ 0x0103, /* version number (1.03) */
NULL, /* status variables */ NULL, /* status variables */
connect_system_variables, /* system variables */ connect_system_variables, /* system variables */
"1.03.0006", /* string version */ "1.03.0007", /* string version */
MariaDB_PLUGIN_MATURITY_BETA /* maturity */ MariaDB_PLUGIN_MATURITY_BETA /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;

View File

@@ -23,7 +23,7 @@
#define ARGS MY_MIN(24,len-i),s+MY_MAX(i-3,0) #define ARGS MY_MIN(24,len-i),s+MY_MAX(i-3,0)
#if defined(WIN32) #if defined(__WIN__)
#define EL "\r\n" #define EL "\r\n"
#else #else
#define EL "\n" #define EL "\n"

View File

@@ -533,8 +533,8 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn)
// This function does not crash ( // This function does not crash (
if (xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0) < 0) { if (xmlSaveFormatFileEnc((const char *)ofn, Docp, Encoding, 0) < 0) {
xmlErrorPtr err = xmlGetLastError(); xmlErrorPtr err = xmlGetLastError();
strcpy(g->Message, (err) ? err->message : "Error saving XML doc"); strcpy(g->Message, (err) ? err->message : "Error saving XML doc");
xmlResetError(Xerr);
rc = -1; rc = -1;
} // endif Save } // endif Save
// rc = xmlDocDump(of, Docp); // rc = xmlDocDump(of, Docp);
@@ -569,6 +569,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0); htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0);
//if (xp && xp->Count == 1) { //if (xp && xp->Count == 1) {
if (xp) {
if (Nlist) { if (Nlist) {
xmlXPathFreeNodeSet(Nlist); xmlXPathFreeNodeSet(Nlist);
@@ -605,7 +606,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
Ctxp = NULL; Ctxp = NULL;
} // endif Ctxp } // endif Ctxp
// } // endif Count } // endif xp
CloseXML2File(g, xp, false); CloseXML2File(g, xp, false);
} // end of Close } // end of Close

View File

@@ -2,11 +2,11 @@
/* MACUTIL: Author Olivier Bertrand -- 2008-2012 */ /* MACUTIL: Author Olivier Bertrand -- 2008-2012 */
/* From the article and sample code by Khalid Shaikh. */ /* From the article and sample code by Khalid Shaikh. */
/***********************************************************************/ /***********************************************************************/
#if defined(WIN32) #if defined(__WIN__)
#include "my_global.h" #include "my_global.h"
#else // !WIN32 #else // !__WIN__
#error This is WIN32 only DLL #error This is WINDOWS only DLL
#endif // !WIN32 #endif // !__WIN__
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
#include "macutil.h" #include "macutil.h"

View File

@@ -1,10 +1,10 @@
// MACUTIL.H Olivier Bertrand 2008-2012 // MACUTIL.H Olivier Bertrand 2008-2012
// Get Mac Addresses via GetAdaptersInfo // Get Mac Addresses via GetAdaptersInfo
#if defined(WIN32) #if defined(__WIN__)
#include <iphlpapi.h> #include <iphlpapi.h>
#else // !WIN32 #else // !__WIN__
#error This is WIN32 only #error This is WINDOWS only
#endif // !WIN32 #endif // !__WIN__
#include "block.h" #include "block.h"
typedef class MACINFO *MACIP; typedef class MACINFO *MACIP;

View File

@@ -14,7 +14,7 @@
#include "plgdbsem.h" #include "plgdbsem.h"
#include "maputil.h" #include "maputil.h"
#ifdef WIN32 #ifdef __WIN__
/***********************************************************************/ /***********************************************************************/
/* In Insert mode, just open the file for append. Otherwise */ /* In Insert mode, just open the file for append. Otherwise */
/* create the mapping file object. The map handle can be released */ /* create the mapping file object. The map handle can be released */

View File

@@ -30,7 +30,7 @@
/***********************************************************************/ /***********************************************************************/
#include <my_config.h> #include <my_config.h>
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
//#include <sqlext.h> //#include <sqlext.h>
#elif defined(UNIX) #elif defined(UNIX)
@@ -66,10 +66,10 @@
#include "tabfmt.h" #include "tabfmt.h"
#include "tabvct.h" #include "tabvct.h"
#include "tabsys.h" #include "tabsys.h"
#if defined(WIN32) #if defined(__WIN__)
#include "tabmac.h" #include "tabmac.h"
#include "tabwmi.h" #include "tabwmi.h"
#endif // WIN32 #endif // __WIN__
//#include "tabtbl.h" //#include "tabtbl.h"
#include "tabxcl.h" #include "tabxcl.h"
#include "tabtbl.h" #include "tabtbl.h"
@@ -93,9 +93,9 @@
/***********************************************************************/ /***********************************************************************/
/* Extern static variables. */ /* Extern static variables. */
/***********************************************************************/ /***********************************************************************/
#if defined(WIN32) #if defined(__WIN__)
extern "C" HINSTANCE s_hModule; // Saved module handle extern "C" HINSTANCE s_hModule; // Saved module handle
#endif // !WIN32 #endif // !__WIN__
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
@@ -142,7 +142,7 @@ TABTYPE GetTypeID(const char *type)
: (!stricmp(type, "MYSQL")) ? TAB_MYSQL : (!stricmp(type, "MYSQL")) ? TAB_MYSQL
: (!stricmp(type, "MYPRX")) ? TAB_MYSQL : (!stricmp(type, "MYPRX")) ? TAB_MYSQL
: (!stricmp(type, "DIR")) ? TAB_DIR : (!stricmp(type, "DIR")) ? TAB_DIR
#ifdef WIN32 #ifdef __WIN__
: (!stricmp(type, "MAC")) ? TAB_MAC : (!stricmp(type, "MAC")) ? TAB_MAC
: (!stricmp(type, "WMI")) ? TAB_WMI : (!stricmp(type, "WMI")) ? TAB_WMI
#endif #endif
@@ -349,11 +349,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
typedef PQRYRES (__stdcall *XCOLDEF) (PGLOBAL, void*, char*, char*, bool); typedef PQRYRES (__stdcall *XCOLDEF) (PGLOBAL, void*, char*, char*, bool);
const char *module, *subtype; const char *module, *subtype;
char c, soname[_MAX_PATH], getname[40] = "Col"; char c, soname[_MAX_PATH], getname[40] = "Col";
#if defined(WIN32) #if defined(__WIN__)
HANDLE hdll; /* Handle to the external DLL */ HANDLE hdll; /* Handle to the external DLL */
#else // !WIN32 #else // !__WIN__
void *hdll; /* Handle for the loaded shared library */ void *hdll; /* Handle for the loaded shared library */
#endif // !WIN32 #endif // !__WIN__
XCOLDEF coldef = NULL; XCOLDEF coldef = NULL;
PQRYRES qrp = NULL; PQRYRES qrp = NULL;
@@ -381,7 +381,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
if (!c) break; if (!c) break;
} // endfor i } // endfor i
#if defined(WIN32) #if defined(__WIN__)
// Load the Dll implementing the table // Load the Dll implementing the table
if (!(hdll = LoadLibrary(soname))) { if (!(hdll = LoadLibrary(soname))) {
char buf[256]; char buf[256];
@@ -401,7 +401,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
FreeLibrary((HMODULE)hdll); FreeLibrary((HMODULE)hdll);
return NULL; return NULL;
} // endif coldef } // endif coldef
#else // !WIN32 #else // !__WIN__
const char *error = NULL; const char *error = NULL;
// Load the desired shared library // Load the desired shared library
@@ -418,7 +418,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
dlclose(hdll); dlclose(hdll);
return NULL; return NULL;
} // endif coldef } // endif coldef
#endif // !WIN32 #endif // !__WIN__
// Just in case the external Get function does not set error messages // Just in case the external Get function does not set error messages
sprintf(g->Message, "Error getting column info from %s", subtype); sprintf(g->Message, "Error getting column info from %s", subtype);
@@ -426,11 +426,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
// Get the table column definition // Get the table column definition
qrp = coldef(g, topt, tab, db, info); qrp = coldef(g, topt, tab, db, info);
#if defined(WIN32) #if defined(__WIN__)
FreeLibrary((HMODULE)hdll); FreeLibrary((HMODULE)hdll);
#else // !WIN32 #else // !__WIN__
dlclose(hdll); dlclose(hdll);
#endif // !WIN32 #endif // !__WIN__
return qrp; return qrp;
} // end of OEMColumns } // end of OEMColumns
@@ -442,11 +442,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info)
/***********************************************************************/ /***********************************************************************/
CATALOG::CATALOG(void) CATALOG::CATALOG(void)
{ {
#if defined(WIN32) #if defined(__WIN__)
//DataPath= ".\\"; //DataPath= ".\\";
#else // !WIN32 #else // !__WIN__
//DataPath= "./"; //DataPath= "./";
#endif // !WIN32 #endif // !__WIN__
memset(&Ctb, 0, sizeof(CURTAB)); memset(&Ctb, 0, sizeof(CURTAB));
Cbuf= NULL; Cbuf= NULL;
Cblen= 0; Cblen= 0;
@@ -489,11 +489,11 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path)
} }
if (*path != '.') { if (*path != '.') {
#if defined(WIN32) #if defined(__WIN__)
char *s= "\\"; char *s= "\\";
#else // !WIN32 #else // !__WIN__
char *s= "/"; char *s= "/";
#endif // !WIN32 #endif // !__WIN__
strcat(strcat(strcat(strcpy(buf, "."), s), path), s); strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
} else } else
strcpy(buf, path); strcpy(buf, path);
@@ -554,10 +554,10 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
#if defined(ODBC_SUPPORT) #if defined(ODBC_SUPPORT)
case TAB_ODBC: tdp= new(g) ODBCDEF; break; case TAB_ODBC: tdp= new(g) ODBCDEF; break;
#endif // ODBC_SUPPORT #endif // ODBC_SUPPORT
#if defined(WIN32) #if defined(__WIN__)
case TAB_MAC: tdp= new(g) MACDEF; break; case TAB_MAC: tdp= new(g) MACDEF; break;
case TAB_WMI: tdp= new(g) WMIDEF; break; case TAB_WMI: tdp= new(g) WMIDEF; break;
#endif // WIN32 #endif // __WIN__
case TAB_OEM: tdp= new(g) OEMDEF; break; case TAB_OEM: tdp= new(g) OEMDEF; break;
case TAB_TBL: tdp= new(g) TBLDEF; break; case TAB_TBL: tdp= new(g) TBLDEF; break;
case TAB_XCL: tdp= new(g) XCLDEF; break; case TAB_XCL: tdp= new(g) XCLDEF; break;

View File

@@ -24,7 +24,7 @@
#include "block.h" #include "block.h"
#include "catalog.h" #include "catalog.h"
typedef struct ha_table_option_struct TOS, *PTOS; //typedef struct ha_table_option_struct TOS, *PTOS;
/** /**
structure for CREATE TABLE options (table options) structure for CREATE TABLE options (table options)

View File

@@ -35,11 +35,11 @@
#include "my_sys.h" #include "my_sys.h"
#include "mysqld_error.h" #include "mysqld_error.h"
#endif // !MYSQL_PREPARED_STATEMENTS #endif // !MYSQL_PREPARED_STATEMENTS
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#include "osutil.h" #include "osutil.h"
#endif // !WIN32 #endif // !__WIN__
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
@@ -451,15 +451,15 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt); mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt);
//mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...); //mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...);
#if defined(WIN32) #if defined(__WIN__)
if (!strcmp(host, ".")) { if (!strcmp(host, ".")) {
mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL); mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL);
pipe = mysqld_unix_port; pipe = mysqld_unix_port;
} // endif host } // endif host
#else // !WIN32 #else // !__WIN__
if (!strcmp(host, "localhost")) if (!strcmp(host, "localhost"))
pipe = mysqld_unix_port; pipe = mysqld_unix_port;
#endif // !WIN32 #endif // !__WIN__
#if 0 #if 0
if (pwd && !strcmp(pwd, "*")) { if (pwd && !strcmp(pwd, "*")) {

View File

@@ -7,24 +7,24 @@
/* DO NOT define DLL_EXPORT in your application so these items are */ /* DO NOT define DLL_EXPORT in your application so these items are */
/* declared are imported from the Myconn DLL. */ /* declared are imported from the Myconn DLL. */
/***********************************************************************/ /***********************************************************************/
#if defined(WIN32) #if defined(__WIN__)
#include <winsock.h> #include <winsock.h>
#else // !WIN32 #else // !__WIN__
#include <sys/socket.h> #include <sys/socket.h>
#endif // !WIN32 #endif // !__WIN__
#include <mysql.h> #include <mysql.h>
#include <errmsg.h> #include <errmsg.h>
#include "myutil.h" #include "myutil.h"
#if defined(WIN32) && defined(MYCONN_EXPORTS) #if defined(__WIN__) && defined(MYCONN_EXPORTS)
#if defined(DLL_EXPORT) #if defined(DLL_EXPORT)
#define DllItem _declspec(dllexport) #define DllItem _declspec(dllexport)
#else // !DLL_EXPORT #else // !DLL_EXPORT
#define DllItem _declspec(dllimport) #define DllItem _declspec(dllimport)
#endif // !DLL_EXPORT #endif // !DLL_EXPORT
#else // !WIN32 || !MYCONN_EXPORTS #else // !__WIN__ || !MYCONN_EXPORTS
#define DllItem #define DllItem
#endif // !WIN32 #endif // !__WIN__
#define MYSQL_ENABLED 0x00000001 #define MYSQL_ENABLED 0x00000001
#define MYSQL_LOGON 0x00000002 #define MYSQL_LOGON 0x00000002

View File

@@ -15,11 +15,11 @@ CREATE TABLE t1
( (
fig INT(4) NOT NULL FIELD_FORMAT='C', fig INT(4) NOT NULL FIELD_FORMAT='C',
name CHAR(10) NOT NULL, name CHAR(10) NOT NULL,
birth DATE NOT NULL FIELD_FORMAT='L', birth DATE NOT NULL,
id CHAR(5) NOT NULL FIELD_FORMAT='L2', id CHAR(5) NOT NULL FIELD_FORMAT='S',
salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
dept INT(4) NOT NULL FIELD_FORMAT='L2' dept INT(4) NOT NULL FIELD_FORMAT='S'
) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; ) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little';
SELECT * FROM t1; SELECT * FROM t1;
fig name birth id salary dept fig name birth id salary dept
5500 ARCHIBALD 1980-01-25 3789 4380.50 318 5500 ARCHIBALD 1980-01-25 3789 4380.50 318
@@ -42,11 +42,11 @@ CREATE TABLE t1
( (
fig INT(4) NOT NULL FIELD_FORMAT='C', fig INT(4) NOT NULL FIELD_FORMAT='C',
name CHAR(10) NOT NULL, name CHAR(10) NOT NULL,
birth DATE NOT NULL FIELD_FORMAT='L', birth DATE NOT NULL,
id CHAR(5) NOT NULL FIELD_FORMAT='L2', id CHAR(5) NOT NULL FIELD_FORMAT='S',
salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
dept INT(4) NOT NULL FIELD_FORMAT='L2' dept INT(4) NOT NULL FIELD_FORMAT='S'
) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat'; ) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little';
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
ERROR HY000: Table 't1' is read only ERROR HY000: Table 't1' is read only
ALTER TABLE t1 READONLY=NO; ALTER TABLE t1 READONLY=NO;
@@ -55,11 +55,11 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`fig` int(4) NOT NULL `FIELD_FORMAT`='C', `fig` int(4) NOT NULL `FIELD_FORMAT`='C',
`name` char(10) NOT NULL, `name` char(10) NOT NULL,
`birth` date NOT NULL `FIELD_FORMAT`='L', `birth` date NOT NULL,
`id` char(5) NOT NULL `FIELD_FORMAT`='L2', `id` char(5) NOT NULL `FIELD_FORMAT`='S',
`salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F', `salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F',
`dept` int(4) NOT NULL `FIELD_FORMAT`='L2' `dept` int(4) NOT NULL `FIELD_FORMAT`='S'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `READONLY`=NO ) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=NO
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
SELECT * FROM t1; SELECT * FROM t1;
fig name birth id salary dept fig name birth id salary dept
@@ -74,11 +74,11 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`fig` int(4) NOT NULL `FIELD_FORMAT`='C', `fig` int(4) NOT NULL `FIELD_FORMAT`='C',
`name` char(10) NOT NULL, `name` char(10) NOT NULL,
`birth` date NOT NULL `FIELD_FORMAT`='L', `birth` date NOT NULL,
`id` char(5) NOT NULL `FIELD_FORMAT`='L2', `id` char(5) NOT NULL `FIELD_FORMAT`='S',
`salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F', `salary` double(9,2) NOT NULL DEFAULT '0.00' `FIELD_FORMAT`='F',
`dept` int(4) NOT NULL `FIELD_FORMAT`='L2' `dept` int(4) NOT NULL `FIELD_FORMAT`='S'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `READONLY`=YES ) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=BIN `FILE_NAME`='Testbal.dat' `OPTION_LIST`='Endian=Little' `READONLY`=YES
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
ERROR HY000: Table 't1' is read only ERROR HY000: Table 't1' is read only
DROP TABLE t1; DROP TABLE t1;

View File

@@ -20,11 +20,11 @@ CREATE TABLE t1
( (
fig INT(4) NOT NULL FIELD_FORMAT='C', fig INT(4) NOT NULL FIELD_FORMAT='C',
name CHAR(10) NOT NULL, name CHAR(10) NOT NULL,
birth DATE NOT NULL FIELD_FORMAT='L', birth DATE NOT NULL,
id CHAR(5) NOT NULL FIELD_FORMAT='L2', id CHAR(5) NOT NULL FIELD_FORMAT='S',
salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
dept INT(4) NOT NULL FIELD_FORMAT='L2' dept INT(4) NOT NULL FIELD_FORMAT='S'
) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat'; ) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little';
SELECT * FROM t1; SELECT * FROM t1;
--error ER_GET_ERRMSG --error ER_GET_ERRMSG
@@ -41,11 +41,11 @@ CREATE TABLE t1
( (
fig INT(4) NOT NULL FIELD_FORMAT='C', fig INT(4) NOT NULL FIELD_FORMAT='C',
name CHAR(10) NOT NULL, name CHAR(10) NOT NULL,
birth DATE NOT NULL FIELD_FORMAT='L', birth DATE NOT NULL,
id CHAR(5) NOT NULL FIELD_FORMAT='L2', id CHAR(5) NOT NULL FIELD_FORMAT='S',
salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F', salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
dept INT(4) NOT NULL FIELD_FORMAT='L2' dept INT(4) NOT NULL FIELD_FORMAT='S'
) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat'; ) ENGINE=CONNECT TABLE_TYPE=BIN READONLY=Yes FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little';
--error ER_OPEN_AS_READONLY --error ER_OPEN_AS_READONLY
INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777); INSERT INTO t1 VALUES (7777,'BILL','1973-06-30',4444,5555.555,777);
ALTER TABLE t1 READONLY=NO; ALTER TABLE t1 READONLY=NO;

View File

@@ -13,11 +13,11 @@
/************************************************************************/ /************************************************************************/
#include "my_global.h" #include "my_global.h"
#include <mysql.h> #include <mysql.h>
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#include "osutil.h" #include "osutil.h"
#endif // !WIN32 #endif // !__WIN__
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"

View File

@@ -11,7 +11,7 @@
/***********************************************************************/ /***********************************************************************/
#include <my_global.h> #include <my_global.h>
#include <m_string.h> #include <m_string.h>
#if defined(WIN32) #if defined(__WIN__)
//nclude <io.h> //nclude <io.h>
//nclude <fcntl.h> //nclude <fcntl.h>
#include <direct.h> // for getcwd #include <direct.h> // for getcwd
@@ -45,13 +45,13 @@
#include "osutil.h" #include "osutil.h"
#if defined(WIN32) #if defined(__WIN__)
/***********************************************************************/ /***********************************************************************/
/* For dynamic load of ODBC32.DLL */ /* For dynamic load of ODBC32.DLL */
/***********************************************************************/ /***********************************************************************/
#pragma comment(lib, "odbc32.lib") #pragma comment(lib, "odbc32.lib")
extern "C" HINSTANCE s_hModule; // Saved module handle extern "C" HINSTANCE s_hModule; // Saved module handle
#endif // WIN32 #endif // __WIN__
int GetConvSize(); int GetConvSize();
@@ -116,16 +116,24 @@ static int GetSQLCType(int type)
/***********************************************************************/ /***********************************************************************/
/* TranslateSQLType: translate a SQL Type to a PLG type. */ /* TranslateSQLType: translate a SQL Type to a PLG type. */
/***********************************************************************/ /***********************************************************************/
int TranslateSQLType(int stp, int prec, int& len, char& v) int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w)
{ {
int type; int type;
switch (stp) { switch (stp) {
case SQL_WVARCHAR: // (-9)
w = true;
case SQL_VARCHAR: // 12 case SQL_VARCHAR: // 12
v = 'V'; v = 'V';
type = TYPE_STRING;
break;
case SQL_WCHAR: // (-8)
w = true;
case SQL_CHAR: // 1 case SQL_CHAR: // 1
type = TYPE_STRING; type = TYPE_STRING;
break; break;
case SQL_WLONGVARCHAR: // (-10)
w = true;
case SQL_LONGVARCHAR: // (-1) case SQL_LONGVARCHAR: // (-1)
v = 'V'; v = 'V';
type = TYPE_STRING; type = TYPE_STRING;
@@ -180,7 +188,6 @@ int TranslateSQLType(int stp, int prec, int& len, char& v)
case SQL_BINARY: // (-2) case SQL_BINARY: // (-2)
case SQL_VARBINARY: // (-3) case SQL_VARBINARY: // (-3)
case SQL_LONGVARBINARY: // (-4) case SQL_LONGVARBINARY: // (-4)
// case SQL_BIT: // (-7)
case SQL_GUID: // (-11) case SQL_GUID: // (-11)
default: default:
type = TYPE_ERROR; type = TYPE_ERROR;
@@ -410,6 +417,7 @@ PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop)
PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info)
{ {
// int i, type, len, prec; // int i, type, len, prec;
bool w = false;
// PCOLRES crp, crpt, crpl, crpp; // PCOLRES crp, crpt, crpl, crpp;
PQRYRES qrp; PQRYRES qrp;
ODBConn *ocp; ODBConn *ocp;
@@ -455,7 +463,7 @@ PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info)
type = crpt->Kdata->GetIntValue(i); type = crpt->Kdata->GetIntValue(i);
len = crpl->Kdata->GetIntValue(i); len = crpl->Kdata->GetIntValue(i);
prec = crpp->Kdata->GetIntValue(i); prec = crpp->Kdata->GetIntValue(i);
type = TranslateSQLType(type, prec, len); type = TranslateSQLType(type, prec, len, w);
crpt->Kdata->SetValue(type, i); crpt->Kdata->SetValue(type, i);
// Some data sources do not count prec in length // Some data sources do not count prec in length
@@ -1201,15 +1209,15 @@ bool ODBConn::DriverConnect(DWORD Options)
SWORD nResult; SWORD nResult;
PUCHAR ConnOut = (PUCHAR)PlugSubAlloc(m_G, NULL, MAX_CONNECT_LEN); PUCHAR ConnOut = (PUCHAR)PlugSubAlloc(m_G, NULL, MAX_CONNECT_LEN);
UWORD wConnectOption = SQL_DRIVER_COMPLETE; UWORD wConnectOption = SQL_DRIVER_COMPLETE;
#if defined(WIN32) #if defined(__WIN__)
HWND hWndTop = GetForegroundWindow(); HWND hWndTop = GetForegroundWindow();
HWND hWnd = GetParent(hWndTop); HWND hWnd = GetParent(hWndTop);
if (hWnd == NULL) if (hWnd == NULL)
hWnd = GetDesktopWindow(); hWnd = GetDesktopWindow();
#else // !WIN32 #else // !__WIN__
HWND hWnd = (HWND)1; HWND hWnd = (HWND)1;
#endif // !WIN32 #endif // !__WIN__
PGLOBAL& g = m_G; PGLOBAL& g = m_G;
PDBUSER dup = PlgGetUser(g); PDBUSER dup = PlgGetUser(g);
@@ -1222,10 +1230,10 @@ bool ODBConn::DriverConnect(DWORD Options)
SQL_NTS, ConnOut, MAX_CONNECT_LEN, SQL_NTS, ConnOut, MAX_CONNECT_LEN,
&nResult, wConnectOption); &nResult, wConnectOption);
#if defined(WIN32) #if defined(__WIN__)
if (hWndTop) if (hWndTop)
EnableWindow(hWndTop, true); EnableWindow(hWndTop, true);
#endif // WIN32 #endif // __WIN__
// If user hit 'Cancel' // If user hit 'Cancel'
if (rc == SQL_NO_DATA_FOUND) { if (rc == SQL_NO_DATA_FOUND) {

View File

@@ -29,9 +29,9 @@
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name //efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type #define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type
#if !defined(WIN32) #if !defined(__WIN__)
typedef unsigned char *PUCHAR; typedef unsigned char *PUCHAR;
#endif // !WIN32 #endif // !__WIN__
// Field Flags, used to indicate status of fields // Field Flags, used to indicate status of fields
//efine SQL_FIELD_FLAG_DIRTY 0x1 //efine SQL_FIELD_FLAG_DIRTY 0x1

View File

@@ -15,16 +15,16 @@ typedef off_t off64_t;
#endif #endif
#endif #endif
#if defined(WIN32) #if defined(__WIN__)
typedef __int64 BIGINT; typedef __int64 BIGINT;
#else // !WIN32 #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
#endif // !WIN32 #endif // !__WIN__
#if !defined(WIN32) #if !defined(__WIN__)
typedef const void *LPCVOID; typedef const void *LPCVOID;
typedef const char *LPCTSTR; typedef const char *LPCTSTR;
typedef const char *LPCSTR; typedef const char *LPCSTR;
@@ -61,6 +61,6 @@ typedef int HANDLE;
#define _MAX_EXT FN_EXTLEN #define _MAX_EXT FN_EXTLEN
#define INVALID_HANDLE_VALUE (-1) #define INVALID_HANDLE_VALUE (-1)
#define __stdcall #define __stdcall
#endif /* !WIN32 */ #endif /* !__WIN__ */
#endif /* _OS_H_INCLUDED */ #endif /* _OS_H_INCLUDED */

View File

@@ -4,7 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include "osutil.h" #include "osutil.h"
#ifdef WIN32 #ifdef __WIN__
my_bool CloseFileHandle(HANDLE h) my_bool CloseFileHandle(HANDLE h)
{ {
return !CloseHandle(h); return !CloseHandle(h);

View File

@@ -389,6 +389,7 @@ typedef struct _qryres *PQRYRES;
typedef struct _colres *PCOLRES; typedef struct _colres *PCOLRES;
typedef struct _datpar *PDTP; typedef struct _datpar *PDTP;
typedef struct indx_used *PXUSED; typedef struct indx_used *PXUSED;
typedef struct ha_table_option_struct TOS, *PTOS;
/***********************************************************************/ /***********************************************************************/
/* Utility blocks for file and storage. */ /* Utility blocks for file and storage. */
@@ -543,11 +544,11 @@ typedef struct _colres {
char Var; /* Type added information */ char Var; /* Type added information */
} COLRES; } COLRES;
#if defined(WIN32) && !defined(NOEX) #if defined(__WIN__) && !defined(NOEX)
#define DllExport __declspec( dllexport ) #define DllExport __declspec( dllexport )
#else // !WIN32 #else // !__WIN__
#define DllExport #define DllExport
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Utility routines. */ /* Utility routines. */
@@ -593,6 +594,9 @@ DllExport void NewPointer(PTABS, void *, void *);
DllExport void SetTrc(void); DllExport void SetTrc(void);
DllExport char *GetListOption(PGLOBAL, const char *, const char *, DllExport char *GetListOption(PGLOBAL, const char *, const char *,
const char *def=NULL); const char *def=NULL);
DllExport char *GetStringTableOption(PGLOBAL, PTOS, char *, char *);
DllExport bool GetBooleanTableOption(PGLOBAL, PTOS, char *, bool);
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

@@ -38,12 +38,12 @@
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#define BIGMEM 1048576 // 1 Megabyte #define BIGMEM 1048576 // 1 Megabyte
#else // !WIN32 #else // !__WIN__
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#if defined(THREAD) #if defined(THREAD)
@@ -51,7 +51,7 @@
#endif // THREAD #endif // THREAD
#include <stdarg.h> #include <stdarg.h>
#define BIGMEM 2147483647 // Max int value #define BIGMEM 2147483647 // Max int value
#endif // !WIN32 #endif // !__WIN__
#include <locale.h> #include <locale.h>
/***********************************************************************/ /***********************************************************************/
@@ -73,11 +73,11 @@
/* Macro or external routine definition */ /* Macro or external routine definition */
/***********************************************************************/ /***********************************************************************/
#if defined(THREAD) #if defined(THREAD)
#if defined(WIN32) #if defined(__WIN__)
extern CRITICAL_SECTION parsec; // Used calling the Flex parser extern CRITICAL_SECTION parsec; // Used calling the Flex parser
#else // !WIN32 #else // !__WIN__
extern pthread_mutex_t parmut; extern pthread_mutex_t parmut;
#endif // !WIN32 #endif // !__WIN__
#endif // THREAD #endif // THREAD
/***********************************************************************/ /***********************************************************************/
@@ -403,11 +403,11 @@ char *SetPath(PGLOBAL g, const char *path)
} // endif path } // endif path
if (*path != '.') { if (*path != '.') {
#if defined(WIN32) #if defined(__WIN__)
char *s= "\\"; char *s= "\\";
#else // !WIN32 #else // !__WIN__
char *s= "/"; char *s= "/";
#endif // !WIN32 #endif // !__WIN__
strcat(strcat(strcat(strcpy(buf, "."), s), path), s); strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
} else } else
strcpy(buf, path); strcpy(buf, path);
@@ -426,7 +426,7 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op)
char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL; char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL;
switch (op) { // Determine which part to extract switch (op) { // Determine which part to extract
#if !defined(UNIX) #if defined(__WIN__)
case OP_FDISK: drive = pBuff; break; case OP_FDISK: drive = pBuff; break;
#endif // !UNIX #endif // !UNIX
case OP_FPATH: direc = pBuff; break; case OP_FPATH: direc = pBuff; break;
@@ -702,19 +702,19 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag)
/* instruction is included in an Enter/LeaveCriticalSection bracket. */ /* instruction is included in an Enter/LeaveCriticalSection bracket. */
/*********************************************************************/ /*********************************************************************/
#if defined(THREAD) #if defined(THREAD)
#if defined(WIN32) #if defined(__WIN__)
EnterCriticalSection((LPCRITICAL_SECTION)&parsec); EnterCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !WIN32 #else // !__WIN__
pthread_mutex_lock(&parmut); pthread_mutex_lock(&parmut);
#endif // !WIN32 #endif // !__WIN__
#endif // THREAD #endif // THREAD
/*int rc =*/ fmdflex(pdp); /*int rc =*/ fmdflex(pdp);
#if defined(THREAD) #if defined(THREAD)
#if defined(WIN32) #if defined(__WIN__)
LeaveCriticalSection((LPCRITICAL_SECTION)&parsec); LeaveCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !WIN32 #else // !__WIN__
pthread_mutex_unlock(&parmut); pthread_mutex_unlock(&parmut);
#endif // !WIN32 #endif // !__WIN__
#endif // THREAD #endif // THREAD
if (trace) if (trace)
@@ -1109,7 +1109,7 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp)
return amn; return amn;
} // end of GetAmName } // end of GetAmName
#if defined(WIN32) && !defined(NOCATCH) #if defined(__WIN__) && !defined(NOCATCH)
/***********************************************************************/ /***********************************************************************/
/* GetExceptionDesc: return the description of an exception code. */ /* GetExceptionDesc: return the description of an exception code. */
/***********************************************************************/ /***********************************************************************/
@@ -1197,7 +1197,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e)
return p; return p;
} // end of GetExceptionDesc } // end of GetExceptionDesc
#endif // WIN32 && !NOCATCH #endif // __WIN__ && !NOCATCH
/***********************************************************************/ /***********************************************************************/
/* PlgDBalloc: allocates or suballocates memory conditionally. */ /* PlgDBalloc: allocates or suballocates memory conditionally. */
@@ -1239,7 +1239,7 @@ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp)
if (!mp.Sub) { if (!mp.Sub) {
// For allocations greater than one fourth of remaining storage // For allocations greater than one fourth of remaining storage
// in the area, do allocate from virtual storage. // in the area, do allocate from virtual storage.
#if defined(WIN32) #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, PAGE_READWRITE);
else else
@@ -1336,7 +1336,7 @@ void PlgDBfree(MBLOCK& mp)
htrc("PlgDBfree: %p sub=%d size=%d\n", mp.Memp, mp.Sub, mp.Size); htrc("PlgDBfree: %p sub=%d size=%d\n", mp.Memp, mp.Sub, mp.Size);
if (!mp.Sub && mp.Memp) if (!mp.Sub && mp.Memp)
#if defined(WIN32) #if defined(__WIN__)
if (mp.Size >= BIGMEM) if (mp.Size >= BIGMEM)
VirtualFree(mp.Memp, 0, MEM_RELEASE); VirtualFree(mp.Memp, 0, MEM_RELEASE);
else else
@@ -1532,11 +1532,11 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
bp[0] = buff1; bp[1] = buff2; bp[0] = buff1; bp[1] = buff2;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
#if defined(WIN32) #if defined(__WIN__)
h[i]= global_open(g, MSGID_NONE, fn[i], _O_RDONLY | _O_BINARY); h[i]= global_open(g, MSGID_NONE, fn[i], _O_RDONLY | _O_BINARY);
#else // !WIN32 #else // !__WIN__
h[i]= global_open(g, MSGOD_NONE, fn[i], O_RDONLY); h[i]= global_open(g, MSGOD_NONE, fn[i], O_RDONLY);
#endif // !WIN32 #endif // !__WIN__
if (h[i] == -1) { if (h[i] == -1) {
// if (errno != ENOENT) { // if (errno != ENOENT) {

View File

@@ -44,7 +44,7 @@
/* */ /* */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#else #else
#if defined(UNIX) || defined(UNIV_LINUX) #if defined(UNIX) || defined(UNIV_LINUX)
@@ -80,9 +80,9 @@
#include "rcmsg.h" #include "rcmsg.h"
#endif // NEWMSG #endif // NEWMSG
#if defined(WIN32) #if defined(__WIN__)
extern HINSTANCE s_hModule; /* Saved module handle */ extern HINSTANCE s_hModule; /* Saved module handle */
#endif // WIN32 #endif // __WIN__
#if defined(XMSG) #if defined(XMSG)
extern char *msg_path; extern char *msg_path;
@@ -192,7 +192,7 @@ int PlugExit(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName)
{ {
#if !defined(UNIX) && !defined(UNIV_LINUX) #if defined(__WIN__)
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
#else #else
char *drive = NULL; char *drive = NULL;
@@ -220,7 +220,7 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName)
BOOL PlugIsAbsolutePath(LPCSTR path) BOOL PlugIsAbsolutePath(LPCSTR path)
{ {
#if defined(WIN32) #if defined(__WIN__)
return ((path[0] >= 'a' && path[0] <= 'z') || return ((path[0] >= 'a' && path[0] <= 'z') ||
(path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':'; (path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':';
#else #else
@@ -238,7 +238,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
char direc[_MAX_DIR], defdir[_MAX_DIR], tmpdir[_MAX_DIR]; char direc[_MAX_DIR], defdir[_MAX_DIR], tmpdir[_MAX_DIR];
char fname[_MAX_FNAME]; char fname[_MAX_FNAME];
char ftype[_MAX_EXT]; char ftype[_MAX_EXT];
#if !defined(UNIX) && !defined(UNIV_LINUX) #if defined(__WIN__)
char drive[_MAX_DRIVE], defdrv[_MAX_DRIVE]; char drive[_MAX_DRIVE], defdrv[_MAX_DRIVE];
#else #else
char *drive = NULL, *defdrv = NULL; char *drive = NULL, *defdrv = NULL;
@@ -255,7 +255,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
return pBuff; return pBuff;
} // endif } // endif
#if !defined(WIN32) #if !defined(__WIN__)
if (*FileName == '~') { if (*FileName == '~') {
if (_fullpath(pBuff, FileName, _MAX_PATH)) { if (_fullpath(pBuff, FileName, _MAX_PATH)) {
if (trace > 1) if (trace > 1)
@@ -266,7 +266,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
return FileName; // Error, return unchanged name return FileName; // Error, return unchanged name
} // endif FileName } // endif FileName
#endif // !WIN32 #endif // !__WIN__
if (prefix && strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath)) if (prefix && strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath))
{ {
@@ -295,11 +295,11 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
if (trace > 1) { if (trace > 1) {
htrc("after _splitpath: FileName=%s\n", FileName); htrc("after _splitpath: FileName=%s\n", FileName);
#if defined(UNIX) || defined(UNIV_LINUX) #if defined(__WIN__)
htrc("dir=%s fname=%s ext=%s\n", direc, fname, ftype);
#else
htrc("drive=%s dir=%s fname=%s ext=%s\n", drive, direc, fname, ftype); htrc("drive=%s dir=%s fname=%s ext=%s\n", drive, direc, fname, ftype);
htrc("defdrv=%s defdir=%s\n", defdrv, defdir); htrc("defdrv=%s defdir=%s\n", defdrv, defdir);
#else
htrc("dir=%s fname=%s ext=%s\n", direc, fname, ftype);
#endif #endif
} // endif trace } // endif trace
@@ -427,7 +427,7 @@ char *PlugGetMessage(PGLOBAL g, int mid)
} // end of PlugGetMessage } // end of PlugGetMessage
#endif // NEWMSG #endif // NEWMSG
#if defined(WIN32) #if defined(__WIN__)
/***********************************************************************/ /***********************************************************************/
/* Return the line length of the console screen buffer. */ /* Return the line length of the console screen buffer. */
/***********************************************************************/ /***********************************************************************/
@@ -439,7 +439,7 @@ short GetLineLength(PGLOBAL g)
return (b) ? coninfo.dwSize.X : 0; return (b) ? coninfo.dwSize.X : 0;
} // end of GetLineLength } // end of GetLineLength
#endif // WIN32 #endif // __WIN__
/***********************************************************************/ /***********************************************************************/
/* Program for memory allocation of work and language areas. */ /* Program for memory allocation of work and language areas. */
@@ -502,7 +502,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */ size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */
pph = (PPOOLHEADER)memp; pph = (PPOOLHEADER)memp;
if (trace > 2) if (trace > 3)
htrc("SubAlloc in %p size=%d used=%d free=%d\n", htrc("SubAlloc in %p size=%d used=%d free=%d\n",
memp, size, pph->To_Free, pph->FreeBlk); memp, size, pph->To_Free, pph->FreeBlk);
@@ -526,7 +526,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
pph->To_Free += size; /* New offset of pool free block */ pph->To_Free += size; /* New offset of pool free block */
pph->FreeBlk -= size; /* New size of pool free block */ pph->FreeBlk -= size; /* New size of pool free block */
if (trace > 2) if (trace > 3)
htrc("Done memp=%p used=%d free=%d\n", htrc("Done memp=%p used=%d free=%d\n",
memp, pph->To_Free, pph->FreeBlk); memp, pph->To_Free, pph->FreeBlk);

View File

@@ -21,9 +21,9 @@
#include "msgid.h" #include "msgid.h"
#endif // NEWMSG #endif // NEWMSG
#if !defined(WIN32) #if !defined(__WIN__)
#define stricmp strcasecmp #define stricmp strcasecmp
#endif // !WIN32 #endif // !__WIN__
char *msglang(void); char *msglang(void);

View File

@@ -17,7 +17,7 @@
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <sqlext.h> #include <sqlext.h>
#else #else
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ... #include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
@@ -48,9 +48,9 @@
#include "tabmul.h" #include "tabmul.h"
#include "ha_connect.h" #include "ha_connect.h"
#if !defined(WIN32) #if !defined(__WIN__)
extern handlerton *connect_hton; extern handlerton *connect_hton;
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* External function. */ /* External function. */
@@ -247,7 +247,7 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
/***********************************************************************/ /***********************************************************************/
PSZ TABDEF::GetPath(void) PSZ TABDEF::GetPath(void)
{ {
return (Database) ? (PSZ)Database : Hc->GetDataPath(); return (Database) ? (PSZ)Database : (Hc) ? Hc->GetDataPath() : NULL;
} // end of GetPath } // end of GetPath
/***********************************************************************/ /***********************************************************************/
@@ -256,7 +256,8 @@ PSZ TABDEF::GetPath(void)
int TABDEF::GetColCatInfo(PGLOBAL g) int TABDEF::GetColCatInfo(PGLOBAL g)
{ {
char *type= GetStringCatInfo(g, "Type", "*"); char *type= GetStringCatInfo(g, "Type", "*");
int i, loff, poff, nof, nlg; char c, fty, eds;
int i, n, loff, poff, nof, nlg;
void *field= NULL; void *field= NULL;
TABTYPE tc; TABTYPE tc;
PCOLDEF cdp, lcdp= NULL, tocols= NULL; PCOLDEF cdp, lcdp= NULL, tocols= NULL;
@@ -331,28 +332,52 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
cdp->SetOffset(0); // Not to have shift cdp->SetOffset(0); // Not to have shift
case TAB_BIN: case TAB_BIN:
// BIN/VEC are packed by default // BIN/VEC are packed by default
if (nof) if (nof) {
// Field width is the internal representation width // Field width is the internal representation width
// that can also depend on the column format // that can also depend on the column format
switch (cdp->Fmt ? *cdp->Fmt : cdp->Decode ? 'C' : 'X') { fty = cdp->Decode ? 'C' : 'X';
case 'X': nof= cdp->Clen; eds = 0;
case 'C': break; n = 0;
case 'R':
case 'F':
// case 'L':
case 'I': nof= 4; break;
case 'D': nof= 8; break;
case 'S': nof= 2; break;
case 'T': nof= 1; break;
default: /* New format */
for (nof= 0, i= 0; cdp->Fmt[i]; i++)
if (isdigit(cdp->Fmt[i]))
nof= (nof * 10 + (cdp->Fmt[i] - '0'));
if (!nof) if (cdp->Fmt && !cdp->Decode) {
for (i = 0; cdp->Fmt[i]; i++) {
c = toupper(cdp->Fmt[i]);
if (isdigit(c))
n = (n * 10 + (c - '0'));
else if (c == 'L' || c == 'B' || c == 'H')
eds = c;
else
fty = c;
} // endfor i
} // endif Fmt
if (n)
nof = n;
else switch (fty) {
case 'X':
if (eds && IsTypeChar(cdp->Buf_Type))
nof = sizeof(longlong);
else
nof= cdp->Clen; nof= cdp->Clen;
} // endswitch Fmt break;
case 'C': break;
case 'R':
case 'F': nof = sizeof(float); break;
case 'I': nof = sizeof(int); break;
case 'D': nof = sizeof(double); break;
case 'S': nof = sizeof(short); break;
case 'T': nof = sizeof(char); break;
case 'G': nof = sizeof(longlong); break;
default: /* Wrong format */
sprintf(g->Message, "Invalid format %c", fty);
return -1;
} // endswitch fty
} // endif nof
default: default:
break; break;
@@ -454,7 +479,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
} else } else
PlugSetPath(soname, Module, GetPluginDir()); PlugSetPath(soname, Module, GetPluginDir());
#if defined(WIN32) #if defined(__WIN__)
// Is the DLL already loaded? // Is the DLL already loaded?
if (!Hdll && !(Hdll = GetModuleHandle(soname))) if (!Hdll && !(Hdll = GetModuleHandle(soname)))
// No, load the Dll implementing the function // No, load the Dll implementing the function
@@ -483,7 +508,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
FreeLibrary((HMODULE)Hdll); FreeLibrary((HMODULE)Hdll);
return NULL; return NULL;
} // endif getdef } // endif getdef
#else // !WIN32 #else // !__WIN__
const char *error = NULL; const char *error = NULL;
Dl_info dl_info; Dl_info dl_info;
@@ -526,7 +551,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
dlclose(Hdll); dlclose(Hdll);
return NULL; return NULL;
} // endif getdef } // endif getdef
#endif // !WIN32 #endif // !__WIN__
// Just in case the external Get function does not set error messages // Just in case the external Get function does not set error messages
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype); sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);

View File

@@ -139,11 +139,11 @@ class DllExport OEMDEF : public TABDEF { /* OEM table */
PTABDEF GetXdef(PGLOBAL g); PTABDEF GetXdef(PGLOBAL g);
// Members // Members
#if defined(WIN32) #if defined(__WIN__)
HANDLE Hdll; /* Handle to the external DLL */ HANDLE Hdll; /* Handle to the external DLL */
#else // !WIN32 #else // !__WIN__
void *Hdll; /* Handle for the loaded shared library */ void *Hdll; /* Handle for the loaded shared library */
#endif // !WIN32 #endif // !__WIN__
PTABDEF Pxdef; /* Pointer to the external TABDEF class */ PTABDEF Pxdef; /* Pointer to the external TABDEF class */
char *Module; /* Path/Name of the DLL implenting it */ char *Module; /* Path/Name of the DLL implenting it */
char *Subtype; /* The name of the OEM table sub type */ char *Subtype; /* The name of the OEM table sub type */

View File

@@ -17,7 +17,7 @@
/* Include relevant sections of the System header files. */ /* Include relevant sections of the System header files. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <sys\timeb.h> // For testing only #include <sys\timeb.h> // For testing only
#include <fcntl.h> #include <fcntl.h>
@@ -26,7 +26,7 @@
#define __MFC_COMPAT__ // To define min/max as macro #define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__ #endif // __BORLANDC__
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) #if defined(UNIX)
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@@ -34,7 +34,7 @@
#include <io.h> #include <io.h>
#endif // !UNIX #endif // !UNIX
#include <fcntl.h> #include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */
@@ -112,6 +112,7 @@ DOSDEF::DOSDEF(void)
Maxerr = 0; Maxerr = 0;
ReadMode = 0; ReadMode = 0;
Ending = 0; Ending = 0;
Teds = 0;
} // end of DOSDEF constructor } // end of DOSDEF constructor
/***********************************************************************/ /***********************************************************************/
@@ -146,6 +147,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
Padded = GetBoolCatInfo("Padded", false); Padded = GetBoolCatInfo("Padded", false);
Blksize = GetIntCatInfo("Blksize", 0); Blksize = GetIntCatInfo("Blksize", 0);
Eof = (GetIntCatInfo("EOF", 0) != 0); Eof = (GetIntCatInfo("EOF", 0) != 0);
Teds = toupper(*GetStringCatInfo(g, "Endian", ""));
} else if (Recfm == RECFM_DBF) { } else if (Recfm == RECFM_DBF) {
Maxerr = GetIntCatInfo("Maxerr", 0); Maxerr = GetIntCatInfo("Maxerr", 0);
Accept = GetBoolCatInfo("Accept", false); Accept = GetBoolCatInfo("Accept", false);
@@ -206,11 +208,11 @@ void DOSDEF::RemoveOptValues(PGLOBAL g)
// Delete any eventually ill formed non matching optimization file // Delete any eventually ill formed non matching optimization file
if (!GetOptFileName(g, filename)) if (!GetOptFileName(g, filename))
#if defined(WIN32) #if defined(__WIN__)
DeleteFile(filename); DeleteFile(filename);
#else // UNIX #else // UNIX
remove(filename); remove(filename);
#endif // WIN32 #endif // __WIN__
Optimized = 0; Optimized = 0;
} // end of RemoveOptValues } // end of RemoveOptValues
@@ -251,7 +253,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
/*********************************************************************/ /*********************************************************************/
if (sep) { if (sep) {
// Indexes are save in separate files // Indexes are save in separate files
#if !defined(UNIX) #if defined(__WIN__)
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
#else #else
char *drive = NULL; char *drive = NULL;
@@ -268,7 +270,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
strcat(strcat(fname, "_"), pxdf->GetName()); strcat(strcat(fname, "_"), pxdf->GetName());
_makepath(filename, drive, direc, fname, ftype); _makepath(filename, drive, direc, fname, ftype);
PlugSetPath(filename, filename, GetPath()); PlugSetPath(filename, filename, GetPath());
#if defined(WIN32) #if defined(__WIN__)
if (!DeleteFile(filename)) if (!DeleteFile(filename))
rc |= (GetLastError() != ERROR_FILE_NOT_FOUND); rc |= (GetLastError() != ERROR_FILE_NOT_FOUND);
#else // UNIX #else // UNIX
@@ -285,7 +287,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
// Drop all indexes, delete the common file // Drop all indexes, delete the common file
PlugSetPath(filename, Ofn, GetPath()); PlugSetPath(filename, Ofn, GetPath());
strcat(PlugRemoveType(filename, filename), ftype); strcat(PlugRemoveType(filename, filename), ftype);
#if defined(WIN32) #if defined(__WIN__)
if (!DeleteFile(filename)) if (!DeleteFile(filename))
rc = (GetLastError() != ERROR_FILE_NOT_FOUND); rc = (GetLastError() != ERROR_FILE_NOT_FOUND);
#else // UNIX #else // UNIX
@@ -954,7 +956,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
#if 0 #if 0
if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS) if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS)
return false; return false;
#endif // WIN32 #endif // __WIN__
if (defp->Optimized) if (defp->Optimized)
return false; // Already done or to be redone return false; // Already done or to be redone

View File

@@ -91,6 +91,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
int Maxerr; /* Maximum number of bad records (DBF) */ int Maxerr; /* Maximum number of bad records (DBF) */
int ReadMode; /* Specific to DBF */ int ReadMode; /* Specific to DBF */
int Ending; /* Length of end of lines */ int Ending; /* Length of end of lines */
int Teds; /* Binary table default endian setting */
}; // end of DOSDEF }; // end of DOSDEF
/***********************************************************************/ /***********************************************************************/

View File

@@ -17,7 +17,7 @@
/* Include relevant section of system dependant header files. */ /* Include relevant section of system dependant header files. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
@@ -25,7 +25,7 @@
#define __MFC_COMPAT__ // To define min/max as macro #define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__ #endif // __BORLANDC__
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) #if defined(UNIX)
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -35,7 +35,7 @@
#include <io.h> #include <io.h>
#endif // !UNIX #endif // !UNIX
#include <fcntl.h> #include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */
@@ -68,10 +68,12 @@ USETEMP UseTemp(void);
/***********************************************************************/ /***********************************************************************/
TDBFIX::TDBFIX(PDOSDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) TDBFIX::TDBFIX(PDOSDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
{ {
Teds = tdp->Teds; // For BIN tables
} // end of TDBFIX standard constructor } // end of TDBFIX standard constructor
TDBFIX::TDBFIX(PGLOBAL g, PTDBFIX tdbp) : TDBDOS(g, tdbp) TDBFIX::TDBFIX(PGLOBAL g, PTDBFIX tdbp) : TDBDOS(g, tdbp)
{ {
Teds = tdbp->Teds;
} // end of TDBFIX copy constructor } // end of TDBFIX copy constructor
// Method // Method
@@ -374,42 +376,63 @@ int TDBFIX::WriteDB(PGLOBAL g)
BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am) BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
: DOSCOL(g, cdp, tp, cp, i, am) : DOSCOL(g, cdp, tp, cp, i, am)
{ {
char *fmt = cdp->GetFmt(); char c, *fmt = cdp->GetFmt();
Fmt = GetDomain() ? 'C' : 'X';
Buff = NULL; Buff = NULL;
Eds = ((PTDBFIX)tp)->Teds;
N = 0;
M = GetTypeSize(Buf_Type, sizeof(longlong)); M = GetTypeSize(Buf_Type, sizeof(longlong));
Lim = 0; Lim = 0;
if (fmt) { if (fmt) {
Fmt = 'H'; for (N = 0, i = 0; fmt[i]; i++) {
c = toupper(fmt[i]);
for (N = 0, i = 0; fmt[i]; i++) if (isdigit(c))
if (isdigit(fmt[i])) N = (N * 10 + (c - '0'));
N = (N * 10 + (fmt[i] - '0')); else if (c == 'L' || c == 'B' || c == 'H')
Eds = c;
else else
Fmt = toupper(fmt[i]); Fmt = c;
if (N == GetTypeSize(Buf_Type, -1) && (Fmt == 'H' || Fmt == Endian)) { } // endfor i
// New format is a no op
N = 0;
Fmt = 'X';
} else if (Fmt == 'L' || Fmt == 'B' || Fmt == 'H') {
// This is a new format
if (!N)
N = GetTypeSize(Buf_Type, Long);
if (Fmt == 'H') // M is the size of the source value
Fmt = Endian; switch (Fmt) {
case 'C': Eds = 0; break;
case 'X': break;
case 'S': M = sizeof(short); break;
case 'T': M = sizeof(char); break;
case 'I': M = sizeof(int); break;
case 'G': M = sizeof(longlong); break;
case 'R': // Real
case 'F': M = sizeof(float); break;
case 'D': M = sizeof(double); break;
default:
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
longjmp(g->jumper[g->jump_level], 11);
} // endswitch Fmt
} else if (IsTypeChar(Buf_Type))
Eds = 0;
if (Eds) {
// This is a byte order specification
if (!N)
N = M;
if (Eds != 'L' && Eds != 'B')
Eds = Endian;
if (N != M || Eds != Endian || IsTypeChar(Buf_Type)) {
Buff = (char*)PlugSubAlloc(g, NULL, M); Buff = (char*)PlugSubAlloc(g, NULL, M);
memset(Buff, 0, M); memset(Buff, 0, M);
Lim = MY_MIN(N, M); Lim = MY_MIN(N, M);
} // endif Fmt } else
Eds = 0; // New format is a no op
} else { } // endif Eds
N = 0;
Fmt = GetDomain() ? 'C' : 'X';
} // endif fmt
} // end of BINCOL constructor } // end of BINCOL constructor
@@ -419,6 +442,7 @@ BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
/***********************************************************************/ /***********************************************************************/
BINCOL::BINCOL(BINCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp) BINCOL::BINCOL(BINCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
{ {
Eds = col1->Eds;
Fmt = col1->Fmt; Fmt = col1->Fmt;
N = col1->N; N = col1->N;
M = col1->M; M = col1->M;
@@ -470,25 +494,27 @@ void BINCOL::ReadColumn(PGLOBAL g)
/*********************************************************************/ /*********************************************************************/
/* Set Value from the line field. */ /* Set Value from the line field. */
/*********************************************************************/ /*********************************************************************/
if (N) { if (Eds) {
for (int i = 0; i < Lim; i++) for (int i = 0; i < Lim; i++)
if (Fmt == 'B' && Endian == 'L') if (Eds == 'B' && Endian == 'L')
Buff[i] = p[N - i - 1]; Buff[i] = p[N - i - 1];
else if (Fmt == 'L' && Endian == 'B') else if (Eds == 'L' && Endian == 'B')
Buff[M - i - 1] = p[i]; Buff[M - i - 1] = p[i];
else if (Endian == 'B') else if (Endian == 'B')
Buff[M - i - 1] = p[N - i - 1]; Buff[M - i - 1] = p[N - i - 1];
else else
Buff[i] = p[i]; Buff[i] = p[i];
if (IsTypeChar(Buf_Type)) p = Buff;
Value->SetValue(*(longlong*)Buff); } // endif Eds
else
Value->SetBinValue(Buff);
} else switch (Fmt) { switch (Fmt) {
case 'X': // Standard not converted values case 'X': // Standard not converted values
Value->SetBinValue(p); if (Eds && IsTypeChar(Buf_Type))
Value->SetValue(*(longlong*)p);
else
Value->SetBinValue(p);
break; break;
case 'S': // Short integer case 'S': // Short integer
Value->SetValue(*(short*)p); Value->SetValue(*(short*)p);
@@ -496,12 +522,12 @@ void BINCOL::ReadColumn(PGLOBAL g)
case 'T': // Tiny integer case 'T': // Tiny integer
Value->SetValue(*p); Value->SetValue(*p);
break; break;
// case 'L': // Long Integer
// strcpy(g->Message, "Format L is deprecated, use I");
// longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer case 'I': // Integer
Value->SetValue(*(int*)p); Value->SetValue(*(int*)p);
break; break;
case 'G': // Large (great) integer
Value->SetValue(*(longlong*)p);
break;
case 'F': // Float case 'F': // Float
case 'R': // Real case 'R': // Real
Value->SetValue((double)*(float*)p); Value->SetValue((double)*(float*)p);
@@ -553,41 +579,23 @@ void BINCOL::WriteColumn(PGLOBAL g)
if (Value != To_Val) if (Value != To_Val)
Value->SetValue_pval(To_Val, false); // Convert the updated value Value->SetValue_pval(To_Val, false); // Convert the updated value
p = tdbp->To_Line + Deplac; p = (Eds) ? Buff : tdbp->To_Line + Deplac;
/*********************************************************************/ /*********************************************************************/
/* Check whether updating is Ok, meaning col value is not too long. */ /* Check whether updating is Ok, meaning col value is not too long. */
/* Updating will be done only during the second pass (Status=true) */ /* Updating will be done only during the second pass (Status=true) */
/* Conversion occurs if the external format Fmt is specified. */ /* Conversion occurs if the external format Fmt is specified. */
/*********************************************************************/ /*********************************************************************/
if (N) { switch (Fmt) {
if (IsTypeChar(Buf_Type))
*(longlong *)Buff = Value->GetBigintValue();
else if (Value->GetBinValue(Buff, M, Status)) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG),
Name, Value->GetSize(), M);
longjmp(g->jumper[g->jump_level], 31);
} // endif Buff
if (Status)
for (int i = 0; i < Lim; i++)
if (Fmt == 'B' && Endian == 'L')
p[N - i - 1] = Buff[i];
else if (Fmt == 'L' && Endian == 'B')
p[i] = Buff[M - i - 1];
else if (Endian == 'B')
p[N - i - 1] = Buff[M - i - 1];
else
p[i] = Buff[i];
} else switch (Fmt) {
case 'X': case 'X':
// Standard not converted values // Standard not converted values
if (Value->GetBinValue(p, Long, Status)) { if (Eds && IsTypeChar(Buf_Type))
*(longlong *)p = Value->GetBigintValue();
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);
longjmp(g->jumper[g->jump_level], 31); longjmp(g->jumper[g->jump_level], 31);
} // endif p } // endif p
break; break;
case 'S': // Short integer case 'S': // Short integer
@@ -610,9 +618,6 @@ void BINCOL::WriteColumn(PGLOBAL g)
*p = (char)n; *p = (char)n;
break; break;
case 'L': // Long Integer
strcpy(g->Message, "Format L is deprecated, use I");
longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer case 'I': // Integer
n = Value->GetBigintValue(); n = Value->GetBigintValue();
@@ -623,7 +628,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
*(int *)p = Value->GetIntValue(); *(int *)p = Value->GetIntValue();
break; break;
case 'B': // Large (big) integer case 'G': // Large (great) integer
if (Status) if (Status)
*(longlong *)p = Value->GetBigintValue(); *(longlong *)p = Value->GetBigintValue();
@@ -657,6 +662,21 @@ void BINCOL::WriteColumn(PGLOBAL g)
longjmp(g->jumper[g->jump_level], 11); longjmp(g->jumper[g->jump_level], 11);
} // endswitch Fmt } // endswitch Fmt
if (Eds && Status) {
p = tdbp->To_Line + Deplac;
for (int i = 0; i < Lim; i++)
if (Eds == 'B' && Endian == 'L')
p[N - i - 1] = Buff[i];
else if (Eds == 'L' && Endian == 'B')
p[i] = Buff[M - i - 1];
else if (Endian == 'B')
p[N - i - 1] = Buff[M - i - 1];
else
p[i] = Buff[i];
} // endif Eds
} // end of WriteColumn } // end of WriteColumn
/* ------------------------ End of TabFix ---------------------------- */ /* ------------------------ End of TabFix ---------------------------- */

View File

@@ -53,7 +53,8 @@ class DllExport TDBFIX : public TDBDOS {
protected: protected:
virtual bool PrepareWriting(PGLOBAL g) {return false;} virtual bool PrepareWriting(PGLOBAL g) {return false;}
// Members are inherited from TDBDOS // Members
char Teds; /* Binary table default endian setting */
}; // end of class TDBFIX }; // end of class TDBFIX
/***********************************************************************/ /***********************************************************************/
@@ -86,7 +87,8 @@ class DllExport BINCOL : public DOSCOL {
// Members // Members
static char Endian; // The host endian setting (L or B) static char Endian; // The host endian setting (L or B)
char *Buff; // Utility buffer char *Buff; // Utility buffer
char Fmt; // The file endian setting or old format char Eds; // The file endian setting
char Fmt; // The converted value format
int N; // The number of bytes in the file int N; // The number of bytes in the file
int M; // The buffer type size int M; // The buffer type size
int Lim; // Min(N,M) int Lim; // Min(N,M)

View File

@@ -20,7 +20,7 @@
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
@@ -102,14 +102,14 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
} // endif info } // endif info
// num_max = atoi(p+1); // Max num of record to test // num_max = atoi(p+1); // Max num of record to test
#if defined(WIN32) #if defined(__WIN__)
if (sep == ',' || strnicmp(setlocale(LC_NUMERIC, NULL), "French", 6)) if (sep == ',' || strnicmp(setlocale(LC_NUMERIC, NULL), "French", 6))
dechar = '.'; dechar = '.';
else else
dechar = ','; dechar = ',';
#else // !WIN32 #else // !__WIN__
dechar = '.'; dechar = '.';
#endif // !WIN32 #endif // !__WIN__
if (trace) if (trace)
htrc("File %s sep=%c q=%c hdr=%d mxr=%d\n", htrc("File %s sep=%c q=%c hdr=%d mxr=%d\n",
@@ -147,7 +147,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
if (fgets(buf, sizeof(buf), infile)) { if (fgets(buf, sizeof(buf), infile)) {
n = strlen(buf) + 1; n = strlen(buf) + 1;
buf[n - 2] = '\0'; buf[n - 2] = '\0';
#if defined(UNIX) #if !defined(__WIN__)
// The file can be imported from Windows // The file can be imported from Windows
if (buf[n - 3] == '\r') if (buf[n - 3] == '\r')
buf[n - 3] = 0; buf[n - 3] = 0;
@@ -204,7 +204,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
if (fgets(buf, sizeof(buf), infile)) { if (fgets(buf, sizeof(buf), infile)) {
n = strlen(buf); n = strlen(buf);
buf[n - 1] = '\0'; buf[n - 1] = '\0';
#if defined(UNIX) #if !defined(__WIN__)
// The file can be imported from Windows // The file can be imported from Windows
if (buf[n - 2] == '\r') if (buf[n - 2] == '\r')
buf[n - 2] = 0; buf[n - 2] = 0;

View File

@@ -59,16 +59,15 @@ 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 *dp, const char *fn, char *objn, PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
int pretty, int lrecl, int lvl, 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};
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 filename[_MAX_PATH], colname[65], fmt[129]; char *fn, colname[65], fmt[129];
int i, j, n = 0; int i, j, lvl, n = 0;
int ncol = sizeof(buftyp) / sizeof(int); int ncol = sizeof(buftyp) / sizeof(int);
PVAL valp; PVAL valp;
JCOL jcol; JCOL jcol;
@@ -91,26 +90,29 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
goto skipit; goto skipit;
} // endif info } // endif info
if (trace)
htrc("File %s pretty=%d lvl=%d lrecl=%d\n",
SVP(fn), pretty, lvl, lrecl);
/*********************************************************************/ /*********************************************************************/
/* Open the input file. */ /* Open the input file. */
/*********************************************************************/ /*********************************************************************/
if (!fn) { if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) {
strcpy(g->Message, MSG(MISSING_FNAME)); strcpy(g->Message, MSG(MISSING_FNAME));
return NULL; return NULL;
} else } else {
PlugSetPath(filename, fn, dp); lvl = GetIntegerTableOption(g, topt, "Level", 0);
lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl;
} // endif fn
tdp = new(g) JSONDEF; tdp = new(g) JSONDEF;
tdp->Database = dp; tdp->Fn = fn;
tdp->Fn = filename; tdp->Database = SetPath(g, db);
tdp->Objname = objn; tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
tdp->Pretty = pretty; tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2);
if (pretty == 2) { if (trace)
htrc("File %s objname=%s pretty=%d lvl=%d\n",
tdp->Fn, tdp->Objname, tdp->Pretty, lvl);
if (tdp->Pretty == 2) {
tjsp = new(g) TDBJSON(tdp, new(g) MAPFAM(tdp)); tjsp = new(g) TDBJSON(tdp, new(g) MAPFAM(tdp));
if (tjsp->MakeDocument(g)) if (tjsp->MakeDocument(g))
@@ -118,13 +120,12 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL; jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL;
} else { } else {
if (!lrecl) { if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) {
sprintf(g->Message, "LRECL must be specified for pretty=%d", pretty); sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty);
return NULL; return NULL;
} // endif lrecl } // endif lrecl
tdp->Lrecl = lrecl; tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF);
tdp->Ending = CRLF;
tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp)); tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp));
tjnp->SetMode(MODE_READ); tjnp->SetMode(MODE_READ);
@@ -265,7 +266,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
jcp->Found = false; jcp->Found = false;
} // endfor jcp } // endfor jcp
if (pretty != 2) { if (tdp->Pretty != 2) {
// Read next record // Read next record
switch (tjnp->ReadDB(g)) { switch (tjnp->ReadDB(g)) {
case RC_EF: case RC_EF:
@@ -285,7 +286,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
} // endor i } // endor i
if (pretty != 2) if (tdp->Pretty != 2)
tjnp->CloseDB(g); tjnp->CloseDB(g);
skipit: skipit:
@@ -341,7 +342,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *dp, const char *fn, char *objn,
return qrp; return qrp;
err: err:
if (pretty != 2) if (tdp->Pretty != 2)
tjnp->CloseDB(g); tjnp->CloseDB(g);
return NULL; return NULL;
@@ -356,8 +357,7 @@ JSONDEF::JSONDEF(void)
Xcol = NULL; Xcol = NULL;
Pretty = 2; Pretty = 2;
Limit = 1; Limit = 1;
Level = 0; Base = 0;
ReadMode = 0;
Strict = false; Strict = false;
} // end of JSONDEF constructor } // end of JSONDEF constructor
@@ -370,9 +370,8 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
Objname = GetStringCatInfo(g, "Object", NULL); Objname = GetStringCatInfo(g, "Object", NULL);
Xcol = GetStringCatInfo(g, "Expand", NULL); Xcol = GetStringCatInfo(g, "Expand", NULL);
Pretty = GetIntCatInfo("Pretty", 2); Pretty = GetIntCatInfo("Pretty", 2);
Level = GetIntCatInfo("Level", 0);
Limit = GetIntCatInfo("Limit", 10); Limit = GetIntCatInfo("Limit", 10);
Base = GetIntCatInfo("Base", 0); Base = GetIntCatInfo("Base", 0) ? 1 : 0;
return DOSDEF::DefineAM(g, "DOS", poff); return DOSDEF::DefineAM(g, "DOS", poff);
} // end of DefineAM } // end of DefineAM
@@ -624,11 +623,11 @@ bool TDBJSN::SkipHeader(PGLOBAL g)
return true; return true;
#endif // _DEBUG #endif // _DEBUG
#if defined(WIN32) #if defined(__WIN__)
#define Ending 2 #define Ending 2
#else // !WIN32 #else // !__WIN__
#define Ending 1 #define Ending 1
#endif // !WIN32 #endif // !__WIN__
if (Pretty == 1) { if (Pretty == 1) {
if (Mode == MODE_INSERT || Mode == MODE_DELETE) { if (Mode == MODE_INSERT || Mode == MODE_DELETE) {
@@ -1856,11 +1855,8 @@ void TDBJSON::CloseDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
{ {
Fn = tdp->GetFn(); Topt = tdp->GetTopt();
Objn = tdp->Objname; Db = (char*)tdp->GetDB();
Pretty = tdp->Pretty;
Lrecl = tdp->Lrecl;
lvl = tdp->Level;
} // end of TDBJCL constructor } // end of TDBJCL constructor
/***********************************************************************/ /***********************************************************************/
@@ -1868,8 +1864,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp)
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBJCL::GetResult(PGLOBAL g) PQRYRES TDBJCL::GetResult(PGLOBAL g)
{ {
return JSONColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, Objn, return JSONColumns(g, Db, Topt, false);
Pretty, Lrecl, lvl, false);
} // end of GetResult } // end of GetResult
/* --------------------------- End of json --------------------------- */ /* --------------------------- End of json --------------------------- */

View File

@@ -36,8 +36,7 @@ class 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 *, const char *, char *, friend PQRYRES JSONColumns(PGLOBAL, char*, PTOS, bool);
int, int, int, bool);
public: public:
// Constructor // Constructor
JSONDEF(void); JSONDEF(void);
@@ -226,11 +225,6 @@ class TDBJCL : public TDBCAT {
virtual PQRYRES GetResult(PGLOBAL g); virtual PQRYRES GetResult(PGLOBAL g);
// Members // Members
//char *Dp; PTOS Topt;
const char *Fn; char *Db;
char *Objn;
int Pretty;
int Lrecl;
int lvl;
}; // end of class TDBJCL }; // end of class TDBJCL

View File

@@ -3,12 +3,12 @@
/* From the article and sample code by Khalid Shaikh. */ /* From the article and sample code by Khalid Shaikh. */
/* TABMAC: virtual table to get the list of MAC addresses. */ /* TABMAC: virtual table to get the list of MAC addresses. */
/***********************************************************************/ /***********************************************************************/
#if defined(WIN32) #if defined(__WIN__)
#include "my_global.h" #include "my_global.h"
//#include <iphlpapi.h> //#include <iphlpapi.h>
#else // !WIN32 #else // !__WIN__
#error This is a WIN32 only table type #error This is a WINDOWS only table type
#endif // !WIN32 #endif // !__WIN__
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
//#include "catalog.h" //#include "catalog.h"

View File

@@ -1,11 +1,11 @@
// TABMAC.H Olivier Bertrand 2011-2012 // TABMAC.H Olivier Bertrand 2011-2012
// MAC: virtual table to Get Mac Addresses via GetAdaptersInfo // MAC: virtual table to Get Mac Addresses via GetAdaptersInfo
#if defined(WIN32) #if defined(__WIN__)
#include <windows.h> #include <windows.h>
#include <iphlpapi.h> #include <iphlpapi.h>
#else // !WIN32 #else // !__WIN__
#error This is a WIN32 only table TYPE #error This is a WINDOWS only table TYPE
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Definitions. */ /* Definitions. */

View File

@@ -37,7 +37,7 @@
/* Include relevant section of system dependant header files. */ /* Include relevant section of system dependant header files. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
@@ -145,7 +145,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
/* To_File is a multiple name with special characters */ /* To_File is a multiple name with special characters */
/*******************************************************************/ /*******************************************************************/
#if defined(WIN32) #if defined(__WIN__)
char drive[_MAX_DRIVE], direc[_MAX_DIR]; char drive[_MAX_DRIVE], direc[_MAX_DIR];
WIN32_FIND_DATA FileData; WIN32_FIND_DATA FileData;
HANDLE hSearch; HANDLE hSearch;
@@ -196,7 +196,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
return true; return true;
} // endif FindClose } // endif FindClose
#else // !WIN32 #else // !__WIN__
struct stat fileinfo; struct stat fileinfo;
char fn[FN_REFLEN], direc[FN_REFLEN], pattern[FN_HEADLEN], ftype[FN_EXTLEN]; char fn[FN_REFLEN], direc[FN_REFLEN], pattern[FN_HEADLEN], ftype[FN_EXTLEN];
DIR *dir; DIR *dir;
@@ -249,7 +249,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
// Close the dir handle. // Close the dir handle.
closedir(dir); closedir(dir);
#endif // !WIN32 #endif // !__WIN__
} else { } else {
/*******************************************************************/ /*******************************************************************/
@@ -269,7 +269,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
p = filename + strlen(filename) - 1; p = filename + strlen(filename) - 1;
#if defined(UNIX) #if !defined(__WIN__)
// Data files can be imported from Windows (having CRLF) // Data files can be imported from Windows (having CRLF)
if (*p == '\n' || *p == '\r') { if (*p == '\n' || *p == '\r') {
// is this enough for Unix ??? // is this enough for Unix ???
@@ -297,7 +297,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
} // endif Mul } // endif Mul
#if defined(WIN32) #if defined(__WIN__)
suite: suite:
#endif #endif
@@ -620,17 +620,17 @@ TDBDIR::TDBDIR(PDIRDEF tdp) : TDBASE(tdp)
{ {
To_File = tdp->Fn; To_File = tdp->Fn;
iFile = 0; iFile = 0;
#if defined(WIN32) #if defined(__WIN__)
memset(&FileData, 0, sizeof(_finddata_t)); memset(&FileData, 0, sizeof(_finddata_t));
Hsearch = -1; Hsearch = -1;
*Drive = '\0'; *Drive = '\0';
#else // !WIN32 #else // !__WIN__
memset(&Fileinfo, 0, sizeof(struct stat)); memset(&Fileinfo, 0, sizeof(struct stat));
Entry = NULL; Entry = NULL;
Dir = NULL; Dir = NULL;
Done = false; Done = false;
*Pattern = '\0'; *Pattern = '\0';
#endif // !WIN32 #endif // !__WIN__
*Fpath = '\0'; *Fpath = '\0';
*Direc = '\0'; *Direc = '\0';
*Fname = '\0'; *Fname = '\0';
@@ -641,17 +641,17 @@ TDBDIR::TDBDIR(PTDBDIR tdbp) : TDBASE(tdbp)
{ {
To_File = tdbp->To_File; To_File = tdbp->To_File;
iFile = tdbp->iFile; iFile = tdbp->iFile;
#if defined(WIN32) #if defined(__WIN__)
FileData = tdbp->FileData; FileData = tdbp->FileData;
Hsearch = tdbp->Hsearch; Hsearch = tdbp->Hsearch;
strcpy(Drive, tdbp->Drive); strcpy(Drive, tdbp->Drive);
#else // !WIN32 #else // !__WIN__
Fileinfo = tdbp->Fileinfo; Fileinfo = tdbp->Fileinfo;
Entry = tdbp->Entry; Entry = tdbp->Entry;
Dir = tdbp->Dir; Dir = tdbp->Dir;
Done = tdbp->Done; Done = tdbp->Done;
strcpy(Pattern, tdbp->Pattern); strcpy(Pattern, tdbp->Pattern);
#endif // !WIN32 #endif // !__WIN__
strcpy(Direc, tdbp->Direc); strcpy(Direc, tdbp->Direc);
strcpy(Fname, tdbp->Fname); strcpy(Fname, tdbp->Fname);
strcpy(Ftype, tdbp->Ftype); strcpy(Ftype, tdbp->Ftype);
@@ -675,7 +675,7 @@ char* TDBDIR::Path(PGLOBAL g)
{ {
PCATLG cat = PlgGetCatalog(g); PCATLG cat = PlgGetCatalog(g);
#if defined(WIN32) #if defined(__WIN__)
if (!*Drive) { if (!*Drive) {
PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath()); PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath());
_splitpath(Fpath, Drive, Direc, Fname, Ftype); _splitpath(Fpath, Drive, Direc, Fname, Ftype);
@@ -683,7 +683,7 @@ char* TDBDIR::Path(PGLOBAL g)
_makepath(Fpath, Drive, Direc, Fname, Ftype); // Usefull ??? _makepath(Fpath, Drive, Direc, Fname, Ftype); // Usefull ???
return Fpath; return Fpath;
#else // !WIN32 #else // !__WIN__
if (!Done) { if (!Done) {
PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath()); PlugSetPath(Fpath, To_File, ((PTABDEF)To_Def)->GetPath());
_splitpath(Fpath, NULL, Direc, Fname, Ftype); _splitpath(Fpath, NULL, Direc, Fname, Ftype);
@@ -692,7 +692,7 @@ char* TDBDIR::Path(PGLOBAL g)
} // endif Done } // endif Done
return Pattern; return Pattern;
#endif // !WIN32 #endif // !__WIN__
} // end of Path } // end of Path
/***********************************************************************/ /***********************************************************************/
@@ -710,7 +710,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
{ {
if (MaxSize < 0) { if (MaxSize < 0) {
int n = -1; int n = -1;
#if defined(WIN32) #if defined(__WIN__)
int h; int h;
// Start searching files in the target directory. // Start searching files in the target directory.
@@ -726,7 +726,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
} else } else
n = 0; n = 0;
#else // !WIN32 #else // !__WIN__
Path(g); Path(g);
// Start searching files in the target directory. // Start searching files in the target directory.
@@ -750,7 +750,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
// Close the DIR handle. // Close the DIR handle.
closedir(Dir); closedir(Dir);
#endif // !WIN32 #endif // !__WIN__
MaxSize = n; MaxSize = n;
} // endif MaxSize } // endif MaxSize
@@ -776,10 +776,10 @@ bool TDBDIR::OpenDB(PGLOBAL g)
} // endif use } // endif use
Use = USE_OPEN; Use = USE_OPEN;
#if !defined(WIN32) #if !defined(__WIN__)
Path(g); // Be sure it is done Path(g); // Be sure it is done
Dir = NULL; // For ReadDB Dir = NULL; // For ReadDB
#endif // !WIN32 #endif // !__WIN__
return false; return false;
} // end of OpenDB } // end of OpenDB
@@ -790,7 +790,7 @@ int TDBDIR::ReadDB(PGLOBAL g)
{ {
int rc = RC_OK; int rc = RC_OK;
#if defined(WIN32) #if defined(__WIN__)
if (Hsearch == -1) { if (Hsearch == -1) {
/*******************************************************************/ /*******************************************************************/
/* Start searching files in the target directory. The use of the */ /* Start searching files in the target directory. The use of the */
@@ -848,7 +848,7 @@ int TDBDIR::ReadDB(PGLOBAL g)
rc = RC_EF; rc = RC_EF;
} // endif Entry } // endif Entry
#endif // !WIN32 #endif // !__WIN__
return rc; return rc;
} // end of ReadDB } // end of ReadDB
@@ -876,17 +876,17 @@ int TDBDIR::DeleteDB(PGLOBAL g, int)
/***********************************************************************/ /***********************************************************************/
void TDBDIR::CloseDB(PGLOBAL) void TDBDIR::CloseDB(PGLOBAL)
{ {
#if defined(WIN32) #if defined(__WIN__)
// Close the search handle. // Close the search handle.
_findclose(Hsearch); _findclose(Hsearch);
Hsearch = -1; Hsearch = -1;
#else // !WIN32 #else // !__WIN__
// Close the DIR handle // Close the DIR handle
if (Dir) { if (Dir) {
closedir(Dir); closedir(Dir);
Dir = NULL; Dir = NULL;
} // endif dir } // endif dir
#endif // !WIN32 #endif // !__WIN__
iFile = 0; iFile = 0;
} // end of CloseDB } // end of CloseDB
@@ -935,19 +935,19 @@ void DIRCOL::ReadColumn(PGLOBAL g)
/* Retrieve the information corresponding to the column number. */ /* Retrieve the information corresponding to the column number. */
/*********************************************************************/ /*********************************************************************/
switch (N) { switch (N) {
#if defined(WIN32) #if defined(__WIN__)
case 0: Value->SetValue_psz(tdbp->Drive); break; case 0: Value->SetValue_psz(tdbp->Drive); break;
#endif // WIN32 #endif // __WIN__
case 1: Value->SetValue_psz(tdbp->Direc); break; case 1: Value->SetValue_psz(tdbp->Direc); break;
case 2: Value->SetValue_psz(tdbp->Fname); break; case 2: Value->SetValue_psz(tdbp->Fname); break;
case 3: Value->SetValue_psz(tdbp->Ftype); break; case 3: Value->SetValue_psz(tdbp->Ftype); break;
#if defined(WIN32) #if defined(__WIN__)
case 4: Value->SetValue((int)tdbp->FileData.attrib); break; case 4: Value->SetValue((int)tdbp->FileData.attrib); break;
case 5: Value->SetValue((int)tdbp->FileData.size); break; case 5: Value->SetValue((int)tdbp->FileData.size); break;
case 6: Value->SetValue((int)tdbp->FileData.time_write); break; case 6: Value->SetValue((int)tdbp->FileData.time_write); break;
case 7: Value->SetValue((int)tdbp->FileData.time_create); break; case 7: Value->SetValue((int)tdbp->FileData.time_create); break;
case 8: Value->SetValue((int)tdbp->FileData.time_access); break; case 8: Value->SetValue((int)tdbp->FileData.time_access); break;
#else // !WIN32 #else // !__WIN__
case 4: Value->SetValue((int)tdbp->Fileinfo.st_mode); break; case 4: Value->SetValue((int)tdbp->Fileinfo.st_mode); break;
case 5: Value->SetValue((int)tdbp->Fileinfo.st_size); break; case 5: Value->SetValue((int)tdbp->Fileinfo.st_size); break;
case 6: Value->SetValue((int)tdbp->Fileinfo.st_mtime); break; case 6: Value->SetValue((int)tdbp->Fileinfo.st_mtime); break;
@@ -955,7 +955,7 @@ void DIRCOL::ReadColumn(PGLOBAL g)
case 8: Value->SetValue((int)tdbp->Fileinfo.st_atime); break; case 8: Value->SetValue((int)tdbp->Fileinfo.st_atime); break;
case 9: Value->SetValue((int)tdbp->Fileinfo.st_uid); break; case 9: Value->SetValue((int)tdbp->Fileinfo.st_uid); break;
case 10: Value->SetValue((int)tdbp->Fileinfo.st_gid); break; case 10: Value->SetValue((int)tdbp->Fileinfo.st_gid); break;
#endif // !WIN32 #endif // !__WIN__
default: default:
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N); sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
longjmp(g->jumper[g->jump_level], GetAmType()); longjmp(g->jumper[g->jump_level], GetAmType());
@@ -1006,7 +1006,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
size_t m = strlen(Direc); size_t m = strlen(Direc);
// Start searching files in the target directory. // Start searching files in the target directory.
#if defined(WIN32) #if defined(__WIN__)
int h = _findfirst(Path(g), &FileData); int h = _findfirst(Path(g), &FileData);
if (h != -1) { if (h != -1) {
@@ -1039,7 +1039,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
// Close the search handle. // Close the search handle.
_findclose(h); _findclose(h);
} // endif h } // endif h
#else // !WIN32 #else // !__WIN__
int k; int k;
DIR *dir = opendir(Direc); DIR *dir = opendir(Direc);
@@ -1073,7 +1073,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
// Close the DIR handle. // Close the DIR handle.
closedir(dir); closedir(dir);
#endif // !WIN32 #endif // !__WIN__
return n; return n;
} // end of FindInDir } // end of FindInDir
@@ -1089,13 +1089,13 @@ bool TDBSDR::OpenDB(PGLOBAL g)
Sub = (PSUBDIR)PlugSubAlloc(g, NULL, sizeof(SUBDIR)); Sub = (PSUBDIR)PlugSubAlloc(g, NULL, sizeof(SUBDIR));
Sub->Next = NULL; Sub->Next = NULL;
Sub->Prev = NULL; Sub->Prev = NULL;
#if defined(WIN32) #if defined(__WIN__)
Sub->H = -1; Sub->H = -1;
Sub->Len = strlen(Direc); Sub->Len = strlen(Direc);
#else // !WIN32 #else // !__WIN__
Sub->D = NULL; Sub->D = NULL;
Sub->Len = 0; Sub->Len = 0;
#endif // !WIN32 #endif // !__WIN__
} // endif To_Sub } // endif To_Sub
return TDBDIR::OpenDB(g); return TDBDIR::OpenDB(g);
@@ -1108,7 +1108,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
{ {
int rc; int rc;
#if defined(WIN32) #if defined(__WIN__)
again: again:
rc = TDBDIR::ReadDB(g); rc = TDBDIR::ReadDB(g);
@@ -1160,7 +1160,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
} // endif H } // endif H
} // endif rc } // endif rc
#else // !WIN32 #else // !__WIN__
rc = RC_NF; rc = RC_NF;
again: again:
@@ -1217,7 +1217,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
} // endif Entry } // endif Entry
#endif // !WIN32 #endif // !__WIN__
return rc; return rc;
} // end of ReadDB } // end of ReadDB

View File

@@ -6,14 +6,14 @@
/* */ /* */
/* This file contains the TDBMUL and TDBDIR classes declares. */ /* This file contains the TDBMUL and TDBDIR classes declares. */
/***********************************************************************/ /***********************************************************************/
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#else // !WIN32 #else // !__WIN__
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#endif // !WIN32 #endif // !__WIN__
//#include "osutil.h" //#include "osutil.h"
#include "block.h" #include "block.h"
@@ -132,17 +132,17 @@ class TDBDIR : public TDBASE {
// Members // Members
PSZ To_File; // Points to file search pathname PSZ To_File; // Points to file search pathname
int iFile; // Index of currently retrieved file int iFile; // Index of currently retrieved file
#if defined(WIN32) #if defined(__WIN__)
_finddata_t FileData; // Find data structure _finddata_t FileData; // Find data structure
int Hsearch; // Search handle int Hsearch; // Search handle
char Drive[_MAX_DRIVE]; // Drive name char Drive[_MAX_DRIVE]; // Drive name
#else // !WIN32 #else // !__WIN__
struct stat Fileinfo; // File info structure struct stat Fileinfo; // File info structure
struct dirent *Entry; // Point to directory entry structure struct dirent *Entry; // Point to directory entry structure
DIR *Dir; // To searched directory structure DIR *Dir; // To searched directory structure
bool Done; // true when _splipath is done bool Done; // true when _splipath is done
char Pattern[_MAX_FNAME+_MAX_EXT]; char Pattern[_MAX_FNAME+_MAX_EXT];
#endif // !WIN32 #endif // !__WIN__
char Fpath[_MAX_PATH]; // Absolute file search pattern char Fpath[_MAX_PATH]; // Absolute file search pattern
char Direc[_MAX_DIR]; // Search path char Direc[_MAX_DIR]; // Search path
char Fname[_MAX_FNAME]; // File name char Fname[_MAX_FNAME]; // File name
@@ -183,11 +183,11 @@ class TDBSDR : public TDBDIR {
typedef struct _Sub_Dir { typedef struct _Sub_Dir {
struct _Sub_Dir *Next; struct _Sub_Dir *Next;
struct _Sub_Dir *Prev; struct _Sub_Dir *Prev;
#if defined(WIN32) #if defined(__WIN__)
int H; // Search handle int H; // Search handle
#else // !WIN32 #else // !__WIN__
DIR *D; DIR *D;
#endif // !WIN32 #endif // !__WIN__
size_t Len; // Initial directory name length size_t Len; // Initial directory name length
} SUBDIR, *PSUBDIR; } SUBDIR, *PSUBDIR;

View File

@@ -35,9 +35,9 @@
#include "my_global.h" #include "my_global.h"
#include "sql_class.h" #include "sql_class.h"
#include "sql_servers.h" #include "sql_servers.h"
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
//#include <fnmatch.h> //#include <fnmatch.h>
//#include <errno.h> //#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
@@ -46,7 +46,7 @@
#include "osutil.h" #include "osutil.h"
//#include <io.h> //#include <io.h>
//#include <fcntl.h> //#include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */

View File

@@ -13,7 +13,7 @@
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#include "table.h" // MySQL table definitions #include "table.h" // MySQL table definitions
#if defined(WIN32) #if defined(__WIN__)
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if defined(__BORLANDC__) #if defined(__BORLANDC__)

View File

@@ -35,7 +35,7 @@
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#if defined(__BORLANDC__) #if defined(__BORLANDC__)

View File

@@ -17,7 +17,7 @@
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#include "table.h" // MySQL table definitions #include "table.h" // MySQL table definitions
#if defined(WIN32) #if defined(__WIN__)
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro #define __MFC_COMPAT__ // To define min/max as macro
#endif #endif

View File

@@ -12,12 +12,12 @@
/* Include relevant sections of the System header files. */ /* Include relevant sections of the System header files. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
#define __MFC_COMPAT__ // To define min/max as macro #define __MFC_COMPAT__ // To define min/max as macro
#endif // __BORLANDC__ #endif // __BORLANDC__
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) #if defined(UNIX)
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@@ -25,7 +25,7 @@
#include <io.h> #include <io.h>
#endif // !UNIX #endif // !UNIX
#include <fcntl.h> #include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include application header files: */ /* Include application header files: */
@@ -36,9 +36,9 @@
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
#include "reldef.h" #include "reldef.h"
#if !defined(WIN32) #if !defined(__WIN__)
#include "osutil.h" #include "osutil.h"
#endif // !WIN32 #endif // !__WIN__
#include "filamtxt.h" #include "filamtxt.h"
#include "tabdos.h" #include "tabdos.h"
#include "tabsys.h" #include "tabsys.h"
@@ -48,10 +48,10 @@
#define CSZ 36 // Column section name length #define CSZ 36 // Column section name length
#define CDZ 256 // Column definition length #define CDZ 256 // Column definition length
#if !defined(WIN32) #if !defined(__WIN__)
#define GetPrivateProfileSectionNames(S,L,I) \ #define GetPrivateProfileSectionNames(S,L,I) \
GetPrivateProfileString(NULL,NULL,"",S,L,I) GetPrivateProfileString(NULL,NULL,"",S,L,I)
#endif // !WIN32 #endif // !__WIN__
/* -------------- Implementation of the INI classes ------------------ */ /* -------------- Implementation of the INI classes ------------------ */
@@ -123,7 +123,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g)
// Delete the INI table file if not protected // Delete the INI table file if not protected
if (!IsReadOnly()) { if (!IsReadOnly()) {
PlugSetPath(filename, Fn, GetPath()); PlugSetPath(filename, Fn, GetPath());
#if defined(WIN32) #if defined(__WIN__)
rc = !DeleteFile(filename); rc = !DeleteFile(filename);
#else // UNIX #else // UNIX
rc = remove(filename); rc = remove(filename);
@@ -345,9 +345,9 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/ /***********************************************************************/
void TDBINI::CloseDB(PGLOBAL) void TDBINI::CloseDB(PGLOBAL)
{ {
#if !defined(WIN32) #if !defined(__WIN__)
PROFILE_Close(Ifile); PROFILE_Close(Ifile);
#endif // !WIN32 #endif // !__WIN__
} // end of CloseDB } // end of CloseDB
// ------------------------ INICOL functions ---------------------------- // ------------------------ INICOL functions ----------------------------

View File

@@ -39,7 +39,7 @@
//#include "sql_base.h" //#include "sql_base.h"
#include "my_global.h" #include "my_global.h"
#include "table.h" // MySQL table definitions #include "table.h" // MySQL table definitions
#if defined(WIN32) #if defined(__WIN__)
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
@@ -73,15 +73,15 @@
#include "tabmysql.h" #include "tabmysql.h"
#include "ha_connect.h" #include "ha_connect.h"
#if defined(WIN32) #if defined(__WIN__)
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
#define SYSEXIT void _USERENTRY #define SYSEXIT void _USERENTRY
#else #else
#define SYSEXIT void #define SYSEXIT void
#endif #endif
#else // !WIN32 #else // !__WIN__
#define SYSEXIT void * #define SYSEXIT void *
#endif // !WIN32 #endif // !__WIN__
/* ---------------------------- Class TBLDEF ---------------------------- */ /* ---------------------------- Class TBLDEF ---------------------------- */

View File

@@ -14,7 +14,7 @@
#include "sql_class.h" #include "sql_class.h"
#include "table.h" #include "table.h"
#include "field.h" #include "field.h"
#if defined(WIN32) #if defined(__WIN__)
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if defined(__BORLANDC__) #if defined(__BORLANDC__)

View File

@@ -35,7 +35,7 @@
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
@@ -146,7 +146,7 @@ bool VCTDEF::Erase(char *filename)
for (i = 1, cdp = To_Cols; cdp; i++, cdp = cdp->GetNext()) { for (i = 1, cdp = To_Cols; cdp; i++, cdp = cdp->GetNext()) {
sprintf(filename, fpat, i); sprintf(filename, fpat, i);
//#if defined(WIN32) //#if defined(__WIN__)
// rc |= !DeleteFile(filename); // rc |= !DeleteFile(filename);
//#else // UNIX //#else // UNIX
rc |= remove(filename); rc |= remove(filename);
@@ -175,7 +175,7 @@ bool VCTDEF::Erase(char *filename)
int VCTDEF::MakeFnPattern(char *fpat) int VCTDEF::MakeFnPattern(char *fpat)
{ {
char pat[8]; char pat[8];
#if !defined(UNIX) #if defined(__WIN__)
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
#else #else
char *drive = NULL; char *drive = NULL;

View File

@@ -2,9 +2,9 @@
/* TABWMI: Author Olivier Bertrand -- PlugDB -- 2012 - 2013 */ /* TABWMI: Author Olivier Bertrand -- PlugDB -- 2012 - 2013 */
/* TABWMI: Virtual table to get WMI information. */ /* TABWMI: Virtual table to get WMI information. */
/***********************************************************************/ /***********************************************************************/
#if !defined(WIN32) #if !defined(__WIN__)
#error This is a WIN32 only table type #error This is a WINDOWS only table type
#endif // !WIN32 #endif // !__WIN__
#include "my_global.h" #include "my_global.h"
#include <stdio.h> #include <stdio.h>

View File

@@ -17,7 +17,7 @@
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#include "table.h" // MySQL table definitions #include "table.h" // MySQL table definitions
#if defined(WIN32) #if defined(__WIN__)
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if defined(__BORLANDC__) #if defined(__BORLANDC__)

View File

@@ -15,12 +15,12 @@
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <winsock2.h> #include <winsock2.h>
//#include <windows.h> //#include <windows.h>
#include <comdef.h> #include <comdef.h>
#else // !WIN32 #else // !__WIN__
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
@@ -28,7 +28,7 @@
//#include <ctype.h> //#include <ctype.h>
#include "osutil.h" #include "osutil.h"
#define _O_RDONLY O_RDONLY #define _O_RDONLY O_RDONLY
#endif // !WIN32 #endif // !__WIN__
#include "resource.h" // for IDS_COLUMNS #include "resource.h" // for IDS_COLUMNS
#define INCLUDE_TDBXML #define INCLUDE_TDBXML
@@ -53,11 +53,11 @@
extern "C" char version[]; extern "C" char version[];
#if defined(WIN32) && defined(DOMDOC_SUPPORT) #if defined(__WIN__) && defined(DOMDOC_SUPPORT)
#define XMLSUP "MS-DOM" #define XMLSUP "MS-DOM"
#else // !WIN32 #else // !__WIN__
#define XMLSUP "libxml2" #define XMLSUP "libxml2"
#endif // !WIN32 #endif // !__WIN__
#define TYPE_UNKNOWN 12 /* Must be greater than other types */ #define TYPE_UNKNOWN 12 /* Must be greater than other types */
@@ -110,14 +110,14 @@ typedef struct LVL {
/* XMLColumns: construct the result blocks containing the description */ /* XMLColumns: construct the result blocks containing the description */
/* of all the columns of a table contained inside an XML file. */ /* of all the columns of a table contained inside an XML file. */
/***********************************************************************/ /***********************************************************************/
PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info) PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, 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};
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 *op, colname[65], fmt[129], buf[512]; char *fn, *op, 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;
@@ -138,26 +138,28 @@ PQRYRES XMLColumns(PGLOBAL g, char *dp, char *tab, PTOS topt, bool info)
/*********************************************************************/ /*********************************************************************/
/* Open the input file. */ /* Open the input file. */
/*********************************************************************/ /*********************************************************************/
if (!topt->filename) { if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) {
strcpy(g->Message, MSG(MISSING_FNAME)); strcpy(g->Message, MSG(MISSING_FNAME));
return NULL; return NULL;
} else } else {
lvl = atoi(GetListOption(g, "Level", topt->oplist, "0")); lvl = GetIntegerTableOption(g, topt, "Level", 0);
lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl;
} // endif fn
if (trace) if (trace)
htrc("File %s lvl=%d\n", topt->filename, lvl); htrc("File %s lvl=%d\n", topt->filename, lvl);
tdp = new(g) XMLDEF; tdp = new(g) XMLDEF;
tdp->Database = dp; tdp->Fn = fn;
tdp->Fn = (char*)topt->filename; tdp->Database = SetPath(g, db);
tdp->Tabname = tab; tdp->Tabname = tab;
if (!(op = GetListOption(g, "Xmlsup", topt->oplist, NULL))) if (!(op = GetStringTableOption(g, topt, "Xmlsup", NULL)))
#if defined(WIN32) #if defined(__WIN__)
tdp->Usedom = true; tdp->Usedom = true;
#else // !WIN32 #else // !__WIN__
tdp->Usedom = false; tdp->Usedom = false;
#endif // !WIN32 #endif // !__WIN__
else else
tdp->Usedom = (toupper(*op) == 'M' || toupper(*op) == 'D'); tdp->Usedom = (toupper(*op) == 'M' || toupper(*op) == 'D');
@@ -432,7 +434,7 @@ 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]; char *defrow, *defcol, buf[10];
Fn = GetStringCatInfo(g, "Filename", NULL); Fn = GetStringCatInfo(g, "Filename", NULL);
Encoding = GetStringCatInfo(g, "Encoding", "UTF-8"); Encoding = GetStringCatInfo(g, "Encoding", "UTF-8");
@@ -447,7 +449,7 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
return true; return true;
} // endif flag } // endif flag
defrow = defcol = ""; defrow = defcol = NULL;
GetCharCatInfo("Coltype", "", buf, sizeof(buf)); GetCharCatInfo("Coltype", "", buf, sizeof(buf));
switch (toupper(*buf)) { switch (toupper(*buf)) {
@@ -480,29 +482,29 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Tabname = GetStringCatInfo(g, "Tabname", Tabname); Tabname = GetStringCatInfo(g, "Tabname", Tabname);
Rowname = GetStringCatInfo(g, "Rownode", defrow); Rowname = GetStringCatInfo(g, "Rownode", defrow);
Colname = GetStringCatInfo(g, "Colnode", defcol); Colname = GetStringCatInfo(g, "Colnode", defcol);
Mulnode = GetStringCatInfo(g, "Mulnode", ""); Mulnode = GetStringCatInfo(g, "Mulnode", NULL);
XmlDB = GetStringCatInfo(g, "XmlDB", ""); XmlDB = GetStringCatInfo(g, "XmlDB", NULL);
Nslist = GetStringCatInfo(g, "Nslist", ""); Nslist = GetStringCatInfo(g, "Nslist", NULL);
DefNs = GetStringCatInfo(g, "DefNs", ""); DefNs = GetStringCatInfo(g, "DefNs", NULL);
Limit = GetIntCatInfo("Limit", 10); Limit = GetIntCatInfo("Limit", 10);
Xpand = (GetIntCatInfo("Expand", 0) != 0); Xpand = GetBoolCatInfo("Expand", false);
Header = GetIntCatInfo("Header", 0); Header = GetIntCatInfo("Header", 0);
GetCharCatInfo("Xmlsup", "*", buf, sizeof(buf)); GetCharCatInfo("Xmlsup", "*", buf, sizeof(buf));
// 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
if (*buf == '*') if (*buf == '*')
#if defined(WIN32) #if defined(__WIN__)
Usedom = true; Usedom = true;
#else // !WIN32 #else // !__WIN__
Usedom = false; Usedom = false;
#endif // !WIN32 #endif // !__WIN__
else else
Usedom = (toupper(*buf) == 'M' || toupper(*buf) == 'D'); Usedom = (toupper(*buf) == 'M' || toupper(*buf) == 'D');
// Get eventual table node attribute // Get eventual table node attribute
Attrib = GetStringCatInfo(g, "Attribute", ""); Attrib = GetStringCatInfo(g, "Attribute", NULL);
Hdattr = GetStringCatInfo(g, "HeadAttr", ""); Hdattr = GetStringCatInfo(g, "HeadAttr", NULL);
return false; return false;
} // end of DefineAM } // end of DefineAM
@@ -543,14 +545,14 @@ TDBXML::TDBXML(PXMLDEF tdp) : TDBASE(tdp)
Xfile = tdp->Fn; Xfile = tdp->Fn;
Enc = tdp->Encoding; Enc = tdp->Encoding;
Tabname = tdp->Tabname; Tabname = tdp->Tabname;
Rowname = (tdp->Rowname && *tdp->Rowname) ? tdp->Rowname : NULL; Rowname = (tdp->Rowname) ? tdp->Rowname : NULL;
Colname = (tdp->Colname && *tdp->Colname) ? tdp->Colname : NULL; Colname = (tdp->Colname) ? tdp->Colname : NULL;
Mulnode = (tdp->Mulnode && *tdp->Mulnode) ? tdp->Mulnode : NULL; Mulnode = (tdp->Mulnode) ? tdp->Mulnode : NULL;
XmlDB = (tdp->XmlDB && *tdp->XmlDB) ? tdp->XmlDB : NULL; XmlDB = (tdp->XmlDB) ? tdp->XmlDB : NULL;
Nslist = (tdp->Nslist && *tdp->Nslist) ? tdp->Nslist : NULL; Nslist = (tdp->Nslist) ? tdp->Nslist : NULL;
DefNs = (tdp->DefNs && *tdp->DefNs) ? tdp->DefNs : NULL; DefNs = (tdp->DefNs) ? tdp->DefNs : NULL;
Attrib = (tdp->Attrib && *tdp->Attrib) ? tdp->Attrib : NULL; Attrib = (tdp->Attrib) ? tdp->Attrib : NULL;
Hdattr = (tdp->Hdattr && *tdp->Hdattr) ? tdp->Hdattr : NULL; Hdattr = (tdp->Hdattr) ? tdp->Hdattr : NULL;
Coltype = tdp->Coltype; Coltype = tdp->Coltype;
Limit = tdp->Limit; Limit = tdp->Limit;
Xpand = tdp->Xpand; Xpand = tdp->Xpand;
@@ -876,7 +878,7 @@ bool TDBXML::Initialize(PGLOBAL g)
Nlist = TabNode->GetChildElements(g); Nlist = TabNode->GetChildElements(g);
Docp->SetNofree(true); // For libxml2 Docp->SetNofree(true); // For libxml2
#if defined(WIN32) #if defined(__WIN__)
} catch(_com_error e) { } catch(_com_error e) {
// We come here if a DOM command threw an error // We come here if a DOM command threw an error
char buf[128]; char buf[128];
@@ -890,7 +892,7 @@ bool TDBXML::Initialize(PGLOBAL g)
sprintf(g->Message, "%s hr=%p", MSG(COM_ERROR), e.Error()); sprintf(g->Message, "%s hr=%p", MSG(COM_ERROR), e.Error());
goto error; goto error;
#endif // WIN32 #endif // __WIN__
#if !defined(UNIX) #if !defined(UNIX)
} catch(...) { } catch(...) {
// Other errors // Other errors
@@ -1015,7 +1017,7 @@ int TDBXML::GetMaxSize(PGLOBAL g)
else else
MaxSize = 10; MaxSize = 10;
} // endif MaxSize } // endif MaxSize
return MaxSize; return MaxSize;
} // end of GetMaxSize } // end of GetMaxSize
@@ -1256,7 +1258,7 @@ void TDBXML::CloseDB(PGLOBAL g)
{ {
if (Docp) { if (Docp) {
if (Changed) { if (Changed) {
char filename[_MAX_PATH]; char filename[_MAX_PATH];
// We used the file name relative to recorded datapath // We used the file name relative to recorded datapath
PlugSetPath(filename, Xfile, GetPath()); PlugSetPath(filename, Xfile, GetPath());
@@ -1660,7 +1662,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
/*********************************************************************/ /*********************************************************************/
/* Null values are represented by no node. */ /* Null values are represented by no node. */
/*********************************************************************/ /*********************************************************************/
if (Value->IsNull()) if (Value->IsNull())
return; return;
/*********************************************************************/ /*********************************************************************/
@@ -2160,7 +2162,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp) TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp)
{ {
Topt = tdp->GetTopt(); Topt = tdp->GetTopt();
Dp = tdp->GetPath(); Db = (char*)tdp->GetDB();
Tabn = tdp->Tabname; Tabn = tdp->Tabname;
} // end of TDBXCT constructor } // end of TDBXCT constructor
@@ -2169,7 +2171,7 @@ TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp)
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBXCT::GetResult(PGLOBAL g) PQRYRES TDBXCT::GetResult(PGLOBAL g)
{ {
return XMLColumns(g, Dp, Tabn, Topt, false); return XMLColumns(g, Db, Tabn, Topt, false);
} // end of GetResult } // end of GetResult
/* ------------------------ End of Tabxml ---------------------------- */ /* ------------------------ End of Tabxml ---------------------------- */

View File

@@ -1,7 +1,7 @@
/*************** Tabxml H Declares Source Code File (.H) ***************/ /*************** Tabxml H Declares Source Code File (.H) ***************/
/* Name: TABXML.H Version 1.6 */ /* Name: TABXML.H Version 1.6 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2007-2015 */
/* */ /* */
/* This file contains the XML table classes declares. */ /* This file contains the XML table classes declares. */
/***********************************************************************/ /***********************************************************************/
@@ -255,8 +255,7 @@ class TDBXCT : public TDBCAT {
// Members // Members
PTOS Topt; PTOS Topt;
char *Dp; char *Db;
//const char *Fn;
char *Tabn; char *Tabn;
}; // end of class TDBXCT }; // end of class TDBXCT

View File

@@ -23,7 +23,7 @@
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#else #else
#include "osutil.h" #include "osutil.h"

View File

@@ -30,11 +30,11 @@
#include "sql_class.h" #include "sql_class.h"
#include "sql_time.h" #include "sql_time.h"
#if defined(WIN32) #if defined(__WIN__)
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#include <string.h> #include <string.h>
#endif // !WIN32 #endif // !__WIN__
#include <math.h> #include <math.h>
@@ -77,12 +77,12 @@ int DTVAL::Shift = 0;
/***********************************************************************/ /***********************************************************************/
bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool); bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool);
#if !defined(WIN32) #if !defined(__WIN__)
extern "C" { extern "C" {
PSZ strupr(PSZ s); PSZ strupr(PSZ s);
PSZ strlwr(PSZ s); PSZ strlwr(PSZ s);
} }
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Get a long long number from its character representation. */ /* Get a long long number from its character representation. */
@@ -1618,10 +1618,10 @@ int TYPVAL<PSZ>::CompareValue(PVAL vp)
else else
n = strcmp(Strp, vp->GetCharValue()); n = strcmp(Strp, vp->GetCharValue());
#if defined(WIN32) #if defined(__WIN__)
if (n == _NLSCMPERROR) if (n == _NLSCMPERROR)
return n; // Here we should raise an error return n; // Here we should raise an error
#endif // WIN32 #endif // __WIN__
return (n > 0) ? 1 : (n < 0) ? -1 : 0; return (n > 0) ? 1 : (n < 0) ? -1 : 0;
} // end of CompareValue } // end of CompareValue

View File

@@ -36,8 +36,9 @@ typedef struct _datpar *PDTP; // For DTVAL
DllExport PSZ GetTypeName(int); DllExport PSZ 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 EOM table type DLLs */ /* This function is exported for use in OEM table type DLLs */
DllExport int TranslateSQLType(int stp, int prec, int& len, char& v); DllExport int TranslateSQLType(int stp, int prec,
int& len, char& v, bool& w);
#endif #endif
DllExport char *GetFormatType(int); DllExport char *GetFormatType(int);
DllExport int GetFormatType(char); DllExport int GetFormatType(char);
@@ -359,14 +360,9 @@ 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, PSZ fmt);
//DTVAL(PGLOBAL g, PSZ s, int n);
//DTVAL(PGLOBAL g, short i);
DTVAL(int n); DTVAL(int n);
//DTVAL(PGLOBAL g, longlong n);
//DTVAL(PGLOBAL g, double f);
// Implementation // Implementation
virtual bool IsZero(void) {return Null;}
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(char *p, int n);
virtual void SetValue_psz(PSZ s); virtual void SetValue_psz(PSZ s);

View File

@@ -10,12 +10,12 @@
/* Include relevant sections of the System header files. */ /* Include relevant sections of the System header files. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(__WIN__)
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
//#include <windows.h> //#include <windows.h>
#else // !WIN32 #else // !__WIN__
#if defined(UNIX) #if defined(UNIX)
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -25,7 +25,7 @@
#include <io.h> #include <io.h>
#endif // !UNIX #endif // !UNIX
#include <fcntl.h> #include <fcntl.h>
#endif // !WIN32 #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
@@ -340,6 +340,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
} // endif n } // endif n
if (trace)
htrc("XINDEX Make: n=%d\n", n);
// File position must be stored // File position must be stored
Record.Size = n * sizeof(int); Record.Size = n * sizeof(int);
@@ -477,6 +480,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
} else } else
To_Rec[nkey] = Tdbp->GetRecpos(); To_Rec[nkey] = Tdbp->GetRecpos();
if (trace > 1)
htrc("Make: To_Rec[%d]=%d\n", nkey, To_Rec[nkey]);
/*******************************************************************/ /*******************************************************************/
/* Get the keys and place them in the key blocks. */ /* Get the keys and place them in the key blocks. */
/*******************************************************************/ /*******************************************************************/
@@ -835,7 +841,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
if ((sep = defp->GetBoolCatInfo("SepIndex", false))) { if ((sep = defp->GetBoolCatInfo("SepIndex", false))) {
// Index is saved in a separate file // Index is saved in a separate file
#if !defined(UNIX) #if defined(__WIN__)
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
#else #else
char *drive = NULL; char *drive = NULL;
@@ -988,7 +994,7 @@ bool XINDEX::Init(PGLOBAL g)
if (defp->SepIndex()) { if (defp->SepIndex()) {
// Index was saved in a separate file // Index was saved in a separate file
#if !defined(UNIX) #if defined(__WIN__)
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
#else #else
char *drive = NULL; char *drive = NULL;
@@ -1241,7 +1247,7 @@ bool XINDEX::MapInit(PGLOBAL g)
if (defp->SepIndex()) { if (defp->SepIndex()) {
// Index was save in a separate file // Index was save in a separate file
#if !defined(UNIX) #if defined(__WIN__)
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
#else #else
char *drive = NULL; char *drive = NULL;
@@ -1454,7 +1460,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk)
if (defp->SepIndex()) { if (defp->SepIndex()) {
// Index was saved in a separate file // Index was saved in a separate file
#if !defined(UNIX) #if defined(__WIN__)
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
#else #else
char *drive = NULL; char *drive = NULL;
@@ -1759,6 +1765,9 @@ int XINDEX::Fetch(PGLOBAL g)
if (Num_K == 0) if (Num_K == 0)
return -1; // means end of file return -1; // means end of file
if (trace > 1)
htrc("XINDEX Fetch: Op=%d\n", Op);
/*********************************************************************/ /*********************************************************************/
/* Table read through a sorted index. */ /* Table read through a sorted index. */
/*********************************************************************/ /*********************************************************************/
@@ -1776,9 +1785,6 @@ int XINDEX::Fetch(PGLOBAL g)
break; break;
case OP_SAME: // Read next same case OP_SAME: // Read next same
// Logically the key values should be the same as before // Logically the key values should be the same as before
if (trace > 1)
htrc("looking for next same value\n");
if (NextVal(true)) { if (NextVal(true)) {
Op = OP_EQ; Op = OP_EQ;
return -2; // no more equal values return -2; // no more equal values
@@ -1824,7 +1830,7 @@ int XINDEX::Fetch(PGLOBAL g)
Nth++; Nth++;
if (trace > 1) if (trace > 1)
htrc("Fetch: Looking for new value\n"); htrc("Fetch: Looking for new value Nth=%d\n", Nth);
Cur_K = FastFind(); Cur_K = FastFind();
@@ -1896,6 +1902,10 @@ int XINDEX::FastFind(void)
sup = To_KeyCol->Ndf; sup = To_KeyCol->Ndf;
} // endif Nblk } // endif Nblk
if (trace > 2)
htrc("XINDEX FastFind: Nblk=%d Op=%d inf=%d sup=%d\n",
Nblk, Op, inf, sup);
for (k = 0, kcp = To_KeyCol; kcp; kcp = kcp->Next) { for (k = 0, kcp = To_KeyCol; kcp; kcp = kcp->Next) {
while (sup - inf > 1) { while (sup - inf > 1) {
i = (inf + sup) >> 1; i = (inf + sup) >> 1;
@@ -1970,6 +1980,9 @@ int XINDEX::FastFind(void)
curk = (kcp->Kof) ? kcp->Kof[kcp->Val_K] : kcp->Val_K; curk = (kcp->Kof) ? kcp->Kof[kcp->Val_K] : kcp->Val_K;
} // endfor kcp } // endfor kcp
if (trace > 2)
htrc("XINDEX FastFind: curk=%d\n", curk);
return curk; return curk;
} // end of FastFind } // end of FastFind
@@ -2043,8 +2056,7 @@ int XINDXS::GroupSize(void)
#if defined(_DEBUG) #if defined(_DEBUG)
assert(To_KeyCol->Val_K >= 0 && To_KeyCol->Val_K < Ndif); assert(To_KeyCol->Val_K >= 0 && To_KeyCol->Val_K < Ndif);
#endif // _DEBUG #endif // _DEBUG
return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K] return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K] : 1;
: 1;
} // end of GroupSize } // end of GroupSize
/***********************************************************************/ /***********************************************************************/
@@ -2106,6 +2118,9 @@ int XINDXS::Fetch(PGLOBAL g)
if (Num_K == 0) if (Num_K == 0)
return -1; // means end of file return -1; // means end of file
if (trace > 1)
htrc("XINDXS Fetch: Op=%d\n", Op);
/*********************************************************************/ /*********************************************************************/
/* Table read through a sorted index. */ /* Table read through a sorted index. */
/*********************************************************************/ /*********************************************************************/
@@ -2120,9 +2135,6 @@ int XINDXS::Fetch(PGLOBAL g)
Op = OP_NEXT; Op = OP_NEXT;
break; break;
case OP_SAME: // Read next same case OP_SAME: // Read next same
if (trace > 1)
htrc("looking for next same value\n");
if (!Mul || NextVal(true)) { if (!Mul || NextVal(true)) {
Op = OP_EQ; Op = OP_EQ;
return -2; // No more equal values return -2; // No more equal values
@@ -2160,7 +2172,7 @@ int XINDXS::Fetch(PGLOBAL g)
Nth++; Nth++;
if (trace > 1) if (trace > 1)
htrc("Fetch: Looking for new value\n"); htrc("Fetch: Looking for new value Nth=%d\n", Nth);
Cur_K = FastFind(); Cur_K = FastFind();
@@ -2192,7 +2204,7 @@ int XINDXS::Fetch(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int XINDXS::FastFind(void) int XINDXS::FastFind(void)
{ {
register int sup, inf, i= 0, n = 2; register int sup, inf, i= 0, n = 2;
register PXCOL kcp = To_KeyCol; register PXCOL kcp = To_KeyCol;
if (Nblk && Op == OP_EQ) { if (Nblk && Op == OP_EQ) {
@@ -2215,7 +2227,6 @@ int XINDXS::FastFind(void)
if (inf < 0) if (inf < 0)
return Num_K; return Num_K;
// i = inf;
inf *= Sblk; inf *= Sblk;
if ((sup = inf + Sblk) > Ndif) if ((sup = inf + Sblk) > Ndif)
@@ -2227,6 +2238,10 @@ int XINDXS::FastFind(void)
sup = Ndif; sup = Ndif;
} // endif Nblk } // endif Nblk
if (trace > 2)
htrc("XINDXS FastFind: Nblk=%d Op=%d inf=%d sup=%d\n",
Nblk, Op, inf, sup);
while (sup - inf > 1) { while (sup - inf > 1) {
i = (inf + sup) >> 1; i = (inf + sup) >> 1;
@@ -2249,6 +2264,9 @@ int XINDXS::FastFind(void)
n = 0; n = 0;
} // endif sup } // endif sup
if (trace > 2)
htrc("XINDXS FastFind: n=%d i=%d\n", n, i);
// Loop on kcp because of dynamic indexing // Loop on kcp because of dynamic indexing
for (; kcp; kcp = kcp->Next) for (; kcp; kcp = kcp->Next)
kcp->Val_K = i; // Used by FillValue kcp->Val_K = i; // Used by FillValue
@@ -2330,6 +2348,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
} // endif } // endif
NewOff.Low = (int)ftell(Xfile); NewOff.Low = (int)ftell(Xfile);
if (trace)
htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low);
} else if (mode == MODE_WRITE) { } else if (mode == MODE_WRITE) {
if (id >= 0) { if (id >= 0) {
// New not sep index file. Write the header. // New not sep index file. Write the header.
@@ -2337,6 +2359,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
Write(g, noff, sizeof(IOFF), MAX_INDX, rc); Write(g, noff, sizeof(IOFF), MAX_INDX, rc);
fseek(Xfile, 0, SEEK_END); fseek(Xfile, 0, SEEK_END);
NewOff.Low = (int)ftell(Xfile); NewOff.Low = (int)ftell(Xfile);
if (trace)
htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low);
} // endif id } // endif id
} else if (mode == MODE_READ && id >= 0) { } else if (mode == MODE_READ && id >= 0) {
@@ -2346,6 +2372,9 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
return true; return true;
} // endif MAX_INDX } // endif MAX_INDX
if (trace)
htrc("XFILE Open: noff[%d].Low=%d\n", id, noff[id].Low);
// Position the cursor at the offset of this index // Position the cursor at the offset of this index
if (fseek(Xfile, noff[id].Low, SEEK_SET)) { if (fseek(Xfile, noff[id].Low, SEEK_SET)) {
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek"); sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek");
@@ -2479,7 +2508,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
if (trace) if (trace)
htrc(" Xopen: filename=%s id=%d mode=%d\n", filename, id, mode); htrc(" Xopen: filename=%s id=%d mode=%d\n", filename, id, mode);
#if defined(WIN32) #if defined(__WIN__)
LONG high = 0; LONG high = 0;
DWORD rc, drc, access, share, creation; DWORD rc, drc, access, share, creation;
@@ -2655,7 +2684,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
/***********************************************************************/ /***********************************************************************/
bool XHUGE::Seek(PGLOBAL g, int low, int high, int origin) bool XHUGE::Seek(PGLOBAL g, int low, int high, int origin)
{ {
#if defined(WIN32) #if defined(__WIN__)
LONG hi = high; LONG hi = high;
DWORD rc = SetFilePointer(Hfile, low, &hi, origin); DWORD rc = SetFilePointer(Hfile, low, &hi, origin);
@@ -2691,7 +2720,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size)
{ {
bool rc = false; bool rc = false;
#if defined(WIN32) #if defined(__WIN__)
bool brc; bool brc;
DWORD nbr, count = (DWORD)(n * size); DWORD nbr, count = (DWORD)(n * size);
@@ -2737,7 +2766,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size)
/***********************************************************************/ /***********************************************************************/
int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc) int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc)
{ {
#if defined(WIN32) #if defined(__WIN__)
bool brc; bool brc;
DWORD nbw, count = (DWORD)n * (DWORD) size; DWORD nbw, count = (DWORD)n * (DWORD) size;
@@ -2779,7 +2808,7 @@ void XHUGE::Close(char *fn, int id)
if (trace) if (trace)
htrc("XHUGE::Close: fn=%s id=%d NewOff=%lld\n", fn, id, NewOff.Val); htrc("XHUGE::Close: fn=%s id=%d NewOff=%lld\n", fn, id, NewOff.Val);
#if defined(WIN32) #if defined(__WIN__)
if (id >= 0 && fn) { if (id >= 0 && fn) {
CloseFileHandle(Hfile); CloseFileHandle(Hfile);
Hfile = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, NULL, Hfile = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, NULL,
@@ -2794,7 +2823,7 @@ void XHUGE::Close(char *fn, int id)
} // endif SetFilePointer } // endif SetFilePointer
} // endif id } // endif id
#else // !WIN32 #else // !__WIN__
if (id >= 0 && fn) { if (id >= 0 && fn) {
if (Hfile != INVALID_HANDLE_VALUE) { if (Hfile != INVALID_HANDLE_VALUE) {
if (lseek64(Hfile, id * sizeof(IOFF), SEEK_SET) >= 0) { if (lseek64(Hfile, id * sizeof(IOFF), SEEK_SET) >= 0) {
@@ -2810,7 +2839,7 @@ void XHUGE::Close(char *fn, int id)
htrc("(XHUGE)error reopening %s: %s\n", fn, strerror(errno)); htrc("(XHUGE)error reopening %s: %s\n", fn, strerror(errno));
} // endif id } // endif id
#endif // !WIN32 #endif // !__WIN__
XLOAD::Close(); XLOAD::Close();
} // end of Close } // end of Close
@@ -3158,12 +3187,18 @@ bool KXYCOL::InitFind(PGLOBAL g, PXOB xp)
xp->Reset(); xp->Reset();
xp->Eval(g); xp->Eval(g);
Valp->SetValue_pval(xp->GetValue(), false); Valp->SetValue_pval(xp->GetValue(), false);
// Valp->SetValue_pval(xp->GetValue(), !Prefix);
} // endif Type } // endif Type
if (trace > 1) {
char buf[32];
htrc("KCOL InitFind: value=%s\n", Valp->GetCharString(buf));
} // endif trace
return false; return false;
} // end of InitFind } // end of InitFind
#if 0
/***********************************************************************/ /***********************************************************************/
/* InitBinFind: initialize Value to the value pointed by vp. */ /* InitBinFind: initialize Value to the value pointed by vp. */
/***********************************************************************/ /***********************************************************************/
@@ -3171,6 +3206,7 @@ void KXYCOL::InitBinFind(void *vp)
{ {
Valp->SetBinValue(vp); Valp->SetBinValue(vp);
} // end of InitBinFind } // end of InitBinFind
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* KXYCOL FillValue: called by COLBLK::Eval when a column value is */ /* KXYCOL FillValue: called by COLBLK::Eval when a column value is */

View File

@@ -346,7 +346,7 @@ class DllExport XLOAD : public BLOCK {
protected: protected:
// Members // Members
#if defined(WIN32) #if defined(__WIN__)
HANDLE Hfile; // Handle to file or map HANDLE Hfile; // Handle to file or map
#else // UNIX #else // UNIX
int Hfile; // Descriptor to file or map int Hfile; // Descriptor to file or map
@@ -462,7 +462,7 @@ class KXYCOL: public BLOCK {
virtual void FreeData(void); virtual void FreeData(void);
virtual void FillValue(PVAL valp); virtual void FillValue(PVAL valp);
virtual int CompVal(int i); virtual int CompVal(int i);
void InitBinFind(void *vp); // void InitBinFind(void *vp);
bool MakeBlockArray(PGLOBAL g, int nb, int size); bool MakeBlockArray(PGLOBAL g, int nb, int size);
int Compare(int i1, int i2); int Compare(int i1, int i2);
int CompBval(int i); int CompBval(int i);