1 //gcc -Wall -Werror `pkg-config --libs --cflags libming glib-2.0` compiler.c -o compiler
7 /* This is what is used to compile the Actionscript parts of the source to
8 * Swfdec test scripts that can later be executed.
9 * Note that this is pretty much a hack until someone writes a proper
10 * Actionscript compiler for Swfdec.
11 * Also note that the creation of the include-scripts should probably not be
12 * autorun, as we don't want to depend on external bugs in Ming, only on internal ones.
15 /* header to put in front of script */
16 #define HEADER "Swfdec Test Script\0\1"
19 main (int argc
, char **argv
)
28 g_print ("usage: %s INFILE OUTFILE\n\n", argv
[0]);
34 if (!g_file_get_contents (argv
[1], &contents
, NULL
, &error
)) {
35 g_printerr ("%s\n", error
->message
);
40 action
= newSWFAction (contents
);
41 if (SWFAction_compile (action
, 8, &len
) != 0) {
42 g_printerr ("compilation failed\n");
45 data
= SWFAction_getByteCode (action
, NULL
);
46 contents
= g_malloc (len
+ sizeof (HEADER
));
47 memcpy (contents
, HEADER
, sizeof (HEADER
));
48 memcpy (contents
+ sizeof (HEADER
), data
, len
);
49 if (!g_file_set_contents (argv
[2], contents
, len
+ sizeof (HEADER
), &error
)) {
50 g_printerr ("%s\n", error
->message
);