mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
- MDEV-11295: developing handling files contained in ZIP file.
A first experimental and limited implementation. modified: storage/connect/CMakeLists.txt modified: storage/connect/filamap.cpp new file: storage/connect/filamzip.cpp new file: storage/connect/filamzip.h modified: storage/connect/ha_connect.cc new file: storage/connect/ioapi.c new file: storage/connect/ioapi.h modified: storage/connect/mycat.cc modified: storage/connect/plgdbsem.h modified: storage/connect/plgdbutl.cpp modified: storage/connect/tabdos.cpp modified: storage/connect/tabdos.h modified: storage/connect/tabfmt.cpp modified: storage/connect/tabfmt.h modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h new file: storage/connect/tabzip.cpp new file: storage/connect/tabzip.h new file: storage/connect/unzip.c new file: storage/connect/unzip.h new file: storage/connect/zip.c
This commit is contained in:
@@ -279,6 +279,18 @@ IF(CONNECT_WITH_JDBC)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF(CONNECT_WITH_JDBC)
|
ENDIF(CONNECT_WITH_JDBC)
|
||||||
|
|
||||||
|
#
|
||||||
|
# ZIP
|
||||||
|
#
|
||||||
|
|
||||||
|
OPTION(CONNECT_WITH_ZIP "Compile CONNECT storage engine with ZIP support" ON)
|
||||||
|
|
||||||
|
IF(CONNECT_WITH_ZIP)
|
||||||
|
SET(CONNECT_SOURCES ${CONNECT_SOURCES} filamzip.cpp tabzip.cpp unzip.c ioapi.c zip.c
|
||||||
|
filamzip.h tabzip.h ioapi.h unzip.h zip.h)
|
||||||
|
add_definitions(-DZIP_SUPPORT -DNOCRYPT)
|
||||||
|
ENDIF(CONNECT_WITH_ZIP)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# XMAP
|
# XMAP
|
||||||
|
@@ -87,7 +87,7 @@ int MAPFAM::GetFileLength(PGLOBAL g)
|
|||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = (To_Fb) ? To_Fb->Length : TXTFAM::GetFileLength(g);
|
len = (To_Fb && To_Fb->Count) ? To_Fb->Length : TXTFAM::GetFileLength(g);
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc("Mapped file length=%d\n", len);
|
htrc("Mapped file length=%d\n", len);
|
||||||
@@ -413,7 +413,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
|
|
||||||
if (Tpos == Spos) {
|
if (Tpos == Spos) {
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/* First line to delete. Move of eventual preceeding lines is */
|
/* First line to delete. Move of eventual preceding lines is */
|
||||||
/* not required here, just setting of future Spos and Tpos. */
|
/* not required here, just setting of future Spos and Tpos. */
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
Tpos = Spos = Fpos;
|
Tpos = Spos = Fpos;
|
||||||
@@ -498,7 +498,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
void MAPFAM::CloseTableFile(PGLOBAL g, bool)
|
void MAPFAM::CloseTableFile(PGLOBAL g, bool)
|
||||||
{
|
{
|
||||||
PlugCloseFile(g, To_Fb);
|
PlugCloseFile(g, To_Fb);
|
||||||
To_Fb = NULL; // To get correct file size in Cardinality
|
//To_Fb = NULL; // To get correct file size in Cardinality
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc("MAP Close: closing %s count=%d\n",
|
htrc("MAP Close: closing %s count=%d\n",
|
||||||
|
501
storage/connect/filamzip.cpp
Normal file
501
storage/connect/filamzip.cpp
Normal file
@@ -0,0 +1,501 @@
|
|||||||
|
/*********** File AM Zip C++ Program Source Code File (.CPP) ***********/
|
||||||
|
/* PROGRAM NAME: FILAMZIP */
|
||||||
|
/* ------------- */
|
||||||
|
/* Version 1.0 */
|
||||||
|
/* */
|
||||||
|
/* COPYRIGHT: */
|
||||||
|
/* ---------- */
|
||||||
|
/* (C) Copyright to the author Olivier BERTRAND 2016 */
|
||||||
|
/* */
|
||||||
|
/* WHAT THIS PROGRAM DOES: */
|
||||||
|
/* ----------------------- */
|
||||||
|
/* This program are the ZIP file access method classes. */
|
||||||
|
/* */
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Include relevant sections of the System header files. */
|
||||||
|
/***********************************************************************/
|
||||||
|
#include "my_global.h"
|
||||||
|
#if !defined(__WIN__)
|
||||||
|
#if defined(UNIX)
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#else // !UNIX
|
||||||
|
#include <io.h>
|
||||||
|
#endif // !UNIX
|
||||||
|
#include <fcntl.h>
|
||||||
|
#endif // !__WIN__
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Include application header files: */
|
||||||
|
/* global.h is header containing all global declarations. */
|
||||||
|
/* plgdbsem.h is header containing the DB application declarations. */
|
||||||
|
/***********************************************************************/
|
||||||
|
#include "global.h"
|
||||||
|
#include "plgdbsem.h"
|
||||||
|
#include "osutil.h"
|
||||||
|
#include "filamtxt.h"
|
||||||
|
#include "tabfmt.h"
|
||||||
|
//#include "tabzip.h"
|
||||||
|
#include "filamzip.h"
|
||||||
|
|
||||||
|
/* -------------------------- class ZIPFAM --------------------------- */
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Constructors. */
|
||||||
|
/***********************************************************************/
|
||||||
|
ZIPFAM::ZIPFAM(PDOSDEF tdp) : MAPFAM(tdp)
|
||||||
|
{
|
||||||
|
zipfile = NULL;
|
||||||
|
zfn = tdp->Zipfn;
|
||||||
|
target = tdp->Fn;
|
||||||
|
//*fn = 0;
|
||||||
|
entryopen = false;
|
||||||
|
multiple = tdp->Multiple;
|
||||||
|
|
||||||
|
// Init the case mapping table.
|
||||||
|
#if defined(__WIN__)
|
||||||
|
for (int i = 0; i < 256; ++i) mapCaseTable[i] = toupper(i);
|
||||||
|
#else
|
||||||
|
for (int i = 0; i < 256; ++i) mapCaseTable[i] = i;
|
||||||
|
#endif
|
||||||
|
} // end of ZIPFAM standard constructor
|
||||||
|
|
||||||
|
ZIPFAM::ZIPFAM(PZIPFAM txfp) : MAPFAM(txfp)
|
||||||
|
{
|
||||||
|
zipfile = txfp->zipfile;
|
||||||
|
zfn = txfp->zfn;
|
||||||
|
target = txfp->target;
|
||||||
|
//strcpy(fn, txfp->fn);
|
||||||
|
finfo = txfp->finfo;
|
||||||
|
entryopen = txfp->entryopen;
|
||||||
|
multiple = txfp->multiple;
|
||||||
|
for (int i = 0; i < 256; ++i) mapCaseTable[i] = txfp->mapCaseTable[i];
|
||||||
|
} // end of ZIPFAM copy constructor
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* This code is the copyright property of Alessandro Felice Cantatore. */
|
||||||
|
/* http://xoomer.virgilio.it/acantato/dev/wildcard/wildmatch.html */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool ZIPFAM::WildMatch(PSZ pat, PSZ str) {
|
||||||
|
PSZ s, p;
|
||||||
|
bool star = FALSE;
|
||||||
|
|
||||||
|
loopStart:
|
||||||
|
for (s = str, p = pat; *s; ++s, ++p) {
|
||||||
|
switch (*p) {
|
||||||
|
case '?':
|
||||||
|
if (*s == '.') goto starCheck;
|
||||||
|
break;
|
||||||
|
case '*':
|
||||||
|
star = TRUE;
|
||||||
|
str = s, pat = p;
|
||||||
|
if (!*++pat) return TRUE;
|
||||||
|
goto loopStart;
|
||||||
|
default:
|
||||||
|
if (mapCaseTable[*s] != mapCaseTable[*p])
|
||||||
|
goto starCheck;
|
||||||
|
break;
|
||||||
|
} /* endswitch */
|
||||||
|
} /* endfor */
|
||||||
|
if (*p == '*') ++p;
|
||||||
|
return (!*p);
|
||||||
|
|
||||||
|
starCheck:
|
||||||
|
if (!star) return FALSE;
|
||||||
|
str++;
|
||||||
|
goto loopStart;
|
||||||
|
} // end of WildMatch
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ZIP GetFileLength: returns file size in number of bytes. */
|
||||||
|
/***********************************************************************/
|
||||||
|
int ZIPFAM::GetFileLength(PGLOBAL g)
|
||||||
|
{
|
||||||
|
int len = (entryopen) ? Top - Memory : 100; // not 0 to avoid ASSERT
|
||||||
|
|
||||||
|
if (trace)
|
||||||
|
htrc("Zipped file length=%d\n", len);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
} // end of GetFileLength
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* open a zip file. */
|
||||||
|
/* param: filename path and the filename of the zip file to open. */
|
||||||
|
/* return: true if open, false otherwise. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool ZIPFAM::open(PGLOBAL g, const char *filename)
|
||||||
|
{
|
||||||
|
if (!zipfile && !(zipfile = unzOpen64(filename)))
|
||||||
|
sprintf(g->Message, "Zipfile open error");
|
||||||
|
|
||||||
|
return (zipfile == NULL);
|
||||||
|
} // end of open
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Close the zip file. */
|
||||||
|
/***********************************************************************/
|
||||||
|
void ZIPFAM::close()
|
||||||
|
{
|
||||||
|
if (zipfile) {
|
||||||
|
closeEntry();
|
||||||
|
unzClose(zipfile);
|
||||||
|
zipfile = NULL;
|
||||||
|
} // endif zipfile
|
||||||
|
|
||||||
|
} // end of close
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Find next entry matching target pattern. */
|
||||||
|
/***********************************************************************/
|
||||||
|
int ZIPFAM::findEntry(PGLOBAL g, bool next)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
char fn[FILENAME_MAX]; // The current entry file name
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (next) {
|
||||||
|
rc = unzGoToNextFile(zipfile);
|
||||||
|
|
||||||
|
if (rc == UNZ_END_OF_LIST_OF_FILE)
|
||||||
|
return RC_EF;
|
||||||
|
else if (rc != UNZ_OK) {
|
||||||
|
sprintf(g->Message, "unzGoToNextFile rc = ", rc);
|
||||||
|
return RC_FX;
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
|
} // endif next
|
||||||
|
|
||||||
|
if (target && *target) {
|
||||||
|
rc = unzGetCurrentFileInfo(zipfile, NULL, fn, sizeof(fn),
|
||||||
|
NULL, 0, NULL, 0);
|
||||||
|
if (rc == UNZ_OK) {
|
||||||
|
if (WildMatch(target, fn))
|
||||||
|
return RC_OK;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sprintf(g->Message, "GetCurrentFileInfo rc = %d", rc);
|
||||||
|
return RC_FX;
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
|
} else
|
||||||
|
return RC_OK;
|
||||||
|
|
||||||
|
next = true;
|
||||||
|
} while (true);
|
||||||
|
|
||||||
|
strcpy(g->Message, "FindNext logical error");
|
||||||
|
return RC_FX;
|
||||||
|
} // end of FindNext
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* OpenTableFile: Open a DOS/UNIX table file from a ZIP file. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool ZIPFAM::OpenTableFile(PGLOBAL g)
|
||||||
|
{
|
||||||
|
char filename[_MAX_PATH];
|
||||||
|
MODE mode = Tdbp->GetMode();
|
||||||
|
PFBLOCK fp;
|
||||||
|
PDBUSER dbuserp = (PDBUSER)g->Activityp->Aptr;
|
||||||
|
|
||||||
|
/*********************************************************************/
|
||||||
|
/* The file will be decompressed into virtual memory. */
|
||||||
|
/*********************************************************************/
|
||||||
|
if (mode == MODE_READ) {
|
||||||
|
// We used the file name relative to recorded datapath
|
||||||
|
PlugSetPath(filename, zfn, Tdbp->GetPath());
|
||||||
|
|
||||||
|
bool b = open(g, filename);
|
||||||
|
|
||||||
|
if (!b) {
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (target && *target) {
|
||||||
|
if (!multiple) {
|
||||||
|
rc = unzLocateFile(zipfile, target, 0);
|
||||||
|
|
||||||
|
if (rc == UNZ_END_OF_LIST_OF_FILE) {
|
||||||
|
sprintf(g->Message, "Target file %s not in %s", target, filename);
|
||||||
|
return true;
|
||||||
|
} else if (rc != UNZ_OK) {
|
||||||
|
sprintf(g->Message, "unzLocateFile rc=%d", rc);
|
||||||
|
return true;
|
||||||
|
} // endif's rc
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if ((rc = findEntry(g, false)) == RC_FX)
|
||||||
|
return true;
|
||||||
|
else if (rc == RC_NF) {
|
||||||
|
sprintf(g->Message, "No match of %s in %s", target, filename);
|
||||||
|
return true;
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
|
} // endif multiple
|
||||||
|
|
||||||
|
} // endif target
|
||||||
|
|
||||||
|
if (openEntry(g))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (Top > Memory) {
|
||||||
|
/*******************************************************************/
|
||||||
|
/* Link a Fblock. This make possible to automatically close it */
|
||||||
|
/* in case of error g->jump. */
|
||||||
|
/*******************************************************************/
|
||||||
|
fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
|
||||||
|
fp->Type = TYPE_FB_ZIP;
|
||||||
|
fp->Fname = PlugDup(g, filename);
|
||||||
|
fp->Next = dbuserp->Openlist;
|
||||||
|
dbuserp->Openlist = fp;
|
||||||
|
fp->Count = 1;
|
||||||
|
fp->Length = Top - Memory;
|
||||||
|
fp->Memory = Memory;
|
||||||
|
fp->Mode = mode;
|
||||||
|
fp->File = this;
|
||||||
|
fp->Handle = NULL;
|
||||||
|
} // endif fp
|
||||||
|
|
||||||
|
To_Fb = fp; // Useful when closing
|
||||||
|
} // endif b
|
||||||
|
|
||||||
|
} else {
|
||||||
|
strcpy(g->Message, "Only READ mode supported for ZIP files");
|
||||||
|
return true;
|
||||||
|
} // endif mode
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} // end of OpenTableFile
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Open target in zip file. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool ZIPFAM::openEntry(PGLOBAL g)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
uint size;
|
||||||
|
|
||||||
|
rc = unzGetCurrentFileInfo(zipfile, &finfo, 0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
if (rc != UNZ_OK) {
|
||||||
|
sprintf(g->Message, "unzGetCurrentFileInfo64 rc=%d", rc);
|
||||||
|
return true;
|
||||||
|
} else if ((rc = unzOpenCurrentFile(zipfile)) != UNZ_OK) {
|
||||||
|
sprintf(g->Message, "unzOpenCurrentFile rc=%d", rc);
|
||||||
|
return true;
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
|
size = finfo.uncompressed_size;
|
||||||
|
Memory = new char[size];
|
||||||
|
|
||||||
|
if ((rc = unzReadCurrentFile(zipfile, Memory, size)) < 0) {
|
||||||
|
sprintf(g->Message, "unzReadCurrentFile rc = ", rc);
|
||||||
|
unzCloseCurrentFile(zipfile);
|
||||||
|
free(Memory);
|
||||||
|
entryopen = false;
|
||||||
|
} else {
|
||||||
|
// The pseudo "buffer" is here the entire real buffer
|
||||||
|
Fpos = Mempos = Memory;
|
||||||
|
Top = Memory + size;
|
||||||
|
|
||||||
|
if (trace)
|
||||||
|
htrc("Memory=%p size=%ud Top=%p\n", Memory, size, Top);
|
||||||
|
|
||||||
|
entryopen = true;
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
|
return !entryopen;
|
||||||
|
} // end of openEntry
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Close the zip file. */
|
||||||
|
/***********************************************************************/
|
||||||
|
void ZIPFAM::closeEntry()
|
||||||
|
{
|
||||||
|
if (entryopen) {
|
||||||
|
unzCloseCurrentFile(zipfile);
|
||||||
|
entryopen = false;
|
||||||
|
} // endif entryopen
|
||||||
|
|
||||||
|
if (Memory) {
|
||||||
|
free(Memory);
|
||||||
|
Memory = NULL;
|
||||||
|
} // endif Memory
|
||||||
|
|
||||||
|
} // end of closeEntry
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ReadBuffer: Read one line for a ZIP file. */
|
||||||
|
/***********************************************************************/
|
||||||
|
int ZIPFAM::ReadBuffer(PGLOBAL g)
|
||||||
|
{
|
||||||
|
int rc, len;
|
||||||
|
|
||||||
|
// Are we at the end of the memory
|
||||||
|
if (Mempos >= Top) {
|
||||||
|
if (multiple) {
|
||||||
|
closeEntry();
|
||||||
|
|
||||||
|
if ((rc = findEntry(g, true)) != RC_OK)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
if (openEntry(g))
|
||||||
|
return RC_FX;
|
||||||
|
|
||||||
|
} else
|
||||||
|
return RC_EF;
|
||||||
|
|
||||||
|
} // endif Mempos
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!Placed) {
|
||||||
|
/*******************************************************************/
|
||||||
|
/* Record file position in case of UPDATE or DELETE. */
|
||||||
|
/*******************************************************************/
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
next:
|
||||||
|
Fpos = Mempos;
|
||||||
|
CurBlk = (int)Rows++;
|
||||||
|
|
||||||
|
/*******************************************************************/
|
||||||
|
/* Check whether optimization on ROWID */
|
||||||
|
/* can be done, as well as for join as for local filtering. */
|
||||||
|
/*******************************************************************/
|
||||||
|
switch (Tdbp->TestBlock(g)) {
|
||||||
|
case RC_EF:
|
||||||
|
return RC_EF;
|
||||||
|
case RC_NF:
|
||||||
|
// Skip this record
|
||||||
|
if ((rc = SkipRecord(g, false)) != RC_OK)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
goto next;
|
||||||
|
} // endswitch rc
|
||||||
|
|
||||||
|
} else
|
||||||
|
Placed = false;
|
||||||
|
#else
|
||||||
|
// Perhaps unuseful
|
||||||
|
Fpos = Mempos;
|
||||||
|
CurBlk = (int)Rows++;
|
||||||
|
Placed = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Immediately calculate next position (Used by DeleteDB)
|
||||||
|
while (*Mempos++ != '\n'); // What about Unix ???
|
||||||
|
|
||||||
|
// Set caller line buffer
|
||||||
|
len = (Mempos - Fpos) - 1;
|
||||||
|
|
||||||
|
// Don't rely on ENDING setting
|
||||||
|
if (len > 0 && *(Mempos - 2) == '\r')
|
||||||
|
len--; // Line ends by CRLF
|
||||||
|
|
||||||
|
memcpy(Tdbp->GetLine(), Fpos, len);
|
||||||
|
Tdbp->GetLine()[len] = '\0';
|
||||||
|
return RC_OK;
|
||||||
|
} // end of ReadBuffer
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Table file close routine for MAP access method. */
|
||||||
|
/***********************************************************************/
|
||||||
|
void ZIPFAM::CloseTableFile(PGLOBAL g, bool)
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
} // end of CloseTableFile
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
|
/* -------------------------- class ZPXFAM --------------------------- */
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Constructors. */
|
||||||
|
/***********************************************************************/
|
||||||
|
ZPXFAM::ZPXFAM(PDOSDEF tdp) : ZIPFAM(tdp)
|
||||||
|
{
|
||||||
|
Lrecl = tdp->GetLrecl();
|
||||||
|
} // end of ZPXFAM standard constructor
|
||||||
|
|
||||||
|
ZPXFAM::ZPXFAM(PZPXFAM txfp) : ZIPFAM(txfp)
|
||||||
|
{
|
||||||
|
Lrecl = txfp->Lrecl;
|
||||||
|
} // end of ZPXFAM copy constructor
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ReadBuffer: Read one line for a fixed ZIP file. */
|
||||||
|
/***********************************************************************/
|
||||||
|
int ZPXFAM::ReadBuffer(PGLOBAL g)
|
||||||
|
{
|
||||||
|
int rc, len;
|
||||||
|
|
||||||
|
// Are we at the end of the memory
|
||||||
|
if (Mempos >= Top) {
|
||||||
|
if (multiple) {
|
||||||
|
closeEntry();
|
||||||
|
|
||||||
|
if ((rc = findEntry(g, true)) != RC_OK)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
if (openEntry(g))
|
||||||
|
return RC_FX;
|
||||||
|
|
||||||
|
} else
|
||||||
|
return RC_EF;
|
||||||
|
|
||||||
|
} // endif Mempos
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!Placed) {
|
||||||
|
/*******************************************************************/
|
||||||
|
/* Record file position in case of UPDATE or DELETE. */
|
||||||
|
/*******************************************************************/
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
next:
|
||||||
|
Fpos = Mempos;
|
||||||
|
CurBlk = (int)Rows++;
|
||||||
|
|
||||||
|
/*******************************************************************/
|
||||||
|
/* Check whether optimization on ROWID */
|
||||||
|
/* can be done, as well as for join as for local filtering. */
|
||||||
|
/*******************************************************************/
|
||||||
|
switch (Tdbp->TestBlock(g)) {
|
||||||
|
case RC_EF:
|
||||||
|
return RC_EF;
|
||||||
|
case RC_NF:
|
||||||
|
// Skip this record
|
||||||
|
if ((rc = SkipRecord(g, false)) != RC_OK)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
goto next;
|
||||||
|
} // endswitch rc
|
||||||
|
|
||||||
|
} else
|
||||||
|
Placed = false;
|
||||||
|
#else
|
||||||
|
// Perhaps unuseful
|
||||||
|
Fpos = Mempos;
|
||||||
|
CurBlk = (int)Rows++;
|
||||||
|
Placed = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Immediately calculate next position (Used by DeleteDB)
|
||||||
|
Mempos += Lrecl;
|
||||||
|
|
||||||
|
// Set caller line buffer
|
||||||
|
len = Lrecl;
|
||||||
|
|
||||||
|
// Don't rely on ENDING setting
|
||||||
|
if (len > 0 && *(Mempos - 1) == '\n')
|
||||||
|
len--; // Line ends by LF
|
||||||
|
|
||||||
|
if (len > 0 && *(Mempos - 2) == '\r')
|
||||||
|
len--; // Line ends by CRLF
|
||||||
|
|
||||||
|
memcpy(Tdbp->GetLine(), Fpos, len);
|
||||||
|
Tdbp->GetLine()[len] = '\0';
|
||||||
|
return RC_OK;
|
||||||
|
} // end of ReadBuffer
|
||||||
|
|
83
storage/connect/filamzip.h
Normal file
83
storage/connect/filamzip.h
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/************** filamzip H Declares Source Code File (.H) **************/
|
||||||
|
/* Name: filamzip.h Version 1.0 */
|
||||||
|
/* */
|
||||||
|
/* (C) Copyright to the author Olivier BERTRAND 2016 */
|
||||||
|
/* */
|
||||||
|
/* This file contains the ZIP file access method classes declares. */
|
||||||
|
/***********************************************************************/
|
||||||
|
#ifndef __FILAMZIP_H
|
||||||
|
#define __FILAMZIP_H
|
||||||
|
|
||||||
|
#include "block.h"
|
||||||
|
#include "filamap.h"
|
||||||
|
#include "unzip.h"
|
||||||
|
|
||||||
|
#define DLLEXPORT extern "C"
|
||||||
|
|
||||||
|
typedef class ZIPFAM *PZIPFAM;
|
||||||
|
typedef class ZPXFAM *PZPXFAM;
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* This is the ZIP file access method. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class DllExport ZIPFAM : public MAPFAM {
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
ZIPFAM(PDOSDEF tdp);
|
||||||
|
ZIPFAM(PZIPFAM txfp);
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
|
||||||
|
virtual PTXF Duplicate(PGLOBAL g) {return (PTXF) new(g) ZIPFAM(this);}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual int GetFileLength(PGLOBAL g);
|
||||||
|
virtual int Cardinality(PGLOBAL g) {return (g) ? 10 : 1;}
|
||||||
|
//virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
|
||||||
|
virtual bool OpenTableFile(PGLOBAL g);
|
||||||
|
virtual bool DeferReading(void) {return false;}
|
||||||
|
virtual int ReadBuffer(PGLOBAL g);
|
||||||
|
//virtual int WriteBuffer(PGLOBAL g);
|
||||||
|
//virtual int DeleteRecords(PGLOBAL g, int irc);
|
||||||
|
//virtual void CloseTableFile(PGLOBAL g, bool abort);
|
||||||
|
void close(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool open(PGLOBAL g, const char *filename);
|
||||||
|
bool openEntry(PGLOBAL g);
|
||||||
|
void closeEntry(void);
|
||||||
|
bool WildMatch(PSZ pat, PSZ str);
|
||||||
|
int findEntry(PGLOBAL g, bool next);
|
||||||
|
|
||||||
|
// Members
|
||||||
|
unzFile zipfile; // The ZIP container file
|
||||||
|
PSZ zfn; // The ZIP file name
|
||||||
|
PSZ target; // The target file name
|
||||||
|
unz_file_info finfo; // The current file info
|
||||||
|
//char fn[FILENAME_MAX]; // The current file name
|
||||||
|
bool entryopen; // True when open current entry
|
||||||
|
int multiple; // Multiple targets
|
||||||
|
char mapCaseTable[256];
|
||||||
|
}; // end of ZIPFAM
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* This is the fixed ZIP file access method. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class DllExport ZPXFAM : public ZIPFAM {
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
ZPXFAM(PDOSDEF tdp);
|
||||||
|
ZPXFAM(PZPXFAM txfp);
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
virtual PTXF Duplicate(PGLOBAL g) {return (PTXF) new(g) ZPXFAM(this);}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual int ReadBuffer(PGLOBAL g);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Members
|
||||||
|
int Lrecl;
|
||||||
|
}; // end of ZPXFAM
|
||||||
|
|
||||||
|
#endif // __FILAMZIP_H
|
@@ -171,9 +171,9 @@
|
|||||||
#define JSONMAX 10 // JSON Default max grp size
|
#define JSONMAX 10 // JSON Default max grp size
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
char version[]= "Version 1.04.0008 October 20, 2016";
|
char version[]= "Version 1.04.0009 December 09, 2016";
|
||||||
#if defined(__WIN__)
|
#if defined(__WIN__)
|
||||||
char compver[]= "Version 1.04.0008 " __DATE__ " " __TIME__;
|
char compver[]= "Version 1.04.0009 " __DATE__ " " __TIME__;
|
||||||
char slash= '\\';
|
char slash= '\\';
|
||||||
#else // !__WIN__
|
#else // !__WIN__
|
||||||
char slash= '/';
|
char slash= '/';
|
||||||
@@ -4165,6 +4165,7 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
|
|||||||
case TAB_DIR:
|
case TAB_DIR:
|
||||||
case TAB_MAC:
|
case TAB_MAC:
|
||||||
case TAB_WMI:
|
case TAB_WMI:
|
||||||
|
case TAB_ZIP:
|
||||||
case TAB_OEM:
|
case TAB_OEM:
|
||||||
#ifdef NO_EMBEDDED_ACCESS_CHECKS
|
#ifdef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
return false;
|
return false;
|
||||||
@@ -5173,13 +5174,13 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
char v=0, spc= ',', qch= 0;
|
char v=0, spc= ',', qch= 0;
|
||||||
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, *zfn;
|
||||||
char *tab, *dsn, *shm, *dpath;
|
char *tab, *dsn, *shm, *dpath;
|
||||||
#if defined(__WIN__)
|
#if defined(__WIN__)
|
||||||
char *nsp= NULL, *cls= NULL;
|
char *nsp= NULL, *cls= NULL;
|
||||||
#endif // __WIN__
|
#endif // __WIN__
|
||||||
int port= 0, hdr= 0, mxr= 0, mxe= 0, rc= 0;
|
//int hdr, mxe;
|
||||||
int cop __attribute__((unused))= 0, lrecl= 0;
|
int port = 0, mxr = 0, rc = 0, mul = 0, lrecl = 0;
|
||||||
#if defined(ODBC_SUPPORT)
|
#if defined(ODBC_SUPPORT)
|
||||||
POPARM sop= NULL;
|
POPARM sop= NULL;
|
||||||
char *ucnc= NULL;
|
char *ucnc= NULL;
|
||||||
@@ -5211,7 +5212,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= NULL;
|
user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= zfn= dsn= NULL;
|
||||||
|
|
||||||
// Get the useful create options
|
// Get the useful create options
|
||||||
ttp= GetTypeID(topt->type);
|
ttp= GetTypeID(topt->type);
|
||||||
@@ -5224,7 +5225,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
sep= topt->separator;
|
sep= topt->separator;
|
||||||
spc= (!sep) ? ',' : *sep;
|
spc= (!sep) ? ',' : *sep;
|
||||||
qch= topt->qchar ? *topt->qchar : (signed)topt->quoted >= 0 ? '"' : 0;
|
qch= topt->qchar ? *topt->qchar : (signed)topt->quoted >= 0 ? '"' : 0;
|
||||||
hdr= (int)topt->header;
|
mul = (int)topt->multiple;
|
||||||
tbl= topt->tablist;
|
tbl= topt->tablist;
|
||||||
col= topt->colist;
|
col= topt->colist;
|
||||||
|
|
||||||
@@ -5260,10 +5261,12 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
// prop = GetListOption(g, "Properties", topt->oplist, NULL);
|
// prop = GetListOption(g, "Properties", topt->oplist, NULL);
|
||||||
tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL);
|
tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL);
|
||||||
#endif // JDBC_SUPPORT
|
#endif // JDBC_SUPPORT
|
||||||
mxe= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
|
|
||||||
#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
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
zfn = GetListOption(g, "Zipfile", topt->oplist, NULL);
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
} else {
|
} else {
|
||||||
host= "localhost";
|
host= "localhost";
|
||||||
user= (ttp == TAB_ODBC ? NULL : "root");
|
user= (ttp == TAB_ODBC ? NULL : "root");
|
||||||
@@ -5471,7 +5474,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
case TAB_XML:
|
case TAB_XML:
|
||||||
#endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT
|
#endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT
|
||||||
case TAB_JSON:
|
case TAB_JSON:
|
||||||
if (!fn)
|
if (!fn && !zfn && !mul)
|
||||||
sprintf(g->Message, "Missing %s file name", topt->type);
|
sprintf(g->Message, "Missing %s file name", topt->type);
|
||||||
else
|
else
|
||||||
ok= true;
|
ok= true;
|
||||||
@@ -5585,7 +5588,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
NULL, port, fnc == FNC_COL);
|
NULL, port, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
case TAB_CSV:
|
case TAB_CSV:
|
||||||
qrp= CSVColumns(g, dpath, fn, spc, qch, hdr, mxe, fnc == FNC_COL);
|
qrp = CSVColumns(g, dpath, topt, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
#if defined(__WIN__)
|
#if defined(__WIN__)
|
||||||
case TAB_WMI:
|
case TAB_WMI:
|
||||||
|
247
storage/connect/ioapi.c
Normal file
247
storage/connect/ioapi.c
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||||
|
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
|
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
|
Modifications for Zip64 support
|
||||||
|
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||||
|
|
||||||
|
For more info read MiniZip_info.txt
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS)))
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__) || defined(IOAPI_NO_64)
|
||||||
|
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||||
|
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||||
|
#define FTELLO_FUNC(stream) ftello(stream)
|
||||||
|
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
|
||||||
|
#else
|
||||||
|
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
|
||||||
|
#define FTELLO_FUNC(stream) ftello64(stream)
|
||||||
|
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "ioapi.h"
|
||||||
|
|
||||||
|
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
|
||||||
|
{
|
||||||
|
if (pfilefunc->zfile_func64.zopen64_file != NULL)
|
||||||
|
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
|
||||||
|
{
|
||||||
|
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||||
|
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uLong offsetTruncated = (uLong)offset;
|
||||||
|
if (offsetTruncated != offset)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
|
||||||
|
{
|
||||||
|
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||||
|
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||||
|
if ((tell_uLong) == MAXU32)
|
||||||
|
return (ZPOS64_T)-1;
|
||||||
|
else
|
||||||
|
return tell_uLong;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
|
||||||
|
{
|
||||||
|
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
|
||||||
|
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
|
||||||
|
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||||
|
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
|
||||||
|
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
|
||||||
|
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
|
||||||
|
p_filefunc64_32->zfile_func64.zseek64_file = NULL;
|
||||||
|
p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
|
||||||
|
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||||
|
p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
|
||||||
|
p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
|
||||||
|
p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
|
||||||
|
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||||
|
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
|
||||||
|
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
|
||||||
|
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||||
|
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
|
||||||
|
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
|
||||||
|
|
||||||
|
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
|
||||||
|
{
|
||||||
|
FILE* file = NULL;
|
||||||
|
const char* mode_fopen = NULL;
|
||||||
|
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||||
|
mode_fopen = "rb";
|
||||||
|
else
|
||||||
|
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||||
|
mode_fopen = "r+b";
|
||||||
|
else
|
||||||
|
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||||
|
mode_fopen = "wb";
|
||||||
|
|
||||||
|
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||||
|
file = fopen(filename, mode_fopen);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
|
||||||
|
{
|
||||||
|
FILE* file = NULL;
|
||||||
|
const char* mode_fopen = NULL;
|
||||||
|
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||||
|
mode_fopen = "rb";
|
||||||
|
else
|
||||||
|
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||||
|
mode_fopen = "r+b";
|
||||||
|
else
|
||||||
|
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||||
|
mode_fopen = "wb";
|
||||||
|
|
||||||
|
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||||
|
file = FOPEN_FUNC((const char*)filename, mode_fopen);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
||||||
|
{
|
||||||
|
uLong ret;
|
||||||
|
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
|
||||||
|
{
|
||||||
|
uLong ret;
|
||||||
|
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
||||||
|
{
|
||||||
|
long ret;
|
||||||
|
ret = ftell((FILE *)stream);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
||||||
|
{
|
||||||
|
ZPOS64_T ret;
|
||||||
|
ret = FTELLO_FUNC((FILE *)stream);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
|
||||||
|
{
|
||||||
|
int fseek_origin=0;
|
||||||
|
long ret;
|
||||||
|
switch (origin)
|
||||||
|
{
|
||||||
|
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||||
|
fseek_origin = SEEK_CUR;
|
||||||
|
break;
|
||||||
|
case ZLIB_FILEFUNC_SEEK_END :
|
||||||
|
fseek_origin = SEEK_END;
|
||||||
|
break;
|
||||||
|
case ZLIB_FILEFUNC_SEEK_SET :
|
||||||
|
fseek_origin = SEEK_SET;
|
||||||
|
break;
|
||||||
|
default: return -1;
|
||||||
|
}
|
||||||
|
ret = 0;
|
||||||
|
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
|
||||||
|
ret = -1;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
|
||||||
|
{
|
||||||
|
int fseek_origin=0;
|
||||||
|
long ret;
|
||||||
|
switch (origin)
|
||||||
|
{
|
||||||
|
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||||
|
fseek_origin = SEEK_CUR;
|
||||||
|
break;
|
||||||
|
case ZLIB_FILEFUNC_SEEK_END :
|
||||||
|
fseek_origin = SEEK_END;
|
||||||
|
break;
|
||||||
|
case ZLIB_FILEFUNC_SEEK_SET :
|
||||||
|
fseek_origin = SEEK_SET;
|
||||||
|
break;
|
||||||
|
default: return -1;
|
||||||
|
}
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
ret = fclose((FILE *)stream);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
ret = ferror((FILE *)stream);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fill_fopen_filefunc (pzlib_filefunc_def)
|
||||||
|
zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
|
{
|
||||||
|
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
||||||
|
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||||
|
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||||
|
pzlib_filefunc_def->ztell_file = ftell_file_func;
|
||||||
|
pzlib_filefunc_def->zseek_file = fseek_file_func;
|
||||||
|
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||||
|
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||||
|
pzlib_filefunc_def->opaque = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
|
||||||
|
{
|
||||||
|
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
|
||||||
|
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||||
|
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||||
|
pzlib_filefunc_def->ztell64_file = ftell64_file_func;
|
||||||
|
pzlib_filefunc_def->zseek64_file = fseek64_file_func;
|
||||||
|
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||||
|
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||||
|
pzlib_filefunc_def->opaque = NULL;
|
||||||
|
}
|
208
storage/connect/ioapi.h
Normal file
208
storage/connect/ioapi.h
Normal file
@@ -0,0 +1,208 @@
|
|||||||
|
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||||
|
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
|
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
|
Modifications for Zip64 support
|
||||||
|
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||||
|
|
||||||
|
For more info read MiniZip_info.txt
|
||||||
|
|
||||||
|
Changes
|
||||||
|
|
||||||
|
Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
|
||||||
|
Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
|
||||||
|
More if/def section may be needed to support other platforms
|
||||||
|
Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
|
||||||
|
(but you should use iowin32.c for windows instead)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ZLIBIOAPI64_H
|
||||||
|
#define _ZLIBIOAPI64_H
|
||||||
|
|
||||||
|
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
|
||||||
|
|
||||||
|
// Linux needs this to support file operation on files larger then 4+GB
|
||||||
|
// But might need better if/def to select just the platforms that needs them.
|
||||||
|
|
||||||
|
#ifndef __USE_FILE_OFFSET64
|
||||||
|
#define __USE_FILE_OFFSET64
|
||||||
|
#endif
|
||||||
|
#ifndef __USE_LARGEFILE64
|
||||||
|
#define __USE_LARGEFILE64
|
||||||
|
#endif
|
||||||
|
#ifndef _LARGEFILE64_SOURCE
|
||||||
|
#define _LARGEFILE64_SOURCE
|
||||||
|
#endif
|
||||||
|
#ifndef _FILE_OFFSET_BIT
|
||||||
|
#define _FILE_OFFSET_BIT 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "zlib.h"
|
||||||
|
|
||||||
|
#if defined(USE_FILE32API)
|
||||||
|
#define fopen64 fopen
|
||||||
|
#define ftello64 ftell
|
||||||
|
#define fseeko64 fseek
|
||||||
|
#else
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#define fopen64 fopen
|
||||||
|
#define ftello64 ftello
|
||||||
|
#define fseeko64 fseeko
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define fopen64 fopen
|
||||||
|
#if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
|
||||||
|
#define ftello64 _ftelli64
|
||||||
|
#define fseeko64 _fseeki64
|
||||||
|
#else // old MSC
|
||||||
|
#define ftello64 ftell
|
||||||
|
#define fseeko64 fseek
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
#ifndef ZPOS64_T
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define ZPOS64_T fpos_t
|
||||||
|
#else
|
||||||
|
#include <stdint.h>
|
||||||
|
#define ZPOS64_T uint64_t
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_MINIZIP64_CONF_H
|
||||||
|
#include "mz64conf.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* a type choosen by DEFINE */
|
||||||
|
#ifdef HAVE_64BIT_INT_CUSTOM
|
||||||
|
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
||||||
|
#else
|
||||||
|
#ifdef HAS_STDINT_H
|
||||||
|
#include "stdint.h"
|
||||||
|
typedef uint64_t ZPOS64_T;
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||||
|
#define MAXU32 0xffffffff
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
|
typedef unsigned __int64 ZPOS64_T;
|
||||||
|
#else
|
||||||
|
typedef unsigned long long int ZPOS64_T;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||||
|
#define ZLIB_FILEFUNC_SEEK_END (2)
|
||||||
|
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
||||||
|
|
||||||
|
#define ZLIB_FILEFUNC_MODE_READ (1)
|
||||||
|
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
||||||
|
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
||||||
|
|
||||||
|
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
||||||
|
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ZCALLBACK
|
||||||
|
#if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||||
|
#define ZCALLBACK CALLBACK
|
||||||
|
#else
|
||||||
|
#define ZCALLBACK
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
||||||
|
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||||
|
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||||
|
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||||
|
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||||
|
|
||||||
|
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
|
||||||
|
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
||||||
|
|
||||||
|
|
||||||
|
/* here is the "old" 32 bits structure structure */
|
||||||
|
typedef struct zlib_filefunc_def_s
|
||||||
|
{
|
||||||
|
open_file_func zopen_file;
|
||||||
|
read_file_func zread_file;
|
||||||
|
write_file_func zwrite_file;
|
||||||
|
tell_file_func ztell_file;
|
||||||
|
seek_file_func zseek_file;
|
||||||
|
close_file_func zclose_file;
|
||||||
|
testerror_file_func zerror_file;
|
||||||
|
voidpf opaque;
|
||||||
|
} zlib_filefunc_def;
|
||||||
|
|
||||||
|
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
|
||||||
|
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||||
|
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
|
||||||
|
|
||||||
|
typedef struct zlib_filefunc64_def_s
|
||||||
|
{
|
||||||
|
open64_file_func zopen64_file;
|
||||||
|
read_file_func zread_file;
|
||||||
|
write_file_func zwrite_file;
|
||||||
|
tell64_file_func ztell64_file;
|
||||||
|
seek64_file_func zseek64_file;
|
||||||
|
close_file_func zclose_file;
|
||||||
|
testerror_file_func zerror_file;
|
||||||
|
voidpf opaque;
|
||||||
|
} zlib_filefunc64_def;
|
||||||
|
|
||||||
|
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||||
|
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||||
|
|
||||||
|
/* now internal definition, only for zip.c and unzip.h */
|
||||||
|
typedef struct zlib_filefunc64_32_def_s
|
||||||
|
{
|
||||||
|
zlib_filefunc64_def zfile_func64;
|
||||||
|
open_file_func zopen32_file;
|
||||||
|
tell_file_func ztell32_file;
|
||||||
|
seek_file_func zseek32_file;
|
||||||
|
} zlib_filefunc64_32_def;
|
||||||
|
|
||||||
|
|
||||||
|
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||||
|
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||||
|
//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
|
||||||
|
//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
|
||||||
|
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||||
|
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||||
|
|
||||||
|
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
|
||||||
|
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
|
||||||
|
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
|
||||||
|
|
||||||
|
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
|
||||||
|
|
||||||
|
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
|
||||||
|
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
|
||||||
|
#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@@ -16,7 +16,7 @@
|
|||||||
/*************** Mycat CC Program Source Code File (.CC) ***************/
|
/*************** Mycat CC Program Source Code File (.CC) ***************/
|
||||||
/* PROGRAM NAME: MYCAT */
|
/* PROGRAM NAME: MYCAT */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 1.4 */
|
/* Version 1.5 */
|
||||||
/* */
|
/* */
|
||||||
/* Author: Olivier Bertrand 2012 - 2016 */
|
/* Author: Olivier Bertrand 2012 - 2016 */
|
||||||
/* */
|
/* */
|
||||||
@@ -95,6 +95,9 @@
|
|||||||
#if defined(XML_SUPPORT)
|
#if defined(XML_SUPPORT)
|
||||||
#include "tabxml.h"
|
#include "tabxml.h"
|
||||||
#endif // XML_SUPPORT
|
#endif // XML_SUPPORT
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
#include "tabzip.h"
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
#include "mycat.h"
|
#include "mycat.h"
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -154,6 +157,9 @@ TABTYPE GetTypeID(const char *type)
|
|||||||
#endif
|
#endif
|
||||||
: (!stricmp(type, "VIR")) ? TAB_VIR
|
: (!stricmp(type, "VIR")) ? TAB_VIR
|
||||||
: (!stricmp(type, "JSON")) ? TAB_JSON
|
: (!stricmp(type, "JSON")) ? TAB_JSON
|
||||||
|
#ifdef ZIP_SUPPORT
|
||||||
|
: (!stricmp(type, "ZIP")) ? TAB_ZIP
|
||||||
|
#endif
|
||||||
: (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY;
|
: (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY;
|
||||||
} // end of GetTypeID
|
} // end of GetTypeID
|
||||||
|
|
||||||
@@ -175,6 +181,7 @@ bool IsFileType(TABTYPE type)
|
|||||||
case TAB_INI:
|
case TAB_INI:
|
||||||
case TAB_VEC:
|
case TAB_VEC:
|
||||||
case TAB_JSON:
|
case TAB_JSON:
|
||||||
|
// case TAB_ZIP:
|
||||||
isfile= true;
|
isfile= true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -575,6 +582,9 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
|
|||||||
#endif // PIVOT_SUPPORT
|
#endif // PIVOT_SUPPORT
|
||||||
case TAB_VIR: tdp= new(g) VIRDEF; break;
|
case TAB_VIR: tdp= new(g) VIRDEF; break;
|
||||||
case TAB_JSON: tdp= new(g) JSONDEF; break;
|
case TAB_JSON: tdp= new(g) JSONDEF; break;
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
case TAB_ZIP: tdp= new(g) ZIPDEF; break;
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name);
|
sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name);
|
||||||
} // endswitch
|
} // endswitch
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
/************** PlgDBSem H Declares Source Code File (.H) **************/
|
/************** PlgDBSem H Declares Source Code File (.H) **************/
|
||||||
/* Name: PLGDBSEM.H Version 3.6 */
|
/* Name: PLGDBSEM.H Version 3.7 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
|
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the PlugDB++ application type definitions. */
|
/* This file contains the CONNECT storage engine definitions. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -49,7 +49,8 @@ enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */
|
|||||||
TYPE_FB_MAP = 23, /* Mapped file block (storage) */
|
TYPE_FB_MAP = 23, /* Mapped file block (storage) */
|
||||||
TYPE_FB_HANDLE = 24, /* File block (handle) */
|
TYPE_FB_HANDLE = 24, /* File block (handle) */
|
||||||
TYPE_FB_XML = 21, /* DOM XML file block */
|
TYPE_FB_XML = 21, /* DOM XML file block */
|
||||||
TYPE_FB_XML2 = 27}; /* libxml2 XML file block */
|
TYPE_FB_XML2 = 27, /* libxml2 XML file block */
|
||||||
|
TYPE_FB_ZIP = 28}; /* ZIP file block */
|
||||||
|
|
||||||
enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */
|
enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */
|
||||||
TAB_DOS = 1, /* Fixed column offset, variable LRECL */
|
TAB_DOS = 1, /* Fixed column offset, variable LRECL */
|
||||||
@@ -78,7 +79,8 @@ enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */
|
|||||||
TAB_JCT = 24, /* Junction tables NIY */
|
TAB_JCT = 24, /* Junction tables NIY */
|
||||||
TAB_DMY = 25, /* DMY Dummy tables NIY */
|
TAB_DMY = 25, /* DMY Dummy tables NIY */
|
||||||
TAB_JDBC = 26, /* Table accessed via JDBC */
|
TAB_JDBC = 26, /* Table accessed via JDBC */
|
||||||
TAB_NIY = 27}; /* Table not implemented yet */
|
TAB_ZIP = 27, /* ZIP file info table */
|
||||||
|
TAB_NIY = 28}; /* Table not implemented yet */
|
||||||
|
|
||||||
enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
|
enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
|
||||||
TYPE_AM_ROWID = 1, /* ROWID type (special column) */
|
TYPE_AM_ROWID = 1, /* ROWID type (special column) */
|
||||||
@@ -140,6 +142,7 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
|
|||||||
TYPE_AM_MYSQL = 192, /* MYSQL access method type no */
|
TYPE_AM_MYSQL = 192, /* MYSQL access method type no */
|
||||||
TYPE_AM_MYX = 193, /* MYSQL EXEC access method type */
|
TYPE_AM_MYX = 193, /* MYSQL EXEC access method type */
|
||||||
TYPE_AM_CAT = 195, /* Catalog access method type no */
|
TYPE_AM_CAT = 195, /* Catalog access method type no */
|
||||||
|
TYPE_AM_ZIP = 198, /* ZIP access method type no */
|
||||||
TYPE_AM_OUT = 200}; /* Output relations (storage) */
|
TYPE_AM_OUT = 200}; /* Output relations (storage) */
|
||||||
|
|
||||||
enum RECFM {RECFM_NAF = -2, /* Not a file */
|
enum RECFM {RECFM_NAF = -2, /* Not a file */
|
||||||
|
@@ -68,6 +68,9 @@
|
|||||||
#include "tabcol.h" // header of XTAB and COLUMN classes
|
#include "tabcol.h" // header of XTAB and COLUMN classes
|
||||||
#include "valblk.h"
|
#include "valblk.h"
|
||||||
#include "rcmsg.h"
|
#include "rcmsg.h"
|
||||||
|
#ifdef ZIP_SUPPORT
|
||||||
|
#include "filamzip.h"
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* DB static variables. */
|
/* DB static variables. */
|
||||||
@@ -934,6 +937,15 @@ int PlugCloseFile(PGLOBAL g __attribute__((unused)), PFBLOCK fp, bool all)
|
|||||||
CloseXML2File(g, fp, all);
|
CloseXML2File(g, fp, all);
|
||||||
break;
|
break;
|
||||||
#endif // LIBXML2_SUPPORT
|
#endif // LIBXML2_SUPPORT
|
||||||
|
#ifdef ZIP_SUPPORT
|
||||||
|
case TYPE_FB_ZIP:
|
||||||
|
((PZIPFAM)fp->File)->close();
|
||||||
|
fp->Memory = NULL;
|
||||||
|
fp->Mode = MODE_ANY;
|
||||||
|
fp->Count = 0;
|
||||||
|
fp->File = NULL;
|
||||||
|
break;
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
default:
|
default:
|
||||||
rc = RC_FX;
|
rc = RC_FX;
|
||||||
} // endswitch Type
|
} // endswitch Type
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************* TabDos C++ Program Source Code File (.CPP) **************/
|
/************* TabDos C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: TABDOS */
|
/* PROGRAM NAME: TABDOS */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 4.9.1 */
|
/* Version 4.9.2 */
|
||||||
/* */
|
/* */
|
||||||
/* COPYRIGHT: */
|
/* COPYRIGHT: */
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
@@ -54,6 +54,9 @@
|
|||||||
#if defined(GZ_SUPPORT)
|
#if defined(GZ_SUPPORT)
|
||||||
#include "filamgz.h"
|
#include "filamgz.h"
|
||||||
#endif // GZ_SUPPORT
|
#endif // GZ_SUPPORT
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
#include "filamzip.h"
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
#include "tabdos.h"
|
#include "tabdos.h"
|
||||||
#include "tabfix.h"
|
#include "tabfix.h"
|
||||||
#include "tabmul.h"
|
#include "tabmul.h"
|
||||||
@@ -93,6 +96,7 @@ DOSDEF::DOSDEF(void)
|
|||||||
Pseudo = 3;
|
Pseudo = 3;
|
||||||
Fn = NULL;
|
Fn = NULL;
|
||||||
Ofn = NULL;
|
Ofn = NULL;
|
||||||
|
Zipfn = NULL;
|
||||||
To_Indx = NULL;
|
To_Indx = NULL;
|
||||||
Recfm = RECFM_VAR;
|
Recfm = RECFM_VAR;
|
||||||
Mapped = false;
|
Mapped = false;
|
||||||
@@ -126,7 +130,20 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
|
|||||||
: (am && (*am == 'B' || *am == 'b')) ? "B"
|
: (am && (*am == 'B' || *am == 'b')) ? "B"
|
||||||
: (am && !stricmp(am, "DBF")) ? "D" : "V";
|
: (am && !stricmp(am, "DBF")) ? "D" : "V";
|
||||||
|
|
||||||
|
if (*dfm != 'D')
|
||||||
|
Zipfn = GetStringCatInfo(g, "Zipfile", NULL);
|
||||||
|
|
||||||
|
if (Zipfn && Multiple) {
|
||||||
|
// Prevent Fn to default to table name
|
||||||
|
Desc = GetStringCatInfo(g, "Filename", NULL);
|
||||||
|
Fn = GetStringCatInfo(g, "Filename", "<%>");
|
||||||
|
|
||||||
|
if (!strcmp(Fn, "<%>"))
|
||||||
|
Fn = NULL;
|
||||||
|
|
||||||
|
} else
|
||||||
Desc = Fn = GetStringCatInfo(g, "Filename", NULL);
|
Desc = Fn = GetStringCatInfo(g, "Filename", NULL);
|
||||||
|
|
||||||
Ofn = GetStringCatInfo(g, "Optname", Fn);
|
Ofn = GetStringCatInfo(g, "Optname", Fn);
|
||||||
GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf));
|
GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf));
|
||||||
Recfm = (toupper(*buf) == 'F') ? RECFM_FIX :
|
Recfm = (toupper(*buf) == 'F') ? RECFM_FIX :
|
||||||
@@ -333,7 +350,20 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
|
|||||||
/* Allocate table and file processing class of the proper type. */
|
/* Allocate table and file processing class of the proper type. */
|
||||||
/* Column blocks will be allocated only when needed. */
|
/* Column blocks will be allocated only when needed. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
if (Recfm == RECFM_DBF) {
|
if (Zipfn) {
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
if (Recfm == RECFM_VAR)
|
||||||
|
txfp = new(g) ZIPFAM(this);
|
||||||
|
else
|
||||||
|
txfp = new(g) ZPXFAM(this);
|
||||||
|
|
||||||
|
tdbp = new(g) TDBDOS(this, txfp);
|
||||||
|
return tdbp;
|
||||||
|
#else // !ZIP_SUPPORT
|
||||||
|
strcpy(g->Message, "ZIP not supported");
|
||||||
|
return NULL;
|
||||||
|
#endif // !ZIP_SUPPORT
|
||||||
|
} else if (Recfm == RECFM_DBF) {
|
||||||
if (Catfunc == FNC_NO) {
|
if (Catfunc == FNC_NO) {
|
||||||
if (map)
|
if (map)
|
||||||
txfp = new(g) DBMFAM(this);
|
txfp = new(g) DBMFAM(this);
|
||||||
|
@@ -28,6 +28,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
|
|||||||
friend class TDBFIX;
|
friend class TDBFIX;
|
||||||
friend class TXTFAM;
|
friend class TXTFAM;
|
||||||
friend class DBFBASE;
|
friend class DBFBASE;
|
||||||
|
friend class ZIPFAM;
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
DOSDEF(void);
|
DOSDEF(void);
|
||||||
@@ -58,7 +59,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
|
|||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual int Indexable(void)
|
virtual int Indexable(void)
|
||||||
{return (!Multiple && Compressed != 1) ? 1 : 0;}
|
{return (!Multiple && !Zipfn && Compressed != 1) ? 1 : 0;}
|
||||||
virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf);
|
virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf);
|
||||||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
|
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
|
||||||
virtual PTDB GetTable(PGLOBAL g, MODE mode);
|
virtual PTDB GetTable(PGLOBAL g, MODE mode);
|
||||||
@@ -72,6 +73,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
|
|||||||
// Members
|
// Members
|
||||||
PSZ Fn; /* Path/Name of corresponding file */
|
PSZ Fn; /* Path/Name of corresponding file */
|
||||||
PSZ Ofn; /* Base Path/Name of matching index files*/
|
PSZ Ofn; /* Base Path/Name of matching index files*/
|
||||||
|
PSZ Zipfn; /* Zip container name */
|
||||||
PIXDEF To_Indx; /* To index definitions blocks */
|
PIXDEF To_Indx; /* To index definitions blocks */
|
||||||
RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */
|
RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */
|
||||||
bool Mapped; /* 0: disk file, 1: memory mapped file */
|
bool Mapped; /* 0: disk file, 1: memory mapped file */
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************* TabFmt C++ Program Source Code File (.CPP) **************/
|
/************* TabFmt C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: TABFMT */
|
/* PROGRAM NAME: TABFMT */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 3.9.1 */
|
/* Version 3.9.2 */
|
||||||
/* */
|
/* */
|
||||||
/* COPYRIGHT: */
|
/* COPYRIGHT: */
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
@@ -54,6 +54,9 @@
|
|||||||
#if defined(GZ_SUPPORT)
|
#if defined(GZ_SUPPORT)
|
||||||
#include "filamgz.h"
|
#include "filamgz.h"
|
||||||
#endif // GZ_SUPPORT
|
#endif // GZ_SUPPORT
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
#include "filamzip.h"
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
#include "tabfmt.h"
|
#include "tabfmt.h"
|
||||||
#include "tabmul.h"
|
#include "tabmul.h"
|
||||||
#define NO_FUNC
|
#define NO_FUNC
|
||||||
@@ -78,20 +81,24 @@ USETEMP UseTemp(void);
|
|||||||
/* of types (TYPE_STRING < TYPE_DOUBLE < TYPE_INT) (1 < 2 < 7). */
|
/* of types (TYPE_STRING < TYPE_DOUBLE < TYPE_INT) (1 < 2 < 7). */
|
||||||
/* If these values are changed, this will have to be revisited. */
|
/* If these values are changed, this will have to be revisited. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
|
||||||
char q, int hdr, int mxr, bool info)
|
|
||||||
{
|
{
|
||||||
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
|
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
|
||||||
TYPE_INT, TYPE_INT, TYPE_SHORT};
|
TYPE_INT, TYPE_INT, TYPE_SHORT};
|
||||||
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME,
|
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME,
|
||||||
FLD_PREC, FLD_LENGTH, FLD_SCALE};
|
FLD_PREC, FLD_LENGTH, FLD_SCALE};
|
||||||
static unsigned int length[] = {6, 6, 8, 10, 10, 6};
|
static unsigned int length[] = {6, 6, 8, 10, 10, 6};
|
||||||
char *p, *colname[MAXCOL], dechar, filename[_MAX_PATH], buf[4096];
|
const char *fn;
|
||||||
|
char sep, q;
|
||||||
|
int rc, mxr;
|
||||||
|
bool hdr;
|
||||||
|
char *p, *colname[MAXCOL], dechar, buf[8];
|
||||||
int i, imax, hmax, n, nerr, phase, blank, digit, dec, type;
|
int i, imax, hmax, n, nerr, phase, blank, digit, dec, type;
|
||||||
int ncol = sizeof(buftyp) / sizeof(int);
|
int ncol = sizeof(buftyp) / sizeof(int);
|
||||||
int num_read = 0, num_max = 10000000; // Statistics
|
int num_read = 0, num_max = 10000000; // Statistics
|
||||||
int len[MAXCOL], typ[MAXCOL], prc[MAXCOL];
|
int len[MAXCOL], typ[MAXCOL], prc[MAXCOL];
|
||||||
FILE *infile;
|
PCSVDEF tdp;
|
||||||
|
PTDBCSV tdbp;
|
||||||
PQRYRES qrp;
|
PQRYRES qrp;
|
||||||
PCOLRES crp;
|
PCOLRES crp;
|
||||||
|
|
||||||
@@ -102,26 +109,7 @@ 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(__WIN__)
|
|
||||||
if (sep == ',' || strnicmp(setlocale(LC_NUMERIC, NULL), "French", 6))
|
|
||||||
dechar = '.';
|
|
||||||
else
|
|
||||||
dechar = ',';
|
|
||||||
#else // !__WIN__
|
|
||||||
dechar = '.';
|
|
||||||
#endif // !__WIN__
|
|
||||||
|
|
||||||
if (trace)
|
|
||||||
htrc("File %s sep=%c q=%c hdr=%d mxr=%d\n",
|
|
||||||
SVP(fn), sep, q, hdr, mxr);
|
|
||||||
|
|
||||||
if (!fn) {
|
|
||||||
strcpy(g->Message, MSG(MISSING_FNAME));
|
|
||||||
return NULL;
|
|
||||||
} // endif fn
|
|
||||||
|
|
||||||
imax = hmax = nerr = 0;
|
imax = hmax = nerr = 0;
|
||||||
mxr = MY_MAX(0, mxr);
|
|
||||||
|
|
||||||
for (i = 0; i < MAXCOL; i++) {
|
for (i = 0; i < MAXCOL; i++) {
|
||||||
colname[i] = NULL;
|
colname[i] = NULL;
|
||||||
@@ -131,11 +119,72 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
|||||||
} // endfor i
|
} // endfor i
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Open the input file. */
|
/* Get the CSV table description block. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
PlugSetPath(filename, fn, dp);
|
tdp = new(g) CSVDEF;
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
tdp->Zipfn = GetStringTableOption(g, topt, "Zipfile", NULL);
|
||||||
|
tdp->Multiple = GetIntegerTableOption(g, topt, "Multiple", 0);
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
|
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
|
||||||
|
|
||||||
if (!(infile= global_fopen(g, MSGID_CANNOT_OPEN, filename, "r")))
|
if (!tdp->Fn && !tdp->Zipfn && !tdp->Multiple) {
|
||||||
|
strcpy(g->Message, MSG(MISSING_FNAME));
|
||||||
|
return NULL;
|
||||||
|
} // endif Fn
|
||||||
|
|
||||||
|
fn = (tdp->Fn) ? tdp->Fn : "unnamed";
|
||||||
|
|
||||||
|
if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))
|
||||||
|
tdp->Lrecl = 4096;
|
||||||
|
|
||||||
|
p = GetStringTableOption(g, topt, "Separator", ",");
|
||||||
|
tdp->Sep = (strlen(p) == 2 && p[0] == '\\' && p[1] == 't') ? '\t' : *p;
|
||||||
|
|
||||||
|
#if defined(__WIN__)
|
||||||
|
if (tdp->Sep == ',' || strnicmp(setlocale(LC_NUMERIC, NULL), "French", 6))
|
||||||
|
dechar = '.';
|
||||||
|
else
|
||||||
|
dechar = ',';
|
||||||
|
#else // !__WIN__
|
||||||
|
dechar = '.';
|
||||||
|
#endif // !__WIN__
|
||||||
|
|
||||||
|
sep = tdp->Sep;
|
||||||
|
tdp->Quoted = GetIntegerTableOption(g, topt, "Quoted", -1);
|
||||||
|
p = GetStringTableOption(g, topt, "Qchar", "");
|
||||||
|
tdp->Qot = *p;
|
||||||
|
|
||||||
|
if (tdp->Qot && tdp->Quoted < 0)
|
||||||
|
tdp->Quoted = 0;
|
||||||
|
else if (!tdp->Qot && tdp->Quoted >= 0)
|
||||||
|
tdp->Qot = '"';
|
||||||
|
|
||||||
|
q = tdp->Qot;
|
||||||
|
hdr = GetBooleanTableOption(g, topt, "Header", false);
|
||||||
|
tdp->Maxerr = GetIntegerTableOption(g, topt, "Maxerr", 0);
|
||||||
|
tdp->Accept = GetBooleanTableOption(g, topt, "Accept", false);
|
||||||
|
|
||||||
|
if (tdp->Accept && tdp->Maxerr == 0)
|
||||||
|
tdp->Maxerr = INT_MAX32; // Accept all bad lines
|
||||||
|
|
||||||
|
mxr = MY_MAX(0, tdp->Maxerr);
|
||||||
|
|
||||||
|
if (trace)
|
||||||
|
htrc("File %s Sep=%c Qot=%c Header=%d maxerr=%d\n",
|
||||||
|
SVP(tdp->Fn), tdp->Sep, tdp->Qot, tdp->Header, tdp->Maxerr);
|
||||||
|
|
||||||
|
if (tdp->Zipfn)
|
||||||
|
tdbp = new(g) TDBCSV(tdp, new(g) ZIPFAM(tdp));
|
||||||
|
else
|
||||||
|
tdbp = new(g) TDBCSV(tdp, new(g) DOSFAM(tdp));
|
||||||
|
|
||||||
|
tdbp->SetMode(MODE_READ);
|
||||||
|
|
||||||
|
/*********************************************************************/
|
||||||
|
/* Open the CSV file. */
|
||||||
|
/*********************************************************************/
|
||||||
|
if (tdbp->OpenDB(g))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (hdr) {
|
if (hdr) {
|
||||||
@@ -144,16 +193,8 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
|||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
phase = 0;
|
phase = 0;
|
||||||
|
|
||||||
if (fgets(buf, sizeof(buf), infile)) {
|
if ((rc = tdbp->ReadDB(g)) == RC_OK) {
|
||||||
n = strlen(buf) + 1;
|
p = PlgDBDup(g, tdbp->To_Line);
|
||||||
buf[n - 2] = '\0';
|
|
||||||
#if !defined(__WIN__)
|
|
||||||
// The file can be imported from Windows
|
|
||||||
if (buf[n - 3] == '\r')
|
|
||||||
buf[n - 3] = 0;
|
|
||||||
#endif // UNIX
|
|
||||||
p = (char*)PlugSubAlloc(g, NULL, n);
|
|
||||||
memcpy(p, buf, n);
|
|
||||||
|
|
||||||
//skip leading blanks
|
//skip leading blanks
|
||||||
for (; *p == ' '; p++) ;
|
for (; *p == ' '; p++) ;
|
||||||
@@ -165,10 +206,11 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
|||||||
} // endif q
|
} // endif q
|
||||||
|
|
||||||
colname[0] = p;
|
colname[0] = p;
|
||||||
} else {
|
} else if (rc == RC_EF) {
|
||||||
sprintf(g->Message, MSG(FILE_IS_EMPTY), fn);
|
sprintf(g->Message, MSG(FILE_IS_EMPTY), fn);
|
||||||
goto err;
|
goto err;
|
||||||
} // endif's
|
} else
|
||||||
|
goto err;
|
||||||
|
|
||||||
for (i = 1; *p; p++)
|
for (i = 1; *p; p++)
|
||||||
if (phase == 1 && *p == q) {
|
if (phase == 1 && *p == q) {
|
||||||
@@ -201,15 +243,8 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
|||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/* Now start the reading process. Read one line. */
|
/* Now start the reading process. Read one line. */
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
if (fgets(buf, sizeof(buf), infile)) {
|
if ((rc = tdbp->ReadDB(g)) == RC_OK) {
|
||||||
n = strlen(buf);
|
} else if (rc == RC_EF) {
|
||||||
buf[n - 1] = '\0';
|
|
||||||
#if !defined(__WIN__)
|
|
||||||
// The file can be imported from Windows
|
|
||||||
if (buf[n - 2] == '\r')
|
|
||||||
buf[n - 2] = 0;
|
|
||||||
#endif // UNIX
|
|
||||||
} else if (feof(infile)) {
|
|
||||||
sprintf(g->Message, MSG(EOF_AFTER_LINE), num_read -1);
|
sprintf(g->Message, MSG(EOF_AFTER_LINE), num_read -1);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@@ -222,7 +257,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
|||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
i = n = phase = blank = digit = dec = 0;
|
i = n = phase = blank = digit = dec = 0;
|
||||||
|
|
||||||
for (p = buf; *p; p++)
|
for (p = tdbp->To_Line; *p; p++)
|
||||||
if (*p == sep) {
|
if (*p == sep) {
|
||||||
if (phase != 1) {
|
if (phase != 1) {
|
||||||
if (i == MAXCOL - 1) {
|
if (i == MAXCOL - 1) {
|
||||||
@@ -331,7 +366,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
|||||||
htrc("\n");
|
htrc("\n");
|
||||||
} // endif trace
|
} // endif trace
|
||||||
|
|
||||||
fclose(infile);
|
tdbp->CloseDB(g);
|
||||||
|
|
||||||
skipit:
|
skipit:
|
||||||
if (trace)
|
if (trace)
|
||||||
@@ -381,7 +416,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
|||||||
return qrp;
|
return qrp;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
fclose(infile);
|
tdbp->CloseDB(g);
|
||||||
return NULL;
|
return NULL;
|
||||||
} // end of CSVCColumns
|
} // end of CSVCColumns
|
||||||
|
|
||||||
@@ -458,7 +493,21 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
|
|||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/* Allocate a file processing class of the proper type. */
|
/* Allocate a file processing class of the proper type. */
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
if (map) {
|
if (Zipfn) {
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
txfp = new(g) ZIPFAM(this);
|
||||||
|
|
||||||
|
if (!Fmtd)
|
||||||
|
tdbp = new(g) TDBCSV(this, txfp);
|
||||||
|
else
|
||||||
|
tdbp = new(g) TDBFMT(this, txfp);
|
||||||
|
|
||||||
|
return tdbp;
|
||||||
|
#else // !ZIP_SUPPORT
|
||||||
|
strcpy(g->Message, "ZIP not supported");
|
||||||
|
return NULL;
|
||||||
|
#endif // !ZIP_SUPPORT
|
||||||
|
} else if (map) {
|
||||||
// Should be now compatible with UNIX
|
// Should be now compatible with UNIX
|
||||||
txfp = new(g) MAPFAM(this);
|
txfp = new(g) MAPFAM(this);
|
||||||
} else if (Compressed) {
|
} else if (Compressed) {
|
||||||
@@ -1476,21 +1525,16 @@ void CSVCOL::WriteColumn(PGLOBAL g)
|
|||||||
/* TDBCCL class constructor. */
|
/* TDBCCL class constructor. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
TDBCCL::TDBCCL(PCSVDEF tdp) : TDBCAT(tdp)
|
TDBCCL::TDBCCL(PCSVDEF tdp) : TDBCAT(tdp)
|
||||||
{
|
{
|
||||||
Fn = tdp->GetFn();
|
Topt = tdp->GetTopt();
|
||||||
Hdr = tdp->Header;
|
} // end of TDBCCL constructor
|
||||||
Mxr = tdp->Maxerr;
|
|
||||||
Qtd = tdp->Quoted;
|
|
||||||
Sep = tdp->Sep;
|
|
||||||
} // end of TDBCCL constructor
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* GetResult: Get the list the CSV file columns. */
|
/* GetResult: Get the list the CSV file columns. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PQRYRES TDBCCL::GetResult(PGLOBAL g)
|
PQRYRES TDBCCL::GetResult(PGLOBAL g)
|
||||||
{
|
{
|
||||||
return CSVColumns(g, ((PTABDEF)To_Def)->GetPath(),
|
return CSVColumns(g, ((PTABDEF)To_Def)->GetPath(), Topt, false);
|
||||||
Fn, Sep, Qtd, Hdr, Mxr, false);
|
|
||||||
} // end of GetResult
|
} // end of GetResult
|
||||||
|
|
||||||
/* ------------------------ End of TabFmt ---------------------------- */
|
/* ------------------------ End of TabFmt ---------------------------- */
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*************** TabFmt H Declares Source Code File (.H) ***************/
|
/*************** TabFmt H Declares Source Code File (.H) ***************/
|
||||||
/* Name: TABFMT.H Version 2.4 */
|
/* Name: TABFMT.H Version 2.5 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2001-2014 */
|
/* (C) Copyright to the author Olivier BERTRAND 2001-2016 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the CSV and FMT classes declares. */
|
/* This file contains the CSV and FMT classes declares. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -13,8 +13,7 @@ typedef class TDBFMT *PTDBFMT;
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Functions used externally. */
|
/* Functions used externally. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info);
|
||||||
char q, int hdr, int mxr, bool info);
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* CSV table. */
|
/* CSV table. */
|
||||||
@@ -22,7 +21,8 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, const char *fn, char sep,
|
|||||||
class DllExport CSVDEF : public DOSDEF { /* Logical table description */
|
class DllExport CSVDEF : public DOSDEF { /* Logical table description */
|
||||||
friend class TDBCSV;
|
friend class TDBCSV;
|
||||||
friend class TDBCCL;
|
friend class TDBCCL;
|
||||||
public:
|
friend PQRYRES CSVColumns(PGLOBAL, char *, PTOS, bool);
|
||||||
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
CSVDEF(void);
|
CSVDEF(void);
|
||||||
|
|
||||||
@@ -50,9 +50,10 @@ class DllExport CSVDEF : public DOSDEF { /* Logical table description */
|
|||||||
/* This is the DOS/UNIX Access Method class declaration for files */
|
/* This is the DOS/UNIX Access Method class declaration for files */
|
||||||
/* that are CSV files with columns separated by the Sep character. */
|
/* that are CSV files with columns separated by the Sep character. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class TDBCSV : public TDBDOS {
|
class DllExport TDBCSV : public TDBDOS {
|
||||||
friend class CSVCOL;
|
friend class CSVCOL;
|
||||||
public:
|
friend PQRYRES CSVColumns(PGLOBAL, char *, PTOS, bool);
|
||||||
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
TDBCSV(PCSVDEF tdp, PTXF txfp);
|
TDBCSV(PCSVDEF tdp, PTXF txfp);
|
||||||
TDBCSV(PGLOBAL g, PTDBCSV tdbp);
|
TDBCSV(PGLOBAL g, PTDBCSV tdbp);
|
||||||
@@ -101,7 +102,7 @@ class TDBCSV : public TDBDOS {
|
|||||||
/* Class CSVCOL: CSV access method column descriptor. */
|
/* Class CSVCOL: CSV access method column descriptor. */
|
||||||
/* This A.M. is used for Comma Separated V(?) files. */
|
/* This A.M. is used for Comma Separated V(?) files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class CSVCOL : public DOSCOL {
|
class DllExport CSVCOL : public DOSCOL {
|
||||||
friend class TDBCSV;
|
friend class TDBCSV;
|
||||||
friend class TDBFMT;
|
friend class TDBFMT;
|
||||||
public:
|
public:
|
||||||
@@ -129,7 +130,7 @@ class CSVCOL : public DOSCOL {
|
|||||||
/* This is the DOS/UNIX Access Method class declaration for files */
|
/* This is the DOS/UNIX Access Method class declaration for files */
|
||||||
/* whose record format is described by a Format keyword. */
|
/* whose record format is described by a Format keyword. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class TDBFMT : public TDBCSV {
|
class DllExport TDBFMT : public TDBCSV {
|
||||||
friend class CSVCOL;
|
friend class CSVCOL;
|
||||||
//friend class FMTCOL;
|
//friend class FMTCOL;
|
||||||
public:
|
public:
|
||||||
@@ -173,7 +174,7 @@ class TDBFMT : public TDBCSV {
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* This is the class declaration for the CSV catalog table. */
|
/* This is the class declaration for the CSV catalog table. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class TDBCCL : public TDBCAT {
|
class DllExport TDBCCL : public TDBCAT {
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
TDBCCL(PCSVDEF tdp);
|
TDBCCL(PCSVDEF tdp);
|
||||||
@@ -183,11 +184,7 @@ class TDBCCL : public TDBCAT {
|
|||||||
virtual PQRYRES GetResult(PGLOBAL g);
|
virtual PQRYRES GetResult(PGLOBAL g);
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
char *Fn; // The CSV file (path) name
|
PTOS Topt;
|
||||||
bool Hdr; // true if first line contains headers
|
}; // end of class TDBCCL
|
||||||
int Mxr; // Maximum number of bad records
|
|
||||||
int Qtd; // Quoting level for quoted fields
|
|
||||||
char Sep; // Separator for standard CSV files
|
|
||||||
}; // end of class TDBCCL
|
|
||||||
|
|
||||||
/* ------------------------- End of TabFmt.H ------------------------- */
|
/* ------------------------- End of TabFmt.H ------------------------- */
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/************* tabjson C++ Program Source Code File (.CPP) *************/
|
/************* tabjson C++ Program Source Code File (.CPP) *************/
|
||||||
/* PROGRAM NAME: tabjson Version 1.2 */
|
/* PROGRAM NAME: tabjson Version 1.3 */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2016 */
|
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2016 */
|
||||||
/* This program are the JSON class DB execution routines. */
|
/* This program are the JSON class DB execution routines. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -28,6 +28,9 @@
|
|||||||
#if defined(GZ_SUPPORT)
|
#if defined(GZ_SUPPORT)
|
||||||
#include "filamgz.h"
|
#include "filamgz.h"
|
||||||
#endif // GZ_SUPPORT
|
#endif // GZ_SUPPORT
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
#include "filamzip.h"
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
#include "tabmul.h"
|
#include "tabmul.h"
|
||||||
#include "checklvl.h"
|
#include "checklvl.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
@@ -67,7 +70,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
|||||||
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
|
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
|
||||||
FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT};
|
FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT};
|
||||||
static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0};
|
static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0};
|
||||||
char *fn, colname[65], fmt[129];
|
char colname[65], fmt[129];
|
||||||
int i, j, lvl, n = 0;
|
int i, j, lvl, n = 0;
|
||||||
int ncol = sizeof(buftyp) / sizeof(int);
|
int ncol = sizeof(buftyp) / sizeof(int);
|
||||||
PVAL valp;
|
PVAL valp;
|
||||||
@@ -94,16 +97,21 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Open the input file. */
|
/* Open the input file. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) {
|
|
||||||
strcpy(g->Message, MSG(MISSING_FNAME));
|
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
lvl = GetIntegerTableOption(g, topt, "Level", 0);
|
lvl = GetIntegerTableOption(g, topt, "Level", 0);
|
||||||
lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl;
|
lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl;
|
||||||
} // endif fn
|
|
||||||
|
|
||||||
tdp = new(g) JSONDEF;
|
tdp = new(g) JSONDEF;
|
||||||
tdp->Fn = fn;
|
#if defined(ZIP_SUPPORT)
|
||||||
|
tdp->Zipfn = GetStringTableOption(g, topt, "Zipfile", NULL);
|
||||||
|
tdp->Multiple = GetIntegerTableOption(g, topt, "Multiple", 0);
|
||||||
|
#endif // ZIP_SUPPORT
|
||||||
|
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
|
||||||
|
|
||||||
|
if (!tdp->Fn && !tdp->Zipfn && !tdp->Multiple) {
|
||||||
|
strcpy(g->Message, MSG(MISSING_FNAME));
|
||||||
|
return NULL;
|
||||||
|
} // endif Fn
|
||||||
|
|
||||||
tdp->Database = SetPath(g, db);
|
tdp->Database = SetPath(g, db);
|
||||||
tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
|
tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
|
||||||
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
|
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
|
||||||
@@ -114,6 +122,9 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
|||||||
tdp->Fn, tdp->Objname, tdp->Pretty, lvl);
|
tdp->Fn, tdp->Objname, tdp->Pretty, lvl);
|
||||||
|
|
||||||
if (tdp->Pretty == 2) {
|
if (tdp->Pretty == 2) {
|
||||||
|
if (tdp->Zipfn)
|
||||||
|
tjsp = new(g) TDBJSON(tdp, new(g) ZIPFAM(tdp));
|
||||||
|
else
|
||||||
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))
|
||||||
@@ -127,9 +138,27 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
|||||||
} // endif lrecl
|
} // endif lrecl
|
||||||
|
|
||||||
tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF);
|
tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF);
|
||||||
|
|
||||||
|
if (tdp->Zipfn)
|
||||||
|
tjnp = new(g) TDBJSN(tdp, new(g) ZIPFAM(tdp));
|
||||||
|
else
|
||||||
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);
|
||||||
|
|
||||||
|
#if USE_G
|
||||||
|
// Allocate the parse work memory
|
||||||
|
PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL));
|
||||||
|
memset(G, 0, sizeof(GLOBAL));
|
||||||
|
G->Sarea_Size = tdp->Lrecl * 10;
|
||||||
|
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||||
|
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||||
|
G->jump_level = -1;
|
||||||
|
tjnp->SetG(G);
|
||||||
|
#else
|
||||||
|
tjnp->SetG(g);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (tjnp->OpenDB(g))
|
if (tjnp->OpenDB(g))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -395,7 +424,14 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
|||||||
!(tmp == TMP_FORCE &&
|
!(tmp == TMP_FORCE &&
|
||||||
(m == MODE_UPDATE || m == MODE_DELETE));
|
(m == MODE_UPDATE || m == MODE_DELETE));
|
||||||
|
|
||||||
if (Compressed) {
|
if (Zipfn) {
|
||||||
|
#if defined(ZIP_SUPPORT)
|
||||||
|
txfp = new(g) ZIPFAM(this);
|
||||||
|
#else // !ZIP_SUPPORT
|
||||||
|
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP");
|
||||||
|
return NULL;
|
||||||
|
#endif // !ZIP_SUPPORT
|
||||||
|
} else if (Compressed) {
|
||||||
#if defined(GZ_SUPPORT)
|
#if defined(GZ_SUPPORT)
|
||||||
if (Compressed == 1)
|
if (Compressed == 1)
|
||||||
txfp = new(g) GZFAM(this);
|
txfp = new(g) GZFAM(this);
|
||||||
@@ -426,12 +462,16 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
|||||||
((TDBJSN*)tdbp)->G = g;
|
((TDBJSN*)tdbp)->G = g;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
if (Zipfn)
|
||||||
|
txfp = new(g) ZIPFAM(this);
|
||||||
|
else
|
||||||
txfp = new(g) MAPFAM(this);
|
txfp = new(g) MAPFAM(this);
|
||||||
|
|
||||||
tdbp = new(g) TDBJSON(this, txfp);
|
tdbp = new(g) TDBJSON(this, txfp);
|
||||||
((TDBJSON*)tdbp)->G = g;
|
((TDBJSON*)tdbp)->G = g;
|
||||||
} // endif Pretty
|
} // endif Pretty
|
||||||
|
|
||||||
if (Multiple)
|
if (Multiple && !Zipfn)
|
||||||
tdbp = new(g) TDBMUL(tdbp);
|
tdbp = new(g) TDBMUL(tdbp);
|
||||||
|
|
||||||
return tdbp;
|
return tdbp;
|
||||||
|
@@ -79,6 +79,7 @@ public:
|
|||||||
virtual bool SkipHeader(PGLOBAL g);
|
virtual bool SkipHeader(PGLOBAL g);
|
||||||
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);}
|
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);}
|
||||||
PJSON GetRow(void) {return Row;}
|
PJSON GetRow(void) {return Row;}
|
||||||
|
void SetG(PGLOBAL g) {G = g;}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual PTDB CopyOne(PTABS t);
|
virtual PTDB CopyOne(PTABS t);
|
||||||
|
230
storage/connect/tabzip.cpp
Normal file
230
storage/connect/tabzip.cpp
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
/************* TabZip C++ Program Source Code File (.CPP) **************/
|
||||||
|
/* PROGRAM NAME: TABZIP Version 1.0 */
|
||||||
|
/* (C) Copyright to the author Olivier BERTRAND 2016 */
|
||||||
|
/* This program are the TABZIP class DB execution routines. */
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Include relevant sections of the MariaDB header file. */
|
||||||
|
/***********************************************************************/
|
||||||
|
#include <my_global.h>
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Include application header files: */
|
||||||
|
/* global.h is header containing all global declarations. */
|
||||||
|
/* plgdbsem.h is header containing the DB application declarations. */
|
||||||
|
/* (x)table.h is header containing the TDBASE declarations. */
|
||||||
|
/* tabzip.h is header containing the TABZIP classes declarations. */
|
||||||
|
/***********************************************************************/
|
||||||
|
#include "global.h"
|
||||||
|
#include "plgdbsem.h"
|
||||||
|
#include "xtable.h"
|
||||||
|
#include "filamtxt.h"
|
||||||
|
#include "filamzip.h"
|
||||||
|
#include "resource.h" // for IDS_COLUMNS
|
||||||
|
#include "tabdos.h"
|
||||||
|
#include "tabzip.h"
|
||||||
|
|
||||||
|
/* -------------------------- Class ZIPDEF --------------------------- */
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
/* DefineAM: define specific AM block values. */
|
||||||
|
/************************************************************************/
|
||||||
|
bool ZIPDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
||||||
|
{
|
||||||
|
//target = GetStringCatInfo(g, "Target", NULL);
|
||||||
|
return DOSDEF::DefineAM(g, "ZIP", poff);
|
||||||
|
} // end of DefineAM
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* GetTable: makes a new Table Description Block. */
|
||||||
|
/***********************************************************************/
|
||||||
|
PTDB ZIPDEF::GetTable(PGLOBAL g, MODE m)
|
||||||
|
{
|
||||||
|
return new(g) TDBZIP(this);
|
||||||
|
} // end of GetTable
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Implementation of the TDBZIP class. */
|
||||||
|
/***********************************************************************/
|
||||||
|
TDBZIP::TDBZIP(PZIPDEF tdp) : TDBASE(tdp)
|
||||||
|
{
|
||||||
|
zipfile = NULL;
|
||||||
|
zfn = tdp->Fn;
|
||||||
|
//target = tdp->target;
|
||||||
|
nexterr = UNZ_OK;
|
||||||
|
} // end of TDBZIP standard constructor
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Allocate ZIP column description block. */
|
||||||
|
/***********************************************************************/
|
||||||
|
PCOL TDBZIP::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
|
||||||
|
{
|
||||||
|
return new(g) ZIPCOL(cdp, this, cprec, n);
|
||||||
|
} // end of MakeCol
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* open a zip file. */
|
||||||
|
/* param: filename path and the filename of the zip file to open. */
|
||||||
|
/* return: true if open, false otherwise. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool TDBZIP::open(PGLOBAL g, const char *filename)
|
||||||
|
{
|
||||||
|
if (!zipfile && !(zipfile = unzOpen64(filename)))
|
||||||
|
sprintf(g->Message, "Zipfile open error");
|
||||||
|
|
||||||
|
return (zipfile == NULL);
|
||||||
|
} // end of open
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Close the zip file. */
|
||||||
|
/***********************************************************************/
|
||||||
|
void TDBZIP::close()
|
||||||
|
{
|
||||||
|
if (zipfile) {
|
||||||
|
unzClose(zipfile);
|
||||||
|
zipfile = NULL;
|
||||||
|
} // endif zipfile
|
||||||
|
|
||||||
|
} // end of close
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ZIP Cardinality: returns table size in number of rows. */
|
||||||
|
/***********************************************************************/
|
||||||
|
int TDBZIP::Cardinality(PGLOBAL g)
|
||||||
|
{
|
||||||
|
if (!g)
|
||||||
|
return 1;
|
||||||
|
else if (Cardinal < 0) {
|
||||||
|
if (!open(g, zfn)) {
|
||||||
|
unz_global_info64 ginfo;
|
||||||
|
int err = unzGetGlobalInfo64(zipfile, &ginfo);
|
||||||
|
|
||||||
|
Cardinal = (err == UNZ_OK) ? ginfo.number_entry : 0;
|
||||||
|
} else
|
||||||
|
Cardinal = 0;
|
||||||
|
|
||||||
|
} // endif Cardinal
|
||||||
|
|
||||||
|
return Cardinal;
|
||||||
|
} // end of Cardinality
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ZIP GetMaxSize: returns file size estimate in number of lines. */
|
||||||
|
/***********************************************************************/
|
||||||
|
int TDBZIP::GetMaxSize(PGLOBAL g)
|
||||||
|
{
|
||||||
|
if (MaxSize < 0)
|
||||||
|
MaxSize = Cardinality(g);
|
||||||
|
|
||||||
|
return MaxSize;
|
||||||
|
} // end of GetMaxSize
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ZIP Access Method opening routine. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool TDBZIP::OpenDB(PGLOBAL g)
|
||||||
|
{
|
||||||
|
if (Use == USE_OPEN)
|
||||||
|
// Table already open
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Use = USE_OPEN; // To be clean
|
||||||
|
return open(g, zfn);
|
||||||
|
} // end of OpenDB
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ReadDB: Data Base read routine for ZIP access method. */
|
||||||
|
/***********************************************************************/
|
||||||
|
int TDBZIP::ReadDB(PGLOBAL g)
|
||||||
|
{
|
||||||
|
if (nexterr == UNZ_END_OF_LIST_OF_FILE)
|
||||||
|
return RC_EF;
|
||||||
|
else if (nexterr != UNZ_OK) {
|
||||||
|
sprintf(g->Message, "unzGoToNextFile error %d", nexterr);
|
||||||
|
return RC_FX;
|
||||||
|
} // endif nexterr
|
||||||
|
|
||||||
|
int err = unzGetCurrentFileInfo64(zipfile, &finfo, fn,
|
||||||
|
sizeof(fn), NULL, 0, NULL, 0);
|
||||||
|
|
||||||
|
if (err != UNZ_OK) {
|
||||||
|
sprintf(g->Message, "unzGetCurrentFileInfo64 error %d", err);
|
||||||
|
return RC_FX;
|
||||||
|
} // endif err
|
||||||
|
|
||||||
|
nexterr = unzGoToNextFile(zipfile);
|
||||||
|
return RC_OK;
|
||||||
|
} // end of ReadDB
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* WriteDB: Data Base write routine for ZIP access method. */
|
||||||
|
/***********************************************************************/
|
||||||
|
int TDBZIP::WriteDB(PGLOBAL g)
|
||||||
|
{
|
||||||
|
strcpy(g->Message, "ZIP tables are read only");
|
||||||
|
return RC_FX;
|
||||||
|
} // end of WriteDB
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Data Base delete line routine for ZIP access method. */
|
||||||
|
/***********************************************************************/
|
||||||
|
int TDBZIP::DeleteDB(PGLOBAL g, int irc)
|
||||||
|
{
|
||||||
|
strcpy(g->Message, "Delete not enabled for ZIP tables");
|
||||||
|
return RC_FX;
|
||||||
|
} // end of DeleteDB
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Data Base close routine for ZIP access method. */
|
||||||
|
/***********************************************************************/
|
||||||
|
void TDBZIP::CloseDB(PGLOBAL g)
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
Use = USE_READY; // Just to be clean
|
||||||
|
} // end of CloseDB
|
||||||
|
|
||||||
|
/* ---------------------------- ZIPCOL ------------------------------- */
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ZIPCOL public constructor. */
|
||||||
|
/***********************************************************************/
|
||||||
|
ZIPCOL::ZIPCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
|
||||||
|
: COLBLK(cdp, tdbp, i)
|
||||||
|
{
|
||||||
|
if (cprec) {
|
||||||
|
Next = cprec->GetNext();
|
||||||
|
cprec->SetNext(this);
|
||||||
|
} else {
|
||||||
|
Next = tdbp->GetColumns();
|
||||||
|
tdbp->SetColumns(this);
|
||||||
|
} // endif cprec
|
||||||
|
|
||||||
|
Tdbz = (TDBZIP*)tdbp;
|
||||||
|
flag = cdp->GetOffset();
|
||||||
|
} // end of ZIPCOL constructor
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ReadColumn: */
|
||||||
|
/***********************************************************************/
|
||||||
|
void ZIPCOL::ReadColumn(PGLOBAL g)
|
||||||
|
{
|
||||||
|
switch (flag) {
|
||||||
|
case 1:
|
||||||
|
Value->SetValue(Tdbz->finfo.compressed_size);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Value->SetValue(Tdbz->finfo.uncompressed_size);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Value->SetValue((int)Tdbz->finfo.compression_method);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Value->SetValue_psz((PSZ)Tdbz->fn);
|
||||||
|
} // endswitch flag
|
||||||
|
|
||||||
|
} // end of ReadColumn
|
||||||
|
|
||||||
|
/* -------------------------- End of tabzip -------------------------- */
|
100
storage/connect/tabzip.h
Normal file
100
storage/connect/tabzip.h
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/*************** tabzip H Declares Source Code File (.H) ***************/
|
||||||
|
/* Name: tabzip.h Version 1.0 */
|
||||||
|
/* */
|
||||||
|
/* (C) Copyright to the author Olivier BERTRAND 2016 */
|
||||||
|
/* */
|
||||||
|
/* This file contains the ZIP classe declares. */
|
||||||
|
/***********************************************************************/
|
||||||
|
#include "osutil.h"
|
||||||
|
#include "block.h"
|
||||||
|
#include "colblk.h"
|
||||||
|
#include "xtable.h"
|
||||||
|
#include "unzip.h"
|
||||||
|
|
||||||
|
typedef class ZIPDEF *PZIPDEF;
|
||||||
|
typedef class TDBZIP *PTDBZIP;
|
||||||
|
typedef class ZIPCOL *PZIPCOL;
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* ZIP table: display info about a ZIP file. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class DllExport ZIPDEF : public DOSDEF { /* Table description */
|
||||||
|
friend class TDBZIP;
|
||||||
|
friend class ZIPFAM;
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
ZIPDEF(void) {}
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
virtual const char *GetType(void) {return "ZIP";}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
|
||||||
|
virtual PTDB GetTable(PGLOBAL g, MODE m);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Members
|
||||||
|
PSZ target; // The inside file to query
|
||||||
|
}; // end of ZIPDEF
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* This is the ZIP Access Method class declaration. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class DllExport TDBZIP : public TDBASE {
|
||||||
|
friend class ZIPCOL;
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
TDBZIP(PZIPDEF tdp);
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||||
|
virtual int Cardinality(PGLOBAL g);
|
||||||
|
virtual int GetMaxSize(PGLOBAL g);
|
||||||
|
virtual int GetRecpos(void) {return 0;}
|
||||||
|
|
||||||
|
// Database routines
|
||||||
|
virtual bool OpenDB(PGLOBAL g);
|
||||||
|
virtual int ReadDB(PGLOBAL g);
|
||||||
|
virtual int WriteDB(PGLOBAL g);
|
||||||
|
virtual int DeleteDB(PGLOBAL g, int irc);
|
||||||
|
virtual void CloseDB(PGLOBAL g);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool open(PGLOBAL g, const char *filename);
|
||||||
|
void close(void);
|
||||||
|
|
||||||
|
// Members
|
||||||
|
unzFile zipfile; // The ZIP container file
|
||||||
|
PSZ zfn; // The ZIP file name
|
||||||
|
//PSZ target;
|
||||||
|
unz_file_info64 finfo; // The current file info
|
||||||
|
char fn[FILENAME_MAX]; // The current file name
|
||||||
|
int nexterr; // Next file error
|
||||||
|
}; // end of class TDBZIP
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Class ZIPCOL: ZIP access method column descriptor. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class DllExport ZIPCOL : public COLBLK {
|
||||||
|
friend class TDBZIP;
|
||||||
|
public:
|
||||||
|
// Constructors
|
||||||
|
ZIPCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "ZIP");
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
virtual int GetAmType(void) { return TYPE_AM_ZIP; }
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual void ReadColumn(PGLOBAL g);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Default constructor not to be used
|
||||||
|
ZIPCOL(void) {}
|
||||||
|
|
||||||
|
// Members
|
||||||
|
TDBZIP *Tdbz;
|
||||||
|
int flag;
|
||||||
|
}; // end of class ZIPCOL
|
2125
storage/connect/unzip.c
Normal file
2125
storage/connect/unzip.c
Normal file
File diff suppressed because it is too large
Load Diff
437
storage/connect/unzip.h
Normal file
437
storage/connect/unzip.h
Normal file
@@ -0,0 +1,437 @@
|
|||||||
|
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||||
|
Version 1.1, February 14h, 2010
|
||||||
|
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
|
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
|
Modifications of Unzip for Zip64
|
||||||
|
Copyright (C) 2007-2008 Even Rouault
|
||||||
|
|
||||||
|
Modifications for Zip64 support on both zip and unzip
|
||||||
|
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||||
|
|
||||||
|
For more info read MiniZip_info.txt
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Condition of use and distribution are the same than zlib :
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Changes
|
||||||
|
|
||||||
|
See header of unzip64.c
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _unz64_H
|
||||||
|
#define _unz64_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _ZLIB_H
|
||||||
|
#include "zlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _ZLIBIOAPI_H
|
||||||
|
#include "ioapi.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_BZIP2
|
||||||
|
#include "bzlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define Z_BZIP2ED 12
|
||||||
|
|
||||||
|
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||||
|
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||||
|
from (void*) without cast */
|
||||||
|
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||||
|
typedef unzFile__ *unzFile;
|
||||||
|
#else
|
||||||
|
typedef voidp unzFile;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define UNZ_OK (0)
|
||||||
|
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||||
|
#define UNZ_ERRNO (Z_ERRNO)
|
||||||
|
#define UNZ_EOF (0)
|
||||||
|
#define UNZ_PARAMERROR (-102)
|
||||||
|
#define UNZ_BADZIPFILE (-103)
|
||||||
|
#define UNZ_INTERNALERROR (-104)
|
||||||
|
#define UNZ_CRCERROR (-105)
|
||||||
|
|
||||||
|
/* tm_unz contain date/time info */
|
||||||
|
typedef struct tm_unz_s
|
||||||
|
{
|
||||||
|
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||||
|
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||||
|
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||||
|
uInt tm_mday; /* day of the month - [1,31] */
|
||||||
|
uInt tm_mon; /* months since January - [0,11] */
|
||||||
|
uInt tm_year; /* years - [1980..2044] */
|
||||||
|
} tm_unz;
|
||||||
|
|
||||||
|
/* unz_global_info structure contain global data about the ZIPfile
|
||||||
|
These data comes from the end of central dir */
|
||||||
|
typedef struct unz_global_info64_s
|
||||||
|
{
|
||||||
|
ZPOS64_T number_entry; /* total number of entries in
|
||||||
|
the central dir on this disk */
|
||||||
|
uLong size_comment; /* size of the global comment of the zipfile */
|
||||||
|
} unz_global_info64;
|
||||||
|
|
||||||
|
typedef struct unz_global_info_s
|
||||||
|
{
|
||||||
|
uLong number_entry; /* total number of entries in
|
||||||
|
the central dir on this disk */
|
||||||
|
uLong size_comment; /* size of the global comment of the zipfile */
|
||||||
|
} unz_global_info;
|
||||||
|
|
||||||
|
/* unz_file_info contain information about a file in the zipfile */
|
||||||
|
typedef struct unz_file_info64_s
|
||||||
|
{
|
||||||
|
uLong version; /* version made by 2 bytes */
|
||||||
|
uLong version_needed; /* version needed to extract 2 bytes */
|
||||||
|
uLong flag; /* general purpose bit flag 2 bytes */
|
||||||
|
uLong compression_method; /* compression method 2 bytes */
|
||||||
|
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||||
|
uLong crc; /* crc-32 4 bytes */
|
||||||
|
ZPOS64_T compressed_size; /* compressed size 8 bytes */
|
||||||
|
ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
|
||||||
|
uLong size_filename; /* filename length 2 bytes */
|
||||||
|
uLong size_file_extra; /* extra field length 2 bytes */
|
||||||
|
uLong size_file_comment; /* file comment length 2 bytes */
|
||||||
|
|
||||||
|
uLong disk_num_start; /* disk number start 2 bytes */
|
||||||
|
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||||
|
uLong external_fa; /* external file attributes 4 bytes */
|
||||||
|
|
||||||
|
tm_unz tmu_date;
|
||||||
|
} unz_file_info64;
|
||||||
|
|
||||||
|
typedef struct unz_file_info_s
|
||||||
|
{
|
||||||
|
uLong version; /* version made by 2 bytes */
|
||||||
|
uLong version_needed; /* version needed to extract 2 bytes */
|
||||||
|
uLong flag; /* general purpose bit flag 2 bytes */
|
||||||
|
uLong compression_method; /* compression method 2 bytes */
|
||||||
|
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||||
|
uLong crc; /* crc-32 4 bytes */
|
||||||
|
uLong compressed_size; /* compressed size 4 bytes */
|
||||||
|
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||||
|
uLong size_filename; /* filename length 2 bytes */
|
||||||
|
uLong size_file_extra; /* extra field length 2 bytes */
|
||||||
|
uLong size_file_comment; /* file comment length 2 bytes */
|
||||||
|
|
||||||
|
uLong disk_num_start; /* disk number start 2 bytes */
|
||||||
|
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||||
|
uLong external_fa; /* external file attributes 4 bytes */
|
||||||
|
|
||||||
|
tm_unz tmu_date;
|
||||||
|
} unz_file_info;
|
||||||
|
|
||||||
|
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||||
|
const char* fileName2,
|
||||||
|
int iCaseSensitivity));
|
||||||
|
/*
|
||||||
|
Compare two filename (fileName1,fileName2).
|
||||||
|
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||||
|
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||||
|
or strcasecmp)
|
||||||
|
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||||
|
(like 1 on Unix, 2 on Windows)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||||
|
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
|
||||||
|
/*
|
||||||
|
Open a Zip file. path contain the full pathname (by example,
|
||||||
|
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||||
|
"zlib/zlib113.zip".
|
||||||
|
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||||
|
return value is NULL.
|
||||||
|
Else, the return value is a unzFile Handle, usable with other function
|
||||||
|
of this unzip package.
|
||||||
|
the "64" function take a const void* pointer, because the path is just the
|
||||||
|
value passed to the open64_file_func callback.
|
||||||
|
Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
|
||||||
|
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
|
||||||
|
does not describe the reality
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||||
|
zlib_filefunc_def* pzlib_filefunc_def));
|
||||||
|
/*
|
||||||
|
Open a Zip file, like unzOpen, but provide a set of file low level API
|
||||||
|
for read/write the zip file (see ioapi.h)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
|
||||||
|
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||||
|
/*
|
||||||
|
Open a Zip file, like unz64Open, but provide a set of file low level API
|
||||||
|
for read/write the zip file (see ioapi.h)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzClose OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Close a ZipFile opened with unzOpen.
|
||||||
|
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||||
|
these files MUST be closed with unzCloseCurrentFile before call unzClose.
|
||||||
|
return UNZ_OK if there is no problem. */
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||||
|
unz_global_info *pglobal_info));
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
|
||||||
|
unz_global_info64 *pglobal_info));
|
||||||
|
/*
|
||||||
|
Write info about the ZipFile in the *pglobal_info structure.
|
||||||
|
No preparation of the structure is needed
|
||||||
|
return UNZ_OK if there is no problem. */
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||||
|
char *szComment,
|
||||||
|
uLong uSizeBuf));
|
||||||
|
/*
|
||||||
|
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||||
|
uSizeBuf is the size of the szComment buffer.
|
||||||
|
return the number of byte copied or an error code <0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
/* Unzip package allow you browse the directory of the zipfile */
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Set the current file of the zipfile to the first file.
|
||||||
|
return UNZ_OK if there is no problem
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Set the current file of the zipfile to the next file.
|
||||||
|
return UNZ_OK if there is no problem
|
||||||
|
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||||
|
const char *szFileName,
|
||||||
|
int iCaseSensitivity));
|
||||||
|
/*
|
||||||
|
Try locate the file szFileName in the zipfile.
|
||||||
|
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||||
|
|
||||||
|
return value :
|
||||||
|
UNZ_OK if the file is found. It becomes the current file.
|
||||||
|
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* ****************************************** */
|
||||||
|
/* Ryan supplied functions */
|
||||||
|
/* unz_file_info contain information about a file in the zipfile */
|
||||||
|
typedef struct unz_file_pos_s
|
||||||
|
{
|
||||||
|
uLong pos_in_zip_directory; /* offset in zip file directory */
|
||||||
|
uLong num_of_file; /* # of file */
|
||||||
|
} unz_file_pos;
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetFilePos(
|
||||||
|
unzFile file,
|
||||||
|
unz_file_pos* file_pos);
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGoToFilePos(
|
||||||
|
unzFile file,
|
||||||
|
unz_file_pos* file_pos);
|
||||||
|
|
||||||
|
typedef struct unz64_file_pos_s
|
||||||
|
{
|
||||||
|
ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
|
||||||
|
ZPOS64_T num_of_file; /* # of file */
|
||||||
|
} unz64_file_pos;
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetFilePos64(
|
||||||
|
unzFile file,
|
||||||
|
unz64_file_pos* file_pos);
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGoToFilePos64(
|
||||||
|
unzFile file,
|
||||||
|
const unz64_file_pos* file_pos);
|
||||||
|
|
||||||
|
/* ****************************************** */
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
|
||||||
|
unz_file_info64 *pfile_info,
|
||||||
|
char *szFileName,
|
||||||
|
uLong fileNameBufferSize,
|
||||||
|
void *extraField,
|
||||||
|
uLong extraFieldBufferSize,
|
||||||
|
char *szComment,
|
||||||
|
uLong commentBufferSize));
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||||
|
unz_file_info *pfile_info,
|
||||||
|
char *szFileName,
|
||||||
|
uLong fileNameBufferSize,
|
||||||
|
void *extraField,
|
||||||
|
uLong extraFieldBufferSize,
|
||||||
|
char *szComment,
|
||||||
|
uLong commentBufferSize));
|
||||||
|
/*
|
||||||
|
Get Info about the current file
|
||||||
|
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||||
|
the current file
|
||||||
|
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||||
|
(fileNameBufferSize is the size of the buffer)
|
||||||
|
if extraField!=NULL, the extra field information will be copied in extraField
|
||||||
|
(extraFieldBufferSize is the size of the buffer).
|
||||||
|
This is the Central-header version of the extra field
|
||||||
|
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||||
|
(commentBufferSize is the size of the buffer)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** Addition for GDAL : START */
|
||||||
|
|
||||||
|
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
|
||||||
|
|
||||||
|
/** Addition for GDAL : END */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
/* for reading the content of the current zipfile, you can open it, read data
|
||||||
|
from it, and close it (you can close it before reading all the file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Open for reading data the current file in the zipfile.
|
||||||
|
If there is no error, the return value is UNZ_OK.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
|
||||||
|
const char* password));
|
||||||
|
/*
|
||||||
|
Open for reading data the current file in the zipfile.
|
||||||
|
password is a crypting password
|
||||||
|
If there is no error, the return value is UNZ_OK.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||||
|
int* method,
|
||||||
|
int* level,
|
||||||
|
int raw));
|
||||||
|
/*
|
||||||
|
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||||
|
if raw==1
|
||||||
|
*method will receive method of compression, *level will receive level of
|
||||||
|
compression
|
||||||
|
note : you can set level parameter as NULL (if you did not want known level,
|
||||||
|
but you CANNOT set method parameter as NULL
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||||
|
int* method,
|
||||||
|
int* level,
|
||||||
|
int raw,
|
||||||
|
const char* password));
|
||||||
|
/*
|
||||||
|
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||||
|
if raw==1
|
||||||
|
*method will receive method of compression, *level will receive level of
|
||||||
|
compression
|
||||||
|
note : you can set level parameter as NULL (if you did not want known level,
|
||||||
|
but you CANNOT set method parameter as NULL
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Close the file in zip opened with unzOpenCurrentFile
|
||||||
|
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||||
|
voidp buf,
|
||||||
|
unsigned len));
|
||||||
|
/*
|
||||||
|
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||||
|
buf contain buffer where data must be copied
|
||||||
|
len the size of buf.
|
||||||
|
|
||||||
|
return the number of byte copied if somes bytes are copied
|
||||||
|
return 0 if the end of file was reached
|
||||||
|
return <0 with error code if there is an error
|
||||||
|
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||||
|
|
||||||
|
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Give the current position in uncompressed data
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzeof OF((unzFile file));
|
||||||
|
/*
|
||||||
|
return 1 if the end of file was reached, 0 elsewhere
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||||
|
voidp buf,
|
||||||
|
unsigned len));
|
||||||
|
/*
|
||||||
|
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||||
|
This is the local-header version of the extra field (sometimes, there is
|
||||||
|
more info in the local-header version than in the central-header)
|
||||||
|
|
||||||
|
if buf==NULL, it return the size of the local extra field
|
||||||
|
|
||||||
|
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||||
|
buf.
|
||||||
|
the return value is the number of bytes copied in buf, or (if <0)
|
||||||
|
the error code
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
|
||||||
|
/* Get the current file offset */
|
||||||
|
extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
|
||||||
|
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||||
|
|
||||||
|
/* Set the current file offset */
|
||||||
|
extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
|
||||||
|
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _unz64_H */
|
2007
storage/connect/zip.c
Normal file
2007
storage/connect/zip.c
Normal file
File diff suppressed because it is too large
Load Diff
362
storage/connect/zip.h
Normal file
362
storage/connect/zip.h
Normal file
@@ -0,0 +1,362 @@
|
|||||||
|
/* zip.h -- IO on .zip files using zlib
|
||||||
|
Version 1.1, February 14h, 2010
|
||||||
|
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
|
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
|
Modifications for Zip64 support
|
||||||
|
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||||
|
|
||||||
|
For more info read MiniZip_info.txt
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Condition of use and distribution are the same than zlib :
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Changes
|
||||||
|
|
||||||
|
See header of zip.h
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _zip12_H
|
||||||
|
#define _zip12_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#define HAVE_BZIP2
|
||||||
|
|
||||||
|
#ifndef _ZLIB_H
|
||||||
|
#include "zlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _ZLIBIOAPI_H
|
||||||
|
#include "ioapi.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_BZIP2
|
||||||
|
#include "bzlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define Z_BZIP2ED 12
|
||||||
|
|
||||||
|
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
|
||||||
|
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||||
|
from (void*) without cast */
|
||||||
|
typedef struct TagzipFile__ { int unused; } zipFile__;
|
||||||
|
typedef zipFile__ *zipFile;
|
||||||
|
#else
|
||||||
|
typedef voidp zipFile;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ZIP_OK (0)
|
||||||
|
#define ZIP_EOF (0)
|
||||||
|
#define ZIP_ERRNO (Z_ERRNO)
|
||||||
|
#define ZIP_PARAMERROR (-102)
|
||||||
|
#define ZIP_BADZIPFILE (-103)
|
||||||
|
#define ZIP_INTERNALERROR (-104)
|
||||||
|
|
||||||
|
#ifndef DEF_MEM_LEVEL
|
||||||
|
# if MAX_MEM_LEVEL >= 8
|
||||||
|
# define DEF_MEM_LEVEL 8
|
||||||
|
# else
|
||||||
|
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
/* default memLevel */
|
||||||
|
|
||||||
|
/* tm_zip contain date/time info */
|
||||||
|
typedef struct tm_zip_s
|
||||||
|
{
|
||||||
|
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||||
|
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||||
|
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||||
|
uInt tm_mday; /* day of the month - [1,31] */
|
||||||
|
uInt tm_mon; /* months since January - [0,11] */
|
||||||
|
uInt tm_year; /* years - [1980..2044] */
|
||||||
|
} tm_zip;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
tm_zip tmz_date; /* date in understandable format */
|
||||||
|
uLong dosDate; /* if dos_date == 0, tmu_date is used */
|
||||||
|
/* uLong flag; */ /* general purpose bit flag 2 bytes */
|
||||||
|
|
||||||
|
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||||
|
uLong external_fa; /* external file attributes 4 bytes */
|
||||||
|
} zip_fileinfo;
|
||||||
|
|
||||||
|
typedef const char* zipcharpc;
|
||||||
|
|
||||||
|
|
||||||
|
#define APPEND_STATUS_CREATE (0)
|
||||||
|
#define APPEND_STATUS_CREATEAFTER (1)
|
||||||
|
#define APPEND_STATUS_ADDINZIP (2)
|
||||||
|
|
||||||
|
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
|
||||||
|
extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
|
||||||
|
/*
|
||||||
|
Create a zipfile.
|
||||||
|
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
|
||||||
|
an Unix computer "zlib/zlib113.zip".
|
||||||
|
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
|
||||||
|
will be created at the end of the file.
|
||||||
|
(useful if the file contain a self extractor code)
|
||||||
|
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
|
||||||
|
add files in existing zip (be sure you don't add file that doesn't exist)
|
||||||
|
If the zipfile cannot be opened, the return value is NULL.
|
||||||
|
Else, the return value is a zipFile Handle, usable with other function
|
||||||
|
of this zip package.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Note : there is no delete function into a zipfile.
|
||||||
|
If you want delete file into a zipfile, you must open a zipfile, and create another
|
||||||
|
Of couse, you can use RAW reading and writing to copy the file you did not want delte
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
|
||||||
|
int append,
|
||||||
|
zipcharpc* globalcomment,
|
||||||
|
zlib_filefunc_def* pzlib_filefunc_def));
|
||||||
|
|
||||||
|
extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
|
||||||
|
int append,
|
||||||
|
zipcharpc* globalcomment,
|
||||||
|
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||||
|
|
||||||
|
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||||
|
const char* filename,
|
||||||
|
const zip_fileinfo* zipfi,
|
||||||
|
const void* extrafield_local,
|
||||||
|
uInt size_extrafield_local,
|
||||||
|
const void* extrafield_global,
|
||||||
|
uInt size_extrafield_global,
|
||||||
|
const char* comment,
|
||||||
|
int method,
|
||||||
|
int level));
|
||||||
|
|
||||||
|
extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
|
||||||
|
const char* filename,
|
||||||
|
const zip_fileinfo* zipfi,
|
||||||
|
const void* extrafield_local,
|
||||||
|
uInt size_extrafield_local,
|
||||||
|
const void* extrafield_global,
|
||||||
|
uInt size_extrafield_global,
|
||||||
|
const char* comment,
|
||||||
|
int method,
|
||||||
|
int level,
|
||||||
|
int zip64));
|
||||||
|
|
||||||
|
/*
|
||||||
|
Open a file in the ZIP for writing.
|
||||||
|
filename : the filename in zip (if NULL, '-' without quote will be used
|
||||||
|
*zipfi contain supplemental information
|
||||||
|
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
|
||||||
|
contains the extrafield data the the local header
|
||||||
|
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
|
||||||
|
contains the extrafield data the the local header
|
||||||
|
if comment != NULL, comment contain the comment string
|
||||||
|
method contain the compression method (0 for store, Z_DEFLATED for deflate)
|
||||||
|
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
|
||||||
|
zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
|
||||||
|
this MUST be '1' if the uncompressed size is >= 0xffffffff.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
|
||||||
|
const char* filename,
|
||||||
|
const zip_fileinfo* zipfi,
|
||||||
|
const void* extrafield_local,
|
||||||
|
uInt size_extrafield_local,
|
||||||
|
const void* extrafield_global,
|
||||||
|
uInt size_extrafield_global,
|
||||||
|
const char* comment,
|
||||||
|
int method,
|
||||||
|
int level,
|
||||||
|
int raw));
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
|
||||||
|
const char* filename,
|
||||||
|
const zip_fileinfo* zipfi,
|
||||||
|
const void* extrafield_local,
|
||||||
|
uInt size_extrafield_local,
|
||||||
|
const void* extrafield_global,
|
||||||
|
uInt size_extrafield_global,
|
||||||
|
const char* comment,
|
||||||
|
int method,
|
||||||
|
int level,
|
||||||
|
int raw,
|
||||||
|
int zip64));
|
||||||
|
/*
|
||||||
|
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
||||||
|
const char* filename,
|
||||||
|
const zip_fileinfo* zipfi,
|
||||||
|
const void* extrafield_local,
|
||||||
|
uInt size_extrafield_local,
|
||||||
|
const void* extrafield_global,
|
||||||
|
uInt size_extrafield_global,
|
||||||
|
const char* comment,
|
||||||
|
int method,
|
||||||
|
int level,
|
||||||
|
int raw,
|
||||||
|
int windowBits,
|
||||||
|
int memLevel,
|
||||||
|
int strategy,
|
||||||
|
const char* password,
|
||||||
|
uLong crcForCrypting));
|
||||||
|
|
||||||
|
extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
|
||||||
|
const char* filename,
|
||||||
|
const zip_fileinfo* zipfi,
|
||||||
|
const void* extrafield_local,
|
||||||
|
uInt size_extrafield_local,
|
||||||
|
const void* extrafield_global,
|
||||||
|
uInt size_extrafield_global,
|
||||||
|
const char* comment,
|
||||||
|
int method,
|
||||||
|
int level,
|
||||||
|
int raw,
|
||||||
|
int windowBits,
|
||||||
|
int memLevel,
|
||||||
|
int strategy,
|
||||||
|
const char* password,
|
||||||
|
uLong crcForCrypting,
|
||||||
|
int zip64
|
||||||
|
));
|
||||||
|
|
||||||
|
/*
|
||||||
|
Same than zipOpenNewFileInZip2, except
|
||||||
|
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
|
||||||
|
password : crypting password (NULL for no crypting)
|
||||||
|
crcForCrypting : crc of file to compress (needed for crypting)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
|
||||||
|
const char* filename,
|
||||||
|
const zip_fileinfo* zipfi,
|
||||||
|
const void* extrafield_local,
|
||||||
|
uInt size_extrafield_local,
|
||||||
|
const void* extrafield_global,
|
||||||
|
uInt size_extrafield_global,
|
||||||
|
const char* comment,
|
||||||
|
int method,
|
||||||
|
int level,
|
||||||
|
int raw,
|
||||||
|
int windowBits,
|
||||||
|
int memLevel,
|
||||||
|
int strategy,
|
||||||
|
const char* password,
|
||||||
|
uLong crcForCrypting,
|
||||||
|
uLong versionMadeBy,
|
||||||
|
uLong flagBase
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
|
||||||
|
const char* filename,
|
||||||
|
const zip_fileinfo* zipfi,
|
||||||
|
const void* extrafield_local,
|
||||||
|
uInt size_extrafield_local,
|
||||||
|
const void* extrafield_global,
|
||||||
|
uInt size_extrafield_global,
|
||||||
|
const char* comment,
|
||||||
|
int method,
|
||||||
|
int level,
|
||||||
|
int raw,
|
||||||
|
int windowBits,
|
||||||
|
int memLevel,
|
||||||
|
int strategy,
|
||||||
|
const char* password,
|
||||||
|
uLong crcForCrypting,
|
||||||
|
uLong versionMadeBy,
|
||||||
|
uLong flagBase,
|
||||||
|
int zip64
|
||||||
|
));
|
||||||
|
/*
|
||||||
|
Same than zipOpenNewFileInZip4, except
|
||||||
|
versionMadeBy : value for Version made by field
|
||||||
|
flag : value for flag field (compression level info will be added)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||||
|
const void* buf,
|
||||||
|
unsigned len));
|
||||||
|
/*
|
||||||
|
Write data in the zipfile
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||||
|
/*
|
||||||
|
Close the current file in the zipfile
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
|
||||||
|
uLong uncompressed_size,
|
||||||
|
uLong crc32));
|
||||||
|
|
||||||
|
extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
|
||||||
|
ZPOS64_T uncompressed_size,
|
||||||
|
uLong crc32));
|
||||||
|
|
||||||
|
/*
|
||||||
|
Close the current file in the zipfile, for file opened with
|
||||||
|
parameter raw=1 in zipOpenNewFileInZip2
|
||||||
|
uncompressed_size and crc32 are value for the uncompressed size
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT zipClose OF((zipFile file,
|
||||||
|
const char* global_comment));
|
||||||
|
/*
|
||||||
|
Close the zipfile
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));
|
||||||
|
/*
|
||||||
|
zipRemoveExtraInfoBlock - Added by Mathias Svensson
|
||||||
|
|
||||||
|
Remove extra information block from a extra information data for the local file header or central directory header
|
||||||
|
|
||||||
|
It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.
|
||||||
|
|
||||||
|
0x0001 is the signature header for the ZIP64 extra information blocks
|
||||||
|
|
||||||
|
usage.
|
||||||
|
Remove ZIP64 Extra information from a central director extra field data
|
||||||
|
zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);
|
||||||
|
|
||||||
|
Remove ZIP64 Extra information from a Local File Header extra field data
|
||||||
|
zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _zip64_H */
|
Reference in New Issue
Block a user