2010-12-12 11:50 UTC+0200 Petr Chornyj (myorg63 at mail.ru)
* contrib/hblzf/3rd/liblzf/Changes
* contrib/hblzf/3rd/liblzf/crc32.h
* contrib/hblzf/3rd/liblzf/LICENSE
* contrib/hblzf/3rd/liblzf/lzf.h
* contrib/hblzf/3rd/liblzf/lzf_c.c
* contrib/hblzf/3rd/liblzf/lzf_d.c
* contrib/hblzf/3rd/liblzf/lzfP.h
* contrib/hblzf/3rd/liblzf/README
+ Set svn:eol-style=native
* contrib/hblzf/3rd/liblzf/lzf.hbc
* contrib/hblzf/3rd/liblzf/lzf.hbp
* contrib/hblzf/hblzf.c
* contrib/hblzf/hblzf.hbc
* contrib/hblzf/hblzf.hbp
* contrib/hblzf/tests/hbmk.hbm
* contrib/hblzf/tests/test.prg
* contrib/hblzf/tests/test2.prg
! Fixed SVN ID (I hope) and set svn:eol-style=native
This commit is contained in:
@@ -16,6 +16,26 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2010-12-12 11:50 UTC+0200 Petr Chornyj (myorg63 at mail.ru)
|
||||
* contrib/hblzf/3rd/liblzf/Changes
|
||||
* contrib/hblzf/3rd/liblzf/crc32.h
|
||||
* contrib/hblzf/3rd/liblzf/LICENSE
|
||||
* contrib/hblzf/3rd/liblzf/lzf.h
|
||||
* contrib/hblzf/3rd/liblzf/lzf_c.c
|
||||
* contrib/hblzf/3rd/liblzf/lzf_d.c
|
||||
* contrib/hblzf/3rd/liblzf/lzfP.h
|
||||
* contrib/hblzf/3rd/liblzf/README
|
||||
+ Set svn:eol-style=native
|
||||
* contrib/hblzf/3rd/liblzf/lzf.hbc
|
||||
* contrib/hblzf/3rd/liblzf/lzf.hbp
|
||||
* contrib/hblzf/hblzf.c
|
||||
* contrib/hblzf/hblzf.hbc
|
||||
* contrib/hblzf/hblzf.hbp
|
||||
* contrib/hblzf/tests/hbmk.hbm
|
||||
* contrib/hblzf/tests/test.prg
|
||||
* contrib/hblzf/tests/test2.prg
|
||||
! Fixed SVN ID (I hope) and set svn:eol-style=native
|
||||
|
||||
2010-12-12 00:56 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbqt/hbqt_hbmk2_plugin.hbs
|
||||
+ Showing -v output (version string) of detected QT tools in -info mode.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: lzf.hbc 15773 2010-12-08 16:24:57Z petr_ch $
|
||||
#
|
||||
|
||||
libs=${hb_name}${__HB_DYN__}
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
libs=${hb_name}${__HB_DYN__}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
#
|
||||
# $Id: lzf.hbp 15773 2010-12-08 16:24:57Z petr_ch $
|
||||
#
|
||||
|
||||
#-stop
|
||||
|
||||
-hblib
|
||||
-inc
|
||||
|
||||
-o${hb_targetname}
|
||||
|
||||
-warn=low
|
||||
-cpp=no
|
||||
|
||||
# See lzfP.h for more
|
||||
-cflag=-DVERY_FAST=1
|
||||
|
||||
lzf_c.c
|
||||
lzf_d.c
|
||||
|
||||
# ORIGIN http://liblzf.plan9.de
|
||||
# VER 3.5
|
||||
# URL http://dist.schmorp.de/liblzf/liblzf-3.5.tar.gz
|
||||
# DIFF
|
||||
#
|
||||
# MAP LICENSE
|
||||
# MAP Changes
|
||||
# MAP README
|
||||
# MAP crc32.h
|
||||
# MAP lzf.h
|
||||
# MAP lzf_c.c
|
||||
# MAP lzf_d.c
|
||||
# MAP lzfP.h
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
#-stop
|
||||
|
||||
-hblib
|
||||
-inc
|
||||
|
||||
-o${hb_targetname}
|
||||
|
||||
-warn=low
|
||||
-cpp=no
|
||||
|
||||
# See lzfP.h for more
|
||||
-cflag=-DVERY_FAST=1
|
||||
|
||||
lzf_c.c
|
||||
lzf_d.c
|
||||
|
||||
# ORIGIN http://liblzf.plan9.de
|
||||
# VER 3.5
|
||||
# URL http://dist.schmorp.de/liblzf/liblzf-3.5.tar.gz
|
||||
# DIFF
|
||||
#
|
||||
# MAP LICENSE
|
||||
# MAP Changes
|
||||
# MAP README
|
||||
# MAP crc32.h
|
||||
# MAP lzf.h
|
||||
# MAP lzf_c.c
|
||||
# MAP lzf_d.c
|
||||
# MAP lzfP.h
|
||||
|
||||
@@ -1,234 +1,234 @@
|
||||
/*
|
||||
* $Id: hblzf.c 15096 2010-12-08 14:03:07Z petr_ch $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* LZF functions wrapper
|
||||
*
|
||||
* Copyright 2010 Petr Chornyj <myorg63@mail.ru>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* TOFIX: Some platforms don't have this. Build breaker. */
|
||||
#include <errno.h>
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbapiitm.h"
|
||||
|
||||
#include "lzf.h"
|
||||
#include "lzfP.h"
|
||||
|
||||
#include "hblzf.ch"
|
||||
|
||||
static HB_SIZE hb_lzf_compressbound( HB_SIZE nLen )
|
||||
{
|
||||
HB_SIZE nBuffSize = ( HB_SIZE ) ( nLen * 1.04 + 1 );
|
||||
return ( nBuffSize >= 32 ) ? nBuffSize : 32;
|
||||
}
|
||||
|
||||
HB_FUNC( HB_LZF_COMPRESSBOUND )
|
||||
{
|
||||
if( HB_ISCHAR( 1 ) || HB_ISNUM( 1 ) )
|
||||
{
|
||||
HB_SIZE nLen = HB_ISCHAR( 1 ) ? hb_parclen( 1 ) : hb_parns( 1 );
|
||||
hb_retns( hb_lzf_compressbound( nLen ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* Return a LZF_VERSION, API version */
|
||||
HB_FUNC( HB_LZF_VERSION )
|
||||
{
|
||||
hb_retni( LZF_VERSION );
|
||||
}
|
||||
|
||||
/* Return if lzf was optimized for speed (or for compression) */
|
||||
HB_FUNC( HB_LZF_OPTIMIZED_FOR_SPEED )
|
||||
{
|
||||
#if ULTRA_FAST
|
||||
hb_retl( HB_TRUE );
|
||||
#else
|
||||
hb_retl( HB_FALSE );
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return a string compressed with LZF */
|
||||
HB_FUNC( HB_LZF_COMPRESS )
|
||||
{
|
||||
PHB_ITEM pArg = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pArg )
|
||||
{
|
||||
HB_SIZE in_len = hb_itemGetCLen( pArg );
|
||||
|
||||
if( in_len )
|
||||
{
|
||||
PHB_ITEM pBuffer = HB_ISBYREF( 2 ) ? hb_param( 2, HB_IT_STRING ) : NULL;
|
||||
const char * in_data = hb_itemGetCPtr( pArg );
|
||||
char * out_data;
|
||||
HB_SIZE out_len;
|
||||
|
||||
if( pBuffer )
|
||||
{
|
||||
if( ! hb_itemGetWriteCL( pBuffer, &out_data, &out_len ) )
|
||||
out_data = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
out_len = ( HB_ISNUM( 2 ) && hb_parns( 2 ) >= 0 ) ?
|
||||
hb_parns( 2 ) :
|
||||
hb_lzf_compressbound( in_len );
|
||||
|
||||
out_data = ( char * ) hb_xalloc( out_len + 1 );
|
||||
}
|
||||
|
||||
if( out_data )
|
||||
{
|
||||
unsigned int uiResult = lzf_compress( in_data, in_len, out_data, out_len );
|
||||
|
||||
if( uiResult != 0 )
|
||||
{
|
||||
if( pBuffer )
|
||||
hb_retclen( out_data, uiResult );
|
||||
else
|
||||
hb_retclen_buffer( out_data, uiResult );
|
||||
|
||||
hb_storni( HB_LZF_OK, 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ! pBuffer )
|
||||
hb_xfree( out_data );
|
||||
|
||||
hb_storni( HB_LZF_BUF_ERROR, 3 );
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_storni( HB_LZF_MEM_ERROR, 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_retc_null();
|
||||
hb_storni( HB_LZF_OK, 3 );
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* Return a string decompressed with LZF */
|
||||
HB_FUNC( HB_LZF_DECOMPRESS )
|
||||
{
|
||||
PHB_ITEM pArg = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pArg )
|
||||
{
|
||||
HB_SIZE in_len = hb_itemGetCLen( pArg );
|
||||
|
||||
if( in_len )
|
||||
{
|
||||
PHB_ITEM pBuffer = HB_ISBYREF( 2 ) ? hb_param( 2, HB_IT_STRING ) : NULL;
|
||||
const char * in_data = hb_itemGetCPtr( pArg );
|
||||
char * buffer;
|
||||
HB_SIZE buffer_size;
|
||||
|
||||
if( pBuffer )
|
||||
{
|
||||
if( ! hb_itemGetWriteCL( pBuffer, &buffer, &buffer_size ) )
|
||||
buffer = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer_size = ( HB_ISNUM( 2 ) && hb_parns( 2 ) >= 0 ) ?
|
||||
hb_parns( 2 ) : HB_LZF_DEFAULT_BUFFSIZE;
|
||||
|
||||
buffer = ( char * ) hb_xalloc( buffer_size + 1 );
|
||||
}
|
||||
|
||||
if( buffer && buffer_size )
|
||||
{
|
||||
HB_SIZE i = 1;
|
||||
unsigned int uiResult;
|
||||
|
||||
do
|
||||
{
|
||||
buffer_size *= i++;
|
||||
buffer = ( char * ) hb_xrealloc( buffer, buffer_size );
|
||||
|
||||
uiResult = lzf_decompress( in_data, in_len, buffer, buffer_size );
|
||||
}
|
||||
while( uiResult == 0 && errno == E2BIG );
|
||||
|
||||
if( uiResult == 0 )
|
||||
{
|
||||
if( errno == EINVAL )
|
||||
hb_storni( HB_LZF_DATA_CORRUPTED, 3 );
|
||||
|
||||
if( ! pBuffer )
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pBuffer )
|
||||
hb_retclen( buffer, uiResult );
|
||||
else
|
||||
hb_retclen_buffer( buffer, uiResult );
|
||||
|
||||
hb_storni( HB_LZF_OK, 3 );
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_storni( ( buffer_size ) ? HB_LZF_BUF_ERROR : HB_LZF_MEM_ERROR, 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_retc_null();
|
||||
hb_storni( HB_LZF_OK, 3 );
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* LZF functions wrapper
|
||||
*
|
||||
* Copyright 2010 Petr Chornyj <myorg63@mail.ru>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* TOFIX: Some platforms don't have this. Build breaker. */
|
||||
#include <errno.h>
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbapiitm.h"
|
||||
|
||||
#include "lzf.h"
|
||||
#include "lzfP.h"
|
||||
|
||||
#include "hblzf.ch"
|
||||
|
||||
static HB_SIZE hb_lzf_compressbound( HB_SIZE nLen )
|
||||
{
|
||||
HB_SIZE nBuffSize = ( HB_SIZE ) ( nLen * 1.04 + 1 );
|
||||
return ( nBuffSize >= 32 ) ? nBuffSize : 32;
|
||||
}
|
||||
|
||||
HB_FUNC( HB_LZF_COMPRESSBOUND )
|
||||
{
|
||||
if( HB_ISCHAR( 1 ) || HB_ISNUM( 1 ) )
|
||||
{
|
||||
HB_SIZE nLen = HB_ISCHAR( 1 ) ? hb_parclen( 1 ) : hb_parns( 1 );
|
||||
hb_retns( hb_lzf_compressbound( nLen ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* Return a LZF_VERSION, API version */
|
||||
HB_FUNC( HB_LZF_VERSION )
|
||||
{
|
||||
hb_retni( LZF_VERSION );
|
||||
}
|
||||
|
||||
/* Return if lzf was optimized for speed (or for compression) */
|
||||
HB_FUNC( HB_LZF_OPTIMIZED_FOR_SPEED )
|
||||
{
|
||||
#if ULTRA_FAST
|
||||
hb_retl( HB_TRUE );
|
||||
#else
|
||||
hb_retl( HB_FALSE );
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return a string compressed with LZF */
|
||||
HB_FUNC( HB_LZF_COMPRESS )
|
||||
{
|
||||
PHB_ITEM pArg = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pArg )
|
||||
{
|
||||
HB_SIZE in_len = hb_itemGetCLen( pArg );
|
||||
|
||||
if( in_len )
|
||||
{
|
||||
PHB_ITEM pBuffer = HB_ISBYREF( 2 ) ? hb_param( 2, HB_IT_STRING ) : NULL;
|
||||
const char * in_data = hb_itemGetCPtr( pArg );
|
||||
char * out_data;
|
||||
HB_SIZE out_len;
|
||||
|
||||
if( pBuffer )
|
||||
{
|
||||
if( ! hb_itemGetWriteCL( pBuffer, &out_data, &out_len ) )
|
||||
out_data = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
out_len = ( HB_ISNUM( 2 ) && hb_parns( 2 ) >= 0 ) ?
|
||||
hb_parns( 2 ) :
|
||||
hb_lzf_compressbound( in_len );
|
||||
|
||||
out_data = ( char * ) hb_xalloc( out_len + 1 );
|
||||
}
|
||||
|
||||
if( out_data )
|
||||
{
|
||||
unsigned int uiResult = lzf_compress( in_data, in_len, out_data, out_len );
|
||||
|
||||
if( uiResult != 0 )
|
||||
{
|
||||
if( pBuffer )
|
||||
hb_retclen( out_data, uiResult );
|
||||
else
|
||||
hb_retclen_buffer( out_data, uiResult );
|
||||
|
||||
hb_storni( HB_LZF_OK, 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ! pBuffer )
|
||||
hb_xfree( out_data );
|
||||
|
||||
hb_storni( HB_LZF_BUF_ERROR, 3 );
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_storni( HB_LZF_MEM_ERROR, 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_retc_null();
|
||||
hb_storni( HB_LZF_OK, 3 );
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* Return a string decompressed with LZF */
|
||||
HB_FUNC( HB_LZF_DECOMPRESS )
|
||||
{
|
||||
PHB_ITEM pArg = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pArg )
|
||||
{
|
||||
HB_SIZE in_len = hb_itemGetCLen( pArg );
|
||||
|
||||
if( in_len )
|
||||
{
|
||||
PHB_ITEM pBuffer = HB_ISBYREF( 2 ) ? hb_param( 2, HB_IT_STRING ) : NULL;
|
||||
const char * in_data = hb_itemGetCPtr( pArg );
|
||||
char * buffer;
|
||||
HB_SIZE buffer_size;
|
||||
|
||||
if( pBuffer )
|
||||
{
|
||||
if( ! hb_itemGetWriteCL( pBuffer, &buffer, &buffer_size ) )
|
||||
buffer = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer_size = ( HB_ISNUM( 2 ) && hb_parns( 2 ) >= 0 ) ?
|
||||
hb_parns( 2 ) : HB_LZF_DEFAULT_BUFFSIZE;
|
||||
|
||||
buffer = ( char * ) hb_xalloc( buffer_size + 1 );
|
||||
}
|
||||
|
||||
if( buffer && buffer_size )
|
||||
{
|
||||
HB_SIZE i = 1;
|
||||
unsigned int uiResult;
|
||||
|
||||
do
|
||||
{
|
||||
buffer_size *= i++;
|
||||
buffer = ( char * ) hb_xrealloc( buffer, buffer_size );
|
||||
|
||||
uiResult = lzf_decompress( in_data, in_len, buffer, buffer_size );
|
||||
}
|
||||
while( uiResult == 0 && errno == E2BIG );
|
||||
|
||||
if( uiResult == 0 )
|
||||
{
|
||||
if( errno == EINVAL )
|
||||
hb_storni( HB_LZF_DATA_CORRUPTED, 3 );
|
||||
|
||||
if( ! pBuffer )
|
||||
hb_xfree( buffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pBuffer )
|
||||
hb_retclen( buffer, uiResult );
|
||||
else
|
||||
hb_retclen_buffer( buffer, uiResult );
|
||||
|
||||
hb_storni( HB_LZF_OK, 3 );
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_storni( ( buffer_size ) ? HB_LZF_BUF_ERROR : HB_LZF_MEM_ERROR, 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_retc_null();
|
||||
hb_storni( HB_LZF_OK, 3 );
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#
|
||||
# $Id: hblzf.hbc 15773 2010-12-08 16:24:57Z petr_ch $
|
||||
#
|
||||
|
||||
incpaths=.
|
||||
|
||||
libs=${hb_name}${__HB_DYN__}
|
||||
libs=3rd/liblzf/lzf.hbc
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
incpaths=.
|
||||
|
||||
libs=${hb_name}${__HB_DYN__}
|
||||
libs=3rd/liblzf/lzf.hbc
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#
|
||||
# $Id: hblzf.hbp 15781 2010-12-08 00:40:00Z petr_ch $
|
||||
#
|
||||
|
||||
-hblib
|
||||
-inc
|
||||
|
||||
-o${hb_name}
|
||||
|
||||
-w3 -es2
|
||||
|
||||
-depkeyhead=lzf:lzf.h
|
||||
-depcontrol=lzf:local{HB_BUILD_3RDEXT='no'}
|
||||
-depcontrol=lzf:${HB_WITH_LZF}
|
||||
-depincpath=lzf:/usr/include
|
||||
-depincpathlocal=lzf:3rd/liblzf
|
||||
-depfinish=lzf
|
||||
|
||||
-instfile=inc:hblzf.ch
|
||||
|
||||
hblzf.c
|
||||
|
||||
3rd/liblzf/lzf.hbc{HBMK_HAS_LZF_LOCAL}
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
-hblib
|
||||
-inc
|
||||
|
||||
-o${hb_name}
|
||||
|
||||
-w3 -es2
|
||||
|
||||
-depkeyhead=lzf:lzf.h
|
||||
-depcontrol=lzf:local{HB_BUILD_3RDEXT='no'}
|
||||
-depcontrol=lzf:${HB_WITH_LZF}
|
||||
-depincpath=lzf:/usr/include
|
||||
-depincpathlocal=lzf:3rd/liblzf
|
||||
-depfinish=lzf
|
||||
|
||||
-instfile=inc:hblzf.ch
|
||||
|
||||
hblzf.c
|
||||
|
||||
3rd/liblzf/lzf.hbc{HBMK_HAS_LZF_LOCAL}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# $Id: hbmk.hbm 14194 2010-12-07 09:50:12Z petr_ch $
|
||||
#
|
||||
|
||||
../hblzf.hbc
|
||||
|
||||
-w3 -es2
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
../hblzf.hbc
|
||||
|
||||
-w3 -es2
|
||||
|
||||
@@ -1,138 +1,138 @@
|
||||
/*
|
||||
* $Id: test.prg 14179 2010-12-08 23:34:33Z petr_ch $
|
||||
*/
|
||||
|
||||
#include "simpleio.ch"
|
||||
|
||||
#include "hblzf.ch"
|
||||
|
||||
#define TEST_STRING "This is test of LZF extension"
|
||||
#define _NREPL_ 128
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL cStr, str_compressed, str_decompressed
|
||||
LOCAL b64_expected_result := "BFRoaXMgIAIUdGVzdCBvZiBMWkYgZXh0ZW5zaW9u"
|
||||
LOCAL nLen, nResult := 0
|
||||
|
||||
? "LZF Api version is", ;
|
||||
hb_ntos( hb_lzf_version() ) + "(0x" + hb_numtohex( hb_lzf_version() ) +")"
|
||||
? "LibLZF optimized for", iif( hb_lzf_optimized_for_speed(), "speed.", "compression." )
|
||||
|
||||
? "--- test 1 ---"
|
||||
/*
|
||||
If the output buffer is not large enough or any error occurs
|
||||
hb_lzf_compress return NIL
|
||||
*/
|
||||
cStr := TEST_STRING
|
||||
str_compressed := hb_lzf_compress( cStr, 15, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 2 ---"
|
||||
cStr := TEST_STRING
|
||||
str_compressed := Space( 15 )
|
||||
str_compressed := hb_lzf_compress( cStr, @str_compressed, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 3 ---"
|
||||
nLen := hb_lzf_compressBound( cStr )
|
||||
|
||||
cStr := TEST_STRING
|
||||
str_compressed := hb_lzf_compress( cStr, nLen, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
|
||||
? iif( hb_base64encode( str_compressed ) == b64_expected_result, "OK!", "not OK!" )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 4 ---"
|
||||
nLen := hb_lzf_compressBound( cStr )
|
||||
str_compressed := Space( nLen )
|
||||
|
||||
cStr := TEST_STRING
|
||||
str_compressed := hb_lzf_compress( cStr, @str_compressed, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
|
||||
? iif( hb_base64encode( str_compressed ) == b64_expected_result, "OK!", "not OK!" )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 5 ---"
|
||||
cStr := Replicate( TEST_STRING, _NREPL_ )
|
||||
str_compressed := hb_lzf_compress( cStr, NIL, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 6 ---"
|
||||
str_decompressed := hb_lzf_decompress( str_compressed, NIL, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_DATA_CORRUPTED
|
||||
? "LZF decompression failed, compressed data corrupted"
|
||||
ELSE
|
||||
? iif( cStr == str_decompressed, "OK!", "not OK!" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 7 ---"
|
||||
cStr := Replicate( TEST_STRING, _NREPL_ )
|
||||
str_compressed := hb_zcompress( cStr, NIL, @nResult )
|
||||
|
||||
str_decompressed := hb_lzf_decompress( str_compressed, NIL, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_DATA_CORRUPTED
|
||||
? "LZF decompression failed, compressed data corrupted!"
|
||||
ELSE
|
||||
? iif( cStr == str_decompressed, "OK!", "not OK!" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 8 ---"
|
||||
cStr := Replicate( TEST_STRING, _NREPL_ )
|
||||
str_compressed := hb_lzf_compress( cStr, NIL, @nResult )
|
||||
|
||||
str_decompressed := Space( 4096 )
|
||||
str_decompressed := hb_lzf_decompress( str_compressed, @str_decompressed, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_DATA_CORRUPTED
|
||||
? "LZF decompression failed, compressed data corrupted!"
|
||||
ELSE
|
||||
? iif( cStr == str_decompressed, "OK!", "not OK!" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 9 ---"
|
||||
cStr := Replicate( TEST_STRING, _NREPL_ )
|
||||
str_compressed := hb_lzf_compress( cStr, NIL, @nResult )
|
||||
|
||||
str_decompressed := ""
|
||||
str_decompressed := hb_lzf_decompress( str_compressed, @str_decompressed, @nResult )
|
||||
|
||||
IF nResult != HB_LZF_OK
|
||||
? "hb_lzf_decompress() return", ;
|
||||
iif( nResult == HB_LZF_MEM_ERROR, "HB_LZF_MEM_ERROR", hb_ntos( nResult ) )
|
||||
ELSE
|
||||
? iif( cStr == str_decompressed, "OK!", "not OK!" )
|
||||
ENDIF
|
||||
|
||||
RETURN
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "simpleio.ch"
|
||||
|
||||
#include "hblzf.ch"
|
||||
|
||||
#define TEST_STRING "This is test of LZF extension"
|
||||
#define _NREPL_ 128
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL cStr, str_compressed, str_decompressed
|
||||
LOCAL b64_expected_result := "BFRoaXMgIAIUdGVzdCBvZiBMWkYgZXh0ZW5zaW9u"
|
||||
LOCAL nLen, nResult := 0
|
||||
|
||||
? "LZF Api version is", ;
|
||||
hb_ntos( hb_lzf_version() ) + "(0x" + hb_numtohex( hb_lzf_version() ) +")"
|
||||
? "LibLZF optimized for", iif( hb_lzf_optimized_for_speed(), "speed.", "compression." )
|
||||
|
||||
? "--- test 1 ---"
|
||||
/*
|
||||
If the output buffer is not large enough or any error occurs
|
||||
hb_lzf_compress return NIL
|
||||
*/
|
||||
cStr := TEST_STRING
|
||||
str_compressed := hb_lzf_compress( cStr, 15, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 2 ---"
|
||||
cStr := TEST_STRING
|
||||
str_compressed := Space( 15 )
|
||||
str_compressed := hb_lzf_compress( cStr, @str_compressed, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 3 ---"
|
||||
nLen := hb_lzf_compressBound( cStr )
|
||||
|
||||
cStr := TEST_STRING
|
||||
str_compressed := hb_lzf_compress( cStr, nLen, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
|
||||
? iif( hb_base64encode( str_compressed ) == b64_expected_result, "OK!", "not OK!" )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 4 ---"
|
||||
nLen := hb_lzf_compressBound( cStr )
|
||||
str_compressed := Space( nLen )
|
||||
|
||||
cStr := TEST_STRING
|
||||
str_compressed := hb_lzf_compress( cStr, @str_compressed, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
|
||||
? iif( hb_base64encode( str_compressed ) == b64_expected_result, "OK!", "not OK!" )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 5 ---"
|
||||
cStr := Replicate( TEST_STRING, _NREPL_ )
|
||||
str_compressed := hb_lzf_compress( cStr, NIL, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_OK
|
||||
? "Lenght of a string is", hb_ntos( Len( cStr ) )
|
||||
? "Lenght of a compressed string is", hb_ntos( Len( str_compressed ) )
|
||||
ELSE
|
||||
? "hb_lzf_compress() return ", iif( nResult == HB_LZF_BUF_ERROR, "LZF_BUF_ERROR", "LZF_MEM_ERROR" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 6 ---"
|
||||
str_decompressed := hb_lzf_decompress( str_compressed, NIL, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_DATA_CORRUPTED
|
||||
? "LZF decompression failed, compressed data corrupted"
|
||||
ELSE
|
||||
? iif( cStr == str_decompressed, "OK!", "not OK!" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 7 ---"
|
||||
cStr := Replicate( TEST_STRING, _NREPL_ )
|
||||
str_compressed := hb_zcompress( cStr, NIL, @nResult )
|
||||
|
||||
str_decompressed := hb_lzf_decompress( str_compressed, NIL, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_DATA_CORRUPTED
|
||||
? "LZF decompression failed, compressed data corrupted!"
|
||||
ELSE
|
||||
? iif( cStr == str_decompressed, "OK!", "not OK!" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 8 ---"
|
||||
cStr := Replicate( TEST_STRING, _NREPL_ )
|
||||
str_compressed := hb_lzf_compress( cStr, NIL, @nResult )
|
||||
|
||||
str_decompressed := Space( 4096 )
|
||||
str_decompressed := hb_lzf_decompress( str_compressed, @str_decompressed, @nResult )
|
||||
|
||||
IF nResult == HB_LZF_DATA_CORRUPTED
|
||||
? "LZF decompression failed, compressed data corrupted!"
|
||||
ELSE
|
||||
? iif( cStr == str_decompressed, "OK!", "not OK!" )
|
||||
ENDIF
|
||||
|
||||
? "--- test 9 ---"
|
||||
cStr := Replicate( TEST_STRING, _NREPL_ )
|
||||
str_compressed := hb_lzf_compress( cStr, NIL, @nResult )
|
||||
|
||||
str_decompressed := ""
|
||||
str_decompressed := hb_lzf_decompress( str_compressed, @str_decompressed, @nResult )
|
||||
|
||||
IF nResult != HB_LZF_OK
|
||||
? "hb_lzf_decompress() return", ;
|
||||
iif( nResult == HB_LZF_MEM_ERROR, "HB_LZF_MEM_ERROR", hb_ntos( nResult ) )
|
||||
ELSE
|
||||
? iif( cStr == str_decompressed, "OK!", "not OK!" )
|
||||
ENDIF
|
||||
|
||||
RETURN
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
/*
|
||||
* $Id: test2.prg 14179 2010-12-08 23:34:33Z petr_ch $
|
||||
*/
|
||||
|
||||
/* hbmk2 testz.prg -lhbbz2 -lbz2 -lhblzf -llzf -es2 -w3 */
|
||||
|
||||
#include "simpleio.ch"
|
||||
|
||||
#define _NREPL_ 50
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL cStr := Replicate( hb_memoRead( hb_argv( 0 ) ), _NREPL_ )
|
||||
LOCAL aCompressedData := { NIL, NIL, NIL, NIL }
|
||||
LOCAL hFuncs := { ;
|
||||
"GZIP" => @hb_gzCompress(), ;
|
||||
"ZLIB" => @hb_zCompress(), ;
|
||||
"BZ2 " => @hb_bz2_compress(), ;
|
||||
"LZF " => @hb_lzf_compress();
|
||||
}
|
||||
LOCAL hFuncs2 := { ;
|
||||
"GZIP" => @hb_zUncompress(), ;
|
||||
"ZLIB" => @hb_zUncompress(), ;
|
||||
"BZ2 " => @hb_bz2_uncompress(), ;
|
||||
"LZF " => @hb_lzf_decompress();
|
||||
}
|
||||
|
||||
MakeTest( @hFuncs, @aCompressedData, @cStr )
|
||||
MakeTest( @hFuncs2, @aCompressedData )
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC PROCEDURE MakeTest( ... )
|
||||
LOCAL e, e2, cRes, cFmt
|
||||
LOCAL nResult := 0
|
||||
LOCAL nBegin, nEnd
|
||||
LOCAL lCmp := ( PCount() > 2 )
|
||||
|
||||
FOR EACH e, e2 IN hb_pValue( 1 ), hb_pValue( 2 )
|
||||
nBegin := hb_secondsCPU()
|
||||
cRes := Eval( e:__enumValue(), iif( lCmp, hb_pValue( 3 ), e2 ), NIL, @nResult )
|
||||
nEnd := hb_secondsCPU()
|
||||
IF lCmp
|
||||
e2 := cRes
|
||||
ENDIF
|
||||
cFmt := hb_strFormat( ;
|
||||
"%s: %d -> %d, Ratio %.2f%%, Times %.2f", ;
|
||||
e:__enumKey(), ;
|
||||
Len( IIf( lCmp, hb_pValue( 3 ), e2 ) ), Len( cRes ), ;
|
||||
( Len( cRes ) / Len( IIf( lCmp, hb_pValue( 3 ), e2 ) ) ) * 100, ;
|
||||
nEnd - nBegin;
|
||||
)
|
||||
? cFmt
|
||||
NEXT
|
||||
?
|
||||
RETURN
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/* hbmk2 testz.prg -lhbbz2 -lbz2 -lhblzf -llzf -es2 -w3 */
|
||||
|
||||
#include "simpleio.ch"
|
||||
|
||||
#define _NREPL_ 50
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL cStr := Replicate( hb_memoRead( hb_argv( 0 ) ), _NREPL_ )
|
||||
LOCAL aCompressedData := { NIL, NIL, NIL, NIL }
|
||||
LOCAL hFuncs := { ;
|
||||
"GZIP" => @hb_gzCompress(), ;
|
||||
"ZLIB" => @hb_zCompress(), ;
|
||||
"BZ2 " => @hb_bz2_compress(), ;
|
||||
"LZF " => @hb_lzf_compress();
|
||||
}
|
||||
LOCAL hFuncs2 := { ;
|
||||
"GZIP" => @hb_zUncompress(), ;
|
||||
"ZLIB" => @hb_zUncompress(), ;
|
||||
"BZ2 " => @hb_bz2_uncompress(), ;
|
||||
"LZF " => @hb_lzf_decompress();
|
||||
}
|
||||
|
||||
MakeTest( @hFuncs, @aCompressedData, @cStr )
|
||||
MakeTest( @hFuncs2, @aCompressedData )
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC PROCEDURE MakeTest( ... )
|
||||
LOCAL e, e2, cRes, cFmt
|
||||
LOCAL nResult := 0
|
||||
LOCAL nBegin, nEnd
|
||||
LOCAL lCmp := ( PCount() > 2 )
|
||||
|
||||
FOR EACH e, e2 IN hb_pValue( 1 ), hb_pValue( 2 )
|
||||
nBegin := hb_secondsCPU()
|
||||
cRes := Eval( e:__enumValue(), iif( lCmp, hb_pValue( 3 ), e2 ), NIL, @nResult )
|
||||
nEnd := hb_secondsCPU()
|
||||
IF lCmp
|
||||
e2 := cRes
|
||||
ENDIF
|
||||
cFmt := hb_strFormat( ;
|
||||
"%s: %d -> %d, Ratio %.2f%%, Times %.2f", ;
|
||||
e:__enumKey(), ;
|
||||
Len( IIf( lCmp, hb_pValue( 3 ), e2 ) ), Len( cRes ), ;
|
||||
( Len( cRes ) / Len( IIf( lCmp, hb_pValue( 3 ), e2 ) ) ) * 100, ;
|
||||
nEnd - nBegin;
|
||||
)
|
||||
? cFmt
|
||||
NEXT
|
||||
?
|
||||
RETURN
|
||||
|
||||
Reference in New Issue
Block a user