1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
/* compile.h
*
* $Id: compile.h,v 1.1 2004/05/08 17:14:20 kramm Exp $
*
* Notice: This header file contains declarations of functions and types that
* are just used internally. All library functions and types that are supposed
* to be publicly accessable are defined in ./src/ming.h.
*/
#ifndef SWF_COMPILE_H_INCLUDED
#define SWF_COMPILE_H_INCLUDED
#include "ming.h"
typedef struct _buffer *Buffer;
/* shut up bison.simple */
void yyerror(char *msg);
int yylex();
#ifndef max
#define max(x,y) (((x)>(y))?(x):(y))
#endif
enum
{
PUSH_STRING = 0,
PUSH_PROPERTY = 1,
PUSH_NULL = 2,
PUSH_UNDEF = 3,
PUSH_REGISTER = 4,
PUSH_BOOLEAN = 5,
PUSH_DOUBLE = 6,
PUSH_INT = 7,
PUSH_CONSTANT = 8,
PUSH_CONSTANT16 = 9
};
typedef enum
{
FUNCTION_RANDOM,
FUNCTION_LENGTH,
FUNCTION_TIME,
FUNCTION_INT,
FUNCTION_CONCAT,
FUNCTION_DUPLICATECLIP
} SWFActionFunction;
typedef enum
{
GETURL_METHOD_NOSEND = 0,
GETURL_METHOD_GET = 1,
GETURL_METHOD_POST = 2
} SWFGetUrl2Method;
#define GETURL_LOADMOVIE 0x40
#define GETURL_LOADVARIABLES 0x80
#define MAGIC_CONTINUE_NUMBER 0x7FFE
#define MAGIC_BREAK_NUMBER 0x7FFF
#define MAGIC_CONTINUE_NUMBER_LO 0xFE
#define MAGIC_CONTINUE_NUMBER_HI 0x7F
#define MAGIC_BREAK_NUMBER_LO 0xFF
#define MAGIC_BREAK_NUMBER_HI 0x7F
#define BUFFER_INCREMENT 128
struct _buffer
{
byte *buffer;
byte *pos;
int buffersize;
int free;
byte *pushloc;
};
#define BUFFER_SIZE sizeof(struct _buffer)
struct switchcase
{ Buffer cond, action;
int condlen, actlen, isbreak;
};
struct switchcases
{
struct switchcase *list;
int count;
};
enum ctx
{
CTX_FUNCTION = 1,
CTX_LOOP,
CTX_FOR_IN,
CTX_SWITCH,
CTX_BREAK,
CTX_CONTINUE
};
void addctx(enum ctx val);
void delctx(enum ctx val);
int chkctx(enum ctx val);
void checkByteOrder();
/* create/destroy buffer object */
Buffer newBuffer();
void destroyBuffer(Buffer out);
int bufferConcat(Buffer a, Buffer b); /* destroys b. */
int bufferWriteBuffer(Buffer a, Buffer b); /* doesn't. */
/* utilities for writing */
void bufferGrow(Buffer out);
void bufferCheckSize(Buffer out, int bytes);
int bufferLength(Buffer out);
/* constant pool stuff */
int addConstant(const char *s);
int bufferWriteConstants(Buffer out);
#define MAXCONSTANTPOOLSIZE 65533
/* write data to buffer */
int bufferWriteOp(Buffer out, int data);
int bufferWritePushOp(Buffer out);
int bufferWriteU8(Buffer out, int data);
int bufferWriteS16(Buffer out, int data);
int bufferWriteData(Buffer out, const byte *buffer, int bytes);
int bufferWriteHardString(Buffer out, byte *string, int length);
int bufferWriteConstantString(Buffer out, byte *string, int length);
int bufferWriteString(Buffer out, byte *string, int length);
#ifdef __cplusplus
/* helper function to avoid many casts */
inline int bufferWriteString(Buffer out, char *string, int length) {
return bufferWriteString(out,(byte*) string, length); }
#endif
int bufferWriteInt(Buffer out, int i);
int bufferWriteDouble(Buffer out, double d);
int bufferWriteNull(Buffer out);
int bufferWriteBoolean(Buffer out, int val);
int bufferWriteRegister(Buffer out, int num);
int bufferWriteSetRegister(Buffer out, int num);
int bufferWriteGetProperty(Buffer out, char *string);
int bufferWriteSetProperty(Buffer out, char *string);
int bufferWriteWTHITProperty(Buffer out);
/* concat b to a, destroy b */
char *stringConcat(char *a, char *b);
/* resolve magic number standins to relative offsets */
void bufferResolveJumps(Buffer out);
void bufferResolveSwitch(Buffer buffer, struct switchcases *slp);
/* rather than setting globals... */
void swf4ParseInit(const char *string, int debug);
void swf5ParseInit(const char *string, int debug);
int swf4parse(void *b);
int swf5parse(void *b);
#endif /* SWF_COMPILE_H_INCLUDED */
|