swfmill 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.document +5 -0
  2. data/.gitignore +23 -0
  3. data/.swfmill +240 -0
  4. data/LICENSE +340 -0
  5. data/README.rdoc +37 -0
  6. data/Rakefile +59 -0
  7. data/VERSION +1 -0
  8. data/ext/.gitignore +5 -0
  9. data/ext/extconf.rb +86 -0
  10. data/ext/swfmill/.gitignore +27 -0
  11. data/ext/swfmill/AUTHORS +9 -0
  12. data/ext/swfmill/COPYING +340 -0
  13. data/ext/swfmill/Makefile.am +14 -0
  14. data/ext/swfmill/Makefile.in +635 -0
  15. data/ext/swfmill/NEWS +189 -0
  16. data/ext/swfmill/README +170 -0
  17. data/ext/swfmill/TODO +33 -0
  18. data/ext/swfmill/aclocal.m4 +7712 -0
  19. data/ext/swfmill/autogen.sh +7 -0
  20. data/ext/swfmill/compile +142 -0
  21. data/ext/swfmill/config.guess +1516 -0
  22. data/ext/swfmill/config.sub +1626 -0
  23. data/ext/swfmill/configure +21868 -0
  24. data/ext/swfmill/configure.ac +55 -0
  25. data/ext/swfmill/depcomp +589 -0
  26. data/ext/swfmill/install-sh +519 -0
  27. data/ext/swfmill/ltmain.sh +6964 -0
  28. data/ext/swfmill/missing +367 -0
  29. data/ext/swfmill/src/Geom.cpp +107 -0
  30. data/ext/swfmill/src/Geom.h +100 -0
  31. data/ext/swfmill/src/Makefile.am +86 -0
  32. data/ext/swfmill/src/Makefile.in +1025 -0
  33. data/ext/swfmill/src/SWF.h +11941 -0
  34. data/ext/swfmill/src/SWFAction.cpp +41 -0
  35. data/ext/swfmill/src/SWFAction.h +19 -0
  36. data/ext/swfmill/src/SWFBasic.h +7 -0
  37. data/ext/swfmill/src/SWFFile.cpp +406 -0
  38. data/ext/swfmill/src/SWFFile.h +34 -0
  39. data/ext/swfmill/src/SWFFilter.cpp +25 -0
  40. data/ext/swfmill/src/SWFFilter.h +15 -0
  41. data/ext/swfmill/src/SWFGlyphList.cpp +262 -0
  42. data/ext/swfmill/src/SWFGlyphList.h +34 -0
  43. data/ext/swfmill/src/SWFIdItem.h +85 -0
  44. data/ext/swfmill/src/SWFIdItems.h +16 -0
  45. data/ext/swfmill/src/SWFItem.cpp +235 -0
  46. data/ext/swfmill/src/SWFItem.h +60 -0
  47. data/ext/swfmill/src/SWFList.h +179 -0
  48. data/ext/swfmill/src/SWFReader.cpp +352 -0
  49. data/ext/swfmill/src/SWFReader.h +73 -0
  50. data/ext/swfmill/src/SWFShapeItem.cpp +220 -0
  51. data/ext/swfmill/src/SWFShapeItem.h +45 -0
  52. data/ext/swfmill/src/SWFShapeMaker.cpp +401 -0
  53. data/ext/swfmill/src/SWFShapeMaker.h +128 -0
  54. data/ext/swfmill/src/SWFTag.cpp +49 -0
  55. data/ext/swfmill/src/SWFTag.h +20 -0
  56. data/ext/swfmill/src/SWFTrait.cpp +35 -0
  57. data/ext/swfmill/src/SWFTrait.h +22 -0
  58. data/ext/swfmill/src/SWFWriter.cpp +312 -0
  59. data/ext/swfmill/src/SWFWriter.h +84 -0
  60. data/ext/swfmill/src/base64.c +110 -0
  61. data/ext/swfmill/src/base64.h +15 -0
  62. data/ext/swfmill/src/codegen/Makefile.am +15 -0
  63. data/ext/swfmill/src/codegen/Makefile.in +346 -0
  64. data/ext/swfmill/src/codegen/basic.xsl +45 -0
  65. data/ext/swfmill/src/codegen/basics.xsl +235 -0
  66. data/ext/swfmill/src/codegen/dumper.xsl +109 -0
  67. data/ext/swfmill/src/codegen/header.xsl +131 -0
  68. data/ext/swfmill/src/codegen/mk.xsl +26 -0
  69. data/ext/swfmill/src/codegen/parser.xsl +196 -0
  70. data/ext/swfmill/src/codegen/parsexml.xsl +312 -0
  71. data/ext/swfmill/src/codegen/size.xsl +189 -0
  72. data/ext/swfmill/src/codegen/source.xml +2197 -0
  73. data/ext/swfmill/src/codegen/writer.xsl +190 -0
  74. data/ext/swfmill/src/codegen/writexml.xsl +138 -0
  75. data/ext/swfmill/src/swfmill.cpp +482 -0
  76. data/ext/swfmill/src/swft/Makefile.am +55 -0
  77. data/ext/swfmill/src/swft/Makefile.in +717 -0
  78. data/ext/swfmill/src/swft/Parser.cpp +76 -0
  79. data/ext/swfmill/src/swft/Parser.h +37 -0
  80. data/ext/swfmill/src/swft/SVGAttributeParser.cpp +78 -0
  81. data/ext/swfmill/src/swft/SVGAttributeParser.h +35 -0
  82. data/ext/swfmill/src/swft/SVGColor.cpp +116 -0
  83. data/ext/swfmill/src/swft/SVGColor.h +37 -0
  84. data/ext/swfmill/src/swft/SVGColors.h +167 -0
  85. data/ext/swfmill/src/swft/SVGGradient.cpp +258 -0
  86. data/ext/swfmill/src/swft/SVGGradient.h +81 -0
  87. data/ext/swfmill/src/swft/SVGPathParser.cpp +155 -0
  88. data/ext/swfmill/src/swft/SVGPathParser.h +126 -0
  89. data/ext/swfmill/src/swft/SVGPointsParser.cpp +51 -0
  90. data/ext/swfmill/src/swft/SVGPointsParser.h +25 -0
  91. data/ext/swfmill/src/swft/SVGStyle.cpp +181 -0
  92. data/ext/swfmill/src/swft/SVGStyle.h +80 -0
  93. data/ext/swfmill/src/swft/SVGTransformParser.cpp +72 -0
  94. data/ext/swfmill/src/swft/SVGTransformParser.h +32 -0
  95. data/ext/swfmill/src/swft/readpng.c +305 -0
  96. data/ext/swfmill/src/swft/readpng.h +92 -0
  97. data/ext/swfmill/src/swft/swft.cpp +251 -0
  98. data/ext/swfmill/src/swft/swft.h +64 -0
  99. data/ext/swfmill/src/swft/swft_document.cpp +57 -0
  100. data/ext/swfmill/src/swft/swft_import.cpp +38 -0
  101. data/ext/swfmill/src/swft/swft_import_binary.cpp +82 -0
  102. data/ext/swfmill/src/swft/swft_import_jpeg.cpp +255 -0
  103. data/ext/swfmill/src/swft/swft_import_mp3.cpp +268 -0
  104. data/ext/swfmill/src/swft/swft_import_png.cpp +231 -0
  105. data/ext/swfmill/src/swft/swft_import_ttf.cpp +519 -0
  106. data/ext/swfmill/src/swft/swft_import_wav.cpp +255 -0
  107. data/ext/swfmill/src/swft/swft_path.cpp +178 -0
  108. data/ext/swfmill/src/xslt/Makefile.am +51 -0
  109. data/ext/swfmill/src/xslt/Makefile.in +536 -0
  110. data/ext/swfmill/src/xslt/README +19 -0
  111. data/ext/swfmill/src/xslt/assemble.xsl +38 -0
  112. data/ext/swfmill/src/xslt/simple-deprecated.xslt +62 -0
  113. data/ext/swfmill/src/xslt/simple-elements.xslt +627 -0
  114. data/ext/swfmill/src/xslt/simple-import.xslt +565 -0
  115. data/ext/swfmill/src/xslt/simple-svg.xslt +383 -0
  116. data/ext/swfmill/src/xslt/simple-tools.xslt +255 -0
  117. data/ext/swfmill/src/xslt/simple.cpp +1686 -0
  118. data/ext/swfmill/src/xslt/simple.xml +7 -0
  119. data/ext/swfmill/src/xslt/xslt.h +7 -0
  120. data/ext/swfmill/test/Makefile.am +1 -0
  121. data/ext/swfmill/test/Makefile.in +490 -0
  122. data/ext/swfmill/test/xml/Makefile.am +20 -0
  123. data/ext/swfmill/test/xml/Makefile.in +353 -0
  124. data/ext/swfmill/test/xml/test-xml +21 -0
  125. data/ext/swfmill_ext.cc +375 -0
  126. data/lib/swfmill.rb +30 -0
  127. data/spec/data/swfmill-banner1.swf +0 -0
  128. data/spec/spec.opts +1 -0
  129. data/spec/spec_helper.rb +14 -0
  130. data/spec/swfmill_spec.rb +125 -0
  131. metadata +206 -0
