logf argument names changed.
[swftools.git] / lib / modules / swfdump.c
1 /* swfdump.c
2
3    Dump / debug functions
4    
5    Extension module for the rfxswf library.
6    Part of the swftools package.
7
8    Copyright (c) 2001 Rainer Böhme <rfxswf@reflex-studio.de>
9  
10    This file is distributed under the GPL, see file COPYING for details 
11
12 */
13
14 void swf_DumpHeader(FILE * f,SWF * swf)
15 { if (!f) f = stderr;
16   fprintf(f,"File size\t%u\n",swf->fileSize);
17   fprintf(f,"Movie width\t%u\n",(swf->movieSize.xmax - swf->movieSize.xmin)/20);
18   fprintf(f,"Movie height\t%u\n",(swf->movieSize.ymax - swf->movieSize.ymin)/20);
19   fprintf(f,"Frame rate\t%u.%u\n",swf->frameRate>>8,swf->frameRate&0xff);
20   fprintf(f,"Frame count\t%u\n",swf->frameCount);
21 }
22
23 void swf_DumpMatrix(FILE * f,MATRIX * m)
24 { if (!f) f = stderr;
25   fprintf(f,"[%08x][%08x]\n",m->sx,m->r1);
26   fprintf(f,"[%08x][%08x]\n",m->r0,m->sy);
27   fprintf(f," %08x, %08x\n",m->tx,m->ty);
28 }
29
30 void swf_DumpTag(FILE * f,TAG * t)
31 { int i;
32   if (!f) f = stderr;
33   for (i=0;i<t->len;i++)
34   { if (!(i&15)) fprintf(f,"\n");
35     fprintf(f,"%02x ",t->data[i]);
36   }
37   fprintf(f,"\n");
38 }
39
40 void swf_DumpFont(SWFFONT * font)
41 {
42     printf("ID: %d\n", font->id);
43     printf("Version: %d\n", font->version);
44     printf("name: %s\n", font->name);
45     printf("characters: %d\n", font->numchars);
46     printf("layout: %s\n", font->layout?"yes":"no");
47     if(font->layout)
48     {
49         printf(" ascent:%d\n", font->layout->ascent);
50         printf(" descent:%d\n", font->layout->descent);
51         printf(" leading:%d\n", font->layout->leading);
52         printf(" bounds: (not shown)\n");
53         printf(" kerning records:%d\n", font->layout->kerningcount);
54         printf(" kerning records: (not shown)\n");
55     }
56 }
57
58 char* swf_TagGetName(TAG*tag)
59 {
60     switch(tag->id)
61     {
62         case ST_END:
63             return "END";
64         case ST_SHOWFRAME:
65             return "SHOWFRAME";
66         case ST_DEFINESHAPE:
67             return "DEFINESHAPE";
68         case ST_FREECHARACTER:
69             return "FREECHARACTER";
70         case ST_PLACEOBJECT:
71             return "PLACEOBJECT";
72         case ST_REMOVEOBJECT:
73             return "REMOVEOBJECT";
74         case ST_DEFINEBITS:
75             return "DEFINEBITS";
76         case ST_DEFINEBUTTON:
77             return "DEFINEBUTTON";
78         case ST_JPEGTABLES:
79             return "JPEGTABLES";
80         case ST_SETBACKGROUNDCOLOR:
81             return "SETBACKGROUNDCOLOR";
82         case ST_DEFINEFONT:
83             return "DEFINEFONT";
84         case ST_DEFINETEXT:
85             return "DEFINETEXT";
86         case ST_DEFINEEDITTEXT:
87             return "DEFINEEDITTEXT";
88         case ST_DOACTION:
89             return "DOACTION";
90         case ST_DEFINEFONTINFO:
91             return "DEFINEFONTINFO";
92         case ST_DEFINESOUND:
93             return "DEFINESOUND";
94         case ST_STARTSOUND:
95             return "STARTSOUND";
96         case ST_DEFINEBUTTONSOUND:
97             return "DEFINEBUTTONSOUND";
98         case ST_SOUNDSTREAMHEAD:
99             return "SOUNDSTREAMHEAD";
100         case ST_SOUNDSTREAMBLOCK:
101             return "SOUNDSTREAMBLOCK";
102         case ST_DEFINEBITSLOSSLESS:
103             return "DEFINEBITSLOSSLESS";
104         case ST_DEFINEBITSJPEG2:
105             return "DEFINEBITSJPEG2";
106         case ST_DEFINESHAPE2:
107             return "DEFINESHAPE2";
108         case ST_DEFINEBUTTONCXFORM:
109             return "DEFINEBUTTONCXFORM";
110         case ST_PROTECT:
111             return "PROTECT";
112         case ST_PLACEOBJECT2:
113             return "PLACEOBJECT2";
114         case ST_REMOVEOBJECT2:
115             return "REMOVEOBJECT2";
116         case ST_DEFINESHAPE3:
117             return "DEFINESHAPE3";
118         case ST_DEFINETEXT2:
119             return "DEFINETEXT2";
120         case ST_DEFINEBUTTON2:
121             return "DEFINEBUTTON2";
122         case ST_DEFINEBITSJPEG3:
123             return "DEFINEBITSJPEG3";
124         case ST_DEFINEBITSLOSSLESS2:
125             return "DEFINEBITSLOSSLESS2";
126         case ST_DEFINESPRITE:
127             return "DEFINESPRITE";
128         case ST_NAMECHARACTER:
129             return "NAMECHARACTER";
130         case ST_SERIALNUMBER:
131             return "SERIALNUMBER";
132         case ST_GENERATORTEXT:
133             return "GENERATORTEXT";
134         case ST_FRAMELABEL:
135             return "FRAMELABEL";
136         case ST_SOUNDSTREAMHEAD2:
137             return "SOUNDSTREAMHEAD2";
138         case ST_DEFINEMORPHSHAPE:
139             return "DEFINEMORPHSHAPE";
140         case ST_DEFINEFONT2:
141             return "DEFINEFONT2";
142         case ST_TEMPLATECOMMAND:
143             return "TEMPLATECOMMAND";
144         case ST_GENERATOR3:
145             return "GENERATOR3";
146         case ST_EXTERNALFONT:
147             return "EXTERNALFONT";
148         case ST_EXPORTASSETS:
149             return "EXPORTASSETS";
150         case ST_IMPORTASSETS:
151             return "IMPORTASSETS";
152         case ST_ENABLEDEBUGGER:
153             return "ENABLEDEBUGGER";
154         case ST_REFLEX:
155             return "REFLEX";
156     }
157     return 0;
158 }