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 <stdio.h>
22 #include <stdlib.h>
23 
24 struct Rect
25 {
26   int xMin;
27   int xMax;
28   int yMin;
29   int yMax;
30 };
31 
32 struct FontInfo
33 {
34   int ID;
35   int GlyphCount;
36 };
37 
38 struct Movie
39 {
40   int version;
41   int size;                     /* in bytes */
42   struct Rect frame;
43   float rate;
44   int nFrames;
45   int soundStreamFmt;
46   struct FontInfo *fonts;
47   int numFonts;
48 };
49 
50 static inline void
Movie_addFontInfo(struct Movie * m,int ID,int count)51 Movie_addFontInfo(struct Movie *m, int ID, int count)
52 {
53   m->fonts = realloc(m->fonts, (m->numFonts + 1) * sizeof(struct FontInfo));
54   m->fonts[m->numFonts].ID = ID;
55   m->fonts[m->numFonts].GlyphCount = count;
56   m->numFonts++;
57 }
58 
59 static inline int
Movie_getFontGlyphCount(struct Movie * m,int ID)60 Movie_getFontGlyphCount(struct Movie *m, int ID)
61 {
62   int i;
63   for(i = 0; i < m->numFonts; i++)
64   {
65     if(m->fonts[i].ID == ID)
66       return m->fonts[i].GlyphCount;
67   }
68   return -1;
69 }
70 
71 #include "swftypes.h"
72 
73 typedef SWF_Parserstruct *(*SWFParseFunc)(FILE *, int);
74 
75 #include "parserdecl.h"
76