<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problem bei Dekompression von GZIP-Dateien mit inflate() aus ZLIB]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab mein Problem mal in dieses Forum gepostet, weil ich den BCB1 benutze.<br />
Ich möchte über HTTP übertragene gzip-komprimierte Dateien entpacken. Das ganze versuche ich jetzt mit zlib zu lösen (habe noch nie zuvor versucht, eine DLL zu benutzen, vielleicht mache ich da etwas falsch).<br />
inflate(), das eigentlich laut Manual auch gzip-Dateien entpacken können soll, gibt immer nur Z_DATA_ERROR zurück.<br />
Hier den Code, den ich benutze, vielleicht sieht jemand auf Anhieb, was ich falsch mache:</p>
<pre><code class="language-cpp">void* ZLIBH=LoadLibrary(&quot;zlib1.dll&quot;);
FARPROC InflateR,InflateInitR,InflateEndR,VersionR;
InflateR=GetProcAddress(ZLIBH,&quot;inflate&quot;);
InflateInitR=GetProcAddress(ZLIBH,&quot;inflateInit_&quot;);
InflateEndR=GetProcAddress(ZLIBH,&quot;inflateEnd&quot;);
VersionR=GetProcAddress(ZLIBH,&quot;zlibVersion&quot;);
assert(InflateR!=NULL);
assert(InflateInitR!=NULL);
assert(InflateEndR!=NULL);
assert(VersionR!=NULL);
int(*Inflate)(z_streamp stream,int flush)=(int(*)(z_streamp,int))InflateR;
int(*InflateInit)(z_streamp stream,char* Version,int StreamSize)=(int(*)(z_streamp,char*,int))InflateInitR;
int(*InflateEnd)(z_streamp stream)=(int(*)(z_streamp))InflateEndR;
char*(*Version)()=(char*(*)())VersionR;
char* VerStr=Version();
assert(String(VerStr)==String(ZLIB_VERSION));

const unsigned long DestBufLen=100000;
const unsigned long SrcBufLen=100000;
ubyte* DestBuf=new ubyte[DestBufLen];
ubyte* SrcBuf=new ubyte[SrcBufLen];

int SrcLen;
//[...]
//SrcBuf erhält hier den Inhalt einer mit gzip erstellten Testdatei
//SrcLen enthält die Größe der Datei
//[...]

z_stream strm;
strm.zalloc=Z_NULL;
strm.zfree=Z_NULL;
strm.opaque=Z_NULL;
strm.avail_in=SrcLen;
strm.next_in=SrcBuf;
strm.avail_out=DestBufLen;
strm.next_out=DestBuf;
int InflateInitResult=InflateInit(&amp;strm,ZLIB_VERSION,sizeof(z_stream));
int InflateResult=Inflate(&amp;strm,Z_FINISH);
InflateEnd(&amp;strm);

delete[] SrcBuf;
delete[] DestBuf;
FreeLibrary(ZLIBH);
</code></pre>
<p>Was stimmt da nicht? Wäre froh, wenn mir jemand auf die Sprünge helfen könnte.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/163225/problem-bei-dekompression-von-gzip-dateien-mit-inflate-aus-zlib</link><generator>RSS for Node</generator><lastBuildDate>Tue, 30 Jun 2026 14:44:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/163225.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 27 Oct 2006 08:15:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem bei Dekompression von GZIP-Dateien mit inflate() aus ZLIB on Sun, 29 Oct 2006 07:41:35 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab mein Problem mal in dieses Forum gepostet, weil ich den BCB1 benutze.<br />
Ich möchte über HTTP übertragene gzip-komprimierte Dateien entpacken. Das ganze versuche ich jetzt mit zlib zu lösen (habe noch nie zuvor versucht, eine DLL zu benutzen, vielleicht mache ich da etwas falsch).<br />
inflate(), das eigentlich laut Manual auch gzip-Dateien entpacken können soll, gibt immer nur Z_DATA_ERROR zurück.<br />
Hier den Code, den ich benutze, vielleicht sieht jemand auf Anhieb, was ich falsch mache:</p>
<pre><code class="language-cpp">void* ZLIBH=LoadLibrary(&quot;zlib1.dll&quot;);
FARPROC InflateR,InflateInitR,InflateEndR,VersionR;
InflateR=GetProcAddress(ZLIBH,&quot;inflate&quot;);
InflateInitR=GetProcAddress(ZLIBH,&quot;inflateInit_&quot;);
InflateEndR=GetProcAddress(ZLIBH,&quot;inflateEnd&quot;);
VersionR=GetProcAddress(ZLIBH,&quot;zlibVersion&quot;);
assert(InflateR!=NULL);
assert(InflateInitR!=NULL);
assert(InflateEndR!=NULL);
assert(VersionR!=NULL);
int(*Inflate)(z_streamp stream,int flush)=(int(*)(z_streamp,int))InflateR;
int(*InflateInit)(z_streamp stream,char* Version,int StreamSize)=(int(*)(z_streamp,char*,int))InflateInitR;
int(*InflateEnd)(z_streamp stream)=(int(*)(z_streamp))InflateEndR;
char*(*Version)()=(char*(*)())VersionR;
char* VerStr=Version();
assert(String(VerStr)==String(ZLIB_VERSION));

