2008-05-15 03:40 UTC+0100 Viktor Szakats (harbour.01 syenar hu)

* tests/db_brows.prg
     ! Removed note of hbmisc requirement.

   * tests/Makefile
   - tests/twirl.prg
   + contrib/hbmisc/tests/twirl.prg
     ! Test moved to local test dir.

   * source/vm/cmdarg.c
     ! hb_cmdargIsInternal(): Removed '--' as internal option marker, 
       since it will disallow any application code to accept 
       such options. We will now stick with '//' prefix for 
       Clipper compatible internal options.

   * contrib/hbzlib/tests/myzip.prg
   * contrib/hbzlib/tests/myunzip.prg
   * contrib/hbzlib/hbmzip.c
     + Added support for password on Harbour API level.
     ; NOTE: This password is not at the moment compatible 
             with .zip passwords added by standard .zip 
             utilities.
This commit is contained in:
Viktor Szakats
2008-05-15 02:26:49 +00:00
parent f6cbf1390b
commit 40c3c7c2a8
8 changed files with 84 additions and 34 deletions

View File

@@ -8,6 +8,29 @@
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2008-05-15 03:40 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* tests/db_brows.prg
! Removed note of hbmisc requirement.
* tests/Makefile
- tests/twirl.prg
+ contrib/hbmisc/tests/twirl.prg
! Test moved to local test dir.
* source/vm/cmdarg.c
! hb_cmdargIsInternal(): Removed '--' as internal option marker,
since it will disallow any application code to accept
such options. We will now stick with '//' prefix for
Clipper compatible internal options.
* contrib/hbzlib/tests/myzip.prg
* contrib/hbzlib/tests/myunzip.prg
* contrib/hbzlib/hbmzip.c
+ Added support for password on Harbour API level.
; NOTE: This password is not at the moment compatible
with .zip passwords added by standard .zip
utilities.
2008-05-15 02:02 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/debug/tbrwtext.prg
! declare HBDebugger as friend class of HBBrwText to avoid scope

View File

