初始化PHP-Xlswrite扩展
This commit is contained in:
22
include/chart.h
Normal file
22
include/chart.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_EXT_EXCEL_EXPORT_CHART_H
|
||||
#define PHP_EXT_EXCEL_EXPORT_CHART_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern zend_class_entry *vtiful_chart_ce;
|
||||
|
||||
VTIFUL_STARTUP_FUNCTION(chart);
|
||||
|
||||
#endif
|
44
include/common.h
Normal file
44
include/common.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_EXT_XLS_WRITER_COMMON_H
|
||||
#define PHP_EXT_XLS_WRITER_COMMON_H
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
# define PHP_VTIFUL_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define PHP_VTIFUL_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
# define PHP_VTIFUL_API
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
#if PHP_VERSION_ID >= 80000
|
||||
#define TSRMLS_D void
|
||||
#define TSRMLS_DC
|
||||
#define TSRMLS_C
|
||||
#define TSRMLS_CC
|
||||
#endif
|
||||
|
||||
#define VTIFUL_RESOURCE_NAME "xlsx"
|
||||
|
||||
#define VTIFUL_STARTUP_MODULE(module) ZEND_MODULE_STARTUP_N(xlsxwriter_##module)(INIT_FUNC_ARGS_PASSTHRU)
|
||||
#define VTIFUL_STARTUP_FUNCTION(module) ZEND_MINIT_FUNCTION(xlsxwriter_##module)
|
||||
|
||||
#if defined(ZTS) && defined(COMPILE_DL_VTIFUL)
|
||||
ZEND_TSRMLS_CACHE_EXTERN();
|
||||
#endif
|
||||
|
||||
#endif
|
28
include/csv.h
Normal file
28
include/csv.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_EXT_XLS_WRITER_CSV_H
|
||||
#define PHP_EXT_XLS_WRITER_CSV_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
unsigned int xlsx_to_csv(
|
||||
zval *stream_resource,
|
||||
const char *delimiter_str, int delimiter_str_len,
|
||||
const char *enclosure_str, int enclosure_str_len,
|
||||
const char *escape_str, int escape_str_len,
|
||||
xlsxioreadersheet sheet_t,
|
||||
zval *zv_type_arr_t, zend_long data_type_default,
|
||||
unsigned int flag, zend_fcall_info *fci, zend_fcall_info_cache *fci_cache
|
||||
);
|
||||
|
||||
#endif // PHP_EXT_XLS_WRITER_CSV_H
|
52
include/excel.h
Normal file
52
include/excel.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef VTIFUL_XLS_H
|
||||
#define VTIFUL_XLS_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define V_XLS_HANDLE "handle"
|
||||
#define V_XLS_FIL "fileName"
|
||||
#define V_XLS_COF "config"
|
||||
#define V_XLS_PAT "path"
|
||||
#define V_XLS_TYPE "read_row_type"
|
||||
|
||||
#define V_XLS_CONST_READ_TYPE_INT "TYPE_INT"
|
||||
#define V_XLS_CONST_READ_TYPE_DOUBLE "TYPE_DOUBLE"
|
||||
#define V_XLS_CONST_READ_TYPE_STRING "TYPE_STRING"
|
||||
#define V_XLS_CONST_READ_TYPE_DATETIME "TYPE_TIMESTAMP"
|
||||
|
||||
#define V_XLS_CONST_READ_SKIP_NONE "SKIP_NONE"
|
||||
#define V_XLS_CONST_READ_SKIP_EMPTY_ROW "SKIP_EMPTY_ROW"
|
||||
#define V_XLS_CONST_READ_SKIP_HIDDEN_ROW "SKIP_HIDDEN_ROW"
|
||||
#define V_XLS_CONST_READ_SKIP_EMPTY_CELLS "SKIP_EMPTY_CELLS"
|
||||
#define V_XLS_CONST_READ_SKIP_EMPTY_VALUE "SKIP_EMPTY_VALUE"
|
||||
|
||||
#define READ_TYPE_EMPTY 0x00
|
||||
#define READ_TYPE_STRING 0x01
|
||||
#define READ_TYPE_INT 0x02
|
||||
#define READ_TYPE_DOUBLE 0x04
|
||||
#define READ_TYPE_DATETIME 0x08
|
||||
|
||||
#define GET_CONFIG_PATH(dir_path_res, class_name, object) \
|
||||
do { \
|
||||
zval rv; \
|
||||
zval *_config = zend_read_property(class_name, object, ZEND_STRL(V_XLS_COF), 0, &rv); \
|
||||
(dir_path_res) = zend_hash_str_find(Z_ARRVAL_P(_config), ZEND_STRL(V_XLS_PAT)); \
|
||||
} while(0)
|
||||
|
||||
extern zend_class_entry *vtiful_xls_ce;
|
||||
|
||||
VTIFUL_STARTUP_FUNCTION(excel);
|
||||
|
||||
#endif
|
24
include/exception.h
Normal file
24
include/exception.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef VTIFUL_XLS_EXCEPTION_H
|
||||
#define VTIFUL_XLS_EXCEPTION_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern zend_class_entry *vtiful_exception_ce;
|
||||
|
||||
VTIFUL_STARTUP_FUNCTION(exception);
|
||||
|
||||
char* exception_message_map(int code);
|
||||
|
||||
#endif
|
22
include/format.h
Normal file
22
include/format.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_EXT_XLS_EXPORT_FORMAT_H
|
||||
#define PHP_EXT_XLS_EXPORT_FORMAT_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern zend_class_entry *vtiful_format_ce;
|
||||
|
||||
VTIFUL_STARTUP_FUNCTION(format);
|
||||
|
||||
#endif
|
22
include/help.h
Normal file
22
include/help.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_EXT_XLS_EXPORT_HELP_H
|
||||
#define PHP_EXT_XLS_EXPORT_HELP_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
unsigned int file_exists(const char *path);
|
||||
unsigned int directory_exists(const char *path);
|
||||
zend_long date_double_to_timestamp(double value);
|
||||
|
||||
#endif //PHP_EXT_XLS_EXPORT_HELP_H
|
208
include/minizip/ioapi.h
Normal file
208
include/minizip/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
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#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
|
437
include/minizip/unzip.h
Normal file
437
include/minizip/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 */
|
35
include/read.h
Normal file
35
include/read.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_READ_INCLUDE_H
|
||||
#define PHP_READ_INCLUDE_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define READ_SKIP_ROW 0
|
||||
#define READ_ROW 0x01
|
||||
#define SKIP_EMPTY_VALUE 0x100
|
||||
|
||||
int is_number(const char *value);
|
||||
void data_to_null(zval *zv_result_t);
|
||||
int sheet_read_row(xlsxioreadersheet sheet_t);
|
||||
void sheet_list(xlsxioreader file_t, zval *zv_result_t);
|
||||
xlsxioreader file_open(const char *directory, const char *file_name);
|
||||
void skip_rows(xlsxioreadersheet sheet_t, zval *zv_type_t, zend_long data_type_default, zend_long zl_skip_row);
|
||||
void load_sheet_all_data(xlsxioreadersheet sheet_t, zend_long sheet_flag, zval *zv_type_t, zend_long data_type_default, zval *zv_result_t);
|
||||
void load_sheet_row_data (xlsxioreadersheet sheet_t, zend_long sheet_flag, zval *zv_type_t, zend_long data_type_default, zval *zv_result_t);
|
||||
xlsxioreadersheet sheet_open(xlsxioreader file_t, const zend_string *zs_sheet_name_t, const zend_long zl_flag);
|
||||
unsigned int load_sheet_current_row_data(xlsxioreadersheet sheet_t, zval *zv_result_t, zval *zv_type, zend_long data_type_default, unsigned int flag);
|
||||
unsigned int load_sheet_current_row_data_callback(zend_string *zs_sheet_name_t, xlsxioreader file_t, void *callback_data);
|
||||
void data_to_custom_type(const char *string_value, const size_t string_value_length, const zend_ulong type, zval *zv_result_t, const zend_ulong zv_hashtable_index);
|
||||
|
||||
#endif //PHP_READ_INCLUDE_H
|
22
include/rich_string.h
Normal file
22
include/rich_string.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_EXT_XLS_EXPORT_RICH_STRING_H
|
||||
#define PHP_EXT_XLS_EXPORT_RICH_STRING_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern zend_class_entry *vtiful_rich_string_ce;
|
||||
|
||||
VTIFUL_STARTUP_FUNCTION(rich_string);
|
||||
|
||||
#endif
|
22
include/validation.h
Normal file
22
include/validation.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_EXT_XLS_WRITER_VALIDATION_H
|
||||
#define PHP_EXT_XLS_WRITER_VALIDATION_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern zend_class_entry *vtiful_validation_ce;
|
||||
|
||||
VTIFUL_STARTUP_FUNCTION(validation);
|
||||
|
||||
#endif // PHP_EXT_XLS_WRITER_VALIDATION_H
|
364
include/xlswriter.h
Normal file
364
include/xlswriter.h
Normal file
@ -0,0 +1,364 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| XlsWriter Extension |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2017-2018 The Viest |
|
||||
+----------------------------------------------------------------------+
|
||||
| http://www.viest.me |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: viest <dev@service.viest.me> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_XLS_WRITER_INCLUDE_H
|
||||
#define PHP_XLS_WRITER_INCLUDE_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <php.h>
|
||||
#include "ext/date/php_date.h"
|
||||
|
||||
#include "zend_smart_str.h"
|
||||
#include "zend_exceptions.h"
|
||||
#include "zend.h"
|
||||
#include "zend_API.h"
|
||||
#include "php.h"
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
#include "xlsxwriter/packager.h"
|
||||
#include "xlsxwriter/format.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "php_xlswriter.h"
|
||||
#include "excel.h"
|
||||
#include "validation.h"
|
||||
#include "exception.h"
|
||||
#include "format.h"
|
||||
#include "chart.h"
|
||||
#include "rich_string.h"
|
||||
#include "help.h"
|
||||
|
||||
#ifdef ENABLE_READER
|
||||
#include "xlsxio_read.h"
|
||||
#include "read.h"
|
||||
#include "csv.h"
|
||||
|
||||
typedef struct {
|
||||
xlsxioreader file_t;
|
||||
xlsxioreadersheet sheet_t;
|
||||
zend_long data_type_default;
|
||||
zend_long sheet_flag;
|
||||
} xls_resource_read_t;
|
||||
|
||||
typedef struct {
|
||||
zend_long data_type_default;
|
||||
zval *zv_type_t;
|
||||
zend_fcall_info *fci;
|
||||
zend_fcall_info_cache *fci_cache;
|
||||
} xls_read_callback_data;
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_READER
|
||||
typedef struct {
|
||||
void *file_t;
|
||||
void *sheet_t;
|
||||
zend_long data_type_default;
|
||||
zend_long sheet_flag;
|
||||
} xls_resource_read_t;
|
||||
#endif
|
||||
|
||||
enum xlswriter_boolean {
|
||||
XLSWRITER_FALSE,
|
||||
XLSWRITER_TRUE
|
||||
};
|
||||
|
||||
enum xlswirter_printed_direction {
|
||||
XLSWRITER_PRINTED_LANDSCAPE,
|
||||
XLSWRITER_PRINTED_PORTRAIT,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
lxw_workbook *workbook;
|
||||
lxw_worksheet *worksheet;
|
||||
} xls_resource_write_t;
|
||||
|
||||
typedef struct {
|
||||
lxw_format *format;
|
||||
} xls_resource_format_t;
|
||||
|
||||
typedef struct {
|
||||
lxw_data_validation *validation;
|
||||
} xls_resource_validation_t;
|
||||
|
||||
typedef struct {
|
||||
lxw_chart *chart;
|
||||
lxw_chart_series *series;
|
||||
} xls_resource_chart_t;
|
||||
|
||||
typedef struct {
|
||||
lxw_rich_string_tuple *tuple;
|
||||
} xls_resource_rich_string_t;
|
||||
|
||||
typedef struct _vtiful_xls_object {
|
||||
xls_resource_read_t read_ptr;
|
||||
xls_resource_write_t write_ptr;
|
||||
zend_long write_line;
|
||||
xls_resource_format_t format_ptr;
|
||||
zend_object zo;
|
||||
} xls_object;
|
||||
|
||||
typedef struct _vtiful_format_object {
|
||||
xls_resource_format_t ptr;
|
||||
zend_object zo;
|
||||
} format_object;
|
||||
|
||||
typedef struct _vtiful_chart_object {
|
||||
xls_resource_chart_t ptr;
|
||||
zend_object zo;
|
||||
} chart_object;
|
||||
|
||||
typedef struct _vtiful_validation_object {
|
||||
xls_resource_validation_t ptr;
|
||||
zend_object zo;
|
||||
} validation_object;
|
||||
|
||||
typedef struct _vtiful_rich_string_object {
|
||||
xls_resource_rich_string_t ptr;
|
||||
zend_object zo;
|
||||
} rich_string_object;
|
||||
|
||||
#define REGISTER_CLASS_CONST_LONG(class_name, const_name, value) \
|
||||
zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (zend_long)value);
|
||||
|
||||
#define REGISTER_CLASS_PROPERTY_NULL(class_name, property_name, acc) \
|
||||
zend_declare_property_null(class_name, ZEND_STRL(property_name), acc);
|
||||
|
||||
#define Z_XLS_P(zv) php_vtiful_xls_fetch_object(Z_OBJ_P(zv));
|
||||
#define Z_CHART_P(zv) php_vtiful_chart_fetch_object(Z_OBJ_P(zv));
|
||||
#define Z_FORMAT_P(zv) php_vtiful_format_fetch_object(Z_OBJ_P(zv));
|
||||
#define Z_VALIDATION_P(zv) php_vtiful_validation_fetch_object(Z_OBJ_P(zv));
|
||||
#define Z_RICH_STR_P(zv) php_vtiful_rich_string_fetch_object(Z_OBJ_P(zv));
|
||||
|
||||
#define WORKBOOK_NOT_INITIALIZED(xls_object_t) \
|
||||
do { \
|
||||
if(xls_object_t->write_ptr.workbook == NULL) { \
|
||||
zend_throw_exception(vtiful_exception_ce, "Please create a file first, use the filename method", 130); \
|
||||
return; \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define WORKSHEET_NOT_INITIALIZED(xls_object_t) \
|
||||
do { \
|
||||
if (xls_object_t->write_ptr.worksheet == NULL) { \
|
||||
zend_throw_exception(vtiful_exception_ce, "worksheet not initialized", 200); \
|
||||
return; \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define WORKSHEET_INDEX_OUT_OF_CHANGE_IN_OPTIMIZE_EXCEPTION(xls_resource_write_t, error) \
|
||||
do { \
|
||||
if(xls_resource_write_t->worksheet->optimize && error == LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE) { \
|
||||
zend_throw_exception(vtiful_exception_ce, "In const memory mode, you cannot modify the placed cells", 170); \
|
||||
return; \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define WORKSHEET_INDEX_OUT_OF_CHANGE_EXCEPTION(error) \
|
||||
do { \
|
||||
if(error == LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE) { \
|
||||
zend_throw_exception(vtiful_exception_ce, "Worksheet row or column index out of range", 180); \
|
||||
return; \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define WORKSHEET_WRITER_EXCEPTION(error) \
|
||||
do { \
|
||||
if(error > LXW_NO_ERROR) { \
|
||||
zend_throw_exception(vtiful_exception_ce, exception_message_map(error), error); \
|
||||
return; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define FCALL_TWO_ARGS(bucket) \
|
||||
ZVAL_COPY_VALUE(&args[0], &bucket->val); \
|
||||
if (bucket->key) { \
|
||||
ZVAL_STR(&args[1], bucket->key); \
|
||||
} else { \
|
||||
ZVAL_LONG(&args[1], bucket->h); \
|
||||
} \
|
||||
zend_call_function(&fci, &fci_cache);
|
||||
|
||||
#define ROW(range) \
|
||||
lxw_name_to_row(range)
|
||||
|
||||
#define ROWS(range) \
|
||||
lxw_name_to_row(range), lxw_name_to_row_2(range)
|
||||
|
||||
#define SHEET_LINE_INIT(obj_p) \
|
||||
obj_p->write_line = 0;
|
||||
|
||||
#define SHEET_LINE_ADD(obj_p) \
|
||||
++obj_p->write_line;
|
||||
|
||||
#define SHEET_LINE_SET(obj_p, current_line) \
|
||||
obj_p->write_line = current_line;
|
||||
|
||||
#define SHEET_CURRENT_LINE(obj_p) obj_p->write_line
|
||||
|
||||
#ifdef LXW_HAS_SNPRINTF
|
||||
#define lxw_snprintf snprintf
|
||||
#else
|
||||
#define lxw_snprintf __builtin_snprintf
|
||||
#endif
|
||||
|
||||
#if PHP_VERSION_ID < 80000
|
||||
#define PROP_OBJ(zv) (zv)
|
||||
#else
|
||||
#define PROP_OBJ(zv) Z_OBJ_P(zv)
|
||||
#endif
|
||||
|
||||
#if PHP_VERSION_ID < 80000
|
||||
#define Z_PARAM_STRING_OR_NULL(dest, dest_len) \
|
||||
Z_PARAM_STRING_EX(dest, dest_len, 1, 0)
|
||||
#define Z_PARAM_STR_OR_NULL(dest) \
|
||||
Z_PARAM_STR_EX(dest, 1, 0)
|
||||
#define Z_PARAM_RESOURCE_OR_NULL(dest) \
|
||||
Z_PARAM_RESOURCE_EX(dest, 1, 0)
|
||||
#define Z_PARAM_DOUBLE_OR_NULL(dest, is_null) \
|
||||
Z_PARAM_DOUBLE_EX(dest, is_null, 1, 0)
|
||||
#define Z_PARAM_LONG_OR_NULL(dest, is_null) \
|
||||
Z_PARAM_LONG_EX(dest, is_null, 1, 0)
|
||||
#define Z_PARAM_ARRAY_OR_NULL(dest) \
|
||||
Z_PARAM_ARRAY_EX(dest, 1, 0)
|
||||
#define Z_PARAM_BOOL_OR_NULL(dest, is_null) \
|
||||
Z_PARAM_BOOL_EX(dest, is_null, 1, 0)
|
||||
#endif
|
||||
|
||||
static inline xls_object *php_vtiful_xls_fetch_object(zend_object *obj) {
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (xls_object *)((char *)(obj) - XtOffsetOf(xls_object, zo));
|
||||
}
|
||||
|
||||
static inline format_object *php_vtiful_format_fetch_object(zend_object *obj) {
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (format_object *)((char *)(obj) - XtOffsetOf(format_object, zo));
|
||||
}
|
||||
|
||||
static inline chart_object *php_vtiful_chart_fetch_object(zend_object *obj) {
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (chart_object *)((char *)(obj) - XtOffsetOf(chart_object, zo));
|
||||
}
|
||||
|
||||
static inline validation_object *php_vtiful_validation_fetch_object(zend_object *obj) {
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (validation_object *)((char *)(obj) - XtOffsetOf(validation_object, zo));
|
||||
}
|
||||
|
||||
static inline rich_string_object *php_vtiful_rich_string_fetch_object(zend_object *obj) {
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (rich_string_object *)((char *)(obj) - XtOffsetOf(validation_object, zo));
|
||||
}
|
||||
|
||||
static inline void php_vtiful_close_resource(zend_object *obj) {
|
||||
if (obj == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
xls_object *intern = php_vtiful_xls_fetch_object(obj);
|
||||
|
||||
SHEET_LINE_INIT(intern);
|
||||
|
||||
if (intern->write_ptr.workbook != NULL) {
|
||||
lxw_workbook_free(intern->write_ptr.workbook);
|
||||
intern->write_ptr.workbook = NULL;
|
||||
}
|
||||
|
||||
if (intern->format_ptr.format != NULL) {
|
||||
intern->format_ptr.format = NULL;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_READER
|
||||
if (intern->read_ptr.sheet_t != NULL) {
|
||||
xlsxioread_sheet_close(intern->read_ptr.sheet_t);
|
||||
intern->read_ptr.sheet_t = NULL;
|
||||
}
|
||||
|
||||
if (intern->read_ptr.file_t != NULL) {
|
||||
xlsxioread_close(intern->read_ptr.file_t);
|
||||
intern->read_ptr.file_t = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
intern->read_ptr.data_type_default = READ_TYPE_EMPTY;
|
||||
}
|
||||
|
||||
lxw_format * zval_get_format(zval *handle);
|
||||
lxw_data_validation * zval_get_validation(zval *resource);
|
||||
lxw_rich_string_tuple * zval_get_rich_string(zval *resource);
|
||||
xls_resource_write_t * zval_get_resource(zval *handle);
|
||||
xls_resource_chart_t * zval_get_chart(zval *resource);
|
||||
|
||||
STATIC lxw_error _store_defined_name(lxw_workbook *self, const char *name, const char *app_name, const char *formula, int16_t index, uint8_t hidden);
|
||||
|
||||
STATIC int _compare_defined_names(lxw_defined_name *a, lxw_defined_name *b);
|
||||
|
||||
STATIC void _prepare_drawings(lxw_workbook *self);
|
||||
STATIC void _add_chart_cache_data(lxw_workbook *self);
|
||||
STATIC void _prepare_vml(lxw_workbook *self);
|
||||
STATIC void _prepare_defined_names(lxw_workbook *self);
|
||||
STATIC void _populate_range(lxw_workbook *self, lxw_series_range *range);
|
||||
STATIC void _populate_range_dimensions(lxw_workbook *self, lxw_series_range *range);
|
||||
|
||||
void comment_show(xls_resource_write_t *res);
|
||||
void hide_worksheet(xls_resource_write_t *res);
|
||||
void first_worksheet(xls_resource_write_t *res);
|
||||
void zoom(xls_resource_write_t *res, zend_long zoom);
|
||||
void paper(xls_resource_write_t *res, zend_long type);
|
||||
void gridlines(xls_resource_write_t *res, zend_long option);
|
||||
void printed_scale(xls_resource_write_t *res, zend_long scale);
|
||||
void auto_filter(zend_string *range, xls_resource_write_t *res);
|
||||
void protection(xls_resource_write_t *res, zend_string *password);
|
||||
void format_copy(lxw_format *new_format, lxw_format *other_format);
|
||||
void printed_direction(xls_resource_write_t *res, unsigned int direction);
|
||||
void xls_file_path(zend_string *file_name, zval *dir_path, zval *file_path);
|
||||
void freeze_panes(xls_resource_write_t *res, zend_long row, zend_long column);
|
||||
void margins(xls_resource_write_t *res, double left, double right, double top, double bottom);
|
||||
void set_row(zend_string *range, double height, xls_resource_write_t *res, lxw_format *format);
|
||||
void validation(xls_resource_write_t *res, zend_string *range, lxw_data_validation *validation);
|
||||
void set_column(zend_string *range, double width, xls_resource_write_t *res, lxw_format *format);
|
||||
void merge_cells(zend_string *range, zval *value, xls_resource_write_t *res, lxw_format *format);
|
||||
void comment_writer(zend_string *comment, zend_long row, zend_long columns, xls_resource_write_t *res);
|
||||
void call_object_method(zval *object, const char *function_name, uint32_t param_count, zval *params, zval *ret_val);
|
||||
void chart_writer(zend_long row, zend_long columns, xls_resource_chart_t *chart_resource, xls_resource_write_t *res);
|
||||
void worksheet_set_rows(lxw_row_t start, lxw_row_t end, double height, xls_resource_write_t *res, lxw_format *format);
|
||||
void image_writer(zval *value, zend_long row, zend_long columns, double width, double height, xls_resource_write_t *res);
|
||||
void formula_writer(zend_string *value, zend_long row, zend_long columns, xls_resource_write_t *res, lxw_format *format);
|
||||
void type_writer(zval *value, zend_long row, zend_long columns, xls_resource_write_t *res, zend_string *format, lxw_format *format_handle);
|
||||
void rich_string_writer(zend_long row, zend_long columns, xls_resource_write_t *res, zval *rich_strings, lxw_format *format);
|
||||
void datetime_writer(lxw_datetime *datetime, zend_long row, zend_long columns, zend_string *format, xls_resource_write_t *res, lxw_format *format_handle);
|
||||
void url_writer(zend_long row, zend_long columns, xls_resource_write_t *res, zend_string *url, zend_string *text, zend_string *tool_tip, lxw_format *format);
|
||||
|
||||
lxw_error workbook_file(xls_resource_write_t *self);
|
||||
|
||||
lxw_datetime timestamp_to_datetime(zend_long timestamp);
|
||||
zend_string* char_join_to_zend_str(const char *left, const char *right);
|
||||
zend_string* str_pick_up(zend_string *left, const char *right, size_t len);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user