My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "bz2.h"

#define LEN 30
#define LEN2 LEN*2

#define STRING1 "TOTO TOTO"

void hexdump(unsigned char * data, unsigned int amount, size_t addr)
{
unsigned int dp;
unsigned int p;
const char trans[] =
"................................ !\"#$%&'()*+,-./0123456789"
":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklm"
"nopqrstuvwxyz{|}~...................................."
"....................................................."
"........................................";

for ( dp = 1; dp <= amount; dp++ )
{
if ( (dp % 16) == 1 )
{
fprintf( stdout, "%#08x | ", addr+dp-1 );
}

fprintf( stdout, "%02x ", data[dp-1] );
if ( (dp % 8) == 0 && (dp % 16) != 0 )
{
fputs( " ", stdout );
}
if ( (dp % 16) == 0 )
{
fputs( "| ", stdout );
p = dp;
for ( dp -= 16; dp < p; dp++ )
{
fprintf( stdout, "%c", trans[data[dp]] );
}
fputs( "\n", stdout );
}
}

if ( (amount % 16) != 0 )
{
p = dp = 16 - ( amount % 16 );
for ( dp = p; dp > 0; dp-- )
{
fputs( " ", stdout );
if ( ((dp % 8) == 0) && (p != 8) )
{
fputs( " ", stdout );
}
}
fputs( "| ", stdout );
for ( dp = (amount - (16 - p)); dp < amount; dp++ ) {
fprintf( stdout, "%c", trans[data[dp]] );
}
}

fputs( "\n", stdout );
return;
}

int main(int argc, char *argv[])
{
unsigned char data[LEN], data2[LEN2];
unsigned int avail_out;
int ret;

memset(data, 0, sizeof(data));
memset(data2, 0, sizeof(data2));

memcpy(data, STRING1, strlen(STRING1));

avail_out = sizeof(data2);

ret = bz2Compress(9, 0, 30, data, strlen(STRING1), data2, &avail_out);
printf("RET = %d AVAIL OUT %d\n", ret, avail_out);
hexdump(data, sizeof(data), (size_t)data);
hexdump(data2, sizeof(data2), (size_t)data2);

return 0;
}

Change log

0136ea839f68 by po...@camelot on Jan 6, 2011   Diff
add zlib to libncd
add pysco into bytecodes
Go to: 
Project members, sign in to write a code review

Older revisions

a3875c174f01 by po...@camelot on Jan 1, 2011   Diff
update dex
add bz2
All revisions of this file

File info

Size: 2085 bytes, 87 lines
Powered by Google Project Hosting