@@ -164,7 +164,8 @@ HB_FUNC( HB_ZIPCLOSE )
/* HB_ZipFileCreate( hZip, cZipName, dDate, cTime, nInternalAttr, nExternalAttr,
[ nMethod = HB_ZLIB_METHOD_DEFLATE ],
[ nLevel = HB_ZLIB_COMPRESSION_DEFAULT ] ) --> nError */
[ nLevel = HB_ZLIB_COMPRESSION_DEFAULT ],
[ cPassword ] ) --> nError */
HB_FUNC( HB_ZIPFILECREATE )
{
char* szZipName = hb_parc( 2 );
@@ -195,8 +196,10 @@ HB_FUNC( HB_ZIPFILECREATE )
iLevel = hb_parni( 8 );
if( hZip )
hb_retni( zipOpenNewFileInZip( hZip, szZipName, &zfi,
NULL, 0, NULL, 0, NULL, iMethod, iLevel ) );
hb_retni( zipOpenNewFileInZip3( hZip, szZipName, &zfi,
NULL, 0, NULL, 0, NULL, iMethod, iLevel, 0,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
hb_parc( 9 ), 0 ) );
}
else
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, &hb_errFuncName, HB_ERR_ARGS_BASEPARAMS );
@@ -373,7 +376,7 @@ HB_FUNC( HB_UNZIPFILEOPEN )
unzFile hUnzip = hb_unzipfileParam( 1 );
if( hUnzip )
hb_retni( unzOpenCurrentFile( hUnzip ) );
hb_retni( unzOpenCurrentFilePassword( hUnzip, hb_parc( 2 ) ) );
}
@@ -424,7 +427,7 @@ HB_FUNC( HB_UNZIPFILECLOSE )
*
*/
static int hb_zipStoreFile( zipFile hZip, char* szFileName, char* szName )
static int hb_zipStoreFile( zipFile hZip, char* szFileName, char* szName, char* szPassword )
{
char * szZipName, * pString;
FHANDLE hFile;
@@ -561,8 +564,10 @@ static int hb_zipStoreFile( zipFile hZip, char* szFileName, char* szName )
if( ulExtAttr & 0x40000000 )
{
iResult = zipOpenNewFileInZip( hZip, szZipName, &zfi, NULL, 0, NULL, 0, NULL,
Z_DEFLATED, Z_DEFAULT_COMPRESSION );
iResult = zipOpenNewFileInZip3( hZip, szZipName, &zfi, NULL, 0, NULL, 0, NULL,
Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
szPassword, 0 );
if( iResult == 0 )
zipCloseFileInZip( hZip );
}
@@ -590,8 +595,10 @@ static int hb_zipStoreFile( zipFile hZip, char* szFileName, char* szName )
}
}
#endif
iResult = zipOpenNewFileInZip( hZip, szZipName, &zfi, NULL, 0, NULL, 0, NULL,
Z_DEFLATED, Z_DEFAULT_COMPRESSION );
iResult = zipOpenNewFileInZip3( hZip, szZipName, &zfi, NULL, 0, NULL, 0, NULL,
Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
szPassword, 0 );
if( iResult == 0 )
{
pString = (char*) hb_xgrab( 1024 * 16 );
@@ -615,7 +622,7 @@ static int hb_zipStoreFile( zipFile hZip, char* szFileName, char* szName )
}
/* HB_ZipStoreFile( hZip, cFileName [, cZipName ] ) --> nError */
/* HB_ZipStoreFile( hZip, cFileName, [ cZipName ], [ cPassword ] ) --> nError */
HB_FUNC( HB_ZIPSTOREFILE )
{
char* szFileName = hb_parc( 2 );
@@ -625,14 +632,14 @@ HB_FUNC( HB_ZIPSTOREFILE )
zipFile hZip = hb_zipfileParam( 1 );
if( hZip )
hb_retni( hb_zipStoreFile( hZip, szFileName, hb_parc( 3 ) ) );
hb_retni( hb_zipStoreFile( hZip, szFileName, hb_parc( 3 ), hb_parc( 4 ) ) );
}
else
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, &hb_errFuncName, HB_ERR_ARGS_BASEPARAMS );
}
static int hb_unzipExtractCurrentFile( unzFile hUnzip, char* szFileName )
static int hb_unzipExtractCurrentFile( unzFile hUnzip, char* szFileName, char* szPassword )
{
char szName[ _POSIX_PATH_MAX + 1 ];
ULONG ulPos, ulLen;
@@ -646,7 +653,7 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, char* szFileName )
if( iResult != 0 )
return iResult;
iResult = unzOpenCurrentFile( hUnzip );
iResult = unzOpenCurrentFilePassword( hUnzip, szPassword );
if( iResult != 0 )
return iResult;
@@ -761,12 +768,12 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, char* szFileName )
}
/* HB_UnzipExtractCurrentFile( hZip [, cFileName ] ) --> nError */
/* HB_UnzipExtractCurrentFile( hZip, [ cFileName ], [ cPassword ] ) --> nError */
HB_FUNC( HB_UNZIPEXTRACTCURRENTFILE )
{
unzFile hUnzip = hb_unzipfileParam( 1 );
if( hUnzip )
hb_retni( hb_unzipExtractCurrentFile( hUnzip, hb_parc( 2 ) ) );
hb_retni( hb_unzipExtractCurrentFile( hUnzip, hb_parc( 2 ), hb_parc( 3 ) ) );
}

View File