@@ -0,0 +1,41 @@
1
+ #include <SWFAction.h>
2
+ #include "SWF.h"
3
+ #include <cstring>
4
+
5
+ namespace SWF {
6
+
7
+ Action *Action::get( Reader *r, int end, Context *ctx ) {
8
+ uint16_t h = r->getByte();
9
+ int type = h;
10
+ int len = 0;
11
+ if( type >= 0x80 ) {
12
+ len = r->getWord();
13
+ }
14
+
15
+ if( type == 0 ) return( new EndAction ); // terminator
16
+
17
+ Action *ret = getByType( type );
18
+
19
+ // printf("ACTION %02X len %i: %p\n", type, len, ret );
20
+
21
+ if( !ret ) {
22
+ ret = new UnknownAction;
23
+ }
24
+
25
+ ret->setType( type );
26
+ ret->setLength( len );
27
+ ret->parse( r, r->getPosition()+len, ctx );
28
+
29
+ return ret;
30
+ }
31
+
32
+ void Action::writeHeader( Writer *w, Context *ctx, size_t len ) {
33
+ // printf("write action %02X, len %i, recorded %i(+header, 1 or 3), position %i\n", type, len, this->len, w->getPosition() );
34
+
35
+ w->putByte( type );
36
+ if( type >= 0x80 ) {
37
+ w->putWord( len-=3 );
38
+ }
39
+ }
40
+
41
+ }
@@ -0,0 +1,19 @@
1
+ #ifndef SWF_ACTION_H
2
+ #define SWF_ACTION_H
3
+
4
+ #include <SWFIdItem.h>
5
+
6
+ namespace SWF {
7
+
8
+ class Action : public IdItem<Action> {
9
+ protected:
10
+ int getHeaderSize( int size ) { return( (type>=0x80 || size>0) ? 24 : 8 ); }
11
+ void writeHeader( Writer *w, Context *ctx, size_t len );
12
+
13
+ // static stuff
14
+ public:
15
+ static Action* get( Reader *r, int end, Context *ctx );
16
+ };
17
+
18
+ }
19
+ #endif
@@ -0,0 +1,7 @@
1
+ #ifndef SWF_BASIC_H
2
+ #define SWF_BASIC_H
3
+
4
+ #define SWF_WARNING(msg) fprintf(stderr,msg,...);
5
+ #define SWF_ERROR(msg) { fprintf(stderr,msg,...); abort(); }
6
+
7
+ #endif
@@ -0,0 +1,406 @@
1
+ #include "SWFFile.h"
2
+ #include "SWFReader.h"
3
+ #include "SWFWriter.h"
4
+ #include <cstring>
5
+ #include <cstdlib>
6
+ #include <zlib.h>
7
+
8
+ namespace SWF {
9
+
10
+ File::File() {
11
+ // "sane" defaults
12
+ compressed = false;
13
+ version = 7;
14
+ length = 0;
15
+ header = NULL;
16
+ }
17
+
18
+ File::~File() {
19
+ delete header;
20
+ }
21
+
22
+ void File::dump() {
23
+ Context ctx;
24
+ if( !header ) {
25
+ fprintf(stderr,"no SWF loaded to save\n");
26
+ return;
27
+ }
28
+
29
+ fprintf(stderr, "version %i, size %i, %scompressed\n", version, length, (compressed?"":"un") );
30
+ ctx.swfVersion = version;
31
+ header->dump( 2, &ctx );
32
+ }
33
+
34
+ int File::load( FILE *fp, Context *_ctx, unsigned int filesize ) {
35
+ Context *ctx;
36
+ ctx = _ctx ? _ctx : new Context;
37
+ Reader* r = NULL;
38
+ unsigned char *data = NULL;
39
+ char sig[3];
40
+
41
+ // read sig, version
42
+ if( fread( &sig, 3, 1, fp ) != 1
43
+ || fread( &version, 1, 1, fp ) != 1
44
+ || (strncmp(sig,"CWS",2) && strncmp(sig,"FWS",2)) ) {
45
+ fprintf(stderr,"ERROR: input is no SWF\n");
46
+ goto fail;
47
+ }
48
+
49
+ // read length, should be endian-safe
50
+ length = fgetc(fp);
51
+ length += fgetc(fp)<<8;
52
+ length += fgetc(fp)<<16;
53
+ length += fgetc(fp)<<24;
54
+
55
+ ctx->swfVersion = version;
56
+
57
+ length -= 8;
58
+
59
+ compressed = sig[0]=='C';
60
+
61
+ if( length != filesize-8 ) {
62
+ if( length > filesize-8 && !compressed ) {
63
+ /* this allows uncompressed SWFs with invalid filesize to be parsed. */
64
+ fprintf(stderr,"WARNING: size specified in SWF (%i) != filesize (%i), using filesize-8.\n",
65
+ length, filesize );
66
+ length = filesize-8;
67
+ }
68
+ }
69
+
70
+ data = new unsigned char[ length ];
71
+ if( !data ) {
72
+ fprintf(stderr,"cannot load SWF to memory (size %i)\n",length);
73
+ goto fail;
74
+ }
75
+
76
+ if( compressed ) {
77
+ decompress( data, length, fp );
78
+ } else {
79
+ if( fread( data, length, 1, fp ) != 1 ) {
80
+ fprintf(stderr,"could not load SWF to memory (%i, %c)\n",length,sig[0]);
81
+ goto fail;
82
+ }
83
+ }
84
+
85
+ r = new Reader( data, length );
86
+ header = new Header;
87
+
88
+ header->parse( r, length, ctx );
89
+
90
+ if( r->getError() != SWFR_OK ) {
91
+ if( r->getError() == SWFR_EOF ) {
92
+ fprintf(stderr,"WARNING: reached EOF while reading SWF\n");
93
+ } else {
94
+ fprintf(stderr,"unknown error while reading SWF\n");
95
+ goto fail;
96
+ }
97
+ }
98
+
99
+ if( r ) delete r;
100
+ if( !_ctx && ctx ) delete ctx;
101
+ delete[] data;
102
+ return length+8;
103
+
104
+ fail:
105
+ if( data ) delete[] data;
106
+ if( !_ctx && ctx ) delete ctx;
107
+ return 0;
108
+ }
109
+
110
+ int File::save( FILE *fp, Context *_ctx ) {
111
+ Context *ctx;
112
+ ctx = _ctx ? _ctx : new Context;
113
+
114
+ Writer* w = NULL;
115
+ unsigned char *data = NULL;
116
+
117
+ if( !header ) {
118
+ fprintf(stderr,"no SWF loaded to save\n");
119
+ goto fail;
120
+ }
121
+
122
+ if( compressed ) {
123
+ fwrite( "CWS", 3, 1, fp );
124
+ } else {
125
+ fwrite( "FWS", 3, 1, fp );
126
+ }
127
+
128
+ fwrite( &version, 1, 1, fp );
129
+
130
+ length+=8;
131
+ // fwrite( &length, sizeof(length), 1, fp );
132
+ fputc( length&0xFF, fp );
133
+ fputc( (length>>8)&0xFF, fp );
134
+ fputc( (length>>16)&0xFF, fp );
135
+ fputc( (length>>24)&0xFF, fp );
136
+ length-=8;
137
+
138
+ data = new unsigned char[ length ];
139
+ if( !data ) {
140
+ fprintf(stderr,"ERROR: cannot save SWF to memory (size %i)\n",length);
141
+ goto fail;
142
+ }
143
+
144
+ ctx->swfVersion = version;
145
+
146
+ w = new Writer( data, length );
147
+ header->write( w, ctx );
148
+ if( w->getError() != SWFW_OK ) goto fail;
149
+
150
+ if( compressed ) {
151
+ compress( data, length, fp );
152
+ } else {
153
+ if( fwrite( data, length, 1, fp ) != 1 ) {
154
+ fprintf(stderr,"ERROR: could not compress SWF to file (%i)\n",length);
155
+ goto fail;
156
+ }
157
+ }
158
+
159
+ delete w;
160
+ delete[] data;
161
+ if( !_ctx ) delete ctx;
162
+ return( length+8 );
163
+
164
+ fail:
165
+ delete w;
166
+ delete[] data;
167
+ if( !_ctx ) delete ctx;
168
+ return 0;
169
+ }
170
+
171
+ xmlDocPtr File::getXML( Context *_ctx ) {
172
+ Context *ctx;
173
+ ctx = _ctx ? _ctx : new Context;
174
+
175
+ xmlDocPtr doc = 0;
176
+ xmlNodePtr root;
177
+
178
+ if( !header ) {
179
+ fprintf(stderr,"no SWF loaded to save\n");
180
+ goto fail;
181
+ }
182
+
183
+ doc = xmlNewDoc((const xmlChar*)"1.0");
184
+ root = doc->xmlRootNode = xmlNewDocNode( doc, NULL, (const xmlChar *)"swf", NULL );
185
+
186
+ // add version, compression
187
+ char tmp[32];
188
+ snprintf( tmp, 32, "%i", version );
189
+ xmlSetProp( root, (const xmlChar *)"version", (const xmlChar *)tmp );
190
+ snprintf( tmp, 32, "%i", compressed?1:0 );
191
+ xmlSetProp( root, (const xmlChar *)"compressed", (const xmlChar *)tmp );
192
+
193
+ ctx->swfVersion = version;
194
+ header->writeXML( root, ctx );
195
+
196
+ if( !_ctx ) delete ctx;
197
+ return doc;
198
+
199
+ fail:
200
+ if (doc) xmlFreeDoc(doc);
201
+ if( !_ctx ) delete ctx;
202
+ return NULL;
203
+ }
204
+
205
+ int File::saveXML( FILE *fp, Context *ctx ) {
206
+ char *data = NULL;
207
+ int size;
208
+
209
+ xmlDocPtr doc = getXML( ctx );
210
+ if( !doc ) goto fail;
211
+
212
+ xmlDocDumpFormatMemory( doc, (xmlChar**)&data, &size, 1 );
213
+
214
+ if( size ) fwrite( data, size, 1, fp );
215
+
216
+ if( data ) xmlFree(data);
217
+ xmlFreeDoc(doc);
218
+ return size;
219
+
220
+ fail:
221
+ if( data ) xmlFree(data);
222
+ return 0;
223
+ }
224
+
225
+ int File::setXML( xmlNodePtr root, Context *_ctx ) {
226
+ Context *ctx;
227
+ ctx = _ctx ? _ctx : new Context;
228
+
229
+ xmlNodePtr headerNode;
230
+
231
+ if( strcmp( (const char *)root->name, "swf" ) ) {
232
+ fprintf( stderr, "doesn't seem to be a swfml file\n");
233
+ goto fail;
234
+ }
235
+
236
+ if( header ) {
237
+ fprintf( stderr, "SWF file already in memory, not loading XML\n" );
238
+ goto fail;
239
+ }
240
+
241
+ headerNode = root->children;
242
+ while( headerNode && (!headerNode->name || strcmp( (const char *)headerNode->name, "Header" ) ) ) {
243
+ headerNode = headerNode->next;
244
+ }
245
+
246
+ if( !headerNode ) {
247
+ fprintf( stderr, "swfml file is empty\n");
248
+ goto fail;
249
+ }
250
+
251
+ // get version, compression
252
+ int t;
253
+ xmlChar *tmp;
254
+ tmp = xmlGetProp( root, (const xmlChar *)"version" );
255
+ if( tmp ) {
256
+ sscanf( (char *)tmp, "%i", &t );
257
+ ctx->swfVersion = version = t;
258
+ xmlFree( tmp );
259
+ }
260
+ tmp = xmlGetProp( root, (const xmlChar *)"compressed" );
261
+ if( tmp ) {
262
+ sscanf( (char *)tmp, "%i", &t );
263
+ compressed = t>0;
264
+ xmlFree( tmp );
265
+ }
266
+
267
+ header = new Header;
268
+ header->parseXML( headerNode, ctx );
269
+
270
+ length = (header->getSize(ctx,0)/8);
271
+
272
+ if( !_ctx ) delete ctx;
273
+ return length+8;
274
+
275
+ fail:
276
+ if( !_ctx ) delete ctx;
277
+ return 0;
278
+ }
279
+
280
+ int File::loadXML( const char *filename, Context *ctx ) {
281
+ xmlDocPtr doc = NULL;
282
+ xmlNodePtr root;
283
+ int length;
284
+
285
+ doc = xmlParseFile( filename );
286
+ if( !doc ) {
287
+ fprintf( stderr, "could not parse XML\n" );
288
+ return false;
289
+ }
290
+
291
+ root = doc->xmlRootNode;
292
+ length = setXML( root, ctx );
293
+
294
+ xmlFreeDoc( doc );
295
+ return length;
296
+
297
+ fail:
298
+ if( doc ) xmlFreeDoc( doc );
299
+ return 0;
300
+ }
301
+
302
+ #define MAX_BUFFER 1000000
303
+
304
+ void File::compress( unsigned char *inputBuffer, size_t len, FILE *fp ) {
305
+ z_stream stream;
306
+ static unsigned char outputBuffer[ MAX_BUFFER ];
307
+ int status, count;
308
+
309
+ stream.avail_in = len;
310
+ stream.next_in = inputBuffer;
311
+ stream.next_out = outputBuffer;
312
+ stream.zalloc = (alloc_func) NULL;
313
+ stream.zfree = (free_func) NULL;
314
+ stream.opaque = (voidpf) 0;
315
+ stream.avail_out = MAX_BUFFER;
316
+
317
+ status = deflateInit( &stream, Z_BEST_COMPRESSION );
318
+ if( status != Z_OK ) {
319
+ fprintf( stderr, "Error compressing SWF: %s\n", stream.msg );
320
+ return;
321
+ }
322
+
323
+ while( true ) {
324
+ if( stream.avail_in == 0 ) break;
325
+
326
+ status = deflate( &stream, Z_NO_FLUSH );
327
+
328
+ if( status != Z_OK ) {
329
+ fprintf( stderr, "Error compressing SWF: %s\n", stream.msg );
330
+ return;
331
+ }
332
+
333
+ count = MAX_BUFFER - stream.avail_out;
334
+ if( count ) {
335
+ fwrite( outputBuffer, 1, count, fp );
336
+ }
337
+
338
+ stream.next_out = outputBuffer;
339
+ stream.avail_out = MAX_BUFFER;
340
+ }
341
+
342
+ stream.next_out = outputBuffer;
343
+ stream.avail_out = MAX_BUFFER;
344
+
345
+ do {
346
+ status = deflate( &stream, Z_FINISH );
347
+
348
+ count = MAX_BUFFER - stream.avail_out;
349
+ if( count ) {
350
+ fwrite( outputBuffer, 1, count, fp );
351
+ }
352
+
353
+ stream.next_out = outputBuffer;
354
+ stream.avail_out = MAX_BUFFER;
355
+ } while( status == Z_OK );
356
+
357
+ if( status != Z_STREAM_END ) {
358
+ fprintf( stderr, "Error compressing SWF: %s\n", stream.msg );
359
+ return;
360
+ }
361
+
362
+ status = deflateEnd(&stream);
363
+
364
+ if( status != Z_OK ) {
365
+ fprintf( stderr, "Error compressing SWF: %s\n", stream.msg );
366
+ return;
367
+ }
368
+ }
369
+
370
+ void File::decompress( unsigned char *outputBuffer, size_t len, FILE *fp ) {
371
+ z_stream stream;
372
+ static unsigned char inputBuffer[ MAX_BUFFER ];
373
+ int status, count;
374
+
375
+ stream.avail_in = 0;
376
+ stream.next_in = inputBuffer;
377
+ stream.next_out = outputBuffer;
378
+ stream.zalloc = (alloc_func) NULL;
379
+ stream.zfree = (free_func) NULL;
380
+ stream.opaque = (voidpf) 0;
381
+ stream.avail_out = len;
382
+
383
+ status = inflateInit( &stream );
384
+ if( status != Z_OK ) {
385
+ fprintf( stderr, "Error decompressing SWF: %s\n", stream.msg );
386
+ return;
387
+ }
388
+
389
+ do {
390
+ if( stream.avail_in == 0 ) {
391
+ stream.next_in = inputBuffer;
392
+ stream.avail_in = fread( inputBuffer, 1, MAX_BUFFER, fp );
393
+ }
394
+
395
+ if( stream.avail_in == 0 ) break;
396
+
397
+ status = inflate( &stream, Z_SYNC_FLUSH );
398
+ } while( status == Z_OK );
399
+
400
+ if( status != Z_STREAM_END && status != Z_OK ) {
401
+ fprintf( stderr, "Error decompressing SWF: %s\n", stream.msg );
402
+ return;
403
+ }
404
+ }
405
+
406
+ }