new functions
[swftools.git] / lib / rfxswf.c
1 /* vi: set sts=2 sw=2 :*/
2 /* rfxswf.c 
3
4    Library for creating and reading SWF files or parts of it.
5    There's a module directory which provides some extended functionality.
6    Most modules are included at the bottom of this file.
7
8    Part of the swftools package.
9
10    Copyright (c) 2000-2003 Rainer Böhme <rfxswf@reflex-studio.de>
11    Copyright (c) 2003 Matthias Kramm <kramm@quiss.org> 
12
13    This program is free software; you can redistribute it and/or modify
14    it under the terms of the GNU General Public License as published by
15    the Free Software Foundation; either version 2 of the License, or
16    (at your option) any later version.
17
18    This program is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21    GNU General Public License for more details.
22
23    You should have received a copy of the GNU General Public License
24    along with this program; if not, write to the Free Software
25    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
26
27 #include "rfxswf.h"
28
29 #ifdef HAVE_JPEGLIB
30 #define HAVE_BOOLEAN
31 #include <jpeglib.h>
32 #endif // HAVE_JPEGLIB
33
34 #ifdef HAVE_ZLIB
35 #include <zlib.h>
36 #endif // HAVE_ZLIB
37
38 #ifndef RFXSWF_DISABLESOUND
39 #ifdef HAVE_LAME
40 #include "lame/lame.h"
41 #endif
42 #endif
43
44 #ifdef HAVE_TIME_H
45 #include <time.h>
46 #endif
47
48 #include "./bitio.h"
49 #include "./MD5.h"
50
51 // memory allocation
52
53 void* rfxalloc(int size)
54 {
55   void*ptr;
56 #ifdef HAVE_CALLOC
57   ptr = calloc(size);
58 #else
59   ptr = malloc(size);
60   memset(ptr, 0, size);
61 #endif
62   if(!ptr) {
63     fprintf(stderr, "FATAL: Out of memory\n");
64     /* TODO: we should send a signal, so that the debugger kicks in */
65     exit(1);
66   }
67   return ptr;
68 }
69
70 void rfxdealloc(void*ptr)
71 {
72   free(ptr);
73 }
74
75 // internal constants
76
77 #define MALLOC_SIZE     128
78 #define INSERT_RFX_TAG
79
80 #define MEMSIZE(l) (((l/MALLOC_SIZE)+1)*MALLOC_SIZE)
81
82 // inline wrapper functions
83
84 TAG * swf_NextTag(TAG * t) { return t->next; }
85 TAG * swf_PrevTag(TAG * t) { return t->prev; }
86 U16   swf_GetTagID(TAG * t)    { return t->id; }
87 U32   swf_GetTagLen(TAG * t) { return t->len; }
88 U8*   swf_GetTagLenPtr(TAG * t) { return &(t->data[t->len]); }
89 U32   swf_GetTagPos(TAG * t)   { return t->pos; }
90
91 // for future purpose: avoid high level lib functions to change tagpos/bitpos
92
93 #define swf_SaveTagPos(tag)
94 #define swf_RestoreTagPos(tag)
95
96 void swf_SetTagPos(TAG * t,U32 pos)
97 { swf_ResetReadBits(t);
98   if (pos<=t->len) t->pos = pos;
99   else { 
100 #ifdef DEBUG_RFXSWF
101     fprintf(stderr,"SetTagPos(%d) out of bounds: TagID = %i\n",pos, t->id);
102 #endif
103   }
104 }
105
106 char* swf_GetString(TAG*t)
107 {
108     char* str = ((char*)(&(t)->data[(t)->pos]));
109     while(swf_GetU8(t));
110     return str;
111 }
112
113 U8 swf_GetU8(TAG * t)
114 { swf_ResetReadBits(t);
115   #ifdef DEBUG_RFXSWF
116     if (t->pos>=t->len) 
117     { fprintf(stderr,"GetU8() out of bounds: TagID = %i\n",t->id);
118       return 0;
119     }
120   #endif
121   return t->data[t->pos++];
122 }
123
124 U16 swf_GetU16(TAG * t)
125 { U16 res;
126   swf_ResetReadBits(t);
127   #ifdef DEBUG_RFXSWF
128     if (t->pos>(t->len-2)) 
129     { fprintf(stderr,"GetU16() out of bounds: TagID = %i\n",t->id);
130       return 0;
131     }
132   #endif
133   res = t->data[t->pos] | (t->data[t->pos+1]<<8);
134   t->pos+=2;
135   return res;
136 }
137
138 U32 swf_GetU32(TAG * t)
139 { U32 res;
140   swf_ResetReadBits(t);
141   #ifdef DEBUG_RFXSWF
142     if (t->pos>(t->len-4)) 
143     { fprintf(stderr,"GetU32() out of bounds: TagID = %i\n",t->id);
144       return 0;
145     }
146   #endif
147   res = t->data[t->pos]        | (t->data[t->pos+1]<<8) | 
148        (t->data[t->pos+2]<<16) | (t->data[t->pos+3]<<24);
149   t->pos+=4;
150   return res;
151 }
152
153 int swf_GetBlock(TAG * t,U8 * b,int l)
154 // returns number of bytes written (<=l)
155 // b = NULL -> skip data
156 { swf_ResetReadBits(t);
157   if ((t->len-t->pos)<l) l=t->len-t->pos;
158   if (b && l) memcpy(b,&t->data[t->pos],l);
159   t->pos+=l;
160   return l;
161 }
162
163 int swf_SetBlock(TAG * t,U8 * b,int l)
164 // Appends Block to the end of Tagdata, returns size
165 { U32 newlen = t->len + l;
166   swf_ResetWriteBits(t);
167   if (newlen>t->memsize)
168   { U32  newmem  = MEMSIZE(newlen);  
169     U8 * newdata = (U8*)((t->data)?realloc(t->data,newmem):malloc(newmem));
170     if (!newdata)
171     {
172       #ifdef DEBUG_RFXSWF
173         fprintf(stderr,"Fatal Error: malloc()/realloc() failed (1). (%d bytes)\n", newmem);
174         *(int*)0=0;
175       #endif
176       return 0;
177     }
178     t->memsize = newmem;
179     t->data    = newdata;
180   }
181   if (b) memcpy(&t->data[t->len],b,l);
182   else memset(&t->data[t->len],0x00,l);
183   t->len+=l;
184   return l;
185 }
186
187 int swf_SetU8(TAG * t,U8 v)
188 { swf_ResetWriteBits(t);
189   if ((t->len+1)>t->memsize) return (swf_SetBlock(t,&v,1)==1)?0:-1;
190   t->data[t->len++] = v;
191   return 0;
192 }
193
194 int swf_SetU16(TAG * t,U16 v)
195 { U8 a[2];
196   a[0] = v&0xff;
197   a[1] = v>>8;
198   
199   swf_ResetWriteBits(t);
200   if ((t->len+2)>t->memsize) return (swf_SetBlock(t,a,2)==2)?0:-1;
201   t->data[t->len++] = a[0];
202   t->data[t->len++] = a[1];
203   return 0;
204 }
205 void swf_SetS16(TAG * t,int v)
206 {
207     if(v>32767 || v<-32768) {
208         fprintf(stderr, "Warning: S16 overflow: %d\n", v);
209     }
210     swf_SetU16(t, (S16)v);
211 }
212
213 int swf_SetU32(TAG * t,U32 v)
214 { U8 a[4];
215   a[0] = v&0xff;        // to ensure correct handling of non-intel byteorder
216   a[1] = (v>>8)&0xff;
217   a[2] = (v>>16)&0xff;
218   a[3] = (v>>24)&0xff;
219   
220   swf_ResetWriteBits(t);
221   if ((t->len+4)>t->memsize) return (swf_SetBlock(t,a,4)==4)?0:-1;
222   t->data[t->len++] = a[0];
223   t->data[t->len++] = a[1];
224   t->data[t->len++] = a[2];
225   t->data[t->len++] = a[3];
226   return 0;
227 }
228
229 U32 swf_GetBits(TAG * t,int nbits)
230 { U32 res = 0;
231   if (!nbits) return 0;
232   if (!t->readBit) t->readBit = 0x80;
233   while (nbits)
234   { res<<=1;
235     if (t->data[t->pos]&t->readBit) res|=1;
236     t->readBit>>=1;
237     nbits--;
238     if (!t->readBit)
239     { if (nbits) t->readBit = 0x80;
240       #ifdef DEBUG_RFXSWF
241       if (t->pos>=t->len) 
242       { fprintf(stderr,"GetBits() out of bounds: TagID = %i\n",t->id);
243         return res;
244       }
245       #endif
246       t->pos++;
247     }
248   }
249   return res;
250 }
251
252 S32 swf_GetSBits(TAG * t,int nbits)
253 { U32 res = swf_GetBits(t,nbits);
254   if (res&(1<<(nbits-1))) res|=(0xffffffff<<nbits);  
255   return (S32)res;
256 }
257
258 U32 reader_GetBits(struct reader_t*reader, int nbits)
259 { return reader_readbits(reader, nbits);
260 }
261 S32 reader_GetSBits(struct reader_t*reader, int nbits)
262 { U32 res = reader_readbits(reader, nbits);
263   if (res&(1<<(nbits-1))) res|=(0xffffffff<<nbits);  
264   return (S32)res;
265 }
266
267 int swf_SetBits(TAG * t,U32 v,int nbits)
268 { U32 bm = 1<<(nbits-1);
269
270   while (nbits)
271   { if (!t->writeBit)
272     { if (FAILED(swf_SetU8(t,0))) return -1;
273       t->writeBit = 0x80;
274     }
275     if (v&bm) t->data[t->len-1] |= t->writeBit;
276     bm>>=1;
277     t->writeBit>>=1;
278     nbits--;
279   }
280   return 0;
281 }
282
283 // Advanced Data Access Functions
284
285 int swf_SetRGB(TAG * t,RGBA * col)
286 { if (!t) return -1;
287   if (col)
288   { swf_SetU8(t,col->r);
289     swf_SetU8(t,col->g);
290     swf_SetU8(t,col->b);
291   } else swf_SetBlock(t,NULL,3);
292   return 0;
293 }
294 void swf_GetRGB(TAG * t, RGBA * col)
295 {
296     RGBA dummy;
297     if(!col)
298         col = &dummy;
299     col->r = swf_GetU8(t);
300     col->g = swf_GetU8(t);
301     col->b = swf_GetU8(t);
302     col->a = 255;
303 }
304
305 int swf_SetRGBA(TAG * t,RGBA * col)
306 { if (!t) return -1;
307   if (col)
308   { swf_SetU8(t,col->r);
309     swf_SetU8(t,col->g);
310     swf_SetU8(t,col->b);
311     swf_SetU8(t,col->a);
312   } else swf_SetBlock(t,NULL,4);
313   return 0;
314 }
315 void swf_GetRGBA(TAG * t, RGBA * col)
316 {
317     RGBA dummy;
318     if(!col)
319         col = &dummy;
320     col->r = swf_GetU8(t);
321     col->g = swf_GetU8(t);
322     col->b = swf_GetU8(t);
323     col->a = swf_GetU8(t);
324 }
325
326 void swf_GetGradient(TAG * tag, GRADIENT * gradient, char alpha)
327 {
328     GRADIENT dummy;
329     int t;
330     if(!tag) {
331       memset(gradient, 0, sizeof(GRADIENT));
332       return;
333     }
334     if(!gradient)
335         gradient = &dummy;
336     gradient->num = swf_GetU8(tag);
337     for(t=0;t<gradient->num;t++)
338     {
339         int s=t;
340         if(s>=8) //FIXME
341             s=7;
342         gradient->ratios[t] = swf_GetU8(tag);
343         if(!alpha)
344             swf_GetRGB(tag, &gradient->rgba[t]);
345         else
346             swf_GetRGBA(tag, &gradient->rgba[t]);
347     }
348 }
349
350 void swf_SetGradient(TAG * tag, GRADIENT * gradient, char alpha)
351 {
352     int t;
353     if(!tag) {
354       memset(gradient, 0, sizeof(GRADIENT));
355       return;
356     }
357     swf_SetU8(tag, gradient->num);
358     for(t=0; t<8 && t<gradient->num; t++)
359     {
360         swf_SetU8(tag, gradient->ratios[t]);
361         if(!alpha)
362             swf_SetRGB(tag, &gradient->rgba[t]);
363         else
364             swf_SetRGBA(tag, &gradient->rgba[t]);
365     }
366 }
367
368 int swf_CountUBits(U32 v,int nbits)
369 { int n = 32;
370   U32 m = 0x80000000;
371   if(v == 0x00000000) n = 0; 
372   else
373     while (!(v&m))
374     { n--;
375       m>>=1;
376     } 
377   return (n>nbits)?n:nbits;
378 }
379
380 int swf_CountBits(U32 v,int nbits)
381 { int n = 33;
382   U32 m = 0x80000000;
383   if (v&m)
384   { if(v == 0xffffffff) n = 1;
385     else 
386     while (v&m)
387     { n--;
388       m>>=1;
389     } 
390   }
391   else
392   { if(v == 0x00000000) n = 0; 
393     else
394     while (!(v&m))
395     { n--;
396       m>>=1;
397     } 
398   }
399   return (n>nbits)?n:nbits;
400 }
401
402 int swf_GetRect(TAG * t,SRECT * r)
403 { int nbits;
404   SRECT dummy;
405   if(!t) {r->xmin=r->xmax=r->ymin=r->ymax=0;return 0;}
406   if (!r) r = &dummy;
407   nbits = (int) swf_GetBits(t,5);
408   r->xmin = swf_GetSBits(t,nbits);
409   r->xmax = swf_GetSBits(t,nbits);
410   r->ymin = swf_GetSBits(t,nbits);
411   r->ymax = swf_GetSBits(t,nbits);
412   return 0;
413 }
414
415 int reader_GetRect(struct reader_t*reader,SRECT * r)
416 { int nbits;
417   SRECT dummy;
418   if (!r) r = &dummy;
419   nbits = (int) reader_GetBits(reader,5);
420   r->xmin = reader_GetSBits(reader,nbits);
421   r->xmax = reader_GetSBits(reader,nbits);
422   r->ymin = reader_GetSBits(reader,nbits);
423   r->ymax = reader_GetSBits(reader,nbits);
424   return 0;
425 }
426
427 int swf_SetRect(TAG * t,SRECT * r)
428 { int nbits;
429     
430   nbits = swf_CountBits(r->xmin,0);
431   nbits = swf_CountBits(r->xmax,nbits);
432   nbits = swf_CountBits(r->ymin,nbits);
433   nbits = swf_CountBits(r->ymax,nbits);
434   if(nbits>=32) {
435     fprintf(stderr, "rfxswf: Warning: num_bits overflow in swf_SetRect\n");
436     nbits=31;
437   }
438
439   swf_SetBits(t,nbits,5);
440   swf_SetBits(t,r->xmin,nbits);
441   swf_SetBits(t,r->xmax,nbits);
442   swf_SetBits(t,r->ymin,nbits);
443   swf_SetBits(t,r->ymax,nbits);
444
445   return 0;
446 }
447
448 void swf_ExpandRect(SRECT*src, SPOINT add)
449 {
450     if((src->xmin | src->ymin | src->xmax | src->ymax)==0) {
451         src->xmin = add.x;
452         src->ymin = add.y;
453         src->xmax = add.x;
454         src->ymax = add.y;
455         if((add.x|add.y) == 0) src->xmax++; //make sure the bbox is not NULL anymore
456         return;
457     }
458     if(add.x < src->xmin)
459         src->xmin = add.x;
460     if(add.x > src->xmax)
461         src->xmax = add.x;
462     if(add.y < src->ymin)
463         src->ymin = add.y;
464     if(add.y > src->ymax)
465         src->ymax = add.y;
466 }
467 void swf_ExpandRect2(SRECT*src, SRECT*add)
468 {
469     if((add->xmin | add->ymin | add->xmax | add->ymax)==0)
470         return;
471     if((src->xmin | src->ymin | src->xmax | src->ymax)==0)
472         *src = *add;
473     if(add->xmin < src->xmin)
474         src->xmin = add->xmin;
475     if(add->ymin < src->ymin)
476         src->ymin = add->ymin;
477     if(add->xmax > src->xmax)
478         src->xmax = add->xmax;
479     if(add->ymax > src->ymax)
480         src->ymax = add->ymax;
481 }
482 void swf_ExpandRect3(SRECT*src, SPOINT center, int radius)
483 {
484     if((src->xmin | src->ymin | src->xmax | src->ymax)==0) {
485         src->xmin = center.x-radius;
486         src->ymin = center.y-radius;
487         src->xmax = center.x+radius;
488         src->ymax = center.y+radius;
489         if((center.x|center.y|radius) == 0) src->xmax++; //make sure the bbox is not NULL anymore
490         return;
491     }
492     if(center.x - radius < src->xmin)
493         src->xmin = center.x - radius;
494     if(center.x + radius > src->xmax)
495         src->xmax = center.x - radius;
496     if(center.y - radius < src->ymin)
497         src->ymin = center.y - radius;
498     if(center.y + radius > src->ymax)
499         src->ymax = center.y - radius;
500 }
501 SPOINT swf_TurnPoint(SPOINT p, MATRIX* m)
502 {
503     SPOINT r;
504     r.x = (int)(m->sx*(1/65536.0)*p.x + m->r1*(1/65536.0)*p.y + 0.5) + m->tx;
505     r.y = (int)(m->r0*(1/65536.0)*p.x + m->sy*(1/65536.0)*p.y + 0.5) + m->ty;
506     return r;
507 }
508 SRECT swf_TurnRect(SRECT r, MATRIX* m)
509 {
510     SRECT g;
511     SPOINT p1,p2,p3,p4,pp1,pp2,pp3,pp4;
512     p1.x = r.xmin;p1.y = r.ymin;
513     p2.x = r.xmax;p2.y = r.ymin;
514     p3.x = r.xmin;p3.y = r.ymax;
515     p4.x = r.xmax;p4.y = r.ymax;
516     pp1 = swf_TurnPoint(p1, m);
517     pp2 = swf_TurnPoint(p2, m);
518     pp3 = swf_TurnPoint(p3, m);
519     pp4 = swf_TurnPoint(p4, m);
520     g.xmin = g.xmax = pp1.x;
521     g.ymin = g.ymax = pp1.y;
522     swf_ExpandRect(&g, pp2);
523     swf_ExpandRect(&g, pp3);
524     swf_ExpandRect(&g, pp4);
525     return g;
526 }
527         
528
529 int swf_GetMatrix(TAG * t,MATRIX * m)
530 { MATRIX dummy;
531   int nbits;
532     
533   if (!m) m = &dummy;
534   
535   if (!t)
536   { m->sx = m->sy = 0x10000;
537     m->r0 = m->r1 = 0;
538     m->tx = m->ty = 0;
539     return -1;
540   }
541
542   swf_ResetReadBits(t);
543   
544   if (swf_GetBits(t,1))
545   { nbits = swf_GetBits(t,5);
546     m->sx = swf_GetSBits(t,nbits);
547     m->sy = swf_GetSBits(t,nbits);
548   }
549   else m->sx = m->sy = 0x10000;
550   
551   if (swf_GetBits(t,1))
552   { nbits = swf_GetBits(t,5);
553     m->r0 = swf_GetSBits(t,nbits);
554     m->r1 = swf_GetSBits(t,nbits);
555   }
556   else m->r0 = m->r1 = 0x0;
557
558   nbits = swf_GetBits(t,5);
559   m->tx = swf_GetSBits(t,nbits);
560   m->ty = swf_GetSBits(t,nbits);
561   
562   return 0;
563 }
564
565 int swf_SetMatrix(TAG * t,MATRIX * m)
566 { int nbits;
567   MATRIX ma;
568
569   if (!m)
570   { m = &ma;
571     ma.sx = ma.sy = 0x10000;
572     ma.r0 = ma.r1 = 0;
573     ma.tx = ma.ty = 0;
574   }
575
576   swf_ResetWriteBits(t);
577
578   if ((m->sx==0x10000)&&(m->sy==0x10000)) swf_SetBits(t,0,1);
579   else
580   { swf_SetBits(t,1,1);
581     nbits = swf_CountBits(m->sx,0);
582     nbits = swf_CountBits(m->sy,nbits);
583     if(nbits>=32) {
584         fprintf(stderr,"rfxswf: Error: matrix values too large\n");
585         nbits = 31;
586     }
587     swf_SetBits(t,nbits,5);
588     swf_SetBits(t,m->sx,nbits);
589     swf_SetBits(t,m->sy,nbits);
590   }
591
592   if ((!m->r0)&&(!m->r1)) swf_SetBits(t,0,1);
593   else
594   { swf_SetBits(t,1,1);
595     nbits = swf_CountBits(m->r0,0);
596     nbits = swf_CountBits(m->r1,nbits);
597     if(nbits>=32) {
598         fprintf(stderr,"rfxswf: Error: matrix values too large\n");
599         nbits = 31;
600     }
601     swf_SetBits(t,nbits,5);
602     swf_SetBits(t,m->r0,nbits);
603     swf_SetBits(t,m->r1,nbits);
604   }
605
606   nbits = swf_CountBits(m->tx,0);
607   nbits = swf_CountBits(m->ty,nbits);
608   if(nbits>=32) {
609       fprintf(stderr,"rfxswf: Error: matrix values too large\n");
610       nbits = 31;
611   }
612   swf_SetBits(t,nbits,5);
613   swf_SetBits(t,m->tx,nbits);
614   swf_SetBits(t,m->ty,nbits);
615
616   return 0;
617 }
618
619 int swf_GetCXForm(TAG * t,CXFORM * cx,U8 alpha) //FIXME: alpha should be type bool
620 { CXFORM cxf;
621   int hasadd;
622   int hasmul;
623   int nbits;
624     
625   if (!cx) cx = &cxf;
626   
627   cx->a0 = cx->r0 = cx->g0 = cx->b0 = 256;
628   cx->a1 = cx->r1 = cx->g1 = cx->b1 = 0;
629
630   if (!t) return 0;
631   
632   swf_ResetReadBits(t);
633   hasadd = swf_GetBits(t,1);
634   hasmul = swf_GetBits(t,1);
635   nbits  = swf_GetBits(t,4);
636
637   if (hasmul)
638   { cx->r0 = (S16)swf_GetSBits(t,nbits);
639     cx->g0 = (S16)swf_GetSBits(t,nbits);
640     cx->b0 = (S16)swf_GetSBits(t,nbits);
641     if (alpha)
642       cx->a0 = (S16)swf_GetSBits(t,nbits);
643   }
644
645   if (hasadd)
646   { cx->r1 = (S16)swf_GetSBits(t,nbits);
647     cx->g1 = (S16)swf_GetSBits(t,nbits);
648     cx->b1 = (S16)swf_GetSBits(t,nbits);
649     if (alpha)
650       cx->a1 = (S16)swf_GetSBits(t,nbits);
651   }
652   
653   return 0;
654 }
655
656 int swf_SetCXForm(TAG * t,CXFORM * cx,U8 alpha)
657 { CXFORM cxf;
658   int hasadd;
659   int hasmul;
660   int nbits;
661     
662   if (!cx)
663   { cx = &cxf;
664     cx->a0 = cx->r0 = cx->g0 = cx->b0 = 256;
665     cx->a1 = cx->r1 = cx->g1 = cx->b1 = 0;
666   }
667
668   if (!alpha)
669   { cx->a0 = 256;
670     cx->a1 = 0;
671   }
672
673   nbits = 0;
674
675   hasmul = (cx->a0!=256)||(cx->r0!=256)||(cx->g0!=256)||(cx->b0!=256);
676   hasadd = cx->a1|cx->r1|cx->g1|cx->b1;
677
678   if (hasmul)
679   { if (alpha) nbits = swf_CountBits((S32)cx->a0,nbits);
680     nbits = swf_CountBits((S32)cx->r0,nbits);
681     nbits = swf_CountBits((S32)cx->g0,nbits);
682     nbits = swf_CountBits((S32)cx->b0,nbits);
683   }
684
685   if (hasadd)
686   { if (alpha) nbits = swf_CountBits((S32)cx->a1,nbits);
687     nbits = swf_CountBits((S32)cx->r1,nbits);
688     nbits = swf_CountBits((S32)cx->g1,nbits);
689     nbits = swf_CountBits((S32)cx->b1,nbits);
690   }
691   
692   swf_ResetWriteBits(t);
693   swf_SetBits(t,hasadd?1:0,1);
694   swf_SetBits(t,hasmul?1:0,1);
695   swf_SetBits(t,nbits,4);
696
697   if (hasmul)
698   { swf_SetBits(t,cx->r0,nbits);
699     swf_SetBits(t,cx->g0,nbits);
700     swf_SetBits(t,cx->b0,nbits);
701     if (alpha) swf_SetBits(t,cx->a0,nbits);
702   }
703
704   if (hasadd)
705   { swf_SetBits(t,cx->r1,nbits);
706     swf_SetBits(t,cx->g1,nbits);
707     swf_SetBits(t,cx->b1,nbits);
708     if (alpha) swf_SetBits(t,cx->a1,nbits);
709   }
710   
711   return 0;
712 }
713
714 //int swf_GetPoint(TAG * t,SPOINT * p) { return 0; }
715 //int swf_SetPoint(TAG * t,SPOINT * p) { return 0; }
716
717 void  swf_SetPassword(TAG * t, const char * password)
718 {
719     /* WARNING: crypt_md5 is not reentrant */
720     char salt[3];
721     char* md5string;
722
723 #if defined(HAVE_LRAND48) && defined(HAVE_SRAND48) && defined(HAVE_TIME_H) && defined(HAVE_TIME)
724     srand48(time(0));
725     salt[0] = "abcdefghijklmnopqrstuvwxyz0123456789"[lrand48()%36];
726     salt[1] = "abcdefghijklmnopqrstuvwxyz0123456789"[lrand48()%36];
727 #else
728     salt[0] = 'l';
729     salt[1] = '8';
730     fprintf(stderr, "rfxswf: Warning- no usable random generator found\n");
731     fprintf(stderr, "Your password will be vulnerable to dictionary attacks\n");
732 #endif
733     
734     md5string = crypt_md5(password, salt);
735
736     swf_SetU16(t,0);
737     swf_SetString(t, md5string);
738 }
739
740 int swf_VerifyPassword(TAG * t, const char * password)
741 {
742     char*md5string1, *md5string2;
743     char*x;
744     char*md5, *salt;
745     int n;
746
747     if(t->len >= 5 && t->pos==0 && 
748        t->data[0] == 0 &&
749        t->data[1] == 0) {
750       swf_GetU16(t);
751     } else {
752       printf("%d %d %d %d\n", t->len, t->pos, t->data[0], t->data[1]);
753     }
754
755     md5string1 = swf_GetString(t);
756
757     if(strncmp(md5string1, "$1$",3 )) {
758         fprintf(stderr, "rfxswf: no salt in pw string\n");
759         return 0;
760     }
761     x = strchr(md5string1+3, '$');
762     if(!x) {
763         fprintf(stderr, "rfxswf: invalid salt format in pw string\n");
764         return 0;
765     }
766     n = x-(md5string1+3);
767     salt = (char*)malloc(n+1);
768     memcpy(salt, md5string1+3, n);
769     salt[n] = 0;
770
771     md5string2 = crypt_md5(password, salt);
772     free(salt);
773     if(strcmp(md5string1, md5string2) != 0)
774         return 0;
775     return 1;
776 }
777
778 // Tag List Manipulating Functions
779
780 TAG * swf_InsertTag(TAG * after,U16 id)
781 { TAG * t;
782
783   t = (TAG *)malloc(sizeof(TAG));
784   if (t)
785   { memset(t,0x00,sizeof(TAG));
786     t->id = id;
787     
788     if (after)
789     {
790       t->prev  = after;
791       t->next  = after->next;
792       after->next = t;
793       if (t->next) t->next->prev = t;
794     }
795   }
796   return t;
797 }
798
799 TAG * swf_InsertTagBefore(SWF* swf, TAG * before,U16 id)
800 { TAG * t;
801
802   t = (TAG *)malloc(sizeof(TAG));
803   if (t)
804   { memset(t,0x00,sizeof(TAG));
805     t->id = id;
806     
807     if (before)
808     {
809       t->next  = before;
810       t->prev  = before->prev;
811       before->prev = t;
812       if (t->prev) t->prev->next = t;
813     }
814   }
815   if(swf && swf->firstTag == before) {
816     swf->firstTag = t;
817   }
818   return t;
819 }
820
821 void swf_ClearTag(TAG * t)
822 {
823   if (t->data) free(t->data);
824   t->data = 0;
825   t->pos = 0;
826   t->len = 0;
827   t->readBit = 0;
828   t->writeBit = 0;
829   t->memsize = 0;
830 }
831
832 void swf_ResetTag(TAG*tag, U16 id)
833 {
834     tag->len = tag->pos = tag->readBit = tag->writeBit = 0;
835     tag->id = id;
836 }
837
838 TAG* swf_CopyTag(TAG*tag, TAG*to_copy)
839 {
840     tag = swf_InsertTag(tag, to_copy->id);
841     swf_SetBlock(tag, to_copy->data, to_copy->len);
842     return tag;
843 }
844
845 int swf_DeleteTag(TAG * t)
846 { if (!t) return -1;
847
848   if (t->prev) t->prev->next = t->next;
849   if (t->next) t->next->prev = t->prev;
850
851   if (t->data) free(t->data);
852   free(t);
853   return 0;
854 }
855
856 TAG * swf_ReadTag(struct reader_t*reader, TAG * prev)
857 { TAG * t;
858   U16 raw;
859   U32 len;
860   int id;
861
862   if (reader->read(reader, &raw, 2) !=2 ) return NULL;
863   raw = SWAP16(raw);
864
865   len = raw&0x3f;
866   id  = raw>>6;
867
868   if (len==0x3f)
869   {
870       if (reader->read(reader, &len, 4) != 4) return NULL;
871       len = SWAP32(len);
872   }
873
874   if (id==ST_DEFINESPRITE) len = 2*sizeof(U16);
875   // Sprite handling fix: Flatten sprite tree
876
877   t = (TAG *)malloc(sizeof(TAG));
878   
879   if (!t)
880   {
881     #ifdef DEBUG_RFXSWF
882       fprintf(stderr,"Fatal Error: malloc()/realloc() failed (2). (%d bytes)\n", sizeof(TAG));
883     #endif
884     return NULL;
885   }
886
887   memset(t,0x00,sizeof(TAG));
888   
889   t->len = len;
890   t->id  = id;
891
892   if (t->len)
893   { t->data = (U8*)malloc(t->len);
894     if (!t->data)
895     {
896       #ifdef DEBUG_RFXSWF
897         fprintf(stderr,"Fatal Error: malloc()/realloc() failed (3). (%d bytes)\n", t->len);
898       #endif
899       return NULL;
900     }
901     t->memsize = t->len;
902     if (reader->read(reader, t->data, t->len) != t->len) return NULL;
903   }
904
905   if (prev)
906   {
907     t->prev  = prev;
908     prev->next = t;
909   }
910
911   return t;
912 }
913
914 int swf_DefineSprite_GetRealSize(TAG * t);
915
916 int swf_WriteTag2(struct writer_t*writer, TAG * t)
917 // returns tag length in bytes (incl. Header), -1 = Error
918 // writer = 0 -> no output
919 { U16 raw[3];
920   U32 len;
921   int short_tag;
922
923   if (!t) return -1;
924
925   len = (t->id==ST_DEFINESPRITE)?swf_DefineSprite_GetRealSize(t):t->len;
926
927   short_tag = len<0x3f&&(t->id!=ST_DEFINEBITSLOSSLESS&&t->id!=ST_DEFINEBITSLOSSLESS2);
928
929   if (writer)
930   { if (short_tag)
931     { raw[0] = SWAP16(len|((t->id&0x3ff)<<6));
932       if (writer->write(writer,raw,2)!=2)
933       {
934         #ifdef DEBUG_RFXSWF
935           fprintf(stderr,"WriteTag() failed: Short Header.\n");
936         #endif
937         return -1;
938       }
939     }
940     else
941     {
942       raw[0] = SWAP16((t->id<<6)|0x3f);
943       if (writer->write(writer,raw,2)!=2)
944       {
945 #ifdef DEBUG_RFXSWF
946           fprintf(stderr,"WriteTag() failed: Long Header (1).\n");
947 #endif
948           return -1;
949       }
950       
951       len = SWAP32(len);
952       if (writer->write(writer,&len,4)!=4)
953       {
954         #ifdef DEBUG_RFXSWF
955           fprintf(stderr,"WriteTag() failed: Long Header (2).\n");
956         #endif
957         return -1;
958       }
959     }
960     
961     if (t->data)
962     { if (writer->write(writer,t->data,t->len)!=t->len)
963       {
964         #ifdef DEBUG_RFXSWF
965           fprintf(stderr,"WriteTag() failed: Data.\n");
966         #endif
967         return -1;
968       }
969     }
970     #ifdef DEBUG_RFXSWF
971       else if (t->len) fprintf(stderr,"WriteTag(): Tag Data Error, id=%i\n",t->id);
972     #endif
973   }
974
975   return t->len+(short_tag?2:6);
976 }
977
978 int swf_WriteTag(int handle, TAG * t)
979 {
980   struct writer_t writer;
981   int len = 0;
982   if(handle<0)
983     return swf_WriteTag2(0, t);
984   writer_init_filewriter(&writer, handle);
985   len = swf_WriteTag2(&writer, t);
986   writer.finish(&writer);
987   return len;
988 }
989
990 int swf_DefineSprite_GetRealSize(TAG * t)
991 // Sprite Handling: Helper function to pack DefineSprite-Tag
992 { U32 len = t->len;
993   if(len>4) { // folded sprite
994       return t->len;
995   }
996   do
997   { t = swf_NextTag(t);
998     if (t && t->id!=ST_DEFINESPRITE) len += swf_WriteTag(-1, t);
999     else t = NULL;
1000   } while (t&&(t->id!=ST_END));
1001   return len;
1002 }
1003
1004 void swf_UnFoldSprite(TAG * t)
1005 {
1006   U16 id,tmp;
1007   U32 len;
1008   TAG*next = t;
1009   U16 spriteid,spriteframes;
1010   int level;
1011   if(t->id!=ST_DEFINESPRITE)
1012     return;
1013   if(t->len<=4) // not folded
1014     return;
1015
1016   swf_SetTagPos(t,0);
1017
1018   spriteid = swf_GetU16(t); //id
1019   spriteframes = swf_GetU16(t); //frames
1020
1021   level = 1;
1022
1023   while(1)
1024   {
1025     TAG*it = 0;
1026     tmp = swf_GetU16(t);
1027     len = tmp&0x3f;
1028     id  = tmp>>6;
1029     if(id == ST_END)
1030         level--;
1031     if(id == ST_DEFINESPRITE && len<=4)
1032         level++;
1033
1034     if (len==0x3f)
1035         len = swf_GetU32(t);
1036     it = swf_InsertTag(next, id);
1037     next = it;
1038     it->len = len;
1039     it->id  = id;
1040     if (it->len)
1041     { it->data = (U8*)malloc(it->len);
1042       it->memsize = it->len;
1043       swf_GetBlock(t, it->data, it->len);
1044     }
1045
1046     if(!level)
1047         break;
1048   }
1049   
1050   free(t->data); t->data = 0;
1051   t->memsize = t->len = t->pos = 0;
1052
1053   swf_SetU16(t, spriteid);
1054   swf_SetU16(t, spriteframes);
1055 }
1056
1057 void swf_FoldSprite(TAG * t)
1058 {
1059   TAG*sprtag=t,*tmp;
1060   U16 id,frames,tmpid;
1061   int level;
1062   if(t->id!=ST_DEFINESPRITE)
1063       return;
1064   if(!t->len) {
1065       fprintf(stderr, "Error: Sprite has no ID!");
1066       return;
1067   }
1068   if(t->len>4) {
1069     /* sprite is already folded */
1070       return;
1071   }
1072
1073   t->pos = 0;
1074   id = swf_GetU16(t);
1075   free(t->data);
1076   t->len = t->pos = t->memsize = 0;
1077   t->data = 0;
1078
1079   frames = 0;
1080
1081   t = swf_NextTag(sprtag);
1082   level = 1;
1083
1084   do 
1085   { 
1086     if(t->id==ST_SHOWFRAME) frames++;
1087     if(t->id == ST_DEFINESPRITE && t->len<=4)
1088         level++;
1089     if(t->id == ST_END)
1090         level--;
1091     t = swf_NextTag(t);
1092   } while(t && level);
1093   if(level)
1094     fprintf(stderr, "rfxswf error: sprite doesn't end(1)\n");
1095
1096   swf_SetU16(sprtag, id);
1097   swf_SetU16(sprtag, frames);
1098
1099   t = swf_NextTag(sprtag);
1100   level = 1;
1101
1102   do
1103   { 
1104     if(t->len<0x3f&&t->id!=ST_DEFINEBITSLOSSLESS&&t->id!=ST_DEFINEBITSLOSSLESS2) {
1105         swf_SetU16(sprtag,t->len|(t->id<<6));
1106     } else {
1107         swf_SetU16(sprtag,0x3f|(t->id<<6));
1108         swf_SetU32(sprtag,t->len);
1109     }
1110     if(t->len)
1111         swf_SetBlock(sprtag,t->data, t->len);
1112     tmp = t;
1113     if(t->id == ST_DEFINESPRITE && t->len<=4)
1114         level++;
1115     if(t->id == ST_END)
1116         level--;
1117     t = swf_NextTag(t);
1118     swf_DeleteTag(tmp);
1119   } 
1120   while (t && level);
1121   if(level)
1122     fprintf(stderr, "rfxswf error: sprite doesn't end(2)\n");
1123
1124 //  sprtag->next = t;
1125 //  t->prev = sprtag;
1126 }
1127
1128 int swf_IsFolded(TAG * t)
1129 {
1130     return (t->id == ST_DEFINESPRITE && t->len>4);
1131 }
1132
1133 void swf_FoldAll(SWF*swf)
1134 {
1135     TAG*tag = swf->firstTag;
1136     //swf_DumpSWF(stdout, swf);
1137     while(tag) {
1138         if(tag->id == ST_DEFINESPRITE) {
1139             swf_FoldSprite(tag);
1140             //swf_DumpSWF(stdout, swf);
1141         }
1142         tag = swf_NextTag(tag);
1143     }
1144 }
1145
1146 void swf_UnFoldAll(SWF*swf)
1147 {
1148     TAG*tag = swf->firstTag;
1149     while(tag) {
1150         if(tag->id == ST_DEFINESPRITE)
1151             swf_UnFoldSprite(tag);
1152         tag = tag->next;
1153     }
1154 }
1155
1156 void swf_OptimizeTagOrder(SWF*swf)
1157 {
1158   TAG*tag,*next;
1159   TAG*level0;
1160   int level;
1161   int changes;
1162   swf_UnFoldAll(swf);
1163   /* at the moment, we don't actually do optimizing,
1164      only fixing of non-spec-conformant things like
1165      sprite tags */
1166
1167   do {
1168     changes = 0;
1169     level = 0;
1170     level0 = 0;
1171     tag = swf->firstTag;
1172     while(tag) {
1173       next = tag->next;
1174       if(tag->id == ST_DEFINESPRITE) {
1175         if(tag->len>4) {
1176           /* ??? all sprites are supposed to be unfolded */
1177           fprintf(stderr, "librfxswf error - internal error in OptimizeTagOrder/UnfoldAll\n");
1178         }
1179         level++;
1180         if(level==1) {
1181           level0 = tag;
1182           tag = next;
1183           continue;
1184         }
1185       }
1186       if(level>=1) {
1187         /* move non-sprite tags out of sprite */
1188         if(!swf_isAllowedSpriteTag(tag) || level>=2) {
1189           /* remove tag from current position */
1190           tag->prev->next = tag->next;
1191           if(tag->next)
1192             tag->next->prev = tag->prev;
1193
1194           /* insert before tag level0 */
1195           tag->next = level0;
1196           tag->prev = level0->prev;
1197           level0->prev = tag;
1198           tag->prev->next = tag;
1199           changes = 1;
1200         }
1201       }
1202       if(tag->id == ST_END) {
1203         level--;
1204       }
1205
1206       tag = next;
1207     }
1208   } while(changes);
1209 }
1210
1211 // Movie Functions
1212
1213 int swf_ReadSWF2(struct reader_t*reader, SWF * swf)   // Reads SWF to memory (malloc'ed), returns length or <0 if fails
1214 {     
1215   if (!swf) return -1;
1216   memset(swf,0x00,sizeof(SWF));
1217
1218   { char b[32];                         // read Header
1219     int len;
1220     TAG * t;
1221     TAG t1;
1222     struct reader_t zreader;
1223     
1224     if ((len = reader->read(reader ,b,8))<8) return -1;
1225
1226     if (b[0]!='F' && b[0]!='C') return -1;
1227     if (b[1]!='W') return -1;
1228     if (b[2]!='S') return -1;
1229     swf->fileVersion = b[3];
1230     swf->compressed  = (b[0]=='C')?1:0;
1231     swf->fileSize    = GET32(&b[4]);
1232     
1233     if(swf->compressed) {
1234         reader_init_zlibinflate(&zreader, reader);
1235         reader = &zreader;
1236     }
1237
1238     reader_GetRect(reader, &swf->movieSize);
1239     reader->read(reader, &swf->frameRate, 2);
1240     swf->frameRate = SWAP16(swf->frameRate);
1241     reader->read(reader, &swf->frameCount, 2);
1242     swf->frameCount = SWAP16(swf->frameCount);
1243
1244     /* read tags and connect to list */
1245     t = &t1;
1246     while (t) t = swf_ReadTag(reader,t);
1247     swf->firstTag = t1.next;
1248     t1.next->prev = NULL;
1249   }
1250   
1251   return reader->pos;
1252 }
1253
1254 int swf_ReadSWF(int handle, SWF * swf)
1255 {
1256   struct reader_t reader;
1257   reader_init_filereader(&reader, handle);
1258   return swf_ReadSWF2(&reader, swf);
1259 }
1260
1261 int  swf_WriteSWF2(struct writer_t*writer, SWF * swf)     // Writes SWF to file, returns length or <0 if fails
1262 { U32 len;
1263   TAG * t;
1264   int frameCount=0;
1265   struct writer_t zwriter;
1266   int fileSize = 0;
1267   int inSprite = 0;
1268   int writer_lastpos = 0;
1269   int ret;
1270     
1271   if (!swf) return -1;
1272   if (!writer) return -1; // the caller should provide a nullwriter, not 0, for querying SWF size
1273
1274   if(writer) writer_lastpos = writer->pos;
1275
1276   // Insert REFLEX Tag
1277
1278 #ifdef INSERT_RFX_TAG
1279
1280   if (swf->firstTag && swf_NextTag(swf->firstTag))
1281     if (swf_GetTagID(swf_NextTag(swf->firstTag))!=ST_REFLEX)
1282       swf_SetBlock(swf_InsertTagBefore(swf, swf->firstTag,ST_REFLEX),"rfx",3);
1283
1284 #endif // INSERT_RFX_TAG
1285
1286   // Count Frames + File Size
1287
1288   len = 0;
1289   t = swf->firstTag;
1290   frameCount = 0;
1291
1292   while(t) {
1293       len += swf_WriteTag(-1,t);
1294       if(t->id == ST_DEFINESPRITE && !swf_IsFolded(t)) inSprite++;
1295       else if(t->id == ST_END && inSprite) inSprite--;
1296       else if(t->id == ST_SHOWFRAME && !inSprite) frameCount++;
1297       t = swf_NextTag(t);
1298   }
1299   
1300   { TAG t1;
1301     char b[64],b4[4];
1302     U32 l;
1303
1304     memset(&t1,0x00,sizeof(TAG));
1305     t1.data    = (U8*)b;
1306     t1.memsize = 64;
1307     
1308     { // measure header file size
1309       TAG t2;
1310       char b2[64];
1311       memset(&t2,0x00,sizeof(TAG));
1312       t2.data    = (U8*)b2;
1313       t2.memsize = 64;
1314       swf_SetRect(&t2, &swf->movieSize);
1315       swf_SetU16(&t2, swf->frameRate);
1316       swf_SetU16(&t2, swf->frameCount);
1317       l = swf_GetTagLen(&t2)+8;
1318     }
1319     if(swf->compressed == 8) {
1320       l -= 8;
1321     }
1322
1323     fileSize = l+len;
1324     if(len) {// don't touch headers without tags
1325         swf->fileSize = fileSize;
1326         swf->frameCount = frameCount;
1327     }
1328
1329     if(swf->compressed != 8) {
1330     /* compressed flag set to 8 means "skip first 8 
1331        header bytes". This is necessary if the caller wants to
1332        create compressed SWFs himself .
1333        It also means that we don't initialize our own zlib
1334        writer, but assume the caller provided one.
1335      */
1336       if(swf->compressed) {
1337         char*id = "CWS";
1338         writer->write(writer, id, 3);
1339       }
1340       else {
1341         char*id = "FWS";
1342         writer->write(writer, id, 3);
1343       }
1344
1345       writer->write(writer, &swf->fileVersion, 1);
1346       PUT32(b4, swf->fileSize);
1347       writer->write(writer, b4, 4);
1348       
1349       if(swf->compressed) {
1350         writer_init_zlibdeflate(&zwriter, writer);
1351         writer = &zwriter;
1352       }
1353     }
1354
1355     swf_SetRect(&t1,&swf->movieSize);
1356     swf_SetU16(&t1,swf->frameRate);
1357     swf_SetU16(&t1,swf->frameCount);
1358
1359     ret = writer->write(writer,b,swf_GetTagLen(&t1));
1360     if (ret!=swf_GetTagLen(&t1))
1361     {
1362       #ifdef DEBUG_RFXSWF
1363         fprintf(stderr, "ret:%d\n",ret);
1364         perror("write:");
1365         fprintf(stderr,"WriteSWF() failed: Header.\n");
1366       #endif
1367       return -1;
1368     }
1369
1370     t = swf->firstTag;
1371     while (t)
1372     { if (swf_WriteTag2(writer, t)<0) return -1;
1373       t = swf_NextTag(t);
1374     }
1375     if(swf->compressed) {
1376       if(swf->compressed != 8) {
1377         zwriter.finish(&zwriter);
1378         return writer->pos - writer_lastpos;
1379       }
1380       return (int)fileSize;
1381     } else {
1382       return (int)fileSize;
1383     }
1384   }
1385 }
1386
1387 int  swf_WriteSWF(int handle, SWF * swf)     // Writes SWF to file, returns length or <0 if fails
1388 {
1389   struct writer_t writer;
1390   int len = 0;
1391   swf->compressed = 0;
1392   
1393   if(handle<0) {
1394     writer_init_nullwriter(&writer);
1395     len = swf_WriteSWF2(&writer, swf);
1396   }
1397   writer_init_filewriter(&writer, handle);
1398   len = swf_WriteSWF2(&writer, swf);
1399   writer.finish(&writer);
1400   return len;
1401 }
1402
1403 int  swf_WriteSWC(int handle, SWF * swf)     // Writes SWF to file, returns length or <0 if fails
1404 {
1405   struct writer_t writer;
1406   int len = 0;
1407   swf->compressed = 1;
1408
1409   if(handle<0) {
1410     writer_init_nullwriter(&writer);
1411     len = swf_WriteSWF2(&writer, swf);
1412   }
1413   writer_init_filewriter(&writer, handle);
1414   len = swf_WriteSWF2(&writer, swf);
1415   writer.finish(&writer);
1416   return len;
1417 }
1418
1419 int swf_WriteHeader2(struct writer_t*writer,SWF * swf)
1420 {
1421   SWF myswf;
1422   memcpy(&myswf,swf,sizeof(SWF));
1423   myswf.firstTag = 0;
1424   return swf_WriteSWF2(writer, &myswf);
1425 }
1426
1427 int swf_WriteHeader(int handle,SWF * swf)
1428 {
1429   SWF myswf;
1430   memcpy(&myswf,swf,sizeof(SWF));
1431   myswf.firstTag = 0;
1432   return swf_WriteSWF(handle, &myswf);
1433 }
1434
1435 int swf_WriteCGI(SWF * swf)
1436 { int len;
1437   char s[1024];
1438     
1439   len = swf_WriteSWF(-1,swf);
1440
1441   if (len<0) return -1;
1442
1443   sprintf(s,"Content-type: application/x-shockwave-flash\n"
1444             "Accept-Ranges: bytes\n"
1445             "Content-Length: %lu\n"
1446             "Expires: Thu, 13 Apr 2000 23:59:59 GMT\n"
1447             "\n",len);
1448             
1449   write(fileno(stdout),s,strlen(s));
1450   return swf_WriteSWF(fileno(stdout),swf);
1451 }
1452
1453 void swf_FreeTags(SWF * swf)                 // Frees all malloc'ed memory for tags
1454 { TAG * t = swf->firstTag;
1455
1456   while (t)
1457   { TAG * tnew = t->next;
1458     if (t->data) free(t->data);
1459     free(t);
1460     t = tnew;
1461   }
1462   swf->firstTag = 0;
1463 }
1464
1465 // include advanced functions
1466
1467 #include "modules/swfdump.c"
1468 #include "modules/swfshape.c"
1469 #include "modules/swftext.c"
1470 #include "modules/swffont.c"
1471 #include "modules/swfobject.c"
1472 #include "modules/swfbutton.c"
1473 #include "modules/swftools.c"
1474 #include "modules/swfcgi.c"
1475 #include "modules/swfbits.c"
1476 #include "modules/swfaction.c"
1477 #include "modules/swfsound.c"
1478 #include "modules/swfdraw.c"