@@ -53,11 +53,11 @@
PROC MyUnzip( ... )
LOCAL hUnzip, aWild, cFileName, cWild, cFile, dDate, cTime, nSize, nCompSize, nErr
LOCAL hUnzip, aWild, cFileName, cWild, cFile, dDate, cTime, nSize, nCompSize, nErr, cPassword, tmp
aWild := { ... }
IF LEN( aWild ) < 1
? "Usage: myunzip <ZipName> [ <FilePattern1> ... ]"
? "Usage: myunzip <ZipName> [ --pass <password> ] [ <FilePattern1> ... ]"
RETURN
ENDIF
@@ -68,6 +68,15 @@ PROC MyUnzip( ... )
ADEL( aWild, 1 )
ASIZE( aWild, LEN( aWild ) - 1 )
FOR tmp := 1 TO LEN( aWild ) - 1
IF LOWER( aWild[ tmp ] ) == "--pass"
cPassword := aWild[ tmp + 1 ]
aWild[ tmp ] := ""
aWild[ tmp + 1 ] := ""
ENDIF
NEXT
AEVAL( aWild, {|cPattern, nPos| aWild[ nPos ] := STRTRAN( cPattern, "\", "/" ) } )
hUnzip := HB_UNZIPOPEN( cFileName )
@@ -84,7 +93,7 @@ PROC MyUnzip( ... )
IF ASCAN( aWild, {|cPattern| HB_WILDMATCH( cPattern, cFile, .T. ) } ) > 0
?? " Extracting"
HB_UnzipExtractCurrentFile( hUnzip )
HB_UnzipExtractCurrentFile( hUnzip, NIL, cPassword )
ELSE
?? " Skipping"
ENDIF

View File

@@ -53,11 +53,11 @@
PROC MyZip( ... )
LOCAL hZip, aDir, aFile, aWild, cFileName, cPath, cWild
LOCAL hZip, aDir, aFile, aWild, cFileName, cPath, cWild, cPassword, tmp
aWild := { ... }
IF LEN(aWild) < 2
? "Usage: myzip <ZipName> <FilePattern1> [ <FilePattern2> ... ]"
? "Usage: myzip <ZipName> [ --pass <password> ] <FilePattern1> [ <FilePattern2> ... ]"
RETURN
ENDIF
@@ -69,18 +69,28 @@ PROC MyZip( ... )
ADEL( aWild, 1 )
ASIZE( aWild, LEN( aWild ) - 1 )
FOR tmp := 1 TO LEN( aWild ) - 1
IF LOWER( aWild[ tmp ] ) == "--pass"
cPassword := aWild[ tmp + 1 ]
aWild[ tmp ] := ""
aWild[ tmp + 1 ] := ""
ENDIF
NEXT
hZip := HB_ZIPOPEN( cFileName )
IF ! EMPTY( hZip )
? "Archive file:", cFileName
FOR EACH cWild IN aWild
aDir := DIRECTORY( cWild )
cPath = LEFT( cWild, RAT( HB_OSPATHSEPARATOR(), cWild ) )
FOR EACH aFile IN aDir
IF cPath + aFile[ 1 ] != cFileName
? "Adding", cPath + aFile[ 1 ]
HB_ZipStoreFile( hZip, cPath + aFile[ 1 ], cPath + aFile[ 1 ] )
ENDIF
NEXT
IF !EMPTY( cWild )
aDir := DIRECTORY( cWild )
cPath = LEFT( cWild, RAT( HB_OSPATHSEPARATOR(), cWild ) )
FOR EACH aFile IN aDir
IF cPath + aFile[ 1 ] != cFileName
? "Adding", cPath + aFile[ 1 ]
HB_ZipStoreFile( hZip, cPath + aFile[ 1 ], cPath + aFile[ 1 ], cPassword )
ENDIF
NEXT
ENDIF
NEXT
HB_ZIPCLOSE( hZip )
ENDIF

View File

@@ -119,9 +119,12 @@ BOOL hb_cmdargIsInternal( const char * szArg )
{
HB_TRACE(HB_TR_DEBUG, ("hb_cmdargIsInternal(%s)", szArg));
return strlen( szArg ) >= 2 &&
( ( szArg[ 0 ] == '/' && szArg[ 1 ] == '/' ) ||
( szArg[ 0 ] == '-' && szArg[ 1 ] == '-' ) ) ;
/* NOTE: Not checking for '--' here, as it would filter out
valid command line options used by applications. [vszakats] */
return strlen( szArg ) >= 2 &&
szArg[ 0 ] == '/' &&
szArg[ 1 ] == '/';
}
static char * hb_cmdargGet( const char * pszName, BOOL bRetValue )

View File

@@ -190,7 +190,6 @@ BAD_PRG_SOURCES=\
testpp.prg \
testtok.prg \
tstprag.prg \
twirl.prg \
vec1.prg \
C_SOURCES=\

View File

@@ -1,6 +1,7 @@
//
// $Id$
//
*+²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
*+ Browse function
*+
@@ -10,8 +11,6 @@
*+ Time : 19:20
*+ Placed in the public domain
*+
*+ To compile it you need to build libmisc.lib from /contrib/libmisc
*+
*+ Source Module => DB_BROWS.PRG
*+
*+ Functions: Function Main()