* harbour/external/minizip/ioapi.h
! fixed FreeBSD and HAIKU builds
* harbour/src/rtl/fserr.c
* added translation for EPERM
* harbour/include/Makefile
+ harbour/include/hbapicom.h
* harbour/src/rtl/Makefile
+ harbour/src/rtl/hbcom.c
+ added Harbour multiplatform serial port C API (hb_com*() functions).
implemented code for *nixes, MS-Windows and OS2. DOS is not supported
yet. Please make test on different platforms.
; few notes about this code:
termios (*nix) based builds:
- reading LSR is not supported
- duration in break signal is fixed (at least 0.25 seconds, and not
more that 0.5 seconds)
- DTR/DSR hardware flow control is not supported
- setting error character is not supported
- discard card is supported only on few platforms
- checking input/output flow state is not supported
- if some platforms do not support some termio extensions then
compile time warnings TODO_* should be generated.
MS-Windows builds:
- discard card is not supported
OS2 builds:
- checking for input flow state is not supported
- discard card is not supported
In all builds not all RS-232 hardware flags/state are available.
OS2 build supports most of them,
This code needs to be extensively tested. I wrote it without any
serious tests. Especially OS2 builds should be verified by OS2
users. I wrote this port using only documentation which OS2 API
available in the Internet.
DOS is not supported yet though it's possible to compile termio code
for *nixes with DJGPP. Anyhow it would be very nice if we can add
our own DOS serial port code. I would like to ask if any of you
has low level serial port code in C for DOS (i.e. used with Clipper)
and can send it to us so we can use it with Harbour. I have my
own serial port library for Clipper but it's written in assembler
and it's much wider then sth what we need so it cannot be easy
adopted for Harbour.
* harbour/contrib/hbct/Makefile
+ harbour/contrib/hbct/ctcom1.c
+ harbour/contrib/hbct/ctcom.ch
+ harbour/contrib/hbct/ctcom2.c
+ added CT3 compatible COM_*() functions.
+ added CT3 compatible XMOBLOCK(), XMOCHECK(), ZEROINSERT() and
ZEROREMOVE() functions.
+ added new CT COM function:
COM_DEVNAME( <nComPort> [, <cNewName> ] ) -> <cPrevName>
which can be used to specify device name for given port in modern
systems which do not give direct hardware access for the process.
; few notes about CT3 COM_*() functions in Harbour.
In COM_OPEN() only 1-st parameter is significant, input/output buffer
sizes and trap mode parameters are ignored. In modern OS-es such
functionality is controlled by OS and usually buffered read/write
is always enabled. The sizes of IO buffers can be used only as
suggested IO buffer size for OS in some systems. It's possible that
these additional parameters will be used in DOS builds in the future.
COM_READ() does not support 2-nd parameter <lNoDelete>. It can be
implemented but because we do not have direct access to OS buffers
then we will have to emulate it ourselves what is rather inefficient.
Anyhow I can implement it if users think it's critical.
In COM_CRC() I fixed few CT3 bugs so it's not bug compatible with CT3,
i.e. it works correctly for 8 bit and smaller polynomials instead of
returning 0 or supports much larger polynomials up to 64bits.
For 16/17 bit polynomials it gives the same results as CT3 so for most
common usage it should be binary compatible with CT3.
In ZEROREMOVE() I fixed decoding some wrong CCITT strings which does
not have trailing 0 so it returns empty string "" for such corrupted
data. If someone needs original CT3 behavior for some broken code then
is can be enabled by HB_CT3_ZEROREMOVE_BUG macro.
I haven't implemented few functions.
COM_GETIO(), COM_SETIO(), COM_GETIRQ(), COM_SETIRQ() are not portable
and can be implemented only for really few platforms, i.e. for DOS
when/if we add support for serial ports to Harbour DOS builds.
Similar functionality for all other platforms gives our new function
COM_DEVNAME().
COM_KEY(), COM_SKEY() and COM_EVENT() are also not implemented.
To make them well we should add support for asynchronous events to HVM
and such extension is still unavailable. Some simulation can be
implemented using idle tasks but this can be done also by final
Harbour users so I decided to not make it.
Please test it - I've never used CT3 COM_*() API with Clipper.
* harbour/contrib/hbct/dummy.c
* removed dummy CT3 serial communication functions
; such files with dummy functions introduces very serious problems for
user code because they do not respect original module granularity
effectively breaking overloading only chosen functions so it breaks
also some real Clipper code.
209 lines
6.8 KiB
C
209 lines
6.8 KiB
C
/* 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(__MSDOS__) || defined(MSDOS)) && \
|
|
!(defined(OS_2) || defined(__OS2__) || defined(OS2))
|
|
|
|
/* Linux needs this to support file operation on files larger then 4+GB
|
|
* on 32bit platforms
|
|
* But might need better if/def to select just the platforms that needs them.
|
|
*/
|
|
#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"
|
|
|
|
#include "hbsetup.h"
|
|
|
|
#if defined( __BORLANDC__ ) || \
|
|
defined( __WATCOMC__ ) || \
|
|
defined( __MINGW32CE__ ) || \
|
|
defined( HB_OS_BSD ) || \
|
|
defined( HB_OS_DARWIN ) || \
|
|
defined( HB_OS_HAIKU )
|
|
# define USE_FILE32API
|
|
#endif
|
|
|
|
#if defined(USE_FILE32API)
|
|
#define fopen64 fopen
|
|
#define ftello64 ftell
|
|
#define fseeko64 fseek
|
|
#else
|
|
#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
|
|
|
|
|
|
#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
|