Skip to content

Commit 2db0597

Browse files
committed
test debugging now ..
1 parent 2a41568 commit 2db0597

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ LZMATDIR = ${SOURCEDIR}/lzmat
2424
OBJDIR = ./obj
2525
OUTBIN = libendetool.a
2626
DEFINEOPT = -D_GNU_SOURCE
27-
OPTIMOPT = -O2 -fomit-frame-pointer -ffast-math
28-
#OPTIMOPT = -g3 -O2 -DDEBUG
27+
#OPTIMOPT = -O2 -fomit-frame-pointer -ffast-math
28+
OPTIMOPT = -g3 -O2 -DDEBUG
2929
OPTADD =
3030
OPTARCH =
3131

src/endetool.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,24 @@ long long EnDeTool::decodebinary( const char* src, unsigned srcsize, char* &out
232232
}
233233

234234
// checks is it compressed ..
235-
if ( memcmp( &decptr[4], &LZMAT_COMPRESS_HEADER, 4 ) == 0 )
235+
if ( memcmp( decptr, &LZMAT_COMPRESS_HEADER, 4 ) == 0 )
236236
{
237+
#ifdef DEBUG
238+
printf( "data compressed!\n" );
239+
fflush( stdout );
240+
#endif /// of DEBUG
237241
unsigned worksz = srcsize - 4;
238242

239243
// reallocate buffer for decompress buffer.
244+
#ifdef DEBUG
245+
printf( "decompressing ... " );
246+
fflush( stdout );
247+
#endif /// of DEBUG
240248
decbuffsz = decompressbuffer( decptr, worksz );
249+
#ifdef DEBUG
250+
printf( "%u bytes\n", decbuffsz );
251+
fflush( stdout );
252+
#endif /// of DEBUG
241253

242254
if ( decbuffsz < AES_BLOCKLEN )
243255
{

test/test.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ using namespace std;
99

1010
const char ekey[] = "12345678901234567890123456789012";
1111
const char eiv[] = "09876543210987654321098765432109";
12-
//const char teststr[] = "Testing_source_words_for_libendetool_and_endecmd.";
1312
const char teststr[] = "Testing_source_words_for_libendetool_and_endecmd.";
1413

1514
void test1()
@@ -22,9 +21,8 @@ void test1()
2221
printf( "Ok.\n" );
2322
printf( "> Configure : " );
2423
fflush( stdout );
25-
//ende.cryptkey( ekey, eiv );
2624
ende->compress( false );
27-
ende->cryptkey( ekey );
25+
ende->cryptkey( ekey, eiv );
2826

2927
printf( "Ok.\n" );
3028
fflush( stdout );
@@ -33,7 +31,12 @@ void test1()
3331
fflush( stdout );
3432

3533
ende->text( teststr );
36-
string encstr = ende->encodedtext();
34+
printf( "> encoding ... " );
35+
fflush( stdout );
36+
string encstr;
37+
const char* rets = ende->encodedtext();
38+
if ( rets != NULL )
39+
encstr = rets;
3740
printf( "> encoded : %s\n", encstr.c_str() );
3841
fflush( stdout );
3942

@@ -57,9 +60,10 @@ void test2()
5760
if ( ende != NULL )
5861
{
5962
ende->compress( true );
60-
ende->cryptkey( ekey );
63+
ende->cryptkey( ekey, eiv );
6164

6265
printf( "testing compressed encryption\n" );
66+
fflush( stdout );
6367

6468
ende->text( teststr );
6569
string encstr = ende->encodedtext();
@@ -77,14 +81,19 @@ int main( int argc, char** argv )
7781
printf( "libendetool testing.\n" );
7882
fflush( stdout );
7983

84+
printf( "========================================================\n" );
8085
printf( "TESTING 1: plain texts.\n");
8186
fflush( stdout );
8287
test1();
8388

89+
printf( "\n\n" );
90+
printf( "========================================================\n" );
8491
printf( "TESTING 2: compressed texts.\n" );
8592
fflush( stdout );
8693
test2();
8794

95+
printf( "\n\n" );
96+
printf( "========================================================\n" );
8897
fflush( stdout );
8998
system( "pause" );
9099

0 commit comments

Comments
 (0)