1 /****************************************************************************
2  *
3  *  Copyright (C) 2005-2006 "Stuart R. Anderson" <anderson@netsweng.com>
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  ****************************************************************************/
20 
21 #include <stdlib.h>
22 #include "blocks/blocktypes.h"
23 #include "blocks/method.h"
24 #include "blocks/output.h"
25 #include "action.h"
26 #include "parser.h"
27 #include "decompile.h"
28 #define OUTPUTRET SWFOutput
29 #include "swfoutput.h"
30 #include "libming.h"
31 
32 extern const char *blockName (SWFBlocktype header);
33 
34 /*
35  * This should really be passed into each function, but all of the output*.c
36  * file will need to be changed at the same time to match the signature change in
37  * swfoutput.h.
38  */
39 static FILE *outf;
40 
41 /*
42  * This file contains output functions that can display the different SWF block
43  * types in a human readable format.
44  */
45 
46 #define OUT_BEGIN(block) \
47 	struct block *sblock = (struct block *)pblock;
48 
49 static struct SWFBlockOutput outputs[] = {
50 /* Add these back at they are converted
51   {SWF_CHARACTERSET, outputSWF_CHARACTERSET},
52   {SWF_DEFINEBITS, outputSWF_DEFINEBITS},
53   {SWF_DEFINEBITSJPEG2, outputSWF_DEFINEBITSJPEG2},
54   {SWF_DEFINEBITSJPEG3, outputSWF_DEFINEBITSJPEG3},
55   {SWF_DEFINEBITSPTR, outputSWF_DEFINEBITSPTR},
56   {SWF_DEFINEBUTTON, outputSWF_DEFINEBUTTON},
57   {SWF_DEFINEBUTTON2, outputSWF_DEFINEBUTTON2},
58   {SWF_DEFINEBUTTONCXFORM, outputSWF_DEFINEBUTTONCXFORM},
59   {SWF_DEFINEBUTTONSOUND, outputSWF_DEFINEBUTTONSOUND},
60   {SWF_DEFINECOMMANDOBJ, outputSWF_DEFINECOMMANDOBJ},
61   {SWF_DEFINEEDITTEXT, outputSWF_DEFINEEDITTEXT},
62   {SWF_DEFINEFONT, outputSWF_DEFINEFONT},
63 */
64   {SWF_DEFINEFONT2, outputSWF_DEFINEFONT2},
65 /*
66   {SWF_DEFINEFONTINFO, outputSWF_DEFINEFONTINFO},
67   {SWF_DEFINELOSSLESS, outputSWF_DEFINELOSSLESS},
68   {SWF_DEFINELOSSLESS2, outputSWF_DEFINELOSSLESS2},
69   {SWF_DEFINEMORPHSHAPE, outputSWF_DEFINEMORPHSHAPE},
70   {SWF_DEFINESHAPE, outputSWF_DEFINESHAPE},
71   {SWF_DEFINESHAPE2, outputSWF_DEFINESHAPE2},
72   {SWF_DEFINESHAPE3, outputSWF_DEFINESHAPE3},
73   {SWF_DEFINESOUND, outputSWF_DEFINESOUND},
74   {SWF_DEFINESPRITE, outputSWF_DEFINESPRITE},
75   {SWF_DEFINETEXT, outputSWF_DEFINETEXT},
76   {SWF_DEFINETEXT2, outputSWF_DEFINETEXT2},
77   {SWF_DEFINETEXTFORMAT, outputSWF_DEFINETEXTFORMAT},
78   {SWF_DEFINEVIDEO, outputSWF_DEFINEVIDEO},
79   {SWF_DEFINEVIDEOSTREAM, outputSWF_DEFINEVIDEOSTREAM},
80   {SWF_DOACTION, outputSWF_DOACTION},
81   {SWF_ENABLEDEBUGGER, outputSWF_ENABLEDEBUGGER},
82   {SWF_END, outputSWF_END},
83   {SWF_EXPORTASSETS, outputSWF_EXPORTASSETS},
84   {SWF_FONTREF, outputSWF_FONTREF},
85   {SWF_FRAMELABEL, outputSWF_FRAMELABEL},
86   {SWF_FRAMETAG, outputSWF_FRAMETAG},
87   {SWF_FREEALL, outputSWF_FREEALL},
88   {SWF_FREECHARACTER, outputSWF_FREECHARACTER},
89   {SWF_GENCOMMAND, outputSWF_GENCOMMAND},
90   {SWF_IMPORTASSETS, outputSWF_IMPORTASSETS},
91   {SWF_JPEGTABLES, outputSWF_JPEGTABLES},
92   {SWF_NAMECHARACTER, outputSWF_NAMECHARACTER},
93   {SWF_PATHSAREPOSTSCRIPT, outputSWF_PATHSAREPOSTSCRIPT},
94   {SWF_PLACEOBJECT, outputSWF_PLACEOBJECT},
95   {SWF_PLACEOBJECT2, outputSWF_PLACEOBJECT2},
96   {SWF_PREBUILT, outputSWF_PREBUILT},
97   {SWF_PREBUILTCLIP, outputSWF_PREBUILTCLIP},
98   {SWF_PROTECT, outputSWF_PROTECT},
99   {SWF_REMOVEOBJECT, outputSWF_REMOVEOBJECT},
100   {SWF_REMOVEOBJECT2, outputSWF_REMOVEOBJECT2},
101   {SWF_SERIALNUMBER, outputSWF_SERIALNUMBER},
102   {SWF_SETBACKGROUNDCOLOR, outputSWF_SETBACKGROUNDCOLOR},
103   {SWF_SHOWFRAME, outputSWF_SHOWFRAME},
104   {SWF_SOUNDSTREAMBLOCK, outputSWF_SOUNDSTREAMBLOCK},
105   {SWF_SOUNDSTREAMHEAD, outputSWF_SOUNDSTREAMHEAD},
106   {SWF_SOUNDSTREAMHEAD2, outputSWF_SOUNDSTREAMHEAD2},
107   {SWF_STARTSOUND, outputSWF_STARTSOUND},
108   {SWF_SYNCFRAME, outputSWF_SYNCFRAME},
109   {SWF_INITACTION, outputSWF_INITACTION},
110   {SWF_VIDEOFRAME, outputSWF_VIDEOFRAME},
111 */
112 };
113 
114 static int numOutputs = sizeof (outputs) / sizeof (struct SWFBlockOutput);
115 
116 /* Output basic Flash Types */
117 
118 #if 0
119 void
120 outputSWF_RGBA (SWF_RGBA * rgb, char *pname)
121 {
122   printf (" RGBA: (");
123   printf ("%2x,", rgb->red);
124   printf ("%2x,", rgb->green);
125   printf ("%2x,", rgb->blue);
126   printf ("%2x)\n", rgb->alpha);
127 }
128 
129 #endif
130 
131 void
outputswfSWF_RECT(SWFOutput out,SWF_RECT * rect)132 outputswfSWF_RECT (SWFOutput out,SWF_RECT * rect)
133 {
134   SWFOutput_writeBits(out,rect->Nbits,5);
135   SWFOutput_writeSBits(out,rect->Xmin,rect->Nbits);
136   SWFOutput_writeSBits(out,rect->Xmax,rect->Nbits);
137   SWFOutput_writeSBits(out,rect->Ymin,rect->Nbits);
138   SWFOutput_writeSBits(out,rect->Ymax,rect->Nbits);
139 }
140 
141 #if 0
142 void
143 outputSWF_MATRIX (SWF_MATRIX * matrix, char *name)
144 {
145   printf (" Matrix: ");
146   if (matrix->HasScale)
147     {
148       printf ("ScaleX %f ", matrix->ScaleX);
149       printf ("ScaleY %f\n", matrix->ScaleY);
150     }
151   if (matrix->HasRotate)
152     {
153       printf ("RotateSkew0 %f ", matrix->RotateSkew0);
154       printf ("RotateSkew1 %f\n", matrix->RotateSkew1);
155     }
156   printf ("   TranslateX %6ld ", matrix->TranslateX);
157   printf ("TranslateY %6ld\n", matrix->TranslateY);
158 }
159 
160 void
161 outputSWF_BUTTONRECORD (SWF_BUTTONRECORD *brec)
162 {
163   printf (" BUTTONRECORD: ");
164   printf ("  ButtonStateHitTest: %d ", brec->ButtonStateHitTest);
165   printf ("  ButtonStateDown: %d ", brec->ButtonStateDown);
166   printf ("  ButtonStateOver: %d ", brec->ButtonStateOver);
167   printf ("  ButtonStateUp: %d\n", brec->ButtonStateUp);
168   printf ("  CharacterID: %d\n", brec->CharacterId);
169   printf ("  PlaceDepth: %d\n", brec->PlaceDepth);
170 }
171 
172 void
173 outputSWF_BUTTONCONDACTION (SWF_BUTTONCONDACTION *bcarec)
174 {
175 #if 0
176 #ifdef NODECOMPILE
177   int i;
178 #endif
179 #if !defined(ACTIONONLY)
180   printf (" BUTTONCONDACTION: ");
181   printf ("  CondActionSize: %d\n", bcarec->CondActionSize);
182   printf ("  CondIdleToOverDown: %d ", bcarec->CondIdleToOverDown);
183   printf ("  CondOutDownToIdle: %d ", bcarec->CondOutDownToIdle);
184   printf ("  CondOutDownToOverDown: %d ", bcarec->CondOutDownToOverDown);
185   printf ("  CondOverDownToOutDown: %d ", bcarec->CondOverDownToOutDown);
186   printf ("  CondOverDownToOverUp: %d ", bcarec->CondOverDownToOverUp);
187   printf ("  CondOverUpToOverDown: %d ", bcarec->CondOverUpToOverDown);
188   printf ("  CondOverUpToIdle: %d ", bcarec->CondOverUpToIdle);
189   printf ("  CondIdleToOverUp: %d ", bcarec->CondIdleToOverUp);
190   printf ("  CondKeyPress: %d ", bcarec->CondKeyPress);
191   printf ("  CondOverDownToIdle: %d ", bcarec->CondOverDownToIdle);
192   printf ("\n");
193 #endif
194 #ifdef NODECOMPILE
195   printf(" %d Actions\n", bcarec->numActions);
196   for(i=0;i<bcarec->numActions;i++)
197   outputSWF_ACTION(i,&(bcarec->Actions[i]));
198 #else
199   printf (" %s\n", decompile5Action(bcarec->numActions,bcarec->Actions,0));
200 #endif
201 #endif
202 }
203 
204 void
205 outputSWF_CLIPEVENTFLAGS (SWF_CLIPEVENTFLAGS * clipevflags )
206 {
207   printf ("  ClipEventKeyUp: %d ", clipevflags->ClipEventKeyUp);
208   printf ("  ClipEventKeyDown: %d ", clipevflags->ClipEventKeyDown);
209   printf ("  ClipEventMouseUp: %d ", clipevflags->ClipEventMouseUp);
210   printf ("  ClipEventMouseDown: %d ", clipevflags->ClipEventMouseDown);
211   printf ("  ClipEventMouseMove: %d ", clipevflags->ClipEventMouseMove);
212   printf ("  ClipEventUnload: %d ", clipevflags->ClipEventUnload);
213   printf ("  ClipEventEnterFrame: %d ", clipevflags->ClipEventEnterFrame);
214   printf ("  ClipEventLoad: %d ", clipevflags->ClipEventLoad);
215   printf ("  ClipEventDragOver: %d ", clipevflags->ClipEventDragOver);
216   printf ("  ClipEventRollOut: %d ", clipevflags->ClipEventRollOut);
217   printf ("  ClipEventRollOver: %d ", clipevflags->ClipEventRollOver);
218   printf ("  ClipEventReleaseOutside: %d ", clipevflags->ClipEventReleaseOutside);
219   printf ("  ClipEventRelease: %d ", clipevflags->ClipEventRelease);
220   printf ("  ClipEventPress: %d ", clipevflags->ClipEventPress);
221   printf ("  ClipEventInitialize: %d ", clipevflags->ClipEventInitialize);
222   printf ("  ClipEventData: %d ", clipevflags->ClipEventData);
223   printf ("  ClipEventConstruct: %d ", clipevflags->ClipEventConstruct);
224   printf ("  ClipEventKeyPress: %d ", clipevflags->ClipEventKeyPress);
225   printf ("  ClipEventDragOut: %d ", clipevflags->ClipEventDragOut);
226 }
227 
228 void
229 outputSWF_CLIPACTIONRECORD (SWF_CLIPACTIONRECORD * carec )
230 {
231 #if 0
232 #ifdef NODECOMPILE
233   int i;
234 #endif
235 #if !defined(ACTIONONLY)
236   outputSWF_CLIPEVENTFLAGS (&carec->EventFlag);
237   printf(" %ld ActionRecordSize\n", carec->ActionRecordSize);
238   printf(" %d KeyCode\n", carec->KeyCode);
239 #endif
240 #ifdef NODECOMPILE
241   printf(" %d Actions\n", carec->numActions);
242   for(i=0;i<carec->numActions;i++)
243      outputSWF_ACTION(i,&(carec->Actions[i]));
244 #else
245   printf (" %s\n", decompile5Action(carec->numActions,carec->Actions,0));
246 #endif
247 #endif
248 }
249 
250 void
251 outputSWF_CLIPACTIONS (SWF_CLIPACTIONS * clipactions )
252 {
253   int i;
254 #if !defined(ACTIONONLY)
255   outputSWF_CLIPEVENTFLAGS (&clipactions->AllEventFlags);
256   printf(" %d NumClipRecords\n", clipactions->NumClipRecords);
257 #endif
258   for(i=0;i<clipactions->NumClipRecords;i++)
259     outputSWF_CLIPACTIONRECORD(&(clipactions->ClipActionRecords[i]));
260 }
261 
262 void
263 outputSWF_GRADIENTRECORD (SWF_GRADIENTRECORD * gradientrec, char *gname)
264 {
265   printf (" Ratio: %d\n", gradientrec->Ratio);
266   outputSWF_RGBA (&gradientrec->Color, "");
267 }
268 
269 void
270 outputSWF_GRADIENT (SWF_GRADIENT * gradient, char *name)
271 {
272   int i;
273   printf (" Gradient: ");
274   printf (" NumGradients: %d\n", gradient->NumGradients);
275   for (i = 0; i < gradient->NumGradients; i++)
276     outputSWF_GRADIENTRECORD (&(gradient->GradientRecords[i]),"");
277 }
278 
279 
280 void
281 outputSWF_FILLSTYLE (SWF_FILLSTYLE * fillstyle, char *name, int i)
282 {
283   printf (" FillStyle: ");
284   printf (" FillStyleType: %x\n", fillstyle->FillStyleType);
285   switch (fillstyle->FillStyleType)
286     {
287     case 0x00:			/* Solid Fill */
288       outputSWF_RGBA (&fillstyle->Color, "");
289       break;
290     case 0x10:			/* Linear Gradient Fill */
291     case 0x12:			/* Radial Gradient Fill */
292       outputSWF_MATRIX (&fillstyle->GradientMatrix,"");
293       outputSWF_GRADIENT (&fillstyle->Gradient,"");
294       break;
295     case 0x40:			/* Repeating Bitmap Fill */
296     case 0x41:			/* Clipped Bitmap Fill */
297     case 0x42:			/* Non-smoothed Repeating Bitmap Fill */
298     case 0x43:			/* Non-smoothed Clipped Bitmap Fill */
299       printf (" BitmapID: %d\n", fillstyle->BitmapId);
300       outputSWF_MATRIX (&fillstyle->BitmapMatrix,"");
301       break;
302     }
303 }
304 
305 void
306 outputSWF_FILLSTYLEARRAY (SWF_FILLSTYLEARRAY * fillstylearray, char *name)
307 {
308   int count, i;
309 
310   printf (" FillStyleArray: ");
311   printf (" FillStyleCount: %6d ", fillstylearray->FillStyleCount);
312   printf (" FillStyleCountExtended: %6d\n",
313 	  fillstylearray->FillStyleCountExtended);
314   count =
315     (fillstylearray->FillStyleCount !=
316      0xff) ? fillstylearray->FillStyleCount : fillstylearray->
317     FillStyleCountExtended;
318   for (i = 0; i < count; i++)
319     {
320       outputSWF_FILLSTYLE (&(fillstylearray->FillStyles[i]),"",0);
321     }
322 }
323 
324 void
325 outputSWF_LINESTYLE (SWF_LINESTYLE * fillstyle, char *name, int i)
326 {
327   printf (" LineStyle: ");
328   printf (" Width: %d\n", fillstyle->Width);
329   outputSWF_RGBA (&fillstyle->Color, "");
330 }
331 
332 void
333 outputSWF_LINESTYLEARRAY (SWF_LINESTYLEARRAY * linestylearray, char *name)
334 {
335 
336   int count, i;
337 
338   printf (" LineStyleArray: ");
339   printf (" LineStyleCount: %6d ", linestylearray->LineStyleCount);
340   printf (" LineStyleCountExtended: %6d\n",
341 	  linestylearray->LineStyleCountExtended);
342   count =
343     (linestylearray->LineStyleCount !=
344      0xff) ? linestylearray->LineStyleCount : linestylearray->
345     LineStyleCountExtended;
346   for (i = 0; i < count; i++)
347     {
348       outputSWF_LINESTYLE (&(linestylearray->LineStyles[i]),"",0);
349     }
350 }
351 #endif
352 
353 void
outputswfSWF_SHAPERECORD(SWF_SHAPERECORD * shaperec,SWFOutput out,int fillBits,int lineBits)354 outputswfSWF_SHAPERECORD (SWF_SHAPERECORD * shaperec, SWFOutput out, int fillBits, int lineBits)
355 {
356   SWFOutput_writeBits(out,shaperec->EndShape.TypeFlag,1);
357   if (shaperec->EndShape.TypeFlag)
358     {
359       /* An Edge Record */
360       SWFOutput_writeBits(out,shaperec->StraightEdge.StraightEdge,1);
361       if (shaperec->StraightEdge.StraightEdge == 1)
362 	{
363 	  /* A Straight Edge Record */
364           SWFOutput_writeBits(out,shaperec->StraightEdge.NumBits,4);
365           SWFOutput_writeBits(out,shaperec->StraightEdge.GeneralLineFlag,1);
366 	  if( shaperec->StraightEdge.GeneralLineFlag ) {
367           	  SWFOutput_writeSBits(out,shaperec->StraightEdge.DeltaX,shaperec->StraightEdge.NumBits+2);
368           	  SWFOutput_writeSBits(out,shaperec->StraightEdge.DeltaY,shaperec->StraightEdge.NumBits+2);
369 	  } else {
370           	SWFOutput_writeSBits(out,shaperec->StraightEdge.VertLineFlag,1);
371 	  	if( shaperec->StraightEdge.VertLineFlag )  {
372           	  SWFOutput_writeSBits(out,shaperec->StraightEdge.VLDeltaY,shaperec->StraightEdge.NumBits+2);
373 		} else {
374           	  SWFOutput_writeSBits(out,shaperec->StraightEdge.VLDeltaX,shaperec->StraightEdge.NumBits+2);
375 		}
376 	  }
377 	}
378       else
379 	{
380 	  /* A Curved Edge Record */
381           SWFOutput_writeBits(out,shaperec->CurvedEdge.NumBits,4);
382           SWFOutput_writeSBits(out,shaperec->CurvedEdge.ControlDeltaX,shaperec->CurvedEdge.NumBits+2);
383           SWFOutput_writeSBits(out,shaperec->CurvedEdge.ControlDeltaY,shaperec->CurvedEdge.NumBits+2);
384           SWFOutput_writeSBits(out,shaperec->CurvedEdge.AnchorDeltaX,shaperec->CurvedEdge.NumBits+2);
385           SWFOutput_writeSBits(out,shaperec->CurvedEdge.AnchorDeltaY,shaperec->CurvedEdge.NumBits+2);
386 	}
387     }
388   else
389     {
390       /* A Non-Edge Record */
391       if (shaperec->EndShape.EndOfShape == 0)
392 	{
393           SWFOutput_writeBits(out,shaperec->EndShape.EndOfShape,5);
394 	  return;
395 	}
396       SWFOutput_writeBits(out,shaperec->StyleChange.StateNewStyles,1);
397       SWFOutput_writeBits(out,shaperec->StyleChange.StateLineStyle,1);
398       SWFOutput_writeBits(out,shaperec->StyleChange.StateFillStyle1,1);
399       SWFOutput_writeBits(out,shaperec->StyleChange.StateFillStyle0,1);
400       SWFOutput_writeBits(out,shaperec->StyleChange.StateMoveTo,1);
401 
402       if (shaperec->StyleChange.StateMoveTo)
403 	{
404           SWFOutput_writeBits(out,shaperec->StyleChange.MoveBits,5);
405           SWFOutput_writeSBits(out,shaperec->StyleChange.MoveDeltaX,shaperec->StyleChange.MoveBits);
406           SWFOutput_writeSBits(out,shaperec->StyleChange.MoveDeltaY,shaperec->StyleChange.MoveBits);
407 	}
408       if (shaperec->StyleChange.StateFillStyle0) {
409           SWFOutput_writeBits(out,shaperec->StyleChange.FillStyle0,fillBits);
410       }
411       if (shaperec->StyleChange.StateFillStyle1) {
412           SWFOutput_writeBits(out,shaperec->StyleChange.FillStyle1,fillBits);
413       }
414       if (shaperec->StyleChange.StateLineStyle) {
415           SWFOutput_writeBits(out,shaperec->StyleChange.LineStyle,lineBits);
416       }
417     }
418 }
419 
420 SWFOutput
outputswfSWF_SHAPE(SWF_SHAPE * shape)421 outputswfSWF_SHAPE (SWF_SHAPE * shape)
422 {
423   SWFOutput out;
424   int i;
425 
426   out=newSWFOutput();
427   SWFOutput_writeBits(out,shape->NumFillBits,4);
428   SWFOutput_writeBits(out,shape->NumLineBits,4);
429   for (i = 0; i < shape->NumShapeRecords; i++)
430     {
431       outputswfSWF_SHAPERECORD (&(shape->ShapeRecords[i]), out,shape->NumFillBits,shape->NumLineBits);
432     }
433   SWFOutput_byteAlign(out);
434   return out;
435 }
436 
437 #if 0
438 void
439 outputSWF_SHAPEWITHSTYLE (SWF_SHAPEWITHSTYLE * shape, int level, char *name)
440 {
441 /*
442   int i;
443 
444   outputSWF_FILLSTYLEARRAY (&(shape->FillStyles),"");
445   outputSWF_LINESTYLEARRAY (&(shape->LineStyles),"");
446   printf (" NumFillBits: %d\n", shape->NumFillBits);
447   printf (" NumLineBits: %d\n", shape->NumLineBits);
448   for (i = 0; i < shape->NumShapeRecords; i++)
449     {
450       outputswfSWF_SHAPERECORD (&(shape->ShapeRecords[i]),name);
451     }
452 */
453 }
454 
455 void
456 outputSWF_GLYPHENTRY (SWF_GLYPHENTRY *gerec)
457 {
458 	printf("   GlyphIndex[0] = %4.4lx ", gerec->GlyphIndex[0] );
459 	printf("   GlyphAdvance[0] = %4.4lx\n", gerec->GlyphAdvance[0] );
460 }
461 
462 void
463 outputSWF_TEXTRECORD (SWF_TEXTRECORD *trec, int level)
464 {
465   int i;
466   printf (" TEXTRECORD: ");
467   printf ("  TextRecordType: %d ", trec->TextRecordType);
468   printf ("  StyleFlagsReserved: %d ", trec->StyleFlagsReserved);
469   printf ("  StyleFlagHasFont: %d ", trec->StyleFlagHasFont);
470   printf ("  StyleFlagHasColor: %d ", trec->StyleFlagHasColor);
471   printf ("  StyleFlagHasYOffset: %d ", trec->StyleFlagHasYOffset);
472   printf ("  StyleFlagHasXOffset: %d\n", trec->StyleFlagHasXOffset);
473 
474   if ( trec->TextRecordType == 0 )
475   {
476   	/*
477 	 * parser doesn't initialize any other
478 	 * member when TextRecordType == 0,
479 	 * see parseSWF_TEXTRECORD in parser.c
480 	 */
481   	return;
482   }
483 
484   if( trec->StyleFlagHasFont )
485     printf ("  FontID: %d\n", trec->FontID);
486   if( trec->StyleFlagHasColor ) {
487     outputSWF_RGBA(&trec->TextColor, "" );
488   }
489   if( trec->StyleFlagHasYOffset || trec->StyleFlagHasXOffset ) {
490     printf ("  XOffset: %d ", trec->XOffset);
491     printf ("  YOffset: %d\n", trec->YOffset);
492   }
493   if( trec->StyleFlagHasFont )
494     printf ("  TextHeight: %d\n", trec->TextHeight);
495   printf ("  GlyphCount: %d\n", trec->GlyphCount);
496   for(i=0;i<trec->GlyphCount;i++)
497 	  outputSWF_GLYPHENTRY( &(trec->GlyphEntries[i]) );
498 }
499 
500 
501 /* Output Flash Blocks */
502 
503 void
504 outputSWF_CHARACTERSET (SWF_Parserstruct * pblock)
505 {
506   //OUT_BEGIN (SWF_CHARACTERSET);
507 
508 }
509 
510 void
511 outputSWF_DEFINEBITS (SWF_Parserstruct * pblock)
512 {
513   //OUT_BEGIN (SWF_DEFINEBITS);
514 
515 }
516 
517 void
518 outputSWF_DEFINEBITSJPEG2 (SWF_Parserstruct * pblock)
519 {
520   //OUT_BEGIN (SWF_DEFINEBITSJPEG2);
521 
522 }
523 
524 void
525 outputSWF_DEFINEBITSJPEG3 (SWF_Parserstruct * pblock)
526 {
527   //OUT_BEGIN (SWF_DEFINEBITSJPEG3);
528 
529 }
530 
531 void
532 outputSWF_DEFINEBITSPTR (SWF_Parserstruct * pblock)
533 {
534   //OUT_BEGIN (SWF_DEFINEBITSPTR);
535 
536 }
537 
538 void
539 outputSWF_DEFINEBUTTON (SWF_Parserstruct * pblock)
540 {
541   //OUT_BEGIN (SWF_DEFINEBUTTON);
542 
543 }
544 
545 void
546 outputSWF_DEFINEBUTTON2 (SWF_Parserstruct * pblock)
547 {
548   int i;
549   OUT_BEGIN (SWF_DEFINEBUTTON2);
550 
551 #if !defined(ACTIONONLY)
552   printf (" CharacterID: %d\n", sblock->Buttonid);
553   printf (" TrackAsMenu: %d\n", sblock->TrackAsMenu);
554   printf (" ActionOffset: %d\n", sblock->ActionOffset);
555   for(i=0;i<sblock->numCharacters;i++) {
556 	  outputSWF_BUTTONRECORD( &(sblock->Characters[i]) );
557   }
558 #endif
559   for(i=0;i<sblock->numActions;i++) {
560 	  outputSWF_BUTTONCONDACTION( &(sblock->Actions[i]) );
561   }
562 
563 }
564 
565 void
566 outputSWF_DEFINEBUTTONCXFORM (SWF_Parserstruct * pblock)
567 {
568   //OUT_BEGIN (SWF_DEFINEBUTTONCXFORM);
569 
570 }
571 
572 void
573 outputSWF_DEFINEBUTTONSOUND (SWF_Parserstruct * pblock)
574 {
575   //OUT_BEGIN (SWF_DEFINEBUTTONSOUND);
576 
577 }
578 
579 void
580 outputSWF_DEFINECOMMANDOBJ (SWF_Parserstruct * pblock)
581 {
582   //OUT_BEGIN (SWF_DEFINECOMMANDOBJ);
583 
584 }
585 
586 void
587 outputSWF_DEFINEEDITTEXT (SWF_Parserstruct * pblock)
588 {
589   OUT_BEGIN (SWF_DEFINEEDITTEXT);
590 
591   printf (" CharacterID: %d\n", sblock->CharacterID);
592   outputSWF_RECT (&(sblock->Bounds));
593   printf (" Flags: ");
594   printf (" HasText: %d ", sblock->HasText);
595   printf (" WordWrap: %d ", sblock->WordWrap);
596   printf (" Multiline: %d ", sblock->Multiline);
597   printf (" Password: %d ", sblock->Password);
598   printf (" ReadOnly: %d\n", sblock->ReadOnly);
599   printf ("        ");
600   printf (" HasTextColor: %d ", sblock->HasTextColor);
601   printf (" HasMaxLength: %d ", sblock->HasMaxLength);
602   printf (" HasFont: %d ", sblock->HasFont);
603   printf (" AutoSize: %d ", sblock->AutoSize);
604   printf (" HasLayout: %d\n", sblock->HasLayout);
605   printf ("        ");
606   printf (" NoSelect: %d ", sblock->NoSelect);
607   printf (" Border: %d ", sblock->Border);
608   printf (" HTML: %d ", sblock->HTML);
609   printf (" UseOutlines: %d\n", sblock->UseOutlines);
610   if (sblock->HasFont)
611     {
612       printf (" Font: ");
613       printf (" FontID: %d ", sblock->FontID);
614       printf (" FontHeight: %d\n", sblock->FontHeight);
615     }
616   if (sblock->HasTextColor)
617     {
618       outputSWF_RGBA (&sblock->TextColor,"");
619     }
620   if (sblock->HasLayout)
621     {
622       printf (" Layout:: ");
623       printf (" Align: %d ", sblock->Align);
624       printf (" LeftMargin: %d ", sblock->LeftMargin);
625       printf (" RightMargin: %d ", sblock->RightMargin);
626       printf (" Indent: %d ", sblock->Indent);
627       printf (" Leading: %d\n", sblock->Leading);
628     }
629   printf (" VariableName: %s\n", sblock->VariableName);
630   if (sblock->HasText)
631     {
632       printf (" InitialText: %s\n", sblock->InitialText);
633     }
634 }
635 
636 void
637 outputSWF_DEFINEFONT (SWF_Parserstruct * pblock)
638 {
639   //OUT_BEGIN (SWF_DEFINEFONT);
640 
641 }
642 #endif
643 
644 SWFOutput
outputSWF_DEFINEFONT2(SWF_Parserstruct * pblock)645 outputSWF_DEFINEFONT2 (SWF_Parserstruct * pblock)
646 {
647   SWFOutput hdr0,hdr1,offsettbl,*glyphdata;
648   int i,size, glyphbase;
649   OUT_BEGIN (SWF_DEFINEFONT2);
650 
651 
652   glyphdata = calloc(sblock->NumGlyphs,sizeof(SWFOutput *));
653   size=0;
654   for (i = 0; i < sblock->NumGlyphs; i++) {
655 	glyphdata[i] = outputswfSWF_SHAPE (&(sblock->GlyphShapeTable[i]));
656 	size+= SWFOutput_getLength(glyphdata[i]);
657     }
658 
659   if( size > 0xffff )
660     sblock->FontFlagsWideOffsets=1;
661 
662   if (sblock->FontFlagsWideOffsets) {
663     glyphbase=(sblock->NumGlyphs*4)+4;
664     sblock->CodeTableOffset.UI32=glyphbase;
665     sblock->OffsetTable.UI32[0]=glyphbase;
666   } else {
667     glyphbase=(sblock->NumGlyphs*2)+2;
668     sblock->CodeTableOffset.UI16=glyphbase;
669     sblock->OffsetTable.UI16[0]=glyphbase;
670     }
671 
672   for (i = 0; i < sblock->NumGlyphs; i++) {
673         if (sblock->FontFlagsWideOffsets) {
674           sblock->OffsetTable.UI32[i]=sblock->CodeTableOffset.UI32;
675 	  sblock->CodeTableOffset.UI32=sblock->OffsetTable.UI32[i]+SWFOutput_getLength(glyphdata[i]);
676 	} else {
677           sblock->OffsetTable.UI16[i]=sblock->CodeTableOffset.UI16;
678 	  sblock->CodeTableOffset.UI16=sblock->OffsetTable.UI16[i]+SWFOutput_getLength(glyphdata[i]);
679 	}
680     }
681 
682   offsettbl=newSWFOutput();
683   for (i = 0; i < sblock->NumGlyphs; i++) {
684       if (sblock->FontFlagsWideOffsets) {
685 	SWFOutput_writeUInt32(offsettbl,sblock->OffsetTable.UI32[i]);
686       } else {
687 	SWFOutput_writeUInt16(offsettbl,sblock->OffsetTable.UI16[i]);
688 	}
689     }
690 
691   /* Now that we have the glyph data, and it's offset, we can start assembling
692      this block */
693 
694   size=	5		/* Initial header through FontNameLen */
695 	+(sblock->FontNameLen)	/* FontName */
696 	+2;		/* NumGlyphs */
697 
698   hdr1=newSizedSWFOutput(size);
699   SWFOutput_writeUInt16(hdr1,sblock->FontID);
700   SWFOutput_writeBits(hdr1,sblock->FontFlagsHasLayout,1);
701   SWFOutput_writeBits(hdr1,sblock->FontFlagsShiftJis,1);
702   SWFOutput_writeBits(hdr1,sblock->FontFlagsSmallText,1);
703   SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagANSI,1);
704   SWFOutput_writeBits(hdr1,sblock->FontFlagsWideOffsets,1);
705   SWFOutput_writeBits(hdr1,sblock->FontFlagsWideCodes,1);
706   SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagsItalics,1);
707   SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagsBold,1);
708   SWFOutput_writeUInt8(hdr1,sblock->LanguageCode);
709   SWFOutput_writeUInt8(hdr1,sblock->FontNameLen);
710   SWFOutput_writeBuffer(hdr1,(unsigned char *)sblock->FontName,sblock->FontNameLen);
711   SWFOutput_writeUInt16(hdr1,sblock->NumGlyphs);
712 
713   /* Now, copy these parts into the hdr buffer */
714   SWFOutput_writeToMethod(offsettbl,SWFOutputMethod,hdr1);
715   destroySWFOutput(offsettbl);
716   if (sblock->FontFlagsWideOffsets)
717     {
718 	SWFOutput_writeUInt32(hdr1,sblock->CodeTableOffset.UI32);
719     }
720   else
721     {
722 	SWFOutput_writeUInt16(hdr1,sblock->CodeTableOffset.UI16);
723     }
724   for (i = 0; i < sblock->NumGlyphs; i++) {
725     SWFOutput_writeToMethod(glyphdata[i],SWFOutputMethod,hdr1);
726     destroySWFOutput(glyphdata[i]);
727   }
728   free(glyphdata);
729 
730   /* Now, resume the normal linear processing this tag */
731 
732   for (i = 0; i < sblock->NumGlyphs; i++)
733     {
734 	if( sblock->FontFlagsWideCodes ) {
735 	  SWFOutput_writeUInt16(hdr1,sblock->CodeTable[i]);
736 	} else {
737 	  SWFOutput_writeUInt8(hdr1,sblock->CodeTable[i]);
738 	}
739     }
740 
741   if( sblock->FontFlagsHasLayout ) {
742     SWFOutput_writeSInt16(hdr1,sblock->FontAscent);
743     SWFOutput_writeSInt16(hdr1,sblock->FontDecent);
744     SWFOutput_writeSInt16(hdr1,sblock->FontLeading);
745     for (i = 0; i < sblock->NumGlyphs; i++) {
746       SWFOutput_writeSInt16(hdr1,sblock->FontAdvanceTable[i]);
747       }
748     for (i = 0; i < sblock->NumGlyphs; i++) {
749 	outputswfSWF_RECT (hdr1,&(sblock->FontBoundsTable[i]));
750         SWFOutput_byteAlign(hdr1);
751       }
752     SWFOutput_writeUInt16(hdr1,sblock->KerningCount);
753     for (i = 0; i < sblock->KerningCount; i++) {
754       if( sblock->FontFlagsWideCodes ) {
755       	SWFOutput_writeUInt16(hdr1,sblock->FontKerningTable[i].FontKerningCode1);
756       	SWFOutput_writeUInt16(hdr1,sblock->FontKerningTable[i].FontKerningCode2);
757       	SWFOutput_writeSInt16(hdr1,sblock->FontKerningTable[i].FontKerningAdjustment);
758       } else {
759       	SWFOutput_writeUInt8(hdr1,sblock->FontKerningTable[i].FontKerningCode1);
760       	SWFOutput_writeUInt8(hdr1,sblock->FontKerningTable[i].FontKerningCode2);
761       	SWFOutput_writeSInt16(hdr1,sblock->FontKerningTable[i].FontKerningAdjustment);
762       }
763     }
764   }
765 
766 /* This code really belongs in outputTAGHeader() */
767 hdr0=newSizedSWFOutput(6);
768 
769 if(SWFOutput_getLength(hdr1) <= 62 ) {
770 	fprintf(stderr,"TAG %x\n",(SWF_DEFINEFONT2<<6)|SWFOutput_getLength(hdr1));
771 	SWFOutput_writeUInt16(hdr0,(SWF_DEFINEFONT2<<6)|SWFOutput_getLength(hdr1));
772 } else {
773 	SWFOutput_writeUInt16(hdr0,(SWF_DEFINEFONT2<<6)|0x3f);
774 	SWFOutput_writeUInt32(hdr0,SWFOutput_getLength(hdr1));
775 }
776 
777 SWFOutput_writeToMethod(hdr1,SWFOutputMethod,hdr0);
778 destroySWFOutput(hdr1);
779 
780 return hdr0;
781 }
782 
783 #if 0
784 void
785 outputSWF_DEFINEFONTINFO (SWF_Parserstruct * pblock)
786 {
787   //OUT_BEGIN (SWF_DEFINEFONTINFO);
788 
789 }
790 
791 void
792 outputSWF_DEFINELOSSLESS (SWF_Parserstruct * pblock)
793 {
794   //OUT_BEGIN (SWF_DEFINELOSSLESS);
795 
796 }
797 
798 void
799 outputSWF_DEFINELOSSLESS2 (SWF_Parserstruct * pblock)
800 {
801   //OUT_BEGIN (SWF_DEFINELOSSLESS2);
802 
803 }
804 
805 void
806 outputSWF_DEFINEMORPHSHAPE (SWF_Parserstruct * pblock)
807 {
808   //OUT_BEGIN (SWF_DEFINEMORPHSHAPE);
809 
810 }
811 
812 void
813 outputSWF_DEFINESHAPE (SWF_Parserstruct * pblock)
814 {
815   OUT_BEGIN (SWF_DEFINESHAPE);
816 
817   printf (" ShapeID: %d\n", sblock->ShapeID);
818   outputSWF_RECT (&(sblock->ShapeBounds));
819   outputSWF_SHAPEWITHSTYLE (&(sblock->Shapes),1,"");
820 }
821 
822 void
823 outputSWF_DEFINESHAPE2 (SWF_Parserstruct * pblock)
824 {
825   OUT_BEGIN (SWF_DEFINESHAPE2);
826 
827   printf (" ShapeID: %d\n", sblock->ShapeID);
828   outputSWF_RECT (&(sblock->ShapeBounds));
829   outputSWF_SHAPEWITHSTYLE (&(sblock->Shapes),2,"");
830 
831 }
832 
833 void
834 outputSWF_DEFINESHAPE3 (SWF_Parserstruct * pblock)
835 {
836   OUT_BEGIN (SWF_DEFINESHAPE3);
837 
838   printf (" ShapeID: %d\n", sblock->ShapeID);
839   outputSWF_RECT (&(sblock->ShapeBounds));
840   outputSWF_SHAPEWITHSTYLE (&(sblock->Shapes),2,"");
841 
842 }
843 
844 void
845 outputSWF_DEFINESOUND (SWF_Parserstruct * pblock)
846 {
847   //OUT_BEGIN (SWF_DEFINESOUND);
848 
849 }
850 
851 void
852 outputSWF_DEFINESPRITE (SWF_Parserstruct * pblock)
853 {
854   OUT_BEGIN (SWF_DEFINESPRITE);
855   printf(" SpriteId: %d\n", sblock->SpriteId );
856   printf(" FrameCount: %d\n", sblock->FrameCount );
857   printf(" BlockCount: %d\n", sblock->BlockCount );
858 
859 }
860 
861 void
862 outputSWF_DEFINETEXT (SWF_Parserstruct * pblock)
863 {
864   int i;
865   OUT_BEGIN (SWF_DEFINETEXT);
866 
867   printf(" CharacterID: %d\n", sblock->CharacterID );
868   outputSWF_RECT( &sblock->TextBounds );
869   outputSWF_MATRIX( &sblock->TextMatrix, "" );
870   printf(" GlyphBits: %d\n", sblock->GlyphBits );
871   printf(" AdvanceBits: %d\n", sblock->AdvanceBits );
872   printf(" TextRecords: %d\n", sblock->numTextRecords );
873   for(i=0;i<sblock->numTextRecords;i++) {
874 	  outputSWF_TEXTRECORD(&(sblock->TextRecords[i]), 1 );
875   }
876 
877 }
878 
879 void
880 outputSWF_DEFINETEXT2 (SWF_Parserstruct * pblock)
881 {
882   int i;
883   OUT_BEGIN (SWF_DEFINETEXT2);
884 
885   printf(" CharacterID: %d\n", sblock->CharacterID );
886   outputSWF_RECT( &sblock->TextBounds );
887   outputSWF_MATRIX( &sblock->TextMatrix, "" );
888   printf(" GlyphBits: %d\n", sblock->GlyphBits );
889   printf(" AdvanceBits: %d\n", sblock->AdvanceBits );
890   printf(" TextRecords: %d\n", sblock->numTextRecords );
891   for(i=0;i<sblock->numTextRecords;i++) {
892 	  outputSWF_TEXTRECORD(&(sblock->TextRecords[i]), 2 );
893   }
894 }
895 
896 void
897 outputSWF_DEFINETEXTFORMAT (SWF_Parserstruct * pblock)
898 {
899   //OUT_BEGIN (SWF_DEFINETEXTFORMAT);
900 
901 }
902 
903 void
904 outputSWF_DEFINEVIDEO (SWF_Parserstruct * pblock)
905 {
906   //OUT_BEGIN (SWF_DEFINEVIDEO);
907 
908 }
909 
910 void
911 outputSWF_DEFINEVIDEOSTREAM (SWF_Parserstruct * pblock)
912 {
913   //OUT_BEGIN (SWF_DEFINEVIDEOSTREAM);
914 
915 }
916 
917 void
918 outputSWF_DOACTION (SWF_Parserstruct * pblock)
919 {
920 #if 0
921 #ifdef NODECOMPILE
922 	int i;
923 #endif
924 	OUT_BEGIN (SWF_DOACTION);
925 
926 #ifdef NODECOMPILE
927 	printf(" %d Actions\n", sblock->numActions);
928 	for(i=0;i<sblock->numActions;i++)
929 	outputSWF_ACTION(i,&(sblock->Actions[i]));
930 #else
931 	printf ("%s\n", decompile5Action(sblock->numActions,sblock->Actions,0));
932 #endif
933 #endif
934 
935 }
936 
937 void
938 outputSWF_ENABLEDEBUGGER (SWF_Parserstruct * pblock)
939 {
940   //OUT_BEGIN (SWF_ENABLEDEBUGGER);
941 
942 }
943 
944 void
945 outputSWF_END (SWF_Parserstruct * pblock)
946 {
947   //OUT_BEGIN (SWF_END);
948 
949 }
950 
951 void
952 outputSWF_EXPORTASSETS (SWF_Parserstruct * pblock)
953 {
954   int i;
955   OUT_BEGIN (SWF_EXPORTASSETS);
956 
957   printf (" num assets: %d\n", sblock->Count );
958   for (i = 0; i < sblock->Count; i++)
959     {
960 	printf (" Asset[%3.3d]: %s\n", sblock->Tags[i],
961 		  sblock->Names[i]);
962     }
963 
964 }
965 
966 void
967 outputSWF_FONTREF (SWF_Parserstruct * pblock)
968 {
969   //OUT_BEGIN (SWF_FONTREF);
970 
971 }
972 
973 void
974 outputSWF_FRAMELABEL (SWF_Parserstruct * pblock)
975 {
976   //OUT_BEGIN (SWF_FRAMELABEL);
977 
978 }
979 
980 void
981 outputSWF_FRAMETAG (SWF_Parserstruct * pblock)
982 {
983   //OUT_BEGIN (SWF_FRAMETAG);
984 
985 }
986 
987 void
988 outputSWF_FREEALL (SWF_Parserstruct * pblock)
989 {
990   //OUT_BEGIN (SWF_FREEALL);
991 
992 }
993 
994 void
995 outputSWF_FREECHARACTER (SWF_Parserstruct * pblock)
996 {
997   //OUT_BEGIN (SWF_FREECHARACTER);
998 
999 }
1000 
1001 void
1002 outputSWF_GENCOMMAND (SWF_Parserstruct * pblock)
1003 {
1004   //OUT_BEGIN (SWF_GENCOMMAND);
1005 
1006 }
1007 
1008 void
1009 outputSWF_IMPORTASSETS (SWF_Parserstruct * pblock)
1010 {
1011   int i;
1012   OUT_BEGIN (SWF_IMPORTASSETS);
1013 
1014   printf (" URL: %s\n", sblock->URL );
1015   printf (" num assets: %d\n", sblock->Count );
1016   for (i = 0; i < sblock->Count; i++)
1017     {
1018 	printf (" Asset[%3.3d]: %s\n", sblock->Tags[i],
1019 		  sblock->Names[i]);
1020     }
1021 
1022 }
1023 
1024 void
1025 outputSWF_JPEGTABLES (SWF_Parserstruct * pblock)
1026 {
1027   //OUT_BEGIN (SWF_JPEGTABLES);
1028 
1029 }
1030 
1031 void
1032 outputSWF_NAMECHARACTER (SWF_Parserstruct * pblock)
1033 {
1034   //OUT_BEGIN (SWF_NAMECHARACTER);
1035 
1036 }
1037 
1038 void
1039 outputSWF_PATHSAREPOSTSCRIPT (SWF_Parserstruct * pblock)
1040 {
1041   //OUT_BEGIN (SWF_PATHSAREPOSTSCRIPT);
1042 
1043 }
1044 
1045 void
1046 outputSWF_PLACEOBJECT (SWF_Parserstruct * pblock)
1047 {
1048   //OUT_BEGIN (SWF_PLACEOBJECT);
1049 
1050 }
1051 
1052 void
1053 outputSWF_PLACEOBJECT2 (SWF_Parserstruct * pblock)
1054 {
1055   OUT_BEGIN (SWF_PLACEOBJECT2);
1056 
1057 #if !defined(ACTIONONLY)
1058   printf(" PlaceFlagHasClipActions %d\n", sblock->PlaceFlagHasClipActions);
1059   printf(" PlaceFlagHasClipDepth %d\n", sblock->PlaceFlagHasClipDepth);
1060   printf(" PlaceFlagHasName %d\n", sblock->PlaceFlagHasName);
1061   printf(" PlaceFlagHasRatio %d\n", sblock->PlaceFlagHasRatio);
1062   printf(" PlaceFlagHasColorTransform %d\n", sblock->PlaceFlagHasColorTransform);
1063   printf(" PlaceFlagHasMatrix %d\n", sblock->PlaceFlagHasMatrix);
1064   printf(" PlaceFlagHasCharacter %d\n", sblock->PlaceFlagHasCharacter);
1065   printf(" PlaceFlagMove %d\n", sblock->PlaceFlagMove);
1066   printf(" Depth %d\n", sblock->Depth);
1067   if( sblock->PlaceFlagHasCharacter )
1068 	  printf( " CharacterId: %d\n", sblock->CharacterId );
1069   if( sblock->PlaceFlagHasMatrix )
1070 	outputSWF_MATRIX (&(sblock->Matrix), "");
1071 /*
1072   if( sblock->PlaceFlagHasColorTransform )
1073 	outputSWF_CXFORMWITHALPHA (&(sblock->ColorTransform), "");
1074 */
1075   if( sblock->PlaceFlagHasRatio )
1076 	  printf( " Ratio: %d\n", sblock->Ratio );
1077   if( sblock->PlaceFlagHasName )
1078 	  printf( " Name: %s\n", sblock->Name );
1079   if( sblock->PlaceFlagHasClipDepth )
1080 	  printf( " ClipDepth: %d\n", sblock->ClipDepth );
1081 #endif
1082   if( sblock->PlaceFlagHasClipActions )
1083 	outputSWF_CLIPACTIONS (&(sblock->ClipActions));
1084 }
1085 
1086 void
1087 outputSWF_PREBUILT (SWF_Parserstruct * pblock)
1088 {
1089   //OUT_BEGIN (SWF_PREBUILT);
1090 
1091 }
1092 
1093 void
1094 outputSWF_PREBUILTCLIP (SWF_Parserstruct * pblock)
1095 {
1096   //OUT_BEGIN (SWF_PREBUILTCLIP);
1097 
1098 }
1099 
1100 void
1101 outputSWF_PROTECT (SWF_Parserstruct * pblock)
1102 {
1103   OUT_BEGIN (SWF_PROTECT);
1104 
1105   printf(" Password: %s\n", sblock->Password);
1106 
1107 }
1108 
1109 void
1110 outputSWF_REMOVEOBJECT (SWF_Parserstruct * pblock)
1111 {
1112   //OUT_BEGIN (SWF_REMOVEOBJECT);
1113 
1114 }
1115 
1116 void
1117 outputSWF_REMOVEOBJECT2 (SWF_Parserstruct * pblock)
1118 {
1119   //OUT_BEGIN (SWF_REMOVEOBJECT2);
1120 
1121 }
1122 
1123 void
1124 outputSWF_SERIALNUMBER (SWF_Parserstruct * pblock)
1125 {
1126   //OUT_BEGIN (SWF_SERIALNUMBER);
1127 
1128 }
1129 
1130 void
1131 outputSWF_SETBACKGROUNDCOLOR (SWF_Parserstruct * pblock)
1132 {
1133   OUT_BEGIN (SWF_SETBACKGROUNDCOLOR);
1134 
1135   outputSWF_RGBA (&sblock->rgb, "");
1136 
1137 }
1138 
1139 void
1140 outputSWF_SHOWFRAME (SWF_Parserstruct * pblock)
1141 {
1142   //OUT_BEGIN (SWF_SHOWFRAME);
1143 
1144 }
1145 
1146 void
1147 outputSWF_SOUNDSTREAMBLOCK (SWF_Parserstruct * pblock)
1148 {
1149   //OUT_BEGIN (SWF_SOUNDSTREAMBLOCK);
1150 
1151 }
1152 
1153 void
1154 outputSWF_SOUNDSTREAMHEAD (SWF_Parserstruct * pblock)
1155 {
1156   //OUT_BEGIN (SWF_SOUNDSTREAMHEAD);
1157 
1158 }
1159 
1160 void
1161 outputSWF_SOUNDSTREAMHEAD2 (SWF_Parserstruct * pblock)
1162 {
1163   //OUT_BEGIN (SWF_SOUNDSTREAMHEAD2);
1164 
1165 }
1166 
1167 void
1168 outputSWF_STARTSOUND (SWF_Parserstruct * pblock)
1169 {
1170   //OUT_BEGIN (SWF_STARTSOUND);
1171 
1172 }
1173 
1174 void
1175 outputSWF_SYNCFRAME (SWF_Parserstruct * pblock)
1176 {
1177   //OUT_BEGIN (SWF_SYNCFRAME);
1178 
1179 }
1180 
1181 void
1182 outputSWF_INITACTION (SWF_Parserstruct * pblock)
1183 {
1184 #if 0
1185 #ifdef NODECOMPILE
1186 	int i;
1187 #endif
1188 	OUT_BEGIN (SWF_INITACTION);
1189 
1190 #ifdef NODECOMPILE
1191 	printf(" %d Actions\n", sblock->numActions);
1192 	for(i=0;i<sblock->numActions;i++)
1193 	outputSWF_ACTION(i,&(sblock->Actions[i]));
1194 #else
1195 	printf ("%s\n", decompile5Action(sblock->numActions,sblock->Actions,0));
1196 #endif
1197 #endif
1198 
1199 }
1200 void
1201 outputSWF_VIDEOFRAME (SWF_Parserstruct * pblock)
1202 {
1203   //OUT_BEGIN (SWF_VIDEOFRAME);
1204 
1205 }
1206 #endif
1207 
1208 static SWFOutput swfout;
1209 
1210 void
outputHeader(struct Movie * m)1211 outputHeader (struct Movie *m)
1212 {
1213 swfout=newSWFOutput();
1214 }
1215 
1216 void
outputTrailer(struct Movie * m)1217 outputTrailer (struct Movie *m)
1218 {
1219 SWFOutput out;
1220 
1221 out=newSizedSWFOutput(30);
1222 SWFOutput_writeUInt8(out,'F');
1223 SWFOutput_writeUInt8(out,'W');
1224 SWFOutput_writeUInt8(out,'S');
1225 SWFOutput_writeUInt8(out,4);
1226 SWFOutput_writeUInt32(out,SWFOutput_getLength(swfout)+23 /*size of header*/);
1227 SWFOutput_writeBits(out,15,5);
1228 SWFOutput_writeSBits(out,m->frame.xMin,15);
1229 SWFOutput_writeSBits(out,m->frame.xMax,15);
1230 SWFOutput_writeSBits(out,m->frame.yMin,15);
1231 SWFOutput_writeSBits(out,m->frame.yMax,15);
1232 SWFOutput_byteAlign(out);
1233 SWFOutput_writeUInt16(out,m->rate);
1234 SWFOutput_writeUInt16(out,m->nFrames);
1235 
1236 /* Add the SWF_END tag */
1237 SWFOutput_writeUInt16(swfout,0);
1238 
1239 SWFOutput_writeToMethod(out,fileOutputMethod,stdout);
1240 SWFOutput_writeToMethod(swfout,fileOutputMethod,stdout);
1241 destroySWFOutput(swfout);
1242 destroySWFOutput(out);
1243 }
1244 
1245 void
outputBlock(int type,SWF_Parserstruct * blockp,FILE * stream)1246 outputBlock (int type, SWF_Parserstruct * blockp, FILE* stream)
1247 {
1248   SWFOutput blkout;
1249   int i;
1250 
1251   if (type < 0)
1252     return;
1253 
1254   outf = stream;
1255 
1256   for (i = 0; i < numOutputs; i++)
1257     {
1258       if (outputs[i].type == type)
1259 	{
1260 	  blkout=outputs[i].output (blockp);
1261 	  SWFOutput_writeToMethod(blkout,SWFOutputMethod,swfout);
1262 	  destroySWFOutput(blkout);
1263 	}
1264     }
1265   return;
1266 }
1267