swfmill 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +23 -0
- data/.swfmill +240 -0
- data/LICENSE +340 -0
- data/README.rdoc +37 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/ext/.gitignore +5 -0
- data/ext/extconf.rb +86 -0
- data/ext/swfmill/.gitignore +27 -0
- data/ext/swfmill/AUTHORS +9 -0
- data/ext/swfmill/COPYING +340 -0
- data/ext/swfmill/Makefile.am +14 -0
- data/ext/swfmill/Makefile.in +635 -0
- data/ext/swfmill/NEWS +189 -0
- data/ext/swfmill/README +170 -0
- data/ext/swfmill/TODO +33 -0
- data/ext/swfmill/aclocal.m4 +7712 -0
- data/ext/swfmill/autogen.sh +7 -0
- data/ext/swfmill/compile +142 -0
- data/ext/swfmill/config.guess +1516 -0
- data/ext/swfmill/config.sub +1626 -0
- data/ext/swfmill/configure +21868 -0
- data/ext/swfmill/configure.ac +55 -0
- data/ext/swfmill/depcomp +589 -0
- data/ext/swfmill/install-sh +519 -0
- data/ext/swfmill/ltmain.sh +6964 -0
- data/ext/swfmill/missing +367 -0
- data/ext/swfmill/src/Geom.cpp +107 -0
- data/ext/swfmill/src/Geom.h +100 -0
- data/ext/swfmill/src/Makefile.am +86 -0
- data/ext/swfmill/src/Makefile.in +1025 -0
- data/ext/swfmill/src/SWF.h +11941 -0
- data/ext/swfmill/src/SWFAction.cpp +41 -0
- data/ext/swfmill/src/SWFAction.h +19 -0
- data/ext/swfmill/src/SWFBasic.h +7 -0
- data/ext/swfmill/src/SWFFile.cpp +406 -0
- data/ext/swfmill/src/SWFFile.h +34 -0
- data/ext/swfmill/src/SWFFilter.cpp +25 -0
- data/ext/swfmill/src/SWFFilter.h +15 -0
- data/ext/swfmill/src/SWFGlyphList.cpp +262 -0
- data/ext/swfmill/src/SWFGlyphList.h +34 -0
- data/ext/swfmill/src/SWFIdItem.h +85 -0
- data/ext/swfmill/src/SWFIdItems.h +16 -0
- data/ext/swfmill/src/SWFItem.cpp +235 -0
- data/ext/swfmill/src/SWFItem.h +60 -0
- data/ext/swfmill/src/SWFList.h +179 -0
- data/ext/swfmill/src/SWFReader.cpp +352 -0
- data/ext/swfmill/src/SWFReader.h +73 -0
- data/ext/swfmill/src/SWFShapeItem.cpp +220 -0
- data/ext/swfmill/src/SWFShapeItem.h +45 -0
- data/ext/swfmill/src/SWFShapeMaker.cpp +401 -0
- data/ext/swfmill/src/SWFShapeMaker.h +128 -0
- data/ext/swfmill/src/SWFTag.cpp +49 -0
- data/ext/swfmill/src/SWFTag.h +20 -0
- data/ext/swfmill/src/SWFTrait.cpp +35 -0
- data/ext/swfmill/src/SWFTrait.h +22 -0
- data/ext/swfmill/src/SWFWriter.cpp +312 -0
- data/ext/swfmill/src/SWFWriter.h +84 -0
- data/ext/swfmill/src/base64.c +110 -0
- data/ext/swfmill/src/base64.h +15 -0
- data/ext/swfmill/src/codegen/Makefile.am +15 -0
- data/ext/swfmill/src/codegen/Makefile.in +346 -0
- data/ext/swfmill/src/codegen/basic.xsl +45 -0
- data/ext/swfmill/src/codegen/basics.xsl +235 -0
- data/ext/swfmill/src/codegen/dumper.xsl +109 -0
- data/ext/swfmill/src/codegen/header.xsl +131 -0
- data/ext/swfmill/src/codegen/mk.xsl +26 -0
- data/ext/swfmill/src/codegen/parser.xsl +196 -0
- data/ext/swfmill/src/codegen/parsexml.xsl +312 -0
- data/ext/swfmill/src/codegen/size.xsl +189 -0
- data/ext/swfmill/src/codegen/source.xml +2197 -0
- data/ext/swfmill/src/codegen/writer.xsl +190 -0
- data/ext/swfmill/src/codegen/writexml.xsl +138 -0
- data/ext/swfmill/src/swfmill.cpp +482 -0
- data/ext/swfmill/src/swft/Makefile.am +55 -0
- data/ext/swfmill/src/swft/Makefile.in +717 -0
- data/ext/swfmill/src/swft/Parser.cpp +76 -0
- data/ext/swfmill/src/swft/Parser.h +37 -0
- data/ext/swfmill/src/swft/SVGAttributeParser.cpp +78 -0
- data/ext/swfmill/src/swft/SVGAttributeParser.h +35 -0
- data/ext/swfmill/src/swft/SVGColor.cpp +116 -0
- data/ext/swfmill/src/swft/SVGColor.h +37 -0
- data/ext/swfmill/src/swft/SVGColors.h +167 -0
- data/ext/swfmill/src/swft/SVGGradient.cpp +258 -0
- data/ext/swfmill/src/swft/SVGGradient.h +81 -0
- data/ext/swfmill/src/swft/SVGPathParser.cpp +155 -0
- data/ext/swfmill/src/swft/SVGPathParser.h +126 -0
- data/ext/swfmill/src/swft/SVGPointsParser.cpp +51 -0
- data/ext/swfmill/src/swft/SVGPointsParser.h +25 -0
- data/ext/swfmill/src/swft/SVGStyle.cpp +181 -0
- data/ext/swfmill/src/swft/SVGStyle.h +80 -0
- data/ext/swfmill/src/swft/SVGTransformParser.cpp +72 -0
- data/ext/swfmill/src/swft/SVGTransformParser.h +32 -0
- data/ext/swfmill/src/swft/readpng.c +305 -0
- data/ext/swfmill/src/swft/readpng.h +92 -0
- data/ext/swfmill/src/swft/swft.cpp +251 -0
- data/ext/swfmill/src/swft/swft.h +64 -0
- data/ext/swfmill/src/swft/swft_document.cpp +57 -0
- data/ext/swfmill/src/swft/swft_import.cpp +38 -0
- data/ext/swfmill/src/swft/swft_import_binary.cpp +82 -0
- data/ext/swfmill/src/swft/swft_import_jpeg.cpp +255 -0
- data/ext/swfmill/src/swft/swft_import_mp3.cpp +268 -0
- data/ext/swfmill/src/swft/swft_import_png.cpp +231 -0
- data/ext/swfmill/src/swft/swft_import_ttf.cpp +519 -0
- data/ext/swfmill/src/swft/swft_import_wav.cpp +255 -0
- data/ext/swfmill/src/swft/swft_path.cpp +178 -0
- data/ext/swfmill/src/xslt/Makefile.am +51 -0
- data/ext/swfmill/src/xslt/Makefile.in +536 -0
- data/ext/swfmill/src/xslt/README +19 -0
- data/ext/swfmill/src/xslt/assemble.xsl +38 -0
- data/ext/swfmill/src/xslt/simple-deprecated.xslt +62 -0
- data/ext/swfmill/src/xslt/simple-elements.xslt +627 -0
- data/ext/swfmill/src/xslt/simple-import.xslt +565 -0
- data/ext/swfmill/src/xslt/simple-svg.xslt +383 -0
- data/ext/swfmill/src/xslt/simple-tools.xslt +255 -0
- data/ext/swfmill/src/xslt/simple.cpp +1686 -0
- data/ext/swfmill/src/xslt/simple.xml +7 -0
- data/ext/swfmill/src/xslt/xslt.h +7 -0
- data/ext/swfmill/test/Makefile.am +1 -0
- data/ext/swfmill/test/Makefile.in +490 -0
- data/ext/swfmill/test/xml/Makefile.am +20 -0
- data/ext/swfmill/test/xml/Makefile.in +353 -0
- data/ext/swfmill/test/xml/test-xml +21 -0
- data/ext/swfmill_ext.cc +375 -0
- data/lib/swfmill.rb +30 -0
- data/spec/data/swfmill-banner1.swf +0 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/swfmill_spec.rb +125 -0
- metadata +206 -0
@@ -0,0 +1,190 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
|
3
|
+
<xsl:template name="writer">
|
4
|
+
<xsl:document href="g{/format/@format}Writer.cpp" method="text">
|
5
|
+
|
6
|
+
#include "<xsl:value-of select="/format/@format"/>.h"
|
7
|
+
#include "<xsl:value-of select="/format/@format"/>Item.h"
|
8
|
+
#include "<xsl:value-of select="/format/@format"/>List.h"
|
9
|
+
|
10
|
+
namespace <xsl:value-of select="/format/@format"/> {
|
11
|
+
|
12
|
+
<xsl:for-each select="type|tag|action|filter|style|stackitem|namespaceconstant|multinameconstant|trait|opcode">
|
13
|
+
//////////////////////////////////// <xsl:value-of select="@name"/>
|
14
|
+
|
15
|
+
void <xsl:value-of select="@name"/>::write( Writer *w, Context *ctx ) {
|
16
|
+
int start=w->getBitPosition();
|
17
|
+
if( ctx->debugTrace ) {
|
18
|
+
printf("WRITE <xsl:value-of select="@name"/> @%i\n", start/8 );
|
19
|
+
dump(1,ctx);
|
20
|
+
}
|
21
|
+
<!--
|
22
|
+
<xsl:for-each select="*[@set-from-bits-needed]">
|
23
|
+
<xsl:value-of select="@name"/> = SWFBitsNeeded( <xsl:value-of select="@set-from-bits-needed"/> );
|
24
|
+
if( <xsl:value-of select="@name"/> > ctx-><xsl:value-of select="@name"/> ) ctx-><xsl:value-of select="@name"/> = <xsl:value-of select="@name"/>;
|
25
|
+
</xsl:for-each>
|
26
|
+
-->
|
27
|
+
<!-- calculate "next" offsets for some other lists-->
|
28
|
+
<xsl:for-each select="*[@next]">
|
29
|
+
if( !ctx->isLast ) {
|
30
|
+
int r = 0;
|
31
|
+
<xsl:apply-templates select="following-sibling::*" mode="size"/>
|
32
|
+
<xsl:value-of select="@name"/> = (r/8)<xsl:if test="@next-offset"> - (<xsl:value-of select="@next-offset"/>)</xsl:if>;
|
33
|
+
} else {
|
34
|
+
<xsl:value-of select="@name"/> = 0;
|
35
|
+
}
|
36
|
+
</xsl:for-each>
|
37
|
+
|
38
|
+
<xsl:choose>
|
39
|
+
<xsl:when test="@parent">
|
40
|
+
<xsl:apply-templates select="." mode="baseclass"/>::writeHeader( w, ctx, getSize(ctx,w->getBitPosition())/8 );
|
41
|
+
</xsl:when>
|
42
|
+
<xsl:when test="name()='type'"/>
|
43
|
+
<xsl:otherwise>
|
44
|
+
<xsl:apply-templates select="." mode="baseclass"/>::writeHeader( w, ctx, (getSize(ctx,w->getBitPosition())/8) <xsl:if test="@swallow"> - <xsl:value-of select="@swallow"/></xsl:if> );
|
45
|
+
</xsl:otherwise>
|
46
|
+
</xsl:choose>
|
47
|
+
|
48
|
+
<xsl:apply-templates mode="write"/>
|
49
|
+
|
50
|
+
int l = w->getBitPosition()-start;
|
51
|
+
if( l != getSize(ctx,start)) {
|
52
|
+
printf("WARNING: <xsl:value-of select="@name"/> has different size than expected: %i bits instead of %i\n", l, getSize(ctx,start) );
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
</xsl:for-each>
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
</xsl:document>
|
62
|
+
</xsl:template>
|
63
|
+
|
64
|
+
|
65
|
+
<xsl:template match="flagged" mode="write">
|
66
|
+
if( <xsl:if test="@negative">!</xsl:if><xsl:value-of select="@flag"/>
|
67
|
+
<xsl:if test="@signifier"> & <xsl:value-of select="@signifier"/></xsl:if> ) {
|
68
|
+
|
69
|
+
<xsl:apply-templates mode="write"/>
|
70
|
+
}
|
71
|
+
</xsl:template>
|
72
|
+
|
73
|
+
<xsl:template match="if" mode="write">
|
74
|
+
if( <xsl:value-of select="@expression"/> ) {
|
75
|
+
<xsl:apply-templates mode="write"/>
|
76
|
+
}
|
77
|
+
</xsl:template>
|
78
|
+
|
79
|
+
<xsl:template match="byte|word|fixedpoint|fixedpoint2|bit|integer|string|uint32|float|double|double2|half|xml|u30|s24|encodedu32" mode="write">
|
80
|
+
<xsl:apply-templates select="." mode="put"/>;
|
81
|
+
<xsl:if test="@context">
|
82
|
+
ctx-><xsl:value-of select="@name"/> = <xsl:value-of select="@name"/>;
|
83
|
+
</xsl:if>
|
84
|
+
</xsl:template>
|
85
|
+
<xsl:template match="byte" mode="put">w->putByte(<xsl:value-of select="@name"/>)</xsl:template>
|
86
|
+
<xsl:template match="word" mode="put">w->putWord(<xsl:value-of select="@name"/>)</xsl:template>
|
87
|
+
<xsl:template match="uint32" mode="put">w->putInt(<xsl:value-of select="@name"/>)</xsl:template>
|
88
|
+
<xsl:template match="float" mode="put">w->putFloat(<xsl:value-of select="@name"/>)</xsl:template>
|
89
|
+
<xsl:template match="double" mode="put">w->putDouble(<xsl:value-of select="@name"/>)</xsl:template>
|
90
|
+
<xsl:template match="double2" mode="put">w->putDouble2(<xsl:value-of select="@name"/>)</xsl:template>
|
91
|
+
<xsl:template match="half" mode="put">w->putHalf(<xsl:value-of select="@name"/>)</xsl:template>
|
92
|
+
<xsl:template match="fixedpoint" mode="put">w->putNBitFixed(<xsl:value-of select="@name"/>,<xsl:value-of select="@size"/>,<xsl:value-of select="@exp"/><xsl:if test="@signed">,true</xsl:if>)</xsl:template>
|
93
|
+
<xsl:template match="fixedpoint2" mode="put">w->putNBitFixed2(<xsl:value-of select="@name"/>,<xsl:value-of select="@size"/>,<xsl:value-of select="@exp"/><xsl:if test="@signed">,true</xsl:if>)</xsl:template>
|
94
|
+
<xsl:template match="bit" mode="put">w->putNBitInt(<xsl:value-of select="@name"/>,1)</xsl:template>
|
95
|
+
<xsl:template match="integer" mode="put">w->putNBitInt(<xsl:value-of select="@name"/>,<xsl:value-of select="@size"/><xsl:if test="@size-add">+<xsl:value-of select="@size-add"/></xsl:if><xsl:if test="@signed">,true</xsl:if>)</xsl:template>
|
96
|
+
<xsl:template match="string[@mode='pascal']" mode="put">w->putPString(<xsl:value-of select="@name"/>)</xsl:template>
|
97
|
+
<xsl:template match="string[@mode='pascalU30']" mode="put">w->putPStringU30(<xsl:value-of select="@name"/>)</xsl:template>
|
98
|
+
<xsl:template match="string" mode="put" priority="-1">w->putString(<xsl:value-of select="@name"/>)</xsl:template>
|
99
|
+
<xsl:template match="data" mode="put">w->putData(<xsl:value-of select="@name"/>,<xsl:value-of select="@size"/>)</xsl:template>
|
100
|
+
<xsl:template match="xml" mode="put" priority="-1">w->putString(<xsl:value-of select="@name"/>)</xsl:template>
|
101
|
+
<xsl:template match="u30" mode="put">w->putU30(<xsl:value-of select="@name"/>)</xsl:template>
|
102
|
+
<xsl:template match="s24" mode="put">w->putS24(<xsl:value-of select="@name"/>)</xsl:template>
|
103
|
+
<xsl:template match="encodedu32" mode="put">w->putEncodedU32(<xsl:value-of select="@name"/>)</xsl:template>
|
104
|
+
|
105
|
+
<xsl:template match="byteOrWord" mode="write">
|
106
|
+
{
|
107
|
+
int v = <xsl:value-of select="@name"/>;
|
108
|
+
if( v >= 255 && ctx->tagVersion >= 2 ) {
|
109
|
+
w->putByte( 255 );
|
110
|
+
w->putWord( v );
|
111
|
+
} else {
|
112
|
+
w->putByte( v );
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
<xsl:if test="@context">
|
117
|
+
ctx-><xsl:value-of select="@name"/> = <xsl:value-of select="@name"/>;
|
118
|
+
</xsl:if>
|
119
|
+
</xsl:template>
|
120
|
+
|
121
|
+
<xsl:template match="object" mode="write">
|
122
|
+
<xsl:value-of select="@name"/>.write(w,ctx);
|
123
|
+
</xsl:template>
|
124
|
+
|
125
|
+
<xsl:template match="list[@length]" mode="write" priority="1">
|
126
|
+
<xsl:variable name="length">
|
127
|
+
<xsl:choose>
|
128
|
+
<xsl:when test="@length-add">
|
129
|
+
( <xsl:value-of select="@length"/> + <xsl:value-of select="@length-add"/> )
|
130
|
+
</xsl:when>
|
131
|
+
<xsl:when test="@length-sub">
|
132
|
+
( <xsl:value-of select="@length"/> < <xsl:value-of select="@length-sub"/>
|
133
|
+
? 0
|
134
|
+
: <xsl:value-of select="@length"/> - <xsl:value-of select="@length-sub"/> )
|
135
|
+
</xsl:when>
|
136
|
+
<xsl:otherwise>
|
137
|
+
<xsl:value-of select="@length"/>
|
138
|
+
</xsl:otherwise>
|
139
|
+
</xsl:choose>
|
140
|
+
</xsl:variable>
|
141
|
+
|
142
|
+
{
|
143
|
+
<xsl:value-of select="@type"/> *item;
|
144
|
+
ListItem<<xsl:value-of select="@type"/>>* i;
|
145
|
+
i = <xsl:value-of select="@name"/>.first();
|
146
|
+
for( int j=0; j<<xsl:value-of select="$length"/>; j++ ) {
|
147
|
+
if( !i || !i->data() ) {
|
148
|
+
printf("WARNING: list <xsl:value-of select="@name"/> has %i items (%i expected)\n", j, <xsl:value-of select="$length"/> );
|
149
|
+
} else {
|
150
|
+
i->data()->write( w, ctx );
|
151
|
+
}
|
152
|
+
i = i->next();
|
153
|
+
}
|
154
|
+
}
|
155
|
+
</xsl:template>
|
156
|
+
|
157
|
+
<xsl:template match="list" mode="write" priority="-1">
|
158
|
+
{
|
159
|
+
int start = w->getPosition();
|
160
|
+
<xsl:value-of select="@type"/> *item;
|
161
|
+
ListItem<<xsl:value-of select="@type"/>>* i;
|
162
|
+
i = <xsl:value-of select="@name"/>.first();
|
163
|
+
while( i ) {
|
164
|
+
if( !i->data() ) {
|
165
|
+
printf("WARNING: list <xsl:value-of select="@name"/> has an invalid item\n" );
|
166
|
+
} else {
|
167
|
+
ctx->isLast = i->isLast();
|
168
|
+
i->data()->write( w, ctx );
|
169
|
+
}
|
170
|
+
i = i->next();
|
171
|
+
}
|
172
|
+
}
|
173
|
+
</xsl:template>
|
174
|
+
|
175
|
+
<xsl:template match="data" mode="write">
|
176
|
+
if( <xsl:value-of select="@size"/> && <xsl:value-of select="@name"/> ) {
|
177
|
+
w->putData( <xsl:value-of select="@name"/>, <xsl:value-of select="@size"/> );
|
178
|
+
}
|
179
|
+
w->byteAlign();
|
180
|
+
</xsl:template>
|
181
|
+
|
182
|
+
<xsl:template match="fill-byte" mode="write">
|
183
|
+
w->byteAlign();
|
184
|
+
</xsl:template>
|
185
|
+
|
186
|
+
<xsl:template match="context" mode="write">
|
187
|
+
ctx-><xsl:value-of select="@param"/> = <xsl:value-of select="@value"/>;
|
188
|
+
</xsl:template>
|
189
|
+
|
190
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,138 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
|
3
|
+
<xsl:template name="writexml">
|
4
|
+
<xsl:document href="g{/format/@format}WriteXML.cpp" method="text">
|
5
|
+
|
6
|
+
#include "<xsl:value-of select="/format/@format"/>.h"
|
7
|
+
#include "base64.h"
|
8
|
+
#include <cstring>
|
9
|
+
|
10
|
+
namespace <xsl:value-of select="/format/@format"/> {
|
11
|
+
|
12
|
+
#define TMP_STRLEN 0xFF
|
13
|
+
|
14
|
+
<xsl:for-each select="type|tag|action|filter|style|stackitem|namespaceconstant|multinameconstant|trait|opcode">
|
15
|
+
void <xsl:value-of select="@name"/>::writeXML( xmlNodePtr xml, Context *ctx ) {
|
16
|
+
char tmp[TMP_STRLEN];
|
17
|
+
xmlNodePtr node = xml;
|
18
|
+
xmlNodePtr node2;
|
19
|
+
|
20
|
+
node = xmlNewChild( node, NULL, (const xmlChar *)"<xsl:value-of select="@name"/>", NULL );
|
21
|
+
<xsl:apply-templates select="*[@prop]|flagged|if|context" mode="writexml"/>
|
22
|
+
|
23
|
+
if( ctx->transientPropsToXML ) {
|
24
|
+
snprintf( tmp, TMP_STRLEN, "%i", file_offset );
|
25
|
+
xmlSetProp( node, (const xmlChar *)"file_offset", (const xmlChar *)tmp );
|
26
|
+
<xsl:for-each select="*">
|
27
|
+
<xsl:choose>
|
28
|
+
<xsl:when test="@prop"/>
|
29
|
+
<xsl:otherwise>
|
30
|
+
<xsl:apply-templates select="." mode="writexml"/>
|
31
|
+
</xsl:otherwise>
|
32
|
+
</xsl:choose>
|
33
|
+
</xsl:for-each>
|
34
|
+
}
|
35
|
+
|
36
|
+
<xsl:if test="@name='UnknownTag' or @name='UnknownAction'">
|
37
|
+
snprintf( tmp, TMP_STRLEN, "0x%02X", type );
|
38
|
+
xmlSetProp( node, (const xmlChar *)"id", (const xmlChar *)tmp );
|
39
|
+
</xsl:if>
|
40
|
+
}
|
41
|
+
</xsl:for-each>
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
</xsl:document>
|
46
|
+
</xsl:template>
|
47
|
+
|
48
|
+
|
49
|
+
<xsl:template match="flagged" mode="writexml">
|
50
|
+
if( <xsl:if test="@negative">!</xsl:if><xsl:value-of select="@flag"/>
|
51
|
+
<xsl:if test="@signifier"> & <xsl:value-of select="@signifier"/></xsl:if> ) {
|
52
|
+
<xsl:apply-templates select="*[@prop]|flagged|if" mode="writexml"/>
|
53
|
+
}
|
54
|
+
</xsl:template>
|
55
|
+
|
56
|
+
|
57
|
+
<xsl:template match="if" mode="writexml">
|
58
|
+
if( <xsl:value-of select="@expression"/> ) {
|
59
|
+
<xsl:apply-templates select="*[@prop]|flagged|if" mode="writexml"/>
|
60
|
+
}
|
61
|
+
</xsl:template>
|
62
|
+
|
63
|
+
<xsl:template match="double|double2|half|float|fixedpoint|fixedpoint2" mode="writexml">
|
64
|
+
snprintf(tmp,TMP_STRLEN,"%#.*g", 16, <xsl:value-of select="@name"/>);
|
65
|
+
xmlSetProp( node, (const xmlChar *)"<xsl:value-of select="@name"/>", (const xmlChar *)&tmp );
|
66
|
+
</xsl:template>
|
67
|
+
|
68
|
+
<xsl:template match="byte|word|byteOrWord|integer|bit|uint32|u30|s24|encodedu32" mode="writexml">
|
69
|
+
snprintf(tmp,TMP_STRLEN,"<xsl:apply-templates select="." mode="printf"/>", <xsl:value-of select="@name"/>);
|
70
|
+
xmlSetProp( node, (const xmlChar *)"<xsl:value-of select="@name"/>", (const xmlChar *)&tmp );
|
71
|
+
</xsl:template>
|
72
|
+
|
73
|
+
<xsl:template match="string" mode="writexml">
|
74
|
+
if( <xsl:value-of select="@name"/> ) {
|
75
|
+
xmlSetProp( node, (const xmlChar *)"<xsl:value-of select="@name"/>", (const xmlChar *)<xsl:value-of select="@name"/> );
|
76
|
+
}
|
77
|
+
</xsl:template>
|
78
|
+
|
79
|
+
<xsl:template match="object" mode="writexml">
|
80
|
+
node2 = xmlNewChild( node, NULL, (const xmlChar *)"<xsl:value-of select="@name"/>", NULL );
|
81
|
+
<xsl:value-of select="@name"/>.writeXML( node2, ctx );
|
82
|
+
</xsl:template>
|
83
|
+
|
84
|
+
<xsl:template match="list" mode="writexml">
|
85
|
+
{
|
86
|
+
node2 = xmlNewChild( node, NULL, (const xmlChar *)"<xsl:value-of select="@name"/>", NULL );
|
87
|
+
<xsl:value-of select="@type"/> *item;
|
88
|
+
ListItem<<xsl:value-of select="@type"/>>* i;
|
89
|
+
i = <xsl:value-of select="@name"/>.first();
|
90
|
+
while( i ) {
|
91
|
+
item = i->data();
|
92
|
+
if( item ) {
|
93
|
+
item->writeXML( node2, ctx );
|
94
|
+
}
|
95
|
+
i = i->next();
|
96
|
+
}
|
97
|
+
}
|
98
|
+
</xsl:template>
|
99
|
+
|
100
|
+
<!-- FIXME: i dont really know how much memory to allocate for dst string.. -->
|
101
|
+
<xsl:template match="data" mode="writexml">
|
102
|
+
{
|
103
|
+
if( <xsl:value-of select="@size"/> && <xsl:value-of select="@name"/> ) {
|
104
|
+
char *tmp_data = (char *)<xsl:value-of select="@name"/>;
|
105
|
+
int sz = <xsl:value-of select="@size"/>;
|
106
|
+
char *tmpstr = new char[ (sz * 3) ];
|
107
|
+
|
108
|
+
int l = base64_encode( tmpstr, tmp_data, sz );
|
109
|
+
if( l > 0 ) {
|
110
|
+
tmpstr[l] = 0;
|
111
|
+
xmlNewTextChild( node, NULL, (const xmlChar *)"<xsl:value-of select="@name"/>", (const xmlChar *)tmpstr );
|
112
|
+
}
|
113
|
+
delete tmpstr;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
</xsl:template>
|
117
|
+
|
118
|
+
<xsl:template match="xml" mode="writexml">
|
119
|
+
{
|
120
|
+
if(<xsl:value-of select="@name"/> ) {
|
121
|
+
xmlDocPtr doc = xmlParseMemory(<xsl:value-of select="@name"/>, strlen(<xsl:value-of select="@name"/>));
|
122
|
+
if( doc ) {
|
123
|
+
xmlNodePtr child = doc->children;
|
124
|
+
|
125
|
+
child = xmlDocCopyNode(child, node->doc, 1);
|
126
|
+
xmlAddChild(node, child);
|
127
|
+
|
128
|
+
xmlFreeDoc(doc);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
</xsl:template>
|
133
|
+
|
134
|
+
<xsl:template match="context" mode="writexml">
|
135
|
+
ctx-><xsl:value-of select="@param"/> = <xsl:value-of select="@value"/>;
|
136
|
+
</xsl:template>
|
137
|
+
|
138
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,482 @@
|
|
1
|
+
#include <libexslt/exslt.h>
|
2
|
+
#include "SWFFile.h"
|
3
|
+
#include "swft.h"
|
4
|
+
#include "xslt.h"
|
5
|
+
#include <cstdlib>
|
6
|
+
#include <cstring>
|
7
|
+
#include <sys/types.h>
|
8
|
+
#include <sys/stat.h>
|
9
|
+
#include <unistd.h>
|
10
|
+
#include <libxslt/transform.h>
|
11
|
+
#include <libxslt/xsltutils.h>
|
12
|
+
#include <dirent.h>
|
13
|
+
|
14
|
+
using namespace SWF;
|
15
|
+
|
16
|
+
bool quiet = false;
|
17
|
+
bool verbose = false;
|
18
|
+
bool dump = false;
|
19
|
+
bool nonet = false;
|
20
|
+
const char *internal_stylesheet = NULL;
|
21
|
+
|
22
|
+
void usage() {
|
23
|
+
fprintf( stderr,
|
24
|
+
"\n"PACKAGE_NAME" "PACKAGE_VERSION"\n"
|
25
|
+
" XML-based SWF processing tool\n"
|
26
|
+
"\n"
|
27
|
+
"usage: swfmill [<options>] <command>\n"
|
28
|
+
"\n"
|
29
|
+
"<command> is one of:\n"
|
30
|
+
" swf2xml <in> [<out>]\n"
|
31
|
+
" convert from SWF to XML.\n"
|
32
|
+
" <in> is a single SWF file, or 'stdin'\n"
|
33
|
+
" <out> is a single XML file, or (by default) 'stdout'\n"
|
34
|
+
"\n"
|
35
|
+
" xml2swf <in> [<out>]\n"
|
36
|
+
" convert from XML to SWF.\n"
|
37
|
+
" <in> is a single XML file, or 'stdin'\n"
|
38
|
+
" <out> is a single SWF file, or (by default) 'stdout'\n"
|
39
|
+
"\n"
|
40
|
+
" simple <in> [<out>]\n"
|
41
|
+
" convert from a movie definition file to SWF.\n"
|
42
|
+
" <in> is a single XML file, or 'stdin'\n"
|
43
|
+
" <out> is a single SWF file, or (by default) 'stdout'\n"
|
44
|
+
" (for details, see README)\n"
|
45
|
+
"\n"
|
46
|
+
" xslt <xsl> <in> [<out>"
|
47
|
+
//" [<param>*]"
|
48
|
+
"]\n"
|
49
|
+
" transform <in> to <out> as described by <xsl>.\n"
|
50
|
+
" <xsl> is the XSLT stylesheet,\n"
|
51
|
+
" and can use the swft: extension.\n"
|
52
|
+
" <in> must be some XML (depends on <xsl>)\n"
|
53
|
+
" <out> is either SWF (when it ends in .swf)\n"
|
54
|
+
" or XML, by default on 'stdout'\n"
|
55
|
+
// " <param>* is a whitespace-separated list of name=value\n"
|
56
|
+
// " assignments for xsl parameters\n"
|
57
|
+
"\n"
|
58
|
+
"<option>s are:\n"
|
59
|
+
" -h print this help and quit\n"
|
60
|
+
" -v verbose output\n"
|
61
|
+
" -V extra-verbose debugging output\n"
|
62
|
+
" -d dump SWF data when loaded (for debugging)\n"
|
63
|
+
" -n deactivate libxml network access\n"
|
64
|
+
"\n"
|
65
|
+
"Please report bugs at http://bugs.launchpad.net/swfmill/+filebug\n\n"
|
66
|
+
);
|
67
|
+
}
|
68
|
+
|
69
|
+
// helper func
|
70
|
+
xsltStylesheetPtr xsltParseStylesheetMemory( const char *buffer, int size ) {
|
71
|
+
xmlDocPtr doc = xmlParseMemory( buffer, size );
|
72
|
+
if( !doc ) return NULL;
|
73
|
+
xsltStylesheetPtr ret = xsltParseStylesheetDoc( doc );
|
74
|
+
// xmlFreeDoc( doc );
|
75
|
+
return ret;
|
76
|
+
}
|
77
|
+
|
78
|
+
int swfmill_swf2xml( int argc, char *argv[] ) {
|
79
|
+
const char *infile = NULL, *outfile = "stdout";
|
80
|
+
bool success = false;
|
81
|
+
FILE *in_fp=0, *out_fp=0;
|
82
|
+
bool std_in, std_out;
|
83
|
+
|
84
|
+
File input;
|
85
|
+
unsigned int filesize, size, xmlsize;
|
86
|
+
struct stat filestat;
|
87
|
+
char sig;
|
88
|
+
Context ctx;
|
89
|
+
|
90
|
+
// parse filenames
|
91
|
+
if( argc < 1 || argc > 2 ) {
|
92
|
+
usage();
|
93
|
+
goto fail;
|
94
|
+
}
|
95
|
+
infile = argv[0];
|
96
|
+
if( argc>1 ) outfile = argv[1];
|
97
|
+
|
98
|
+
// open files
|
99
|
+
std_in = !strncmp( infile, "stdin", 5 );
|
100
|
+
std_out = !strncmp( outfile, "stdout", 6 );
|
101
|
+
in_fp = std_in ? stdin : fopen( infile, "rb" );
|
102
|
+
if( !in_fp ) {
|
103
|
+
fprintf(stderr,"ERROR: could not open file %s for reading\n", infile?infile:"stdin" );
|
104
|
+
goto fail;
|
105
|
+
}
|
106
|
+
|
107
|
+
if( !quiet ) fprintf(stderr,"Reading from %s\n", infile );
|
108
|
+
|
109
|
+
// stat filesize
|
110
|
+
filesize = (unsigned int)-1;
|
111
|
+
|
112
|
+
if( !std_in ) {
|
113
|
+
stat( infile, &filestat );
|
114
|
+
filesize = filestat.st_size;
|
115
|
+
// fprintf(stderr,"Filesize: %u\n",filesize);
|
116
|
+
}
|
117
|
+
|
118
|
+
// setup context
|
119
|
+
ctx.debugTrace = verbose;
|
120
|
+
ctx.quiet = quiet;
|
121
|
+
|
122
|
+
// treat input as SWF, produce XML
|
123
|
+
if( (size = input.load( in_fp, &ctx, filesize )) != 0 ) {
|
124
|
+
if( dump ) input.dump();
|
125
|
+
out_fp = std_out ? stdout : fopen( outfile, "wb" );
|
126
|
+
if( !out_fp ) {
|
127
|
+
fprintf(stderr,"ERROR: could not open file %s for writing\n", outfile );
|
128
|
+
goto fail;
|
129
|
+
}
|
130
|
+
if( !quiet ) fprintf(stderr,"Writing XML to %s\n", outfile );
|
131
|
+
if( (xmlsize = input.saveXML( out_fp, &ctx )) != 0 ) {
|
132
|
+
if( !quiet ) fprintf(stderr,"XML saved to %s (%i bytes).\n", outfile, xmlsize );
|
133
|
+
success = true;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
fail:
|
137
|
+
if( in_fp && !std_in ) fclose(in_fp);
|
138
|
+
if( out_fp && !std_out ) fclose(out_fp);
|
139
|
+
|
140
|
+
return success ? 0 : -1;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
int swfmill_xml2swf( int argc, char *argv[] ) {
|
145
|
+
const char *infile = NULL, *outfile = "stdout";
|
146
|
+
bool success = false;
|
147
|
+
FILE *in_fp=0, *out_fp=0;
|
148
|
+
bool std_in, std_out;
|
149
|
+
const char *filename;
|
150
|
+
xsltStylesheetPtr transform = NULL;
|
151
|
+
|
152
|
+
File input;
|
153
|
+
int size, xmlsize;
|
154
|
+
Context ctx;
|
155
|
+
xmlDocPtr doc = NULL, doc2;
|
156
|
+
|
157
|
+
// parse filenames
|
158
|
+
if( argc < 1 || argc > 2 ) {
|
159
|
+
usage();
|
160
|
+
goto fail;
|
161
|
+
}
|
162
|
+
infile = argv[0];
|
163
|
+
if( argc>1 ) outfile = argv[1];
|
164
|
+
|
165
|
+
// open files
|
166
|
+
std_in = !strncmp( infile, "stdin", 5 );
|
167
|
+
std_out = !strncmp( outfile, "stdout", 6 );
|
168
|
+
in_fp = std_in ? stdin : fopen( infile, "rb" );
|
169
|
+
if( !in_fp ) {
|
170
|
+
fprintf(stderr,"ERROR: could not open file %s for reading\n", infile?infile:"stdin" );
|
171
|
+
goto fail;
|
172
|
+
}
|
173
|
+
|
174
|
+
if( !quiet ) fprintf(stderr,"Reading from %s\n", infile );
|
175
|
+
|
176
|
+
// setup context
|
177
|
+
ctx.debugTrace = verbose;
|
178
|
+
ctx.quiet = quiet;
|
179
|
+
|
180
|
+
{
|
181
|
+
filename = std_in ? "-" : infile ;
|
182
|
+
doc = xmlParseFile( filename );
|
183
|
+
if( !doc ) {
|
184
|
+
fprintf( stderr, "ERROR: input document %s could not be read.\n", infile );
|
185
|
+
goto fail;
|
186
|
+
}
|
187
|
+
|
188
|
+
// see if one of the internal stylesheets should be used
|
189
|
+
if( internal_stylesheet ) {
|
190
|
+
transform = xsltParseStylesheetMemory( internal_stylesheet, strlen(internal_stylesheet) );
|
191
|
+
if( !transform ) {
|
192
|
+
fprintf( stderr, "ERROR: internal stylesheet could not be read.\n" );
|
193
|
+
goto fail;
|
194
|
+
}
|
195
|
+
|
196
|
+
const char *params[3];
|
197
|
+
params[0] = "quiet";
|
198
|
+
params[1] = "\"false\"";
|
199
|
+
params[2] = NULL;
|
200
|
+
if( quiet ) {
|
201
|
+
params[1] = "\"true\"";
|
202
|
+
}
|
203
|
+
doc2 = xsltApplyStylesheet( transform, doc, (const char **)¶ms );
|
204
|
+
|
205
|
+
if( !doc2 ) {
|
206
|
+
fprintf( stderr, "ERROR: transformation failed.\n" );
|
207
|
+
goto fail;
|
208
|
+
}
|
209
|
+
|
210
|
+
xmlFreeDoc( doc );
|
211
|
+
doc = doc2;
|
212
|
+
}
|
213
|
+
|
214
|
+
// treat input as XML, produce SWF
|
215
|
+
input.setXML( doc->xmlRootNode, NULL );
|
216
|
+
if( dump ) input.dump();
|
217
|
+
out_fp = std_out ? stdout : fopen( outfile, "wb" );
|
218
|
+
if( !out_fp ) {
|
219
|
+
fprintf(stderr,"ERROR: could not open file '%s' for writing\n", outfile );
|
220
|
+
goto fail;
|
221
|
+
}
|
222
|
+
if( !quiet ) fprintf(stderr,"Writing SWF to %s\n", outfile );
|
223
|
+
if( (size = input.save( out_fp, &ctx )) != 0 ) {
|
224
|
+
success = true;
|
225
|
+
if( !quiet ) fprintf(stderr,"SWF saved to %s (%i bytes).\n", outfile, size );
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
fail:
|
230
|
+
if( doc ) xmlFreeDoc( doc );
|
231
|
+
if( in_fp && !std_in ) fclose(in_fp);
|
232
|
+
if( out_fp && !std_out ) fclose(out_fp);
|
233
|
+
|
234
|
+
return success ? 0 : -1;
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
int swfmill_do_xslt( xmlDocPtr doc, xsltStylesheetPtr transform, const char *outfile );
|
239
|
+
|
240
|
+
int swfmill_xslt( int argc, char *argv[] ) {
|
241
|
+
const char *xslfile, *infile, *outfile = "stdout";
|
242
|
+
xmlDocPtr doc = NULL;
|
243
|
+
xsltStylesheetPtr transform;
|
244
|
+
|
245
|
+
// parse filenames
|
246
|
+
if( argc < 2 || argc > 3 ) {
|
247
|
+
usage();
|
248
|
+
goto fail;
|
249
|
+
}
|
250
|
+
xslfile = argv[0];
|
251
|
+
infile = argv[1];
|
252
|
+
if( argc>2 ) outfile = argv[2];
|
253
|
+
|
254
|
+
doc = xmlParseFile( infile );
|
255
|
+
if( !doc ) {
|
256
|
+
fprintf( stderr, "ERROR: input document %s could not be read.\n", infile );
|
257
|
+
goto fail;
|
258
|
+
}
|
259
|
+
|
260
|
+
transform = xsltParseStylesheetFile( (const xmlChar *)xslfile );
|
261
|
+
if( !transform ) {
|
262
|
+
fprintf( stderr, "ERROR: stylesheet %s could not be read.\n", xslfile );
|
263
|
+
goto fail;
|
264
|
+
}
|
265
|
+
|
266
|
+
return swfmill_do_xslt( doc, transform, outfile );
|
267
|
+
|
268
|
+
fail:
|
269
|
+
return -1;
|
270
|
+
}
|
271
|
+
|
272
|
+
int swfmill_do_xslt( xmlDocPtr doc, xsltStylesheetPtr transform, const char *outfile ) {
|
273
|
+
xmlDocPtr doc2 = NULL;
|
274
|
+
FILE *out_fp;
|
275
|
+
const char *ext;
|
276
|
+
Context ctx;
|
277
|
+
int size;
|
278
|
+
|
279
|
+
const char *params[3];
|
280
|
+
params[0] = "quiet";
|
281
|
+
params[1] = "\"FALSE\"";
|
282
|
+
params[2] = NULL;
|
283
|
+
if( quiet ) {
|
284
|
+
params[1] = "\"FALSE\"";
|
285
|
+
}
|
286
|
+
|
287
|
+
// setup context
|
288
|
+
ctx.debugTrace = verbose;
|
289
|
+
ctx.quiet = quiet;
|
290
|
+
|
291
|
+
|
292
|
+
if( !quiet ) fprintf( stderr, "Applying XSLT...\n" );
|
293
|
+
doc2 = xsltApplyStylesheet( transform, doc, params );
|
294
|
+
|
295
|
+
if( !doc2 ) {
|
296
|
+
fprintf( stderr, "ERROR: transformation failed.\n" );
|
297
|
+
goto fail;
|
298
|
+
}
|
299
|
+
|
300
|
+
if( (ext = strrchr(outfile,'.'))!=NULL && !strncmp( ".swf", ext, 4 ) ) {
|
301
|
+
if( !quiet ) fprintf( stderr, "Saving to SWF %s\n", outfile);
|
302
|
+
|
303
|
+
File swf;
|
304
|
+
swf.setXML( doc2->xmlRootNode, NULL );
|
305
|
+
|
306
|
+
out_fp = fopen( outfile, "wb" );
|
307
|
+
if( !out_fp ) {
|
308
|
+
fprintf(stderr,"ERROR: could not open file '%s' for writing\n", outfile );
|
309
|
+
goto fail;
|
310
|
+
}
|
311
|
+
if( !quiet ) fprintf(stderr,"Writing SWF to %s\n", outfile );
|
312
|
+
if( (size = swf.save( out_fp, &ctx )) != 0 ) {
|
313
|
+
if( !quiet ) fprintf(stderr,"SWF saved to %s (%i bytes).\n", outfile, size );
|
314
|
+
if( doc ) xmlFreeDoc(doc);
|
315
|
+
if( doc2 ) xmlFreeDoc(doc2);
|
316
|
+
if( transform ) xsltFreeStylesheet( transform );
|
317
|
+
return 0;
|
318
|
+
}
|
319
|
+
} else {
|
320
|
+
bool std_out = !strncmp( outfile, "stdout", 6 );
|
321
|
+
const char *file = std_out ? "-" : outfile;
|
322
|
+
return xsltSaveResultToFilename( file, doc2, transform, 0 );
|
323
|
+
}
|
324
|
+
|
325
|
+
fail:
|
326
|
+
if( doc ) xmlFreeDoc(doc);
|
327
|
+
if( doc2 ) xmlFreeDoc(doc2);
|
328
|
+
if( transform ) xsltFreeStylesheet( transform );
|
329
|
+
return -1;
|
330
|
+
}
|
331
|
+
|
332
|
+
|
333
|
+
void swfmill_create_library( xmlNodePtr lib, const char *filename );
|
334
|
+
|
335
|
+
void swfmill_create_library_dir( xmlNodePtr lib, const char *dir ) {
|
336
|
+
char tmp[256];
|
337
|
+
|
338
|
+
struct dirent *e;
|
339
|
+
DIR *d = opendir( dir );
|
340
|
+
if( d == NULL ) return;
|
341
|
+
|
342
|
+
while( true ) {
|
343
|
+
e = readdir(d);
|
344
|
+
if( e==NULL ) break;
|
345
|
+
if( e->d_name[0] == '.' ) continue; // no hidden files
|
346
|
+
|
347
|
+
snprintf( tmp, 1023, "%s/%s", dir, e->d_name );
|
348
|
+
swfmill_create_library( lib, tmp );
|
349
|
+
}
|
350
|
+
}
|
351
|
+
|
352
|
+
void swfmill_create_library( xmlNodePtr lib, const char *filename ) {
|
353
|
+
struct stat s;
|
354
|
+
if( stat(filename,&s) ) return;
|
355
|
+
|
356
|
+
/*
|
357
|
+
int i=strlen(filename)-1;
|
358
|
+
while( i>0 && filename[i]!='.' ) i--;
|
359
|
+
const char *ext = &filename[i];
|
360
|
+
*/
|
361
|
+
if( S_ISDIR(s.st_mode) ) {
|
362
|
+
swfmill_create_library_dir( lib, filename );
|
363
|
+
} else {
|
364
|
+
// if( !strcmp( ext, ".jpg" ) || !strcmp( ext, ".jpeg" ) ) {
|
365
|
+
|
366
|
+
xmlNodePtr node = xmlNewChild( lib, NULL, (const xmlChar*)"clip", NULL );
|
367
|
+
xmlSetProp( node, (const xmlChar *)"id", (const xmlChar *)filename );
|
368
|
+
xmlSetProp( node, (const xmlChar *)"import", (const xmlChar *)filename );
|
369
|
+
}
|
370
|
+
|
371
|
+
// fprintf(stderr, "clip %s: %s (%s)\n", filename, S_ISDIR(s.st_mode)?"dir":"file", ext );
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
int swfmill_library( int argc, char *argv[] ) {
|
376
|
+
if( argc < 2 ) {
|
377
|
+
fprintf( stderr, "library creation needs at least two arguments\n\tswfmill library <input file(s)/dir(s)> <output>.swf\n" );
|
378
|
+
return -1;
|
379
|
+
}
|
380
|
+
const char *outfile = argv[argc-1];
|
381
|
+
argc--;
|
382
|
+
|
383
|
+
internal_stylesheet = xslt_simple;
|
384
|
+
|
385
|
+
xmlDocPtr doc = xmlNewDoc((const xmlChar*)"1.0");
|
386
|
+
doc->children = xmlNewDocNode( doc, NULL, (const xmlChar*)"movie", NULL );
|
387
|
+
|
388
|
+
xmlNodePtr lib = xmlNewChild( doc->children, NULL, (const xmlChar *)"library", NULL );
|
389
|
+
|
390
|
+
for( int i=0; i<argc; i++ ) {
|
391
|
+
swfmill_create_library( lib, argv[i] );
|
392
|
+
}
|
393
|
+
|
394
|
+
xmlNodePtr node = xmlNewChild( lib, NULL, (const xmlChar *)"frame", NULL );
|
395
|
+
// xmlSetProp( node, (const xmlChar*)"id", (const xmlChar *)"foo");
|
396
|
+
|
397
|
+
xsltStylesheetPtr transform = xsltParseStylesheetMemory( internal_stylesheet, strlen(internal_stylesheet) );
|
398
|
+
if( !transform ) {
|
399
|
+
fprintf( stderr, "ERROR: internal stylesheet could not be read.\n" );
|
400
|
+
return -1;
|
401
|
+
}
|
402
|
+
|
403
|
+
swfmill_do_xslt( doc, transform, outfile );
|
404
|
+
}
|
405
|
+
|
406
|
+
int main( int argc, char *argv[] ) {
|
407
|
+
char *command = NULL;
|
408
|
+
|
409
|
+
swft_register();
|
410
|
+
exsltRegisterAll();
|
411
|
+
|
412
|
+
quiet = true;
|
413
|
+
|
414
|
+
// parse args
|
415
|
+
int i=1;
|
416
|
+
for( ; i<argc && command==NULL; i++ ) {
|
417
|
+
if( argv[i][0] == '-' ) {
|
418
|
+
int swallow=0;
|
419
|
+
for( int j=1; j<strlen(argv[i]); j++ ) {
|
420
|
+
switch( argv[i][j] ) {
|
421
|
+
case 'q':
|
422
|
+
quiet = true;
|
423
|
+
break;
|
424
|
+
case 'v':
|
425
|
+
quiet = false;
|
426
|
+
break;
|
427
|
+
case 'V':
|
428
|
+
verbose = true;
|
429
|
+
break;
|
430
|
+
case 'd':
|
431
|
+
dump = true;
|
432
|
+
break;
|
433
|
+
case 'n':
|
434
|
+
nonet = true;
|
435
|
+
break;
|
436
|
+
case 'h':
|
437
|
+
case '?':
|
438
|
+
usage();
|
439
|
+
goto fail;
|
440
|
+
break;
|
441
|
+
default:
|
442
|
+
fprintf(stderr,"ERROR: unknown option %c\n",argv[i][j]);
|
443
|
+
usage();
|
444
|
+
goto fail;
|
445
|
+
}
|
446
|
+
}
|
447
|
+
i+=swallow;
|
448
|
+
} else {
|
449
|
+
if( !command ) command=argv[i];
|
450
|
+
}
|
451
|
+
}
|
452
|
+
|
453
|
+
if( !command ) {
|
454
|
+
usage();
|
455
|
+
goto fail;
|
456
|
+
}
|
457
|
+
|
458
|
+
if( nonet ) xmlSetExternalEntityLoader( xmlNoNetExternalEntityLoader );
|
459
|
+
|
460
|
+
if( !quiet ) fprintf( stderr, "%s %s\n", PACKAGE_NAME, PACKAGE_VERSION );
|
461
|
+
|
462
|
+
if( !strcmp( command, "swf2xml" ) ) {
|
463
|
+
return swfmill_swf2xml( argc-i, &argv[i] );
|
464
|
+
} else if( !strcmp( command, "xml2swf" ) ) {
|
465
|
+
return swfmill_xml2swf( argc-i, &argv[i] );
|
466
|
+
} else if( !strcmp( command, "xslt" ) ) {
|
467
|
+
return swfmill_xslt( argc-i, &argv[i] );
|
468
|
+
} else if( !strcmp( command, "simple" ) ) {
|
469
|
+
internal_stylesheet = xslt_simple;
|
470
|
+
return swfmill_xml2swf( argc-i, &argv[i] );
|
471
|
+
} else if( !strcmp( command, "library" ) ) {
|
472
|
+
return swfmill_library( argc-i, &argv[i] );
|
473
|
+
} else {
|
474
|
+
fprintf(stderr,"ERROR: unknown command %s\n", command );
|
475
|
+
usage();
|
476
|
+
goto fail;
|
477
|
+
}
|
478
|
+
|
479
|
+
fail:
|
480
|
+
return -1;
|
481
|
+
}
|
482
|
+
|