const unsigned long DestBufLen=100000;
const unsigned long SrcBufLen=100000;
ubyte* DestBuf=new ubyte[DestBufLen];
ubyte* SrcBuf=new ubyte[SrcBufLen];

int SrcLen;
//[...]
//SrcBuf erhält hier den Inhalt einer mit gzip erstellten Testdatei
//SrcLen enthält die Größe der Datei
//[...]

z_stream strm;
strm.zalloc=Z_NULL;
strm.zfree=Z_NULL;
strm.opaque=Z_NULL;
strm.avail_in=SrcLen;
strm.next_in=SrcBuf;
strm.avail_out=DestBufLen;
strm.next_out=DestBuf;
int InflateInitResult=InflateInit(&amp;strm,ZLIB_VERSION,sizeof(z_stream));
int InflateResult=Inflate(&amp;strm,Z_FINISH);
InflateEnd(&amp;strm);

delete[] SrcBuf;
delete[] DestBuf;
FreeLibrary(ZLIBH);
</code></pre>
<p>Was stimmt da nicht? Wäre froh, wenn mir jemand auf die Sprünge helfen könnte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1162381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1162381</guid><dc:creator><![CDATA[Nanyuki]]></dc:creator><pubDate>Sun, 29 Oct 2006 07:41:35 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Dekompression von GZIP-Dateien mit inflate() aus ZLIB on Fri, 27 Oct 2006 15:33:58 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=437" rel="nofollow">Jansen</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=2" rel="nofollow">VCL/CLX (Borland C++ Builder)</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=8" rel="nofollow">Rund um die Programmierung</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1162622</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1162622</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Fri, 27 Oct 2006 15:33:58 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Dekompression von GZIP-Dateien mit inflate() aus ZLIB on Sun, 29 Oct 2006 04:25:52 GMT]]></title><description><![CDATA[<p>Ist wichtig ._.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163507</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163507</guid><dc:creator><![CDATA[Nanyuki]]></dc:creator><pubDate>Sun, 29 Oct 2006 04:25:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Dekompression von GZIP-Dateien mit inflate() aus ZLIB on Sun, 29 Oct 2006 08:07:41 GMT]]></title><description><![CDATA[<p>Debugger. f'`8k</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163523</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163523</guid><dc:creator><![CDATA[helper]]></dc:creator><pubDate>Sun, 29 Oct 2006 08:07:41 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Dekompression von GZIP-Dateien mit inflate() aus ZLIB on Sun, 29 Oct 2006 10:11:08 GMT]]></title><description><![CDATA[<p>helper schrieb:</p>
<blockquote>
<p>Debugger. f'`8k</p>
</blockquote>
<p>Wie bitte?</p>
<p>Ich hab mal ausprobiert, eine Datei zu dekomprimieren, die ich vorher mit deflate() komprimiert habe... das hat auch funktioniert. Versuche ich das aber mit einer gzip-Datei, kommt Z_DATA_ERROR. Ich hab auch mal versucht inflateSync() aufzurufen, auch das gibt aber nur Z_DATA_ERROR zurück.</p>
<p>Der folgende Abschnitt sagt doch, dass es auch mit gzip-Dateien gehen sollte. Oder habe ich da etwas falsch verstanden?</p>
<blockquote>
<p>inflate() will decompress and check either zlib-wrapped or gzip-wrapped<br />
deflate data. The header type is detected automatically. Any information<br />
contained in the gzip header is not retained, so applications that need that<br />
information should instead use raw inflate, see inflateInit2() below, or<br />
inflateBack() and perform their own processing of the gzip header and<br />
trailer.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1163599</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163599</guid><dc:creator><![CDATA[Nanyuki]]></dc:creator><pubDate>Sun, 29 Oct 2006 10:11:08 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Dekompression von GZIP-Dateien mit inflate() aus ZLIB on Sat, 29 Sep 2007 09:47:32 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">inflateInit2(&amp;strm, MAX_WBITS + 16);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1374747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1374747</guid><dc:creator><![CDATA[helper]]></dc:creator><pubDate>Sat, 29 Sep 2007 09:47:32 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Dekompression von GZIP-Dateien mit inflate() aus ZLIB on Sat, 29 Sep 2007 14:55:05 GMT]]></title><description><![CDATA[<p>In Boost (genauer: Boost.Iostreams) gibt es bequemere Wrapper um zlib und libzip2, vielleicht würde das ja einiges an Mühe sparen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1374888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1374888</guid><dc:creator><![CDATA[Mr. N]]></dc:creator><pubDate>Sat, 29 Sep 2007 14:55:05 GMT</pubDate></item></channel></rss>