1 /*
2 Ming, an SWF output library
3 Copyright (C) 2001 Opaque Industries - http://www.opaque.net/
4
5 3.3.2007 Klaus Rechert
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 #include <stdlib.h>
22 #include "ming.h"
23 #include "block.h"
24 #include "output.h"
25 #include "method.h"
26 #include "scriptlimits.h"
27
28 static void
writeSWFScriptLimitsToMethod(SWFBlock block,SWFByteOutputMethod method,void * data)29 writeSWFScriptLimitsToMethod(SWFBlock block, SWFByteOutputMethod method, void* data)
30 {
31 SWFScriptLimits sl = (SWFScriptLimits)block;
32
33 methodWriteUInt16(sl->maxRecursion, method, data);
34 methodWriteUInt16(sl->timeout, method, data);
35 }
36
37 static int
completeSWFScriptLimits(SWFBlock block)38 completeSWFScriptLimits(SWFBlock block)
39 {
40 (void) block;
41 return 4;
42 }
43
44 void
destroySWFScriptLimits(SWFScriptLimits sl)45 destroySWFScriptLimits(SWFScriptLimits sl)
46 {
47 free(sl);
48 }
49
50 void
SWFScriptLimits_maxRecursion(SWFScriptLimits sl,int count)51 SWFScriptLimits_maxRecursion(SWFScriptLimits sl, int count)
52 {
53 sl->maxRecursion = count;
54 }
55
56 void
SWFScriptLimits_setTimeout(SWFScriptLimits sl,int timeout)57 SWFScriptLimits_setTimeout(SWFScriptLimits sl, int timeout)
58 {
59 sl->timeout = timeout;
60 }
61
62 SWFScriptLimits
newSWFScriptLimits()63 newSWFScriptLimits()
64 {
65 SWFScriptLimits sl = (SWFScriptLimits)malloc(sizeof(struct SWFScriptLimits_s));
66
67 SWFBlockInit(BLOCK(sl));
68 BLOCK(sl)->type = SWF_SCRIPTLIMITS;
69 BLOCK(sl)->writeBlock = writeSWFScriptLimitsToMethod;
70 BLOCK(sl)->complete = completeSWFScriptLimits;
71 BLOCK(sl)->dtor = (destroySWFBlockMethod) destroySWFScriptLimits;
72
73 sl->maxRecursion = 265;
74 sl->timeout = 15;
75 return sl;
76 }
77
78