luc 9 years ago
commit aa60ad1dbc

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="source"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry excluding="api/|env/|processing/domaingraph/applet/|yacy/|api/bookmarks/|api/ymarks/|api/bookmarks/posts/|api/bookmarks/tags/|api/bookmarks/xbel/|solr/|gsa/|solr/collection1/|api/blacklists/|proxymsg/" kind="src" path="htroot"/>
<classpathentry excluding="bookmarks/|ymarks/|bookmarks/posts/|bookmarks/tags/|bookmarks/xbel/|blacklists/" kind="src" path="htroot/api"/>
<classpathentry kind="src" path="htroot/env"/>

Binary file not shown.

@ -0,0 +1,33 @@
Copyright (c) 2001, David N. Main, All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
3. The name of the author may not be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@ -24,7 +24,11 @@
</scm>
<developers>
<developer>
<name>Bruno Martins</name>
<name>Bruno Martins</name> <!-- WebCat -->
</developer>
<developer>
<name>David N. Main</name> <!-- JavaSWF2 -->
<url>http://anotherbigidea.com/</url>
</developer>
</developers>
<properties>
@ -35,4 +39,18 @@
<build>
<sourceDirectory>src</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.10</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.tukaani</groupId>
<artifactId>xz</artifactId>
<version>1.5</version>
<type>jar</type>
</dependency>
</dependencies>
</project>

@ -0,0 +1,194 @@
/****************************************************************
* Copyright (c) 2001, David N. Main, All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. The name of the author may not be used to endorse or
* promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
****************************************************************/
package com.anotherbigidea.flash;
/**
* Action Codes and associated constants
*/
public interface SWFActionCodes
{
public static final int NEXT_FRAME = 0x04; //F3 ***
public static final int PREVIOUS_FRAME = 0x05; //F3 ***
public static final int PLAY = 0x06; //F3 ***
public static final int STOP = 0x07; //F3 ***
public static final int TOGGLE_QUALITY = 0x08; //F3 ***
public static final int STOP_SOUNDS = 0x09; //F3 ***
public static final int ADD = 0x0a; //F4
public static final int SUBTRACT = 0x0b; //F4
public static final int MULTIPLY = 0x0c; //F4
public static final int DIVIDE = 0x0d; //F4
public static final int EQUALS = 0x0e; //F4
public static final int LESS = 0x0f; //F4
public static final int AND = 0x10; //F4
public static final int OR = 0x11; //F4
public static final int NOT = 0x12; //F4
public static final int STRING_EQUALS = 0x13; //F4
public static final int STRING_LENGTH = 0x14; //F4
public static final int STRING_EXTRACT = 0x15; //F4
public static final int POP = 0x17; //F4
public static final int TO_INTEGER = 0x18; //F4
public static final int GET_VARIABLE = 0x1c; //F4
public static final int SET_VARIABLE = 0x1d; //F4
public static final int SET_TARGET_2 = 0x20; //F4
public static final int STRING_ADD = 0x21; //F4
public static final int GET_PROPERTY = 0x22; //F4
public static final int SET_PROPERTY = 0x23; //F4
public static final int CLONE_SPRITE = 0x24; //F4
public static final int REMOVE_SPRITE = 0x25; //F4
public static final int TRACE = 0x26; //F4
public static final int START_DRAG = 0x27; //F4
public static final int END_DRAG = 0x28; //F4
public static final int STRING_LESS = 0x29; //F4
public static final int RANDOM_NUMBER = 0x30; //F4
public static final int MB_STRING_LENGTH = 0x31; //F4
public static final int CHAR_TO_ASCII = 0x32; //F4
public static final int ASCII_TO_CHAR = 0x33; //F4
public static final int GET_TIME = 0x34; //F4
public static final int MB_STRING_EXTRACT = 0x35; //F4
public static final int MB_CHAR_TO_ASCII = 0x36; //F4
public static final int MB_ASCII_TO_CHAR = 0x37; //F4
public static final int DEL_VAR = 0x3a; //F5 ---
public static final int DEL_THREAD_VARS = 0x3b; //F5 ---
public static final int DEFINE_LOCAL_VAL = 0x3c; //F5 ---
public static final int CALL_FUNCTION = 0x3d; //F5 ---
public static final int RETURN = 0x3e; //F5 ---
public static final int MODULO = 0x3f; //F5 ---
public static final int NEW_OBJECT = 0x40; //F5 ---
public static final int DEFINE_LOCAL = 0x41; //F5 ---
public static final int INIT_ARRAY = 0x42; //F5 ---
public static final int INIT_OBJECT = 0x43; //F5 ---
public static final int TYPEOF = 0x44; //F5 ---
public static final int GET_TARGET_PATH = 0x45; //F5 ---
public static final int ENUMERATE = 0x46; //F5 ---
public static final int TYPED_ADD = 0x47; //F5 ---
public static final int TYPED_LESS_THAN = 0x48; //F5 ---
public static final int TYPED_EQUALS = 0x49; //F5 ---
public static final int CONVERT_TO_NUMBER = 0x4a; //F5 ---
public static final int CONVERT_TO_STRING = 0x4b; //F5 ---
public static final int DUPLICATE = 0x4c; //F5 ---
public static final int SWAP = 0x4d; //F5 ---
public static final int GET_MEMBER = 0x4e; //F5 ---
public static final int SET_MEMBER = 0x4f; //F5 ---
public static final int INCREMENT = 0x50; //F5 ---
public static final int DECREMENT = 0x51; //F5 ---
public static final int CALL_METHOD = 0x52; //F5 ---
public static final int CALL_NEW_METHOD = 0x53; //F5 ---
public static final int INSTANCE_OF = 0x54; //MX <<<
public static final int ENUMERATE_OBJECT = 0x55; //MX <<<
public static final int BIT_AND = 0x60; //F5 ---
public static final int BIT_OR = 0x61; //F5 ---
public static final int BIT_XOR = 0x62; //F5 ---
public static final int SHIFT_LEFT = 0x63; //F5 ---
public static final int SHIFT_RIGHT = 0x64; //F5 ---
public static final int SHIFT_UNSIGNED = 0x65; //F5 ---
public static final int STRICT_EQUALS = 0x66; //MX <<<
public static final int GREATER = 0x67; //MX <<<
public static final int STRING_GREATER = 0x68; //MX <<<
public static final int GOTO_FRAME = 0x81; //F3 ***
public static final int GET_URL = 0x83; //F3 ***
public static final int REGISTER = 0x87; //F5 ---
public static final int LOOKUP_TABLE = 0x88; //F5 ---
public static final int WAIT_FOR_FRAME = 0x8a; //F3 ***
public static final int SET_TARGET = 0x8b; //F3 ***
public static final int GOTO_LABEL = 0x8c; //F3 ***
public static final int WAIT_FOR_FRAME_2 = 0x8d; //F4
public static final int WITH = 0x94; //F5 ---
public static final int PUSH = 0x96; //F4
public static final int JUMP = 0x99; //F4
public static final int GET_URL_2 = 0x9a; //F4
public static final int DEFINE_FUNCTION = 0x9b; //F5 ---
public static final int IF = 0x9d; //F4
public static final int CALL = 0x9e; //F4
public static final int GOTO_FRAME_2 = 0x9f; //F4
//--Property Constants
public static final int PROP_X = 0;
public static final int PROP_Y = 1;
public static final int PROP_XSCALE = 2;
public static final int PROP_YSCALE = 3;
public static final int PROP_CURRENTFRAME = 4;
public static final int PROP_TOTALFRAMES = 5;
public static final int PROP_ALPHA = 6;
public static final int PROP_VISIBLE = 7;
public static final int PROP_WIDTH = 8;
public static final int PROP_HEIGHT = 9;
public static final int PROP_ROTATION = 10;
public static final int PROP_TARGET = 11;
public static final int PROP_FRAMESLOADED = 12;
public static final int PROP_NAME = 13;
public static final int PROP_DROPTARGET = 14;
public static final int PROP_URL = 15;
public static final int PROP_HIGHQUALITY = 16;
public static final int PROP_FOCUSRECT = 17;
public static final int PROP_SOUNDBUFTIME = 18;
public static final int PROP_QUALITY = 19; //flash 5 only
public static final int PROP_XMOUSE = 20; //flash 5 only
public static final int PROP_YMOUSE = 21; //flash 5 only
//--TypeOf Strings (from the ActionScript typeof() operator)
public static final String TYPEOF_NUMBER = "number";
public static final String TYPEOF_BOOLEAN = "boolean";
public static final String TYPEOF_STRING = "string";
public static final String TYPEOF_OBJECT = "object";
public static final String TYPEOF_MOVIECLIP = "movieclip";
public static final String TYPEOF_NULL = "null";
public static final String TYPEOF_UNDEFINED = "undefined";
public static final String TYPEOF_FUNCTION = "function";
//--Types for Flash 5 push action
public static final int PUSHTYPE_STRING = 0;
public static final int PUSHTYPE_FLOAT = 1;
public static final int PUSHTYPE_NULL = 2;
public static final int PUSHTYPE_03 = 3; //unknown
public static final int PUSHTYPE_REGISTER = 4;
public static final int PUSHTYPE_BOOLEAN = 5;
public static final int PUSHTYPE_DOUBLE = 6;
public static final int PUSHTYPE_INTEGER = 7;
public static final int PUSHTYPE_LOOKUP = 8;
}

@ -0,0 +1,205 @@
/****************************************************************
* Copyright (c) 2001, David N. Main, All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. The name of the author may not be used to endorse or
* promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
****************************************************************/
package com.anotherbigidea.flash;
/**
* Various SWF Constant Values
*/
public interface SWFConstants
{
public static final int TWIPS = 20; //number of TWIPS per pixel
public static final int TAG_END = 0;
public static final int TAG_SHOWFRAME = 1;
public static final int TAG_DEFINESHAPE = 2;
public static final int TAG_FREECHARACTER = 3;
public static final int TAG_PLACEOBJECT = 4;
public static final int TAG_REMOVEOBJECT = 5;
public static final int TAG_DEFINEBITS = 6;
public static final int TAG_DEFINEBUTTON = 7;
public static final int TAG_JPEGTABLES = 8;
public static final int TAG_SETBACKGROUNDCOLOR = 9;
public static final int TAG_DEFINEFONT = 10;
public static final int TAG_DEFINETEXT = 11;
public static final int TAG_DOACTION = 12;
public static final int TAG_DEFINEFONTINFO = 13;
public static final int TAG_DEFINESOUND = 14;
public static final int TAG_STARTSOUND = 15;
//??? public static final int TAG_DEFINEBUTTONSOUND = 17;
public static final int TAG_SOUNDSTREAMHEAD = 18;
public static final int TAG_SOUNDSTREAMBLOCK = 19;
public static final int TAG_DEFINEBITSLOSSLESS = 20;
public static final int TAG_DEFINEBITSJPEG2 = 21;
public static final int TAG_DEFINESHAPE2 = 22;
public static final int TAG_DEFINEBUTTONCXFORM = 23;
public static final int TAG_PROTECT = 24; //???
public static final int TAG_PLACEOBJECT2 = 26; //???
public static final int TAG_REMOVEOBJECT2 = 28; //???
public static final int TAG_DEFINESHAPE3 = 32;
public static final int TAG_DEFINETEXT2 = 33;
public static final int TAG_DEFINEBUTTON2 = 34;
public static final int TAG_DEFINEBITSJPEG3 = 35;
public static final int TAG_DEFINEBITSLOSSLESS2 = 36; public static final int TAG_DEFINETEXTFIELD = 37;
public static final int TAG_DEFINEQUICKTIMEMOVIE = 38;
public static final int TAG_DEFINESPRITE = 39;
public static final int TAG_NAMECHARACTER = 40; public static final int TAG_SERIALNUMBER = 41;
public static final int TAG_GENERATOR_TEXT = 42;
public static final int TAG_FRAMELABEL = 43; //???
public static final int TAG_SOUNDSTREAMHEAD2 = 45;
public static final int TAG_DEFINEMORPHSHAPE = 46; //???
public static final int TAG_DEFINEFONT2 = 48;
public static final int TAG_TEMPLATECOMMAND = 49;
//???
public static final int TAG_FLASHGENERATOR = 51;
public static final int TAG_GEN_EXTERNAL_FONT = 52;
//???
//???
//???
public static final int TAG_EXPORT = 56;
public static final int TAG_IMPORT = 57;
public static final int TAG_ENABLEDEBUG = 58;
public static final int TAG_DOINITACTION = 59;
//???
//???
public static final int TAG_DEFINEFONTINFO2 = 62;
//???
public static final int TAG_ENABLEDEBUGGER2 = 64;
//--Fill Types
public static final int FILL_SOLID = 0x00;
public static final int FILL_LINEAR_GRADIENT = 0x10;
public static final int FILL_RADIAL_GRADIENT = 0x12;
public static final int FILL_TILED_BITMAP = 0x40;
public static final int FILL_CLIPPED_BITMAP = 0x41;
//--Clip Action Conditions
public static final int CLIP_ACTION_ON_LOAD = 0x01;
public static final int CLIP_ACTION_ENTER_FRAME = 0x02;
public static final int CLIP_ACTION_UNLOAD = 0x04;
public static final int CLIP_ACTION_MOUSE_MOVE = 0x08;
public static final int CLIP_ACTION_MOUSE_DOWN = 0x10;
public static final int CLIP_ACTION_MOUSE_UP = 0x20;
public static final int CLIP_ACTION_KEY_DOWN = 0x40;
public static final int CLIP_ACTION_KEY_UP = 0x80;
public static final int CLIP_ACTION_DATA = 0x100;
//--Font Info flags
public static final int FONT_UNICODE = 0x20;
public static final int FONT_SHIFTJIS = 0x10;
public static final int FONT_ANSI = 0x08;
public static final int FONT_ITALIC = 0x04;
public static final int FONT_BOLD = 0x02;
public static final int FONT_WIDECHARS = 0x01;
//--DefineFont2 flags
public static final int FONT2_HAS_LAYOUT = 0x80;
public static final int FONT2_SHIFTJIS = 0x40;
public static final int FONT2_UNICODE = 0x20;
public static final int FONT2_ANSI = 0x10;
public static final int FONT2_32OFFSETS = 0x08;
public static final int FONT2_WIDECHARS = 0x04;
public static final int FONT2_ITALIC = 0x02;
public static final int FONT2_BOLD = 0x01;
//--Text Field flags
public static final int TEXTFIELD_HAS_LAYOUT = 0x2000; //author always sets this
public static final int TEXTFIELD_NO_SELECTION = 0x1000;
public static final int TEXTFIELD_DRAW_BORDER = 0x0800;
public static final int TEXTFIELD_HTML = 0x0200;
public static final int TEXTFIELD_FONT_GLYPHS = 0x0100;
public static final int TEXTFIELD_HAS_TEXT = 0x0080;
public static final int TEXTFIELD_WORD_WRAP = 0x0040;
public static final int TEXTFIELD_IS_MULTILINE = 0x0020;
public static final int TEXTFIELD_IS_PASSWORD = 0x0010;
public static final int TEXTFIELD_DISABLE_EDIT = 0x0008;
public static final int TEXTFIELD_HAS_TEXT_COLOR = 0x0004; //author always sets this
public static final int TEXTFIELD_LIMIT_CHARS = 0x0002;
public static final int TEXTFIELD_HAS_FONT = 0x0001; //author always sets this
//--Text Field alignment
public static final int TEXTFIELD_ALIGN_LEFT = 0;
public static final int TEXTFIELD_ALIGN_RIGHT = 1;
public static final int TEXTFIELD_ALIGN_CENTER = 2;
public static final int TEXTFIELD_ALIGN_JUSTIFY = 3;
//--Used by TagDefineText(2)..
public static final int TEXT_HAS_FONT = 0x08;
public static final int TEXT_HAS_COLOR = 0x04;
public static final int TEXT_HAS_YOFFSET = 0x02;
public static final int TEXT_HAS_XOFFSET = 0x01;
//--Action Conditions for DefineButton2..
public static final int BUTTON2_OVERDOWN2IDLE = 0x100;
public static final int BUTTON2_IDLE2OVERDOWN = 0x080;
public static final int BUTTON2_OUTDOWN2IDLE = 0x040;
public static final int BUTTON2_OUTDOWN2OVERDOWN = 0x020;
public static final int BUTTON2_OVERDOWN2OUTDOWN = 0x010;
public static final int BUTTON2_OVERDOWN2OVERUP = 0x008;
public static final int BUTTON2_OVERUP2OVERDOWN = 0x004;
public static final int BUTTON2_OVERUP2IDLE = 0x002;
public static final int BUTTON2_IDLE2OVERUP = 0x001;
//--Formats for DefineBitsLossless..
public static final int BITMAP_FORMAT_8_BIT = 3;
public static final int BITMAP_FORMAT_16_BIT = 4;
public static final int BITMAP_FORMAT_32_BIT = 5;
//--Sound Constants..
public static final int SOUND_FORMAT_RAW = 0;
public static final int SOUND_FORMAT_ADPCM = 1;
public static final int SOUND_FORMAT_MP3 = 2;
public static final int SOUND_FORMAT_RAW_LITTLEENDIAN = 3;
public static final int SOUND_FORMAT_NELLYMOSER = 6;
public static final int SOUND_FREQ_5_5KHZ = 0; //5.5 kHz
public static final int SOUND_FREQ_11KHZ = 1;
public static final int SOUND_FREQ_22KHZ = 2;
public static final int SOUND_FREQ_44KHZ = 3;
//--Language Codes for DefineFontInfo2
public static final int LANGUAGE_CODE_NONE = 0;
public static final int LANGUAGE_CODE_LATIN = 1;
public static final int LANGUAGE_CODE_JAPANESE = 2;
public static final int LANGUAGE_CODE_KOREAN = 3;
public static final int LANGUAGE_CODE_SIMPLIFIED_CHINESE = 4;
public static final int LANGUAGE_CODE_TRADITIONAL_CHINESE = 5;
//--String Encodings
public static final String STRING_ENCODING_PRE_MX = "US-ASCII";
public static final String STRING_ENCODING_MX = "UTF-8";
//--MX Version number
public static final int FLASH_MX_VERSION = 6;
}

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFActionCodes;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
@ -510,21 +511,9 @@ public class ActionParser implements SWFActionCodes {
* Description of the Field
*/
public int code;
/**
* Description of the Field
*/
public String label;
/**
* Description of the Field
*/
public String jumpLabel;
/**
* Description of the Field
*/
public byte[] data;
/**
* Description of the Field
*/
public int blockDepth = 0;

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFActionCodes;
import java.io.IOException;
import java.io.PrintWriter;

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFActionCodes;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Hashtable;

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
import java.io.IOException;
/**

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

@ -5,8 +5,9 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.InflaterInputStream;
/**
* Input Stream Wrapper
@ -15,23 +16,11 @@ import java.util.Vector;
*@created 15 de Setembro de 2002
*/
public class InStream {
/**
* Description of the Field
*/
protected InputStream in;
/**
* Description of the Field
*/
protected long bytesRead = 0L;
//--Bit buffer..
/**
* Description of the Field
*/
protected int bitBuf;
/**
* Description of the Field
*/
protected int bitPos;
/**
@ -57,35 +46,27 @@ public class InStream {
/**
* Read a string from the input stream
*
*@return Description of the Return Value
*@exception IOException Description of the Exception
* @return Description of the Return Value
* @exception IOException Description of the Exception
*/
public byte[] readStringBytes() throws IOException {
synchBits();
Vector chars = new Vector();
List<Byte> chars = new ArrayList();
byte[] aChar = new byte[1];
int num = 0;
while ((num = in.read(aChar)) == 1) {
bytesRead++;
if (aChar[0] == 0) {
//end of string
if (aChar[0] == 0) { //end of string
byte[] string = new byte[chars.size()];
int i = 0;
for (Enumeration enumerator = chars.elements();
enumerator.hasMoreElements();
) {
string[i++] = ((Byte) enumerator.nextElement()).byteValue();
for (Object b : chars) {
string[i++] = ((Byte) b).byteValue();
}
return string;
}
chars.addElement(new Byte(aChar[0]));
chars.add(new Byte(aChar[0]));
}
throw new IOException("Unterminated string - reached end of input before null char");
@ -444,6 +425,14 @@ public class InStream {
return new DataInputStream(bin).readDouble();
}
/**
* Start reading compressed data - all further input is assumed to come from
* a zip compressed stream.
*/
public void readCompressed() {
in = new InflaterInputStream(in);
}
/**
* Util to convert an unsigned byte to an unsigned int
*

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;

@ -1,631 +0,0 @@
package pt.tumba.parser.swf;
/**
* Action Codes and associated constants
*
*@author unknown
*@created 15 de Setembro de 2002
*/
public interface SWFActionCodes {
/**
* Description of the Field
*/
public final static int NEXT_FRAME = 0x04;
//F3 ***
/**
* Description of the Field
*/
public final static int PREVIOUS_FRAME = 0x05;
//F3 ***
/**
* Description of the Field
*/
public final static int PLAY = 0x06;
//F3 ***
/**
* Description of the Field
*/
public final static int STOP = 0x07;
//F3 ***
/**
* Description of the Field
*/
public final static int TOGGLE_QUALITY = 0x08;
//F3 ***
/**
* Description of the Field
*/
public final static int STOP_SOUNDS = 0x09;
//F3 ***
/**
* Description of the Field
*/
public final static int ADD = 0x0a;
//F4
/**
* Description of the Field
*/
public final static int SUBTRACT = 0x0b;
//F4
/**
* Description of the Field
*/
public final static int MULTIPLY = 0x0c;
//F4
/**
* Description of the Field
*/
public final static int DIVIDE = 0x0d;
//F4
/**
* Description of the Field
*/
public final static int EQUALS = 0x0e;
//F4
/**
* Description of the Field
*/
public final static int LESS = 0x0f;
//F4
/**
* Description of the Field
*/
public final static int AND = 0x10;
//F4
/**
* Description of the Field
*/
public final static int OR = 0x11;
//F4
/**
* Description of the Field
*/
public final static int NOT = 0x12;
//F4
/**
* Description of the Field
*/
public final static int STRING_EQUALS = 0x13;
//F4
/**
* Description of the Field
*/
public final static int STRING_LENGTH = 0x14;
//F4
/**
* Description of the Field
*/
public final static int STRING_EXTRACT = 0x15;
//F4
/**
* Description of the Field
*/
public final static int POP = 0x17;
//F4
/**
* Description of the Field
*/
public final static int TO_INTEGER = 0x18;
//F4
/**
* Description of the Field
*/
public final static int GET_VARIABLE = 0x1c;
//F4
/**
* Description of the Field
*/
public final static int SET_VARIABLE = 0x1d;
//F4
/**
* Description of the Field
*/
public final static int SET_TARGET_2 = 0x20;
//F4
/**
* Description of the Field
*/
public final static int STRING_ADD = 0x21;
//F4
/**
* Description of the Field
*/
public final static int GET_PROPERTY = 0x22;
//F4
/**
* Description of the Field
*/
public final static int SET_PROPERTY = 0x23;
//F4
/**
* Description of the Field
*/
public final static int CLONE_SPRITE = 0x24;
//F4
/**
* Description of the Field
*/
public final static int REMOVE_SPRITE = 0x25;
//F4
/**
* Description of the Field
*/
public final static int TRACE = 0x26;
//F4
/**
* Description of the Field
*/
public final static int START_DRAG = 0x27;
//F4
/**
* Description of the Field
*/
public final static int END_DRAG = 0x28;
//F4
/**
* Description of the Field
*/
public final static int STRING_LESS = 0x29;
//F4
/**
* Description of the Field
*/
public final static int RANDOM_NUMBER = 0x30;
//F4
/**
* Description of the Field
*/
public final static int MB_STRING_LENGTH = 0x31;
//F4
/**
* Description of the Field
*/
public final static int CHAR_TO_ASCII = 0x32;
//F4
/**
* Description of the Field
*/
public final static int ASCII_TO_CHAR = 0x33;
//F4
/**
* Description of the Field
*/
public final static int GET_TIME = 0x34;
//F4
/**
* Description of the Field
*/
public final static int MB_STRING_EXTRACT = 0x35;
//F4
/**
* Description of the Field
*/
public final static int MB_CHAR_TO_ASCII = 0x36;
//F4
/**
* Description of the Field
*/
public final static int MB_ASCII_TO_CHAR = 0x37;
//F4
/**
* Description of the Field
*/
public final static int DEL_VAR = 0x3a;
//F5 ---
/**
* Description of the Field
*/
public final static int DEL_THREAD_VARS = 0x3b;
//F5 ---
/**
* Description of the Field
*/
public final static int DEFINE_LOCAL_VAL = 0x3c;
//F5 ---
/**
* Description of the Field
*/
public final static int CALL_FUNCTION = 0x3d;
//F5 ---
/**
* Description of the Field
*/
public final static int RETURN = 0x3e;
//F5 ---
/**
* Description of the Field
*/
public final static int MODULO = 0x3f;
//F5 ---
/**
* Description of the Field
*/
public final static int NEW_OBJECT = 0x40;
//F5 ---
/**
* Description of the Field
*/
public final static int DEFINE_LOCAL = 0x41;
//F5 ---
/**
* Description of the Field
*/
public final static int INIT_ARRAY = 0x42;
//F5 ---
/**
* Description of the Field
*/
public final static int INIT_OBJECT = 0x43;
//F5 ---
/**
* Description of the Field
*/
public final static int TYPEOF = 0x44;
//F5 ---
/**
* Description of the Field
*/
public final static int GET_TARGET_PATH = 0x45;
//F5 ---
/**
* Description of the Field
*/
public final static int ENUMERATE = 0x46;
//F5 ---
/**
* Description of the Field
*/
public final static int TYPED_ADD = 0x47;
//F5 ---
/**
* Description of the Field
*/
public final static int TYPED_LESS_THAN = 0x48;
//F5 ---
/**
* Description of the Field
*/
public final static int TYPED_EQUALS = 0x49;
//F5 ---
/**
* Description of the Field
*/
public final static int CONVERT_TO_NUMBER = 0x4a;
//F5 ---
/**
* Description of the Field
*/
public final static int CONVERT_TO_STRING = 0x4b;
//F5 ---
/**
* Description of the Field
*/
public final static int DUPLICATE = 0x4c;
//F5 ---
/**
* Description of the Field
*/
public final static int SWAP = 0x4d;
//F5 ---
/**
* Description of the Field
*/
public final static int GET_MEMBER = 0x4e;
//F5 ---
/**
* Description of the Field
*/
public final static int SET_MEMBER = 0x4f;
//F5 ---
/**
* Description of the Field
*/
public final static int INCREMENT = 0x50;
//F5 ---
/**
* Description of the Field
*/
public final static int DECREMENT = 0x51;
//F5 ---
/**
* Description of the Field
*/
public final static int CALL_METHOD = 0x52;
//F5 ---
/**
* Description of the Field
*/
public final static int CALL_NEW_METHOD = 0x53;
//F5 ---
/**
* Description of the Field
*/
public final static int BIT_AND = 0x60;
//F5 ---
/**
* Description of the Field
*/
public final static int BIT_OR = 0x61;
//F5 ---
/**
* Description of the Field
*/
public final static int BIT_XOR = 0x62;
//F5 ---
/**
* Description of the Field
*/
public final static int SHIFT_LEFT = 0x63;
//F5 ---
/**
* Description of the Field
*/
public final static int SHIFT_RIGHT = 0x64;
//F5 ---
/**
* Description of the Field
*/
public final static int SHIFT_UNSIGNED = 0x65;
//F5 ---
/**
* Description of the Field
*/
public final static int GOTO_FRAME = 0x81;
//F3 ***
/**
* Description of the Field
*/
public final static int GET_URL = 0x83;
//F3 ***
/**
* Description of the Field
*/
public final static int REGISTER = 0x87;
//F5 ---
/**
* Description of the Field
*/
public final static int LOOKUP_TABLE = 0x88;
//F5 ---
/**
* Description of the Field
*/
public final static int WAIT_FOR_FRAME = 0x8a;
//F3 ***
/**
* Description of the Field
*/
public final static int SET_TARGET = 0x8b;
//F3 ***
/**
* Description of the Field
*/
public final static int GOTO_LABEL = 0x8c;
//F3 ***
/**
* Description of the Field
*/
public final static int WAIT_FOR_FRAME_2 = 0x8d;
//F4
/**
* Description of the Field
*/
public final static int WITH = 0x94;
//F5 ---
/**
* Description of the Field
*/
public final static int PUSH = 0x96;
//F4
/**
* Description of the Field
*/
public final static int JUMP = 0x99;
//F4
/**
* Description of the Field
*/
public final static int GET_URL_2 = 0x9a;
//F4
/**
* Description of the Field
*/
public final static int DEFINE_FUNCTION = 0x9b;
//F5 ---
/**
* Description of the Field
*/
public final static int IF = 0x9d;
//F4
/**
* Description of the Field
*/
public final static int CALL = 0x9e;
//F4
/**
* Description of the Field
*/
public final static int GOTO_FRAME_2 = 0x9f;
//F4
//--Property Constants
/**
* Description of the Field
*/
public final static int PROP_X = 0;
/**
* Description of the Field
*/
public final static int PROP_Y = 1;
/**
* Description of the Field
*/
public final static int PROP_XSCALE = 2;
/**
* Description of the Field
*/
public final static int PROP_YSCALE = 3;
/**
* Description of the Field
*/
public final static int PROP_CURRENTFRAME = 4;
/**
* Description of the Field
*/
public final static int PROP_TOTALFRAMES = 5;
/**
* Description of the Field
*/
public final static int PROP_ALPHA = 6;
/**
* Description of the Field
*/
public final static int PROP_VISIBLE = 7;
/**
* Description of the Field
*/
public final static int PROP_WIDTH = 8;
/**
* Description of the Field
*/
public final static int PROP_HEIGHT = 9;
/**
* Description of the Field
*/
public final static int PROP_ROTATION = 10;
/**
* Description of the Field
*/
public final static int PROP_TARGET = 11;
/**
* Description of the Field
*/
public final static int PROP_FRAMESLOADED = 12;
/**
* Description of the Field
*/
public final static int PROP_NAME = 13;
/**
* Description of the Field
*/
public final static int PROP_DROPTARGET = 14;
/**
* Description of the Field
*/
public final static int PROP_URL = 15;
/**
* Description of the Field
*/
public final static int PROP_HIGHQUALITY = 16;
/**
* Description of the Field
*/
public final static int PROP_FOCUSRECT = 17;
/**
* Description of the Field
*/
public final static int PROP_SOUNDBUFTIME = 18;
/**
* Description of the Field
*/
public final static int PROP_QUALITY = 19;
//flash 5 only
/**
* Description of the Field
*/
public final static int PROP_XMOUSE = 20;
//flash 5 only
/**
* Description of the Field
*/
public final static int PROP_YMOUSE = 21;
//flash 5 only
//--TypeOf Strings (from the ActionScript typeof() operator)
/**
* Description of the Field
*/
public final static String TYPEOF_NUMBER = "number";
/**
* Description of the Field
*/
public final static String TYPEOF_BOOLEAN = "boolean";
/**
* Description of the Field
*/
public final static String TYPEOF_STRING = "string";
/**
* Description of the Field
*/
public final static String TYPEOF_OBJECT = "object";
/**
* Description of the Field
*/
public final static String TYPEOF_MOVIECLIP = "movieclip";
/**
* Description of the Field
*/
public final static String TYPEOF_NULL = "null";
/**
* Description of the Field
*/
public final static String TYPEOF_UNDEFINED = "undefined";
/**
* Description of the Field
*/
public final static String TYPEOF_FUNCTION = "function";
//--Types for Flash 5 push action
/**
* Description of the Field
*/
public final static int PUSHTYPE_STRING = 0;
/**
* Description of the Field
*/
public final static int PUSHTYPE_FLOAT = 1;
/**
* Description of the Field
*/
public final static int PUSHTYPE_NULL = 2;
/**
* Description of the Field
*/
public final static int PUSHTYPE_03 = 3;
//unknown
/**
* Description of the Field
*/
public final static int PUSHTYPE_REGISTER = 4;
/**
* Description of the Field
*/
public final static int PUSHTYPE_BOOLEAN = 5;
/**
* Description of the Field
*/
public final static int PUSHTYPE_DOUBLE = 6;
/**
* Description of the Field
*/
public final static int PUSHTYPE_INTEGER = 7;
/**
* Description of the Field
*/
public final static int PUSHTYPE_LOOKUP = 8;
}

@ -1,513 +0,0 @@
package pt.tumba.parser.swf;
/**
* Various SWF Constant Values
*
*@author unknown
*@created 15 de Setembro de 2002
*/
public interface SWFConstants {
/**
* Description of the Field
*/
public final static int TWIPS = 20;
//number of TWIPS per pixel
/**
* Description of the Field
*/
public final static int TAG_END = 0;
/**
* Description of the Field
*/
public final static int TAG_SHOWFRAME = 1;
/**
* Description of the Field
*/
public final static int TAG_DEFINESHAPE = 2;
/**
* Description of the Field
*/
public final static int TAG_FREECHARACTER = 3;
/**
* Description of the Field
*/
public final static int TAG_PLACEOBJECT = 4;
/**
* Description of the Field
*/
public final static int TAG_REMOVEOBJECT = 5;
/**
* Description of the Field
*/
public final static int TAG_DEFINEBITS = 6;
/**
* Description of the Field
*/
public final static int TAG_DEFINEBUTTON = 7;
/**
* Description of the Field
*/
public final static int TAG_JPEGTABLES = 8;
/**
* Description of the Field
*/
public final static int TAG_SETBACKGROUNDCOLOR = 9;
/**
* Description of the Field
*/
public final static int TAG_DEFINEFONT = 10;
/**
* Description of the Field
*/
public final static int TAG_DEFINETEXT = 11;
/**
* Description of the Field
*/
public final static int TAG_DOACTION = 12;
/**
* Description of the Field
*/
public final static int TAG_DEFINEFONTINFO = 13;
/**
* Description of the Field
*/
public final static int TAG_DEFINESOUND = 14;
/**
* Description of the Field
*/
public final static int TAG_STARTSOUND = 15;
//???
/**
* Description of the Field
*/
public final static int TAG_DEFINEBUTTONSOUND = 17;
/**
* Description of the Field
*/
public final static int TAG_SOUNDSTREAMHEAD = 18;
/**
* Description of the Field
*/
public final static int TAG_SOUNDSTREAMBLOCK = 19;
/**
* Description of the Field
*/
public final static int TAG_DEFINEBITSLOSSLESS = 20;
/**
* Description of the Field
*/
public final static int TAG_DEFINEBITSJPEG2 = 21;
/**
* Description of the Field
*/
public final static int TAG_DEFINESHAPE2 = 22;
/**
* Description of the Field
*/
public final static int TAG_DEFINEBUTTONCXFORM = 23;
/**
* Description of the Field
*/
public final static int TAG_PROTECT = 24;
//???
/**
* Description of the Field
*/
public final static int TAG_PLACEOBJECT2 = 26;
//???
/**
* Description of the Field
*/
public final static int TAG_REMOVEOBJECT2 = 28;
//???
/**
* Description of the Field
*/
public final static int TAG_DEFINESHAPE3 = 32;
/**
* Description of the Field
*/
public final static int TAG_DEFINETEXT2 = 33;
/**
* Description of the Field
*/
public final static int TAG_DEFINEBUTTON2 = 34;
/**
* Description of the Field
*/
public final static int TAG_DEFINEBITSJPEG3 = 35;
/**
* Description of the Field
*/
public final static int TAG_DEFINEBITSLOSSLESS2 = 36;
/**
* Description of the Field
*/
public final static int TAG_DEFINETEXTFIELD = 37;
/**
* Description of the Field
*/
public final static int TAG_DEFINEQUICKTIMEMOVIE = 38;
/**
* Description of the Field
*/
public final static int TAG_DEFINESPRITE = 39;
/**
* Description of the Field
*/
public final static int TAG_NAMECHARACTER = 40;
/**
* Description of the Field
*/
public final static int TAG_SERIALNUMBER = 41;
/**
* Description of the Field
*/
public final static int TAG_GENERATOR_TEXT = 42;
/**
* Description of the Field
*/
public final static int TAG_FRAMELABEL = 43;
//???
/**
* Description of the Field
*/
public final static int TAG_SOUNDSTREAMHEAD2 = 45;
/**
* Description of the Field
*/
public final static int TAG_DEFINEMORPHSHAPE = 46;
//???
/**
* Description of the Field
*/
public final static int TAG_DEFINEFONT2 = 48;
/**
* Description of the Field
*/
public final static int TAG_TEMPLATECOMMAND = 49;
//???
/**
* Description of the Field
*/
public final static int TAG_FLASHGENERATOR = 51;
/**
* Description of the Field
*/
public final static int TAG_GEN_EXTERNAL_FONT = 52;
//???
//???
//???
/**
* Description of the Field
*/
public final static int TAG_EXPORT = 56;
/**
* Description of the Field
*/
public final static int TAG_IMPORT = 57;
/**
* Description of the Field
*/
public final static int TAG_ENABLEDEBUG = 58;
//--Fill Types
/**
* Description of the Field
*/
public final static int FILL_SOLID = 0x00;
/**
* Description of the Field
*/
public final static int FILL_LINEAR_GRADIENT = 0x10;
/**
* Description of the Field
*/
public final static int FILL_RADIAL_GRADIENT = 0x12;
/**
* Description of the Field
*/
public final static int FILL_TILED_BITMAP = 0x40;
/**
* Description of the Field
*/
public final static int FILL_CLIPPED_BITMAP = 0x41;
//--Clip Action Conditions
/**
* Description of the Field
*/
public final static int CLIP_ACTION_ON_LOAD = 0x01;
/**
* Description of the Field
*/
public final static int CLIP_ACTION_ENTER_FRAME = 0x02;
/**
* Description of the Field
*/
public final static int CLIP_ACTION_UNLOAD = 0x04;
/**
* Description of the Field
*/
public final static int CLIP_ACTION_MOUSE_MOVE = 0x08;
/**
* Description of the Field
*/
public final static int CLIP_ACTION_MOUSE_DOWN = 0x10;
/**
* Description of the Field
*/
public final static int CLIP_ACTION_MOUSE_UP = 0x20;
/**
* Description of the Field
*/
public final static int CLIP_ACTION_KEY_DOWN = 0x40;
/**
* Description of the Field
*/
public final static int CLIP_ACTION_KEY_UP = 0x80;
/**
* Description of the Field
*/
public final static int CLIP_ACTION_DATA = 0x100;
//--Font Info flags
/**
* Description of the Field
*/
public final static int FONT_UNICODE = 0x20;
/**
* Description of the Field
*/
public final static int FONT_SHIFTJIS = 0x10;
/**
* Description of the Field
*/
public final static int FONT_ANSI = 0x08;
/**
* Description of the Field
*/
public final static int FONT_ITALIC = 0x04;
/**
* Description of the Field
*/
public final static int FONT_BOLD = 0x02;
/**
* Description of the Field
*/
public final static int FONT_WIDECHARS = 0x01;
//--DefineFont2 flags
/**
* Description of the Field
*/
public final static int FONT2_HAS_LAYOUT = 0x80;
/**
* Description of the Field
*/
public final static int FONT2_SHIFTJIS = 0x40;
/**
* Description of the Field
*/
public final static int FONT2_UNICODE = 0x20;
/**
* Description of the Field
*/
public final static int FONT2_ANSI = 0x10;
/**
* Description of the Field
*/
public final static int FONT2_32OFFSETS = 0x08;
/**
* Description of the Field
*/
public final static int FONT2_WIDECHARS = 0x04;
/**
* Description of the Field
*/
public final static int FONT2_ITALIC = 0x02;
/**
* Description of the Field
*/
public final static int FONT2_BOLD = 0x01;
//--Text Field flags
/**
* Description of the Field
*/
public final static int TEXTFIELD_HAS_LAYOUT = 0x2000;
//author always sets this
/**
* Description of the Field
*/
public final static int TEXTFIELD_NO_SELECTION = 0x1000;
/**
* Description of the Field
*/
public final static int TEXTFIELD_DRAW_BORDER = 0x0800;
/**
* Description of the Field
*/
public final static int TEXTFIELD_HTML = 0x0200;
/**
* Description of the Field
*/
public final static int TEXTFIELD_FONT_GLYPHS = 0x0100;
/**
* Description of the Field
*/
public final static int TEXTFIELD_HAS_TEXT = 0x0080;
/**
* Description of the Field
*/
public final static int TEXTFIELD_WORD_WRAP = 0x0040;
/**
* Description of the Field
*/
public final static int TEXTFIELD_IS_MULTILINE = 0x0020;
/**
* Description of the Field
*/
public final static int TEXTFIELD_IS_PASSWORD = 0x0010;
/**
* Description of the Field
*/
public final static int TEXTFIELD_DISABLE_EDIT = 0x0008;
/**
* Description of the Field
*/
public final static int TEXTFIELD_HAS_TEXT_COLOR = 0x0004;
//author always sets this
/**
* Description of the Field
*/
public final static int TEXTFIELD_LIMIT_CHARS = 0x0002;
/**
* Description of the Field
*/
public final static int TEXTFIELD_HAS_FONT = 0x0001;
//author always sets this
//--Text Field alignment
/**
* Description of the Field
*/
public final static int TEXTFIELD_ALIGN_LEFT = 0;
/**
* Description of the Field
*/
public final static int TEXTFIELD_ALIGN_RIGHT = 1;
/**
* Description of the Field
*/
public final static int TEXTFIELD_ALIGN_CENTER = 2;
/**
* Description of the Field
*/
public final static int TEXTFIELD_ALIGN_JUSTIFY = 3;
//--Used by TagDefineText(2)..
/**
* Description of the Field
*/
public final static int TEXT_HAS_FONT = 0x08;
/**
* Description of the Field
*/
public final static int TEXT_HAS_COLOR = 0x04;
/**
* Description of the Field
*/
public final static int TEXT_HAS_YOFFSET = 0x02;
/**
* Description of the Field
*/
public final static int TEXT_HAS_XOFFSET = 0x01;
//--Action Conditions for DefineButton2..
/**
* Description of the Field
*/
public final static int BUTTON2_OVERDOWN2IDLE = 0x100;
/**
* Description of the Field
*/
public final static int BUTTON2_IDLE2OVERDOWN = 0x080;
/**
* Description of the Field
*/
public final static int BUTTON2_OUTDOWN2IDLE = 0x040;
/**
* Description of the Field
*/
public final static int BUTTON2_OUTDOWN2OVERDOWN = 0x020;
/**
* Description of the Field
*/
public final static int BUTTON2_OVERDOWN2OUTDOWN = 0x010;
/**
* Description of the Field
*/
public final static int BUTTON2_OVERDOWN2OVERUP = 0x008;
/**
* Description of the Field
*/
public final static int BUTTON2_OVERUP2OVERDOWN = 0x004;
/**
* Description of the Field
*/
public final static int BUTTON2_OVERUP2IDLE = 0x002;
/**
* Description of the Field
*/
public final static int BUTTON2_IDLE2OVERUP = 0x001;
//--Formats for DefineBitsLossless..
/**
* Description of the Field
*/
public final static int BITMAP_FORMAT_8_BIT = 3;
/**
* Description of the Field
*/
public final static int BITMAP_FORMAT_16_BIT = 4;
/**
* Description of the Field
*/
public final static int BITMAP_FORMAT_32_BIT = 5;
//--Sound Constants..
/**
* Description of the Field
*/
public final static int SOUND_FORMAT_RAW = 0;
/**
* Description of the Field
*/
public final static int SOUND_FORMAT_ADPCM = 1;
/**
* Description of the Field
*/
public final static int SOUND_FORMAT_MP3 = 2;
/**
* Description of the Field
*/
public final static int SOUND_FREQ_5_5KHZ = 0;
//5.5 kHz
/**
* Description of the Field
*/
public final static int SOUND_FREQ_11KHZ = 1;
/**
* Description of the Field
*/
public final static int SOUND_FREQ_22KHZ = 2;
/**
* Description of the Field
*/
public final static int SOUND_FREQ_44KHZ = 3;
}

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -12,22 +13,11 @@ import java.io.InputStream;
*@created 15 de Setembro de 2002
*/
public class SWFReader {
/**
* Description of the Field
*/
protected SWFTags consumer;
/**
* Description of the Field
*/
protected InStream in;
/**
* Description of the Field
*/
protected InputStream inputstream;
/**
* Description of the Field
*/
protected boolean zipCompressed = false; // flag swf zip compressed
public int size;
@ -77,7 +67,8 @@ public class SWFReader {
/**
* Drive the consumer by reading a SWF File - including the header and all
* tags
* tags. Reading first the file signature (3 byte) and throws IOException if
* no match or file version not supported
*
*@exception IOException Description of the Exception
*/
@ -127,18 +118,44 @@ public class SWFReader {
/**
* Only read the SWF file header
*
*@exception IOException Description of the Exception
* Read the SWF file header - including the signature.
*/
public void readHeader() throws IOException {
//--Verify File Signature
//if ((in.readUI8() != 0x46) || (in.readUI8() != 0x57) || (in.readUI8() != 0x53)) {
// throw new IOException("Invalid SWF File Signature");
//}
// magic bytes according to specification http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/swf/pdf/swf-file-format-spec.pdf
// 0x46, 0x57, 0x53 (“FWS”) signature indicates an uncompressed SWF file
// 0x43, 0x57, 0x53 (“CWS”) indicates that the entire file after the first 8 bytes was compressed by using the ZLIB
// 0x5a, 0x57, 0x53 (“ZWS”) indicates that the entire file after the first 8 bytes was compressed by using the LZMA
int magic = in.readUI8();
switch (magic) { // F=uncompressed, C= ZIP-compressed Z=LZMA-compressed
case 'C':
zipCompressed = true;
break;
case 'F':
break;
case 'Z':
throw new IOException("LZMA compressed SWF file not supported"); // lzma compressed not supported yet
default:
throw new IOException("Invalid SWF File Signature");
}
magic = in.readUI8(); // always 'W'
if (magic != 'W') {
throw new IOException("Invalid SWF File Signature");
}
magic = in.readUI8(); // always 'S'
if (magic != 'S') {
throw new IOException("Invalid SWF File Signature");
}
int version = in.readUI8();
long length = in.readUI32();
//may be compressed from this point onwards
if (zipCompressed) {
in.readCompressed();
}
Rect frameSize = new Rect(in);
int frameRate = in.readUI16() >> 8;
int frameCount = in.readUI16();

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

@ -1,5 +1,6 @@
package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFConstants;
/**
* A Transformation matrix that has translation coordinates in pixels

@ -28,6 +28,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.StatusLine;
import net.yacy.cora.document.id.DigestURL;
import net.yacy.cora.federate.solr.FailCategory;
import net.yacy.cora.protocol.ClientIdentification;
@ -142,14 +144,16 @@ public final class HTTPLoader {
// send request
client.GET(url, false);
final int statusCode = client.getHttpResponse().getStatusLine().getStatusCode();
final StatusLine statusline = client.getHttpResponse().getStatusLine();
final int statusCode = statusline.getStatusCode();
final ResponseHeader responseHeader = new ResponseHeader(statusCode, client.getHttpResponse().getAllHeaders());
String requestURLString = request.url().toNormalform(true);
// check redirection
if (statusCode > 299 && statusCode < 310) {
client.finish();
final DigestURL redirectionUrl = extractRedirectURL(request, profile, url, client, statusCode,
final DigestURL redirectionUrl = extractRedirectURL(request, profile, url, statusline,
responseHeader, requestURLString);
if (this.sb.getConfigBool(SwitchboardConstants.CRAWLER_FOLLOW_REDIRECTS, true)) {
@ -182,7 +186,7 @@ public final class HTTPLoader {
// we don't want to follow redirects
this.sb.crawlQueues.errorURL.push(request.url(), request.depth(), profile,
FailCategory.FINAL_PROCESS_CONTEXT, "redirection not wanted", statusCode);
throw new IOException("REJECTED UNWANTED REDIRECTION '" + client.getHttpResponse().getStatusLine()
throw new IOException("REJECTED UNWANTED REDIRECTION '" + statusline
+ "' for URL '" + requestURLString + "'$");
} else if (statusCode == 200 || statusCode == 203) {
// the transfer is ok
@ -192,12 +196,14 @@ public final class HTTPLoader {
*/
long contentLength = client.getHttpResponse().getEntity().getContentLength();
if (profile != null && profile.storeHTCache() && contentLength > 0 && contentLength < (Response.CRAWLER_MAX_SIZE_TO_CACHE) && !url.isLocal()) {
byte[] content = HTTPClient.getByteArray(client.getHttpResponse().getEntity(), maxFileSize);
byte[] content = null;
try {
content = HTTPClient.getByteArray(client.getHttpResponse().getEntity(), maxFileSize);
Cache.store(url, responseHeader, content);
} catch (final IOException e) {
this.log.warn("cannot write " + url + " to Cache (3): " + e.getMessage(), e);
} finally {
client.finish();
}
return new ByteArrayInputStream(content);
@ -209,10 +215,11 @@ public final class HTTPLoader {
*/
return new HTTPInputStream(client);
} else {
client.finish();
// if the response has not the right response type then reject file
this.sb.crawlQueues.errorURL.push(request.url(), request.depth(), profile,
FailCategory.TEMPORARY_NETWORK_FAILURE, "wrong http status code", statusCode);
throw new IOException("REJECTED WRONG STATUS TYPE '" + client.getHttpResponse().getStatusLine()
throw new IOException("REJECTED WRONG STATUS TYPE '" + statusline
+ "' for URL '" + requestURLString + "'$");
}
}
@ -223,7 +230,7 @@ public final class HTTPLoader {
* @throws IOException when an error occured
*/
private DigestURL extractRedirectURL(final Request request, CrawlProfile profile, DigestURL url,
final HTTPClient client, final int statusCode, final ResponseHeader responseHeader, String requestURLString)
final StatusLine statusline, final ResponseHeader responseHeader, String requestURLString)
throws IOException {
// read redirection URL
String redirectionUrlString = responseHeader.get(HeaderFramework.LOCATION);
@ -232,8 +239,8 @@ public final class HTTPLoader {
if (redirectionUrlString.isEmpty()) {
this.sb.crawlQueues.errorURL.push(request.url(), request.depth(), profile,
FailCategory.TEMPORARY_NETWORK_FAILURE,
"no redirection url provided, field '" + HeaderFramework.LOCATION + "' is empty", statusCode);
throw new IOException("REJECTED EMTPY REDIRECTION '" + client.getHttpResponse().getStatusLine()
"no redirection url provided, field '" + HeaderFramework.LOCATION + "' is empty", statusline.getStatusCode());
throw new IOException("REJECTED EMTPY REDIRECTION '" + statusline
+ "' for URL '" + requestURLString + "'$");
}
@ -241,7 +248,7 @@ public final class HTTPLoader {
final DigestURL redirectionUrl = DigestURL.newURL(request.url(), redirectionUrlString);
// restart crawling with new url
this.log.info("CRAWLER Redirection detected ('" + client.getHttpResponse().getStatusLine() + "') for URL "
this.log.info("CRAWLER Redirection detected ('" + statusline + "') for URL "
+ requestURLString);
this.log.info("CRAWLER ..Redirecting request to: " + redirectionUrl.toNormalform(false));
@ -249,7 +256,7 @@ public final class HTTPLoader {
if (this.sb.getConfigBool(SwitchboardConstants.CRAWLER_RECORD_REDIRECTS, true)) {
this.sb.crawlQueues.errorURL.push(request.url(), request.depth(), profile,
FailCategory.FINAL_REDIRECT_RULE, "redirect to " + redirectionUrlString, statusCode);
FailCategory.FINAL_REDIRECT_RULE, "redirect to " + redirectionUrlString, statusline.getStatusCode());
}
return redirectionUrl;
}
@ -335,7 +342,7 @@ public final class HTTPLoader {
// check redirection
if (statusCode > 299 && statusCode < 310) {
final DigestURL redirectionUrl = extractRedirectURL(request, profile, url, client, statusCode,
final DigestURL redirectionUrl = extractRedirectURL(request, profile, url, client.getHttpResponse().getStatusLine(),
responseHeader, requestURLString);
if (this.sb.getConfigBool(SwitchboardConstants.CRAWLER_FOLLOW_REDIRECTS, true)) {

@ -30,15 +30,13 @@ package net.yacy.document.parser;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import net.yacy.cora.document.id.AnchorURL;
import net.yacy.document.AbstractParser;
import net.yacy.document.Document;
import net.yacy.document.Parser;
import net.yacy.document.VocabularyScraper;
import net.yacy.document.parser.html.ContentScraper;
import pt.tumba.parser.swf.SWF2HTML;
public class swfParser extends AbstractParser implements Parser {
@ -70,21 +68,10 @@ public class swfParser extends AbstractParser implements Parser {
try {
final SWF2HTML swf2html = new SWF2HTML();
String contents = "";
ContentScraper htmlscraper=null;
try {
// read and check file signature (library expect stream positioned after signature)
// magic bytes according to specification http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/swf/pdf/swf-file-format-spec.pdf
// 0x46, 0x57, 0x53 (“FWS”) signature indicates an uncompressed SWF file
// 0x43, 0x57, 0x53 (“CWS”) indicates that the entire file after the first 8 bytes was compressed by using the ZLIB
// 0x5a, 0x57, 0x53 (“ZWS”) indicates that the entire file after the first 8 bytes was compressed by using the LZMA
int magic = source.read();
if (magic != 'F') // F=uncompressed, C= ZIP-compressed Z=LZMA-compressed
throw new Parser.Failure("compressed swf file not supported", location); // compressed not supported yet
magic = source.read(); // always 'W'
if (magic != 'W') throw new Parser.Failure("not a swf file (wrong file signature)", location);
magic = source.read(); // always 'S'
if (magic != 'S') throw new Parser.Failure("not a swf file (wrong file signature)", location);
contents = swf2html.convertSWFToHTML(source);
htmlscraper = htmlParser.parseToScraper(location, charset, scraper, timezoneOffset, contents, 100);
} catch (final NegativeArraySizeException e) {
throw new Parser.Failure(e.getMessage(), location);
} catch (final IOException e) {
@ -92,6 +79,7 @@ public class swfParser extends AbstractParser implements Parser {
} catch (final Exception e) {
throw new Parser.Failure(e.getMessage(), location);
}
/*
String url = null;
String urlnr = null;
final String linebreak = System.getProperty("line.separator");
@ -101,12 +89,6 @@ public class swfParser extends AbstractParser implements Parser {
int urlEnd = 0;
int p0 = 0;
//getting rid of HTML-Tags
p0 = contents.indexOf("<html><body>",0);
contents = contents.substring(p0+12);
p0 = contents.indexOf("</body></html>",0);
contents = contents.substring(0,p0);
//extracting urls
while ((urlStart = contents.indexOf("http://",urlEnd)) >= 0){
urlEnd = contents.indexOf(linebreak,urlStart);
@ -117,6 +99,7 @@ public class swfParser extends AbstractParser implements Parser {
anchors.add(u);
contents = contents.substring(0,urlStart)+contents.substring(urlEnd);
}
*/
// As the result of parsing this function must return a plasmaParserDocument object
return new Document[]{new Document(
@ -124,24 +107,20 @@ public class swfParser extends AbstractParser implements Parser {
mimeType, // the documents mime type
StandardCharsets.UTF_8.name(), // charset of the document text
this,
null,
null, //keywords
singleList(((contents.length() > 80)? contents.substring(0, 80):contents.trim()).
replaceAll("\r\n"," ").
replaceAll("\n"," ").
replaceAll("\r"," ").
replaceAll("\t"," ")), // title
null, // TODO: AUTHOR
null,
null, // an array of section headlines
null, // an abstract
0.0d, 0.0d,
contents, // the parsed document text
anchors, // a map of extracted anchors
null,
null,
htmlscraper.getContentLanguages(),
htmlscraper.getKeywords(),
htmlscraper.getTitles(),
htmlscraper.getAuthor(),
htmlscraper.getPublisher(),
null, // sections
htmlscraper.getDescriptions(),
htmlscraper.getLon(), htmlscraper.getLat(),
htmlscraper.getText(),
htmlscraper.getAnchors(),
htmlscraper.getRSS(),
null, // images
false,
new Date())};
htmlscraper.getDate())};
} catch (final Exception e) {
if (e instanceof InterruptedException) throw (InterruptedException) e;

Loading…
Cancel
Save