[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] problemer med zlib



Hej igen, bare ignorer mig, jeg fandt funktionen "uncompress", det
gjorde det hele meget nemmere.

Tomas


On Mon, 31 May 2004 00:02:30 +0200
Tomas Groth <sslug@sslug> wrote:

> Hej, jeg er i gang med at lave et lille program der tager en fil som
> argument, og fra den 8. byte dekomprimerer filen gennem zlib. Eller
> rettere det var meningen men zlib klager over dataformatet (fejlkode:
> -3) efter et lille stykke tid, og jeg kan ikke hitte ud af hvorfor :(
> Kan det passe at det er ligegyldigt hvor store de komprimerede blokke
> er som man giver zlib? Jeg har en spinkel ide om at zlib måske i enden
> af første blok finder ud af at den er uafsluttet (dvs er i næste
> blok), og derfor brokker sig, men jeg kunne ikke rigtig finde noget
> dokumentation omkring det...
> Forresten er de filer jeg prøver at dekomprimere, er nyere flash
> filer, der er f.eks. en lille en her:
> http://www.1go.dk/webhotel/1go_menu.swf
> 
> Jeg håber at en der ved lidt om zlib kan give mig et fingerpeg om hvad
> der er galt.
> 
> MVH
> 
> Tomas
> 
> Programmet er her:
> 
> #include <zlib.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> 
> main(int argc, char **argv)
> {
> 	char *zfinal_data;
> 	char zinput_buffer[2048], zoutput_buffer[2048];
> 	long size;
> 	int status,position;
> 	z_stream stream;
> 	FILE *fin;
> 
> 	if (argc < 2) {
> 		fprintf(stderr,"Usage : %s <file.swf>\n", argv[0]);
> 		exit(1);
> 	}
> 
> 	fin = fopen(argv[1], "rb");
> 	if (!fin){
> 		printf("Unable to open file.\n");
> 		return;
> 	}
> 	stream.avail_in = fread( zinput_buffer, 1, 8, fin );
> 	stream.avail_in = fread( zinput_buffer, 1, 1024, fin );
> 	stream.next_in = zinput_buffer;
> 	stream.next_out = zoutput_buffer;
> 	stream.avail_out = 2048;
> 	stream.zalloc = Z_NULL;
> 	stream.zfree = Z_NULL;
> 
> 	status = inflateInit(&stream);
> 
> 	while (1) {
> 		status = inflate(&stream, Z_SYNC_FLUSH) ;
> 		if (status == Z_STREAM_END) {
> 			printf("Processing\n");
> 			zfinal_data = strcat(zfinal_data, zoutput_buffer);
> 			stream.avail_in = fread( zinput_buffer, 1, 1024, fin );
> 			stream.next_in = zinput_buffer;
> 			stream.avail_out = 10000;
> 			status = inflate(&stream, Z_SYNC_FLUSH);
> 			if (stream.avail_in == 0)
> 				break;
> 		}
> 		if (status != Z_OK) {
> //			printf("decompressed: %d\n", stream.avail_out);
> 			printf("Zlib data error : %d\n", status);
> 			return -1;
> 		}
> //		printf("running\n");
> 		stream.avail_in = 1;
> 	}
> 
> 	inflateEnd(&stream);
> 
> 	exit(0);
> }
> 


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *