From e448c7a56df8e289c9dbd5b8d87753addd541091 Mon Sep 17 00:00:00 2001 From: boehme Date: Tue, 30 Oct 2001 20:33:27 +0000 Subject: [PATCH] rfxswf cleanups: added prefixes and altered structure name conventions --- lib/Makefile.in | 4 +- lib/log.c | 504 +++++++++++++------------- lib/log.h | 78 ++-- lib/modules/swfaction.c | 397 ++++++++++----------- lib/modules/swfbits.c | 75 ++-- lib/modules/swfbutton.c | 72 ++-- lib/modules/swfcgi.c | 25 +- lib/modules/swfdump.c | 190 +++++----- lib/modules/swfobject.c | 38 +- lib/modules/swfshape.c | 288 +++++++-------- lib/modules/swftext.c | 211 ++++++----- lib/modules/swftools.c | 130 +++---- lib/old_rfxswf.h | 1 + lib/rfxswf.c | 374 ++++++++++---------- lib/rfxswf.h | 237 +++++++------ pdf2swf/Makefile.in | 4 +- pdf2swf/fonts/Makefile.in | 4 +- pdf2swf/swfoutput.cc | 820 +++++++++++++++++++++--------------------- pdf2swf/xpdf/Makefile.in | 4 +- src/jpeg2swf.c | 864 ++++++++++++++++++++++----------------------- src/swfdump.c | 376 ++++++++++---------- src/swfstrings.c | 186 +++++----- 22 files changed, 2441 insertions(+), 2441 deletions(-) diff --git a/lib/Makefile.in b/lib/Makefile.in index d24d8d2..e34cc47 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -78,7 +78,7 @@ DIST_COMMON = Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: diff --git a/lib/log.c b/lib/log.c index 6c705ee..312a6dd 100644 --- a/lib/log.c +++ b/lib/log.c @@ -1,252 +1,252 @@ -/* log.c - Logging facilities for displaying information on screen, as well as - (optional) storing it to a file and transmitting it over the network. - - Part of the swftools package. - - Copyright (c) 2001 Matthias Kramm - - This file is distributed under the GPL, see file COPYING for details */ - -#ifdef __NT__ -#include "stdafx.h" -#include -#include -#include -#include -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#else -#include -#include -#include -#include -#include -#endif - -#include "log.h" - -#define LOGLEVEL_FATAL 0 -#define LOGLEVEL_ERROR 1 -#define LOGLEVEL_WARNING 2 -#define LOGLEVEL_NOTICE 3 -#define LOGLEVEL_VERBOSE 4 -#define LOGLEVEL_DEBUG 5 - -int screenloglevel; -int fileloglevel; -int socketloglevel; -FILE *logFile = 0; -#ifdef __NT__ -SOCKET logSocket; -#else -int logSocket = 0; -#endif - -char bLogToSock = 0; - -void initlogSocket(char* servAddr, char* logPort); - -void initLog(char* pLogName, int fileloglevel, char* servAddr, char* logPort, int serverlevel, int screenlevel) -{ - screenloglevel = screenlevel; - fileloglevel = fileloglevel; - socketloglevel = screenlevel; - logFile = NULL; - bLogToSock = 0; - - if (pLogName && fileloglevel>=0) - logFile = fopen(pLogName, "a+"); - bLogToSock = (servAddr && logPort && (serverlevel>=0)); - if(bLogToSock) - initlogSocket(servAddr, logPort); -} - -void initlogSocket(char* servAddr, char* logPort) -{ -#ifndef __NT__ - bLogToSock = 0; -#else - // init winsock - // check and prepare WinSock DLL - WORD wVersionRequested = MAKEWORD( 2, 2 ); - WSADATA wsaData; - if ( WSAStartup(wVersionRequested, &wsaData) != 0 ) - { - bLogToSock = false; - return; - } - // Confirm that the WinSock DLL supports 2.2. - // Note that if the DLL supports versions greater - // than 2.2 in addition to 2.2, it will still return - // 2.2 in wVersion since that is the version we - // requested. - - if ( LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 2 ) - { - bLogToSock = false; - return; - } - - struct hostent *hp; - hp = gethostbyname(servAddr); - if (hp == NULL) // we don't know who this host is - { - bLogToSock = false; - return; - } - - // connect socket - sockaddr_in SocketAddress; - - memset(&SocketAddress, 0, sizeof(SocketAddress)); - memcpy((char*)&SocketAddress.sin_addr, hp->h_addr, hp->h_length); // set address - SocketAddress.sin_family = hp->h_addrtype; - SocketAddress.sin_port = htons((u_short)atoi(logPort)); - - logSocket = socket(hp->h_addrtype, SOCK_STREAM, 0); - if (logSocket == INVALID_SOCKET) - { - bLogToSock = false; - return; - } - - // try to connect to the specified socket - if ( connect(logSocket, (struct sockaddr*)&SocketAddress, sizeof (SocketAddress)) == SOCKET_ERROR) { - bLogToSock = false; - return; - } - bLogToSock = true; -#endif -} - -void exitLog() -{ - // close socket communication - if(bLogToSock) -#ifndef __NT__ - close(logSocket); -#else - closesocket(logSocket); -#endif - // close file - if(logFile != NULL) - fclose(logFile); -} - - -static char * logimportance[]= {"Fatal","Error","Warning","Notice","Verbose","Debug"}; -static int loglevels=6; -static char * logimportance2[]= {" ","FATAL ","ERROR ","WARNING","NOTICE ","VERBOSE","DEBUG "}; -void log(char* logString) -{ - char timebuffer[32]; - char* logBuffer; - char dbuffer[9]; - char tbuffer[9]; - int level; - char*lt; - char*gt; - int l; - - logBuffer = (char*)malloc (strlen(logString) + 24 + 15); -#ifndef __NT__ - { - /*time_t t = time(0); - tm*t2 = localtime(t); - strftime(dbuffer, 8, "%m %d", t2); - strftime(tbuffer, 8, "%m %d", t2); - dbuffer[0]=0; //FIXME - tbuffer[0]=0;*/ - time_t t = time(0); - char* a = ctime(&t); - int l = strlen(a); - while(a[l-1] == 13 || a[l-1] == 10) - l--; - a[l]=0; - sprintf(timebuffer, "%s", a); - } -#else - _strdate( dbuffer ); - _strtime( tbuffer ); - sprintf(timebuffer, "%s - %s",dbuffer,tbuffer); -#endif - - // search for field - level = -1; - lt=strchr(logString, '<'); - gt=strchr(logString, '>'); - if(lt && gt && lt=0) - { - logBuffer[l]=0; - l--; - } - - if (level <= screenloglevel) - { - printf("%s\n", logBuffer); - fflush(stdout); - } - - if (level <= fileloglevel) - { - if (logFile != NULL) - { - fprintf(logFile, "%s\n", logBuffer); - fflush(logFile); - } - } - - if (level <= socketloglevel) - { - if (bLogToSock) - { - // send data -#ifndef __NT__ - write(logSocket, logBuffer, strlen(logBuffer)); -#else - send(logSocket, logBuffer, strlen(logBuffer), 0); -#endif - } - } - free (logBuffer); -} - -void logf(const char* pszFormat, ...) -{ - char buf[1024]; - va_list arglist; - va_start(arglist, pszFormat); - buf[0] = 0; - vsprintf(&buf[strlen(buf)], pszFormat, arglist); - va_end(arglist); - strcat(buf, "\n"); - log(buf); -} - +/* log.c + Logging facilities for displaying information on screen, as well as + (optional) storing it to a file and transmitting it over the network. + + Part of the swftools package. + + Copyright (c) 2001 Matthias Kramm + + This file is distributed under the GPL, see file COPYING for details */ + +#ifdef __NT__ +#include "stdafx.h" +#include +#include +#include +#include +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#else +#include +#include +#include +#include +#include +#endif + +#include "log.h" + +#define LOGLEVEL_FATAL 0 +#define LOGLEVEL_ERROR 1 +#define LOGLEVEL_WARNING 2 +#define LOGLEVEL_NOTICE 3 +#define LOGLEVEL_VERBOSE 4 +#define LOGLEVEL_DEBUG 5 + +int screenloglevel; +int fileloglevel; +int socketloglevel; +FILE *logFile = 0; +#ifdef __NT__ +SOCKET logSocket; +#else +int logSocket = 0; +#endif + +char bLogToSock = 0; + +void initlogSocket(char* servAddr, char* logPort); + +void initLog(char* pLogName, int fileloglevel, char* servAddr, char* logPort, int serverlevel, int screenlevel) +{ + screenloglevel = screenlevel; + fileloglevel = fileloglevel; + socketloglevel = screenlevel; + logFile = NULL; + bLogToSock = 0; + + if (pLogName && fileloglevel>=0) + logFile = fopen(pLogName, "a+"); + bLogToSock = (servAddr && logPort && (serverlevel>=0)); + if(bLogToSock) + initlogSocket(servAddr, logPort); +} + +void initlogSocket(char* servAddr, char* logPort) +{ +#ifndef __NT__ + bLogToSock = 0; +#else + // init winsock + // check and prepare WinSock DLL + WORD wVersionRequested = MAKEWORD( 2, 2 ); + WSADATA wsaData; + if ( WSAStartup(wVersionRequested, &wsaData) != 0 ) + { + bLogToSock = false; + return; + } + // Confirm that the WinSock DLL supports 2.2. + // Note that if the DLL supports versions greater + // than 2.2 in addition to 2.2, it will still return + // 2.2 in wVersion since that is the version we + // requested. + + if ( LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 2 ) + { + bLogToSock = false; + return; + } + + struct hostent *hp; + hp = gethostbyname(servAddr); + if (hp == NULL) // we don't know who this host is + { + bLogToSock = false; + return; + } + + // connect socket + sockaddr_in SocketAddress; + + memset(&SocketAddress, 0, sizeof(SocketAddress)); + memcpy((char*)&SocketAddress.sin_addr, hp->h_addr, hp->h_length); // set address + SocketAddress.sin_family = hp->h_addrtype; + SocketAddress.sin_port = htons((u_short)atoi(logPort)); + + logSocket = socket(hp->h_addrtype, SOCK_STREAM, 0); + if (logSocket == INVALID_SOCKET) + { + bLogToSock = false; + return; + } + + // try to connect to the specified socket + if ( connect(logSocket, (struct sockaddr*)&SocketAddress, sizeof (SocketAddress)) == SOCKET_ERROR) { + bLogToSock = false; + return; + } + bLogToSock = true; +#endif +} + +void exitLog() +{ + // close socket communication + if(bLogToSock) +#ifndef __NT__ + close(logSocket); +#else + closesocket(logSocket); +#endif + // close file + if(logFile != NULL) + fclose(logFile); +} + + +static char * logimportance[]= {"Fatal","Error","Warning","Notice","Verbose","Debug"}; +static int loglevels=6; +static char * logimportance2[]= {" ","FATAL ","ERROR ","WARNING","NOTICE ","VERBOSE","DEBUG "}; +void log(char* logString) +{ + char timebuffer[32]; + char* logBuffer; + char dbuffer[9]; + char tbuffer[9]; + int level; + char*lt; + char*gt; + int l; + + logBuffer = (char*)malloc (strlen(logString) + 24 + 15); +#ifndef __NT__ + { + /*time_t t = time(0); + tm*t2 = localtime(t); + strftime(dbuffer, 8, "%m %d", t2); + strftime(tbuffer, 8, "%m %d", t2); + dbuffer[0]=0; //FIXME + tbuffer[0]=0;*/ + time_t t = time(0); + char* a = ctime(&t); + int l = strlen(a); + while(a[l-1] == 13 || a[l-1] == 10) + l--; + a[l]=0; + sprintf(timebuffer, "%s", a); + } +#else + _strdate( dbuffer ); + _strtime( tbuffer ); + sprintf(timebuffer, "%s - %s",dbuffer,tbuffer); +#endif + + // search for field + level = -1; + lt=strchr(logString, '<'); + gt=strchr(logString, '>'); + if(lt && gt && lt=0) + { + logBuffer[l]=0; + l--; + } + + if (level <= screenloglevel) + { + printf("%s\n", logBuffer); + fflush(stdout); + } + + if (level <= fileloglevel) + { + if (logFile != NULL) + { + fprintf(logFile, "%s\n", logBuffer); + fflush(logFile); + } + } + + if (level <= socketloglevel) + { + if (bLogToSock) + { + // send data +#ifndef __NT__ + write(logSocket, logBuffer, strlen(logBuffer)); +#else + send(logSocket, logBuffer, strlen(logBuffer), 0); +#endif + } + } + free (logBuffer); +} + +void logf(const char* pszFormat, ...) +{ + char buf[1024]; + va_list arglist; + va_start(arglist, pszFormat); + buf[0] = 0; + vsprintf(&buf[strlen(buf)], pszFormat, arglist); + va_end(arglist); + strcat(buf, "\n"); + log(buf); +} + diff --git a/lib/log.h b/lib/log.h index c9a407b..c31eeee 100644 --- a/lib/log.h +++ b/lib/log.h @@ -1,39 +1,39 @@ -/* log.h - Header file for log.c. - - Part of the swftools package. - - Copyright (c) 2001 Matthias Kramm - - This file is distributed under the GPL, see file COPYING for details */ - -#ifndef __log_h__ -#define __log_h__ - -#ifdef __NT__ -#include "stdafx.h" -#include -#include -#else -#include -#include -#include -#endif - -#define LOGLEVEL_FATAL 0 -#define LOGLEVEL_ERROR 1 -#define LOGLEVEL_WARNING 2 -#define LOGLEVEL_NOTICE 3 -#define LOGLEVEL_VERBOSE 4 -#define LOGLEVEL_DEBUG 5 - -extern int screenloglevel; -extern int socketloglevel; -extern int fileloglevel; - -extern void initLog(char* pLogDir, int fileloglevel, char* servAddr, char* logPort, int serverloglevel, int screenloglevel); -extern void log(char* logString); -extern void logf(const char* logFormat, ...); -extern void exitLog(void); - -#endif // __log_h__ +/* log.h + Header file for log.c. + + Part of the swftools package. + + Copyright (c) 2001 Matthias Kramm + + This file is distributed under the GPL, see file COPYING for details */ + +#ifndef __log_h__ +#define __log_h__ + +#ifdef __NT__ +#include "stdafx.h" +#include +#include +#else +#include +#include +#include +#endif + +#define LOGLEVEL_FATAL 0 +#define LOGLEVEL_ERROR 1 +#define LOGLEVEL_WARNING 2 +#define LOGLEVEL_NOTICE 3 +#define LOGLEVEL_VERBOSE 4 +#define LOGLEVEL_DEBUG 5 + +extern int screenloglevel; +extern int socketloglevel; +extern int fileloglevel; + +extern void initLog(char* pLogDir, int fileloglevel, char* servAddr, char* logPort, int serverloglevel, int screenloglevel); +extern void log(char* logString); +extern void logf(const char* logFormat, ...); +extern void exitLog(void); + +#endif // __log_h__ diff --git a/lib/modules/swfaction.c b/lib/modules/swfaction.c index c03c68d..df53167 100644 --- a/lib/modules/swfaction.c +++ b/lib/modules/swfaction.c @@ -127,7 +127,7 @@ r: register (byte) }; static int definedactions = sizeof(actions)/sizeof(struct Action); -ActionTAG* GetActions(TAG*tag) +ActionTAG* swf_GetActions(TAG*tag) { U8 op = 1; int length; @@ -136,189 +136,189 @@ ActionTAG* GetActions(TAG*tag) U8*data; while(op) { - int pos; - action->next = (ActionTAG*)malloc(sizeof(ActionTAG)); - action->next->prev = action; - action->next->next = 0; - action = action->next; + int pos; + action->next = (ActionTAG*)malloc(sizeof(ActionTAG)); + action->next->prev = action; + action->next->next = 0; + action = action->next; - op = GetU8(tag); - if(op<0x80) - length = 0; - else - length = GetU16(tag); + op = swf_GetU8(tag); + if(op<0x80) + length = 0; + else + length = swf_GetU16(tag); - if(length) { - int t; - data = malloc(length); - for(t=0;top = op; - action->len = length; - action->data = data; - action->parent = tag; + if(length) { + int t; + data = malloc(length); + for(t=0;top = op; + action->len = length; + action->data = data; + action->parent = tag; } return tmp.next; } -void SetActions(TAG*tag, ActionTAG*action) +void swf_SetActions(TAG*tag, ActionTAG*action) { while(action) { - SetU8(tag, action->op); - if(action->op & 128) - SetU16(tag, action->len); + swf_SetU8(tag, action->op); + if(action->op & 128) + swf_SetU16(tag, action->len); - SetBlock(tag, action->data, action->len); + swf_SetBlock(tag, action->data, action->len); - action = action->next; + action = action->next; } } -int OpAdvance(char c, char*data) +int swf_OpAdvance(char c, char*data) { switch (c) { - case 'f': - return 2; - case 'u': - return strlen(data)+1; - case 't': - return strlen(data)+1; - case 'l': - return strlen(data)+1; - case 'c': - return strlen(data)+1; - case 's': - return 1; - case 'm': - return 1; - case 'b': - return 2; - case 'p': { - U8 type = *data++; - if(type == 0) { - return 1+strlen(data)+1; //string - } else if (type == 1) { - return 1+4; //float - } else if (type == 2) { - return 1+0; //NULL - } else if (type == 4) { - return 1+1; //register - } else if (type == 5) { - return 1+1; //bool - } else if (type == 6) { - return 1+8; //double - } else if (type == 7) { - return 1+4; //int - } else if (type == 8) { - return 1+1; //lookup - } - } + case 'f': + return 2; + case 'u': + return strlen(data)+1; + case 't': + return strlen(data)+1; + case 'l': + return strlen(data)+1; + case 'c': + return strlen(data)+1; + case 's': + return 1; + case 'm': + return 1; + case 'b': + return 2; + case 'p': { + U8 type = *data++; + if(type == 0) { + return 1+strlen(data)+1; //string + } else if (type == 1) { + return 1+4; //float + } else if (type == 2) { + return 1+0; //NULL + } else if (type == 4) { + return 1+1; //register + } else if (type == 5) { + return 1+1; //bool + } else if (type == 6) { + return 1+8; //double + } else if (type == 7) { + return 1+4; //int + } else if (type == 8) { + return 1+1; //lookup + } + } } } /* TODO: this should be in swfdump.c */ -void DumpActions(ActionTAG*atag, char*prefix) +void swf_DumpActions(ActionTAG*atag, char*prefix) { U8 op; int t; U8*data; char* cp; if(!prefix) - prefix=""; + prefix=""; while(atag) { - for(t=0;top) - break; + for(t=0;top) + break; - if(t==definedactions) { - printf("%s (%5d bytes) action: %02x\n", prefix, atag->len, op); - atag = atag->next; - continue; - } - printf("%s (%5d bytes) action: %s", prefix, atag->len, actions[t].name); - cp = actions[t].flags; - data = atag->data; - if(atag->len) //TODO: check for consistency: should we have a length? - while(*cp) - { - switch(*cp) - { - case 'f': { - printf(" %d", *(U16*)data); //FIXME: le/be - } break; - case 'u': { - printf(" URL:\"%s\"", data); - } break; - case 't': { - printf(" Target:\"%s\"", data); - } break; - case 'l': { - printf(" Label:\"%s\"", data); - } break; - case 'c': { - printf(" Constant Pool:\"%s\"", data); - } break; - case 's': { - printf(" +%d", data); - } break; - case 'm': { + if(t==definedactions) { + printf("%s (%5d bytes) action: %02x\n", prefix, atag->len, op); + atag = atag->next; + continue; + } + printf("%s (%5d bytes) action: %s", prefix, atag->len, actions[t].name); + cp = actions[t].flags; + data = atag->data; + if(atag->len) //TODO: check for consistency: should we have a length? + while(*cp) + { + switch(*cp) + { + case 'f': { + printf(" %d", *(U16*)data); //FIXME: le/be + } break; + case 'u': { + printf(" URL:\"%s\"", data); + } break; + case 't': { + printf(" Target:\"%s\"", data); + } break; + case 'l': { + printf(" Label:\"%s\"", data); + } break; + case 'c': { + printf(" Constant Pool:\"%s\"", data); + } break; + case 's': { + printf(" +%d", data); + } break; + case 'm': { //m: method (byte) url:(0=none, 1=get, 2=datat)/gf2:(1=play) - printf(" %d", data); - } break; - case 'b': { - printf(" %d", *(U16*)data); - } break; - case 'p': { - U8 type = *data; - char*value = data+1; - if(type == 0) { - printf(" String:\"%s\"", value); - } else if (type == 1) { - printf(" Float:\"%f\"", *(float*)value); - } else if (type == 2) { - printf(" NULL"); - } else if (type == 4) { - printf(" register:%d", value); - } else if (type == 5) { - printf(" %s", *value?"true":"false"); - } else if (type == 6) { - printf(" %f", *(double*)value); - } else if (type == 7) { - printf(" %d", *(int*)value); - } else if (type == 8) { - printf(" Lookup:%d", *value); - } - } break; - } - data += OpAdvance(*cp, data); - cp++; - } + printf(" %d", data); + } break; + case 'b': { + printf(" %d", *(U16*)data); + } break; + case 'p': { + U8 type = *data; + char*value = data+1; + if(type == 0) { + printf(" String:\"%s\"", value); + } else if (type == 1) { + printf(" Float:\"%f\"", *(float*)value); + } else if (type == 2) { + printf(" NULL"); + } else if (type == 4) { + printf(" register:%d", value); + } else if (type == 5) { + printf(" %s", *value?"true":"false"); + } else if (type == 6) { + printf(" %f", *(double*)value); + } else if (type == 7) { + printf(" %d", *(int*)value); + } else if (type == 8) { + printf(" Lookup:%d", *value); + } + } break; + } + data += swf_OpAdvance(*cp, data); + cp++; + } - if(data < atag->data + atag->len) - { - int nl = ((atag->data+atag->len)-data); - int t; - printf(" remainder of %d bytes:\"", nl); - for(t=0;tnext; + if(data < atag->data + atag->len) + { + int nl = ((atag->data+atag->len)-data); + int t; + printf(" remainder of %d bytes:\"", nl); + for(t=0;tnext; } } -int ActionEnumerateURLs(ActionTAG*atag, char*(*callback)(char*)) +int swf_ActionEnumerateURLs(ActionTAG*atag, char*(*callback)(char*)) { U8 op; int t; @@ -328,58 +328,59 @@ int ActionEnumerateURLs(ActionTAG*atag, char*(*callback)(char*)) while(atag) { - for(t=0;top) - break; + for(t=0;top) + break; - if(t==definedactions) { - // unknown actiontag - atag = atag->next; - continue; - } - cp = actions[t].flags; - data = atag->data; - if(atag->len) - { - while(*cp) - { - char * replacepos = 0; - int replacelen = 0; - char * replacement; - switch(*cp) - { - case 'u': { - replacelen = strlen(data); - replacepos = data; - replacement = callback(data); // may be null - } break; - /* everything below may very well - contain an URL, too. However, to extract - these, we would have to call callback also for - strings which might not contain an url. - TODO: should we check for Strings which start - with "http://"? - */ - case 'c': { - } break; - case 'o': { - } break; - case 'p': { - U8 type = *data; - char*value = &data[1]; - if(type == 0) { //string - } else if (type == 8) { //lookup - } - } break; - } - data += OpAdvance(*cp, data); - cp++; + if(t==definedactions) { + // unknown actiontag + atag = atag->next; + continue; + } + cp = actions[t].flags; + data = atag->data; + if(atag->len) + { + while(*cp) + { + char * replacepos = 0; + int replacelen = 0; + char * replacement; + switch(*cp) + { + case 'u': { + replacelen = strlen(data); + replacepos = data; + replacement = callback(data); // may be null + } break; + /* everything below may very well + contain an URL, too. However, to extract + these, we would have to call callback also for + strings which might not contain an url. + TODO: should we check for Strings which start + with "http://"? + Nope: user can force it by reg.ex. if he wants to /r + */ + case 'c': { + } break; + case 'o': { + } break; + case 'p': { + U8 type = *data; + char*value = &data[1]; + if(type == 0) { //string + } else if (type == 8) { //lookup + } + } break; + } + data += swf_OpAdvance(*cp, data); + cp++; - //TODO: apply replacement here. - } - } + //TODO: apply replacement here. + } + } - atag = atag->next; + atag = atag->next; } } diff --git a/lib/modules/swfbits.c b/lib/modules/swfbits.c index da8be39..4349b96 100644 --- a/lib/modules/swfbits.c +++ b/lib/modules/swfbits.c @@ -25,29 +25,29 @@ typedef struct _JPEGDESTMGR // Destination manager callbacks -void swf_init_destination(j_compress_ptr cinfo) +void RFXSWF_init_destination(j_compress_ptr cinfo) { JPEGDESTMGR * dmgr = (JPEGDESTMGR *)cinfo->dest; dmgr->buffer = (JOCTET*)malloc(OUTBUFFER_SIZE); dmgr->mgr.next_output_byte = dmgr->buffer; dmgr->mgr.free_in_buffer = OUTBUFFER_SIZE; } -boolean swf_empty_output_buffer(j_compress_ptr cinfo) +boolean RFXSWF_empty_output_buffer(j_compress_ptr cinfo) { JPEGDESTMGR * dmgr = (JPEGDESTMGR *)cinfo->dest; - SetBlock(dmgr->t,(U8*)dmgr->buffer,OUTBUFFER_SIZE); + swf_SetBlock(dmgr->t,(U8*)dmgr->buffer,OUTBUFFER_SIZE); dmgr->mgr.next_output_byte = dmgr->buffer; dmgr->mgr.free_in_buffer = OUTBUFFER_SIZE; return TRUE; } -void swf_term_destination(j_compress_ptr cinfo) +void RFXSWF_term_destination(j_compress_ptr cinfo) { JPEGDESTMGR * dmgr = (JPEGDESTMGR *)cinfo->dest; - SetBlock(dmgr->t,(U8*)dmgr->buffer,OUTBUFFER_SIZE-dmgr->mgr.free_in_buffer); + swf_SetBlock(dmgr->t,(U8*)dmgr->buffer,OUTBUFFER_SIZE-dmgr->mgr.free_in_buffer); free(dmgr->buffer); dmgr->mgr.free_in_buffer = 0; } -JPEGBITS * SetJPEGBitsStart(TAG * t,int width,int height,int quality) +JPEGBITS * swf_SetJPEGBitsStart(TAG * t,int width,int height,int quality) { JPEGDESTMGR * jpeg; @@ -61,9 +61,9 @@ JPEGBITS * SetJPEGBitsStart(TAG * t,int width,int height,int quality) jpeg_create_compress(&jpeg->cinfo); - jpeg->mgr.init_destination = swf_init_destination; - jpeg->mgr.empty_output_buffer = swf_empty_output_buffer; - jpeg->mgr.term_destination = swf_term_destination; + jpeg->mgr.init_destination = RFXSWF_init_destination; + jpeg->mgr.empty_output_buffer = RFXSWF_empty_output_buffer; + jpeg->mgr.term_destination = RFXSWF_term_destination; jpeg->t = t; @@ -91,18 +91,18 @@ JPEGBITS * SetJPEGBitsStart(TAG * t,int width,int height,int quality) return (JPEGBITS *)jpeg; } -int SetJPEGBitsLines(JPEGBITS * jpegbits,U8 ** data,int n) +int swf_SetJPEGBitsLines(JPEGBITS * jpegbits,U8 ** data,int n) { JPEGDESTMGR * jpeg = (JPEGDESTMGR *)jpegbits; if (!jpeg) return -1; jpeg_write_scanlines(&jpeg->cinfo,data,n); return 0; } -int SetJPEGBitsLine(JPEGBITS * jpegbits,U8 * data) -{ return SetJPEGBitsLines(jpegbits,&data,1); +int swf_SetJPEGBitsLine(JPEGBITS * jpegbits,U8 * data) +{ return swf_SetJPEGBitsLines(jpegbits,&data,1); } -int SetJPEGBitsFinish(JPEGBITS * jpegbits) +int swf_SetJPEGBitsFinish(JPEGBITS * jpegbits) { JPEGDESTMGR * jpeg = (JPEGDESTMGR *)jpegbits; if (!jpeg) return -1; jpeg_finish_compress(&jpeg->cinfo); @@ -110,7 +110,7 @@ int SetJPEGBitsFinish(JPEGBITS * jpegbits) return 0; } -int SetJPEGBits(TAG * t,char * fname,int quality) +int swf_SetJPEGBits(TAG * t,char * fname,int quality) { struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; JPEGBITS * out; @@ -127,7 +127,7 @@ int SetJPEGBits(TAG * t,char * fname,int quality) jpeg_read_header(&cinfo, TRUE); jpeg_start_decompress(&cinfo); - out = SetJPEGBitsStart(t,cinfo.output_width,cinfo.output_height,quality); + out = swf_SetJPEGBitsStart(t,cinfo.output_width,cinfo.output_height,quality); scanline = (U8*)malloc(4*cinfo.output_width); if (scanline) @@ -135,11 +135,11 @@ int SetJPEGBits(TAG * t,char * fname,int quality) U8 * js = scanline; for (y=0;yavail_out == 0) - { SetBlock(t,data,zs->next_out-data); + { swf_SetBlock(t,data,zs->next_out-data); zs->next_out = data; zs->avail_out = OUTBUFFER_SIZE; } @@ -174,19 +174,18 @@ int swf_deflate_wraper(TAG * t,z_stream * zs,U8 * data,boolean finish) #endif return status; } - } return 0; } -int SetLosslessBits(TAG * t,U16 width,U16 height,void * bitmap,U8 bitmap_flags) +int swf_SetLosslessBits(TAG * t,U16 width,U16 height,void * bitmap,U8 bitmap_flags) { int res = 0; int bps; U8 * data; switch (bitmap_flags) { case BMF_8BIT: - return SetLosslessBitsIndexed(t,width,height,bitmap,NULL,256); + return swf_SetLosslessBitsIndexed(t,width,height,bitmap,NULL,256); case BMF_16BIT: bps = BYTES_PER_SCANLINE(sizeof(U16)*width); break; @@ -197,9 +196,9 @@ int SetLosslessBits(TAG * t,U16 width,U16 height,void * bitmap,U8 bitmap_flags) return -1; } - SetU8(t,bitmap_flags); - SetU16(t,width); - SetU16(t,height); + swf_SetU8(t,bitmap_flags); + swf_SetU16(t,width); + swf_SetU16(t,height); if (data=malloc(OUTBUFFER_SIZE)) { z_stream zs; @@ -214,8 +213,8 @@ int SetLosslessBits(TAG * t,U16 width,U16 height,void * bitmap,U8 bitmap_flags) zs.next_out = data; zs.avail_out = OUTBUFFER_SIZE; - if (swf_deflate_wraper(t,&zs,data,TRUE)<0) res = -3; - if (zs.next_out>data) SetBlock(t,data,zs.next_out-data); + if (RFXSWF_deflate_wraper(t,&zs,data,TRUE)<0) res = -3; + if (zs.next_out>data) swf_SetBlock(t,data,zs.next_out-data); deflateEnd(&zs); @@ -227,7 +226,7 @@ int SetLosslessBits(TAG * t,U16 width,U16 height,void * bitmap,U8 bitmap_flags) return res; } -int SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * palette,U16 ncolors) +int swf_SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * palette,U16 ncolors) { RGBA * pal = palette; int bps = BYTES_PER_SCANLINE(width); U8 * data; @@ -242,10 +241,10 @@ int SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * palet if ((ncolors<2)||(ncolors>256)||(!t)) return -1; // parameter error - SetU8(t,BMF_8BIT); - SetU16(t,width); - SetU16(t,height); - SetU8(t,ncolors-1); // number of pal entries + swf_SetU8(t,BMF_8BIT); + swf_SetU16(t,width); + swf_SetU16(t,height); + swf_SetU8(t,ncolors-1); // number of pal entries if (data=malloc(OUTBUFFER_SIZE)) { z_stream zs; @@ -271,7 +270,7 @@ int SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * palet alpha values different from 0 and 0xff in lossless bitmaps... */ - if (GetTagID(t)==ST_DEFINEBITSLOSSLESS2) // have alpha channel? + if (swf_GetTagID(t)==ST_DEFINEBITSLOSSLESS2) // have alpha channel? { for (i=0;idata) SetBlock(t,data,zs.next_out-data); + if (zs.next_out>data) swf_SetBlock(t,data,zs.next_out-data); free(zpal); } else res = -2; // memory error @@ -318,8 +317,8 @@ int SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * palet return res; } -int SetLosslessBitsGrayscale(TAG * t,U16 width,U16 height,U8 * bitmap) -{ return SetLosslessBitsIndexed(t,width,height,bitmap,NULL,256); +int swf_SetLosslessBitsGrayscale(TAG * t,U16 width,U16 height,U8 * bitmap) +{ return swf_SetLosslessBitsIndexed(t,width,height,bitmap,NULL,256); } diff --git a/lib/modules/swfbutton.c b/lib/modules/swfbutton.c index fc1d087..4929c8c 100644 --- a/lib/modules/swfbutton.c +++ b/lib/modules/swfbutton.c @@ -11,82 +11,82 @@ */ -int ButtonSetRecord(TAG * t,U8 state,U16 id,U16 layer,MATRIX * m,CXFORM * cx) +int swf_ButtonSetRecord(TAG * t,U8 state,U16 id,U16 layer,MATRIX * m,CXFORM * cx) -{ SetU8(t,state); - SetU16(t,id); - SetU16(t,layer); - SetMatrix(t,m); +{ swf_SetU8(t,state); + swf_SetU16(t,id); + swf_SetU16(t,layer); + swf_SetMatrix(t,m); // SetCXForm(t,cx,0); return 0; } -int ButtonSetCondition(TAG * t,U16 condition) -{ SetU16(t,0); // dummy for Action Offset -> later set by ButtonPostProcess - SetU16(t,condition); +int swf_ButtonSetCondition(TAG * t,U16 condition) +{ swf_SetU16(t,0); // dummy for Action Offset -> later set by ButtonPostProcess + swf_SetU16(t,condition); return 0; } -int ButtonSetFlags(TAG * t,U8 flags) -{ if (GetTagID(t)==ST_DEFINEBUTTON2) - { SetU8(t,flags); - SetU16(t,0); // dummy for Action Offset -> later set by ButtonPostProcess +int swf_ButtonSetFlags(TAG * t,U8 flags) +{ if (swf_GetTagID(t)==ST_DEFINEBUTTON2) + { swf_SetU8(t,flags); + swf_SetU16(t,0); // dummy for Action Offset -> later set by ButtonPostProcess } return 0; } -void SetButtonOffset(TAG * t,U32 offsetpos) -{ U32 now = GetTagPos(t); +void swf_SetButtonOffset(TAG * t,U32 offsetpos) +{ U32 now = swf_GetTagPos(t); U16 diff = now-offsetpos; - SetTagPos(t,offsetpos); + swf_SetTagPos(t,offsetpos); t->data[t->pos++] = (U8)(diff&0xff); t->data[t->pos++] = (U8)(diff>>8); - SetTagPos(t,now); + swf_SetTagPos(t,now); } -int ButtonPostProcess(TAG * t,int anz_action) -{ if (GetTagID(t)==ST_DEFINEBUTTON2) +int swf_ButtonPostProcess(TAG * t,int anz_action) +{ if (swf_GetTagID(t)==ST_DEFINEBUTTON2) { U32 oldTagPos; U32 offsetpos; - oldTagPos = GetTagPos(t); + oldTagPos = swf_GetTagPos(t); // scan DefineButton2 Record - GetU16(t); // Character ID - GetU8(t); // Flags; + swf_GetU16(t); // Character ID + swf_GetU8(t); // Flags; - offsetpos = GetTagPos(t); // first offset - GetU16(t); + offsetpos = swf_GetTagPos(t); // first offset + swf_GetU16(t); - while (GetU8(t)) // state -> parse ButtonRecord - { GetU16(t); // id - GetU16(t); // layer - GetMatrix(t,NULL); // matrix + while (swf_GetU8(t)) // state -> parse ButtonRecord + { swf_GetU16(t); // id + swf_GetU16(t); // layer + swf_GetMatrix(t,NULL); // matrix // evtl.: CXForm } - SetButtonOffset(t,offsetpos); + swf_SetButtonOffset(t,offsetpos); while(anz_action) { U8 a; - offsetpos = GetTagPos(t); // offset - GetU16(t); + offsetpos = swf_GetTagPos(t); // offset + swf_GetU16(t); - GetU16(t); // condition + swf_GetU16(t); // condition - while (a=GetU8(t)) // skip action records + while (a=swf_GetU8(t)) // skip action records { if (a&0x80) - { U16 l = GetU16(t); - GetBlock(t,NULL,l); + { U16 l = swf_GetU16(t); + swf_GetBlock(t,NULL,l); } } - if (--anz_action) SetButtonOffset(t,offsetpos); + if (--anz_action) swf_SetButtonOffset(t,offsetpos); } - SetTagPos(t,oldTagPos); + swf_SetTagPos(t,oldTagPos); } return 0; } diff --git a/lib/modules/swfcgi.c b/lib/modules/swfcgi.c index 67f6881..67e0b4c 100644 --- a/lib/modules/swfcgi.c +++ b/lib/modules/swfcgi.c @@ -18,7 +18,7 @@ #define PREFIX "WWW_" -static int htoi(unsigned char * s) +static int swf_htoi(unsigned char * s) { int value; char c; @@ -33,14 +33,14 @@ static int htoi(unsigned char * s) return (value); } -static void url_unescape(unsigned char * s) +static void swf_url_unescape(unsigned char * s) { unsigned char *dest = s; while (s[0]) { if (s[0] == '+') dest[0] = ' '; else { if (s[0] == '%' && ishex(s[1]) && ishex(s[2])) - { dest[0] = (unsigned char) htoi(s + 1); + { dest[0] = (unsigned char) swf_htoi(s + 1); s += 2; } else dest[0] = s[0]; @@ -50,12 +50,12 @@ static void url_unescape(unsigned char * s) dest[0] = 0; } -static void cgienv(unsigned char * var) +static void swf_cgienv(unsigned char * var) { unsigned char *buf, *c, *s, *t, *oldval = NULL, *newval; int despace = 0, got_cr = 0; // fprintf(stderr,"%s\n",var); - url_unescape(var); + swf_url_unescape(var); // fprintf(stderr,"%s\n",var); @@ -119,14 +119,14 @@ static void cgienv(unsigned char * var) } } -static void scanquery(char * q) +static void swf_scanquery(char * q) { char *next = q; if (!q) return; while (next) { next = strchr(q, '&'); if (next) next[0] = 0; - cgienv(q); + swf_cgienv(q); if (next) { next[0] = '&'; q = next+1; @@ -134,7 +134,7 @@ static void scanquery(char * q) } } -char * postread() +char * swf_postread() { char * buf = NULL; int size = 0, sofar = 0, got; @@ -157,23 +157,24 @@ char * postread() return buf; } -void uncgi() +void swf_uncgi() { char *query, *dupquery, *method; query = getenv("QUERY_STRING"); if ((query) && strlen(query)) { dupquery = strdup(query); - scanquery(dupquery); + swf_scanquery(dupquery); free(dupquery); } method = getenv("REQUEST_METHOD"); if ((method) && ! strcmp(method, "POST")) - { query = postread(); - if ((query)&&(query[0]!=0)) scanquery(query); + { query = swf_postread(); + if ((query)&&(query[0]!=0)) swf_scanquery(query); free(query); } } #undef ishex +#undef PREFIX diff --git a/lib/modules/swfdump.c b/lib/modules/swfdump.c index fe48ee9..063b260 100644 --- a/lib/modules/swfdump.c +++ b/lib/modules/swfdump.c @@ -11,23 +11,23 @@ */ -void DumpHeader(FILE * f,SWF * swf) +void swf_DumpHeader(FILE * f,SWF * swf) { if (!f) f = stderr; - fprintf(f,"File size\t%u\n",swf->FileSize); - fprintf(f,"Movie width\t%u\n",(swf->MovieSize.xmax - swf->MovieSize.xmin)/20); - fprintf(f,"Movie height\t%u\n",(swf->MovieSize.ymax - swf->MovieSize.ymin)/20); - fprintf(f,"Frame rate\t%u.%u\n",swf->FrameRate>>8,swf->FrameRate&0xff); - fprintf(f,"Frame count\t%u\n",swf->FrameCount); + fprintf(f,"File size\t%u\n",swf->fileSize); + fprintf(f,"Movie width\t%u\n",(swf->movieSize.xmax - swf->movieSize.xmin)/20); + fprintf(f,"Movie height\t%u\n",(swf->movieSize.ymax - swf->movieSize.ymin)/20); + fprintf(f,"Frame rate\t%u.%u\n",swf->frameRate>>8,swf->frameRate&0xff); + fprintf(f,"Frame count\t%u\n",swf->frameCount); } -void DumpMatrix(FILE * f,MATRIX * m) +void swf_DumpMatrix(FILE * f,MATRIX * m) { if (!f) f = stderr; fprintf(f,"[%08x][%08x]\n",m->sx,m->r1); fprintf(f,"[%08x][%08x]\n",m->r0,m->sy); fprintf(f," %08x, %08x\n",m->tx,m->ty); } -void DumpTag(FILE * f,TAG * t) +void swf_DumpTag(FILE * f,TAG * t) { int i; if (!f) f = stderr; for (i=0;ilen;i++) @@ -37,96 +37,96 @@ void DumpTag(FILE * f,TAG * t) fprintf(f,"\n"); } -char* getTagName(TAG*tag) +char* swf_TagGetName(TAG*tag) { switch(tag->id) { - case ST_END: - return "END"; - case ST_SHOWFRAME: - return "SHOWFRAME"; - case ST_DEFINESHAPE: - return "DEFINESHAPE"; - case ST_FREECHARACTER: - return "FREECHARACTER"; - case ST_PLACEOBJECT: - return "PLACEOBJECT"; - case ST_REMOVEOBJECT: - return "REMOVEOBJECT"; - case ST_DEFINEBITS: - return "DEFINEBITS"; - case ST_DEFINEBUTTON: - return "DEFINEBUTTON"; - case ST_JPEGTABLES: - return "JPEGTABLES"; - case ST_SETBACKGROUNDCOLOR: - return "SETBACKGROUNDCOLOR"; - case ST_DEFINEFONT: - return "DEFINEFONT"; - case ST_DEFINETEXT: - return "DEFINETEXT"; - case ST_DOACTION: - return "DOACTION"; - case ST_DEFINEFONTINFO: - return "DEFINEFONTINFO"; - case ST_DEFINESOUND: - return "DEFINESOUND"; - case ST_STARTSOUND: - return "STARTSOUND"; - case ST_DEFINEBUTTONSOUND: - return "DEFINEBUTTONSOUND"; - case ST_SOUNDSTREAMHEAD: - return "SOUNDSTREAMHEAD"; - case ST_SOUNDSTREAMBLOCK: - return "SOUNDSTREAMBLOCK"; - case ST_DEFINEBITSLOSSLESS: - return "DEFINEBITSLOSSLESS"; - case ST_DEFINEBITSJPEG2: - return "DEFINEBITSJPEG2"; - case ST_DEFINESHAPE2: - return "DEFINESHAPE2"; - case ST_DEFINEBUTTONCXFORM: - return "DEFINEBUTTONCXFORM"; - case ST_PROTECT: - return "PROTECT"; - case ST_PLACEOBJECT2: - return "PLACEOBJECT2"; - case ST_REMOVEOBJECT2: - return "REMOVEOBJECT2"; - case ST_DEFINESHAPE3: - return "DEFINESHAPE3"; - case ST_DEFINETEXT2: - return "DEFINETEXT2"; - case ST_DEFINEBUTTON2: - return "DEFINEBUTTON2"; - case ST_DEFINEBITSJPEG3: - return "DEFINEBITSJPEG3"; - case ST_DEFINEBITSLOSSLESS2: - return "DEFINEBITSLOSSLESS2"; - case ST_DEFINESPRITE: - return "DEFINESPRITE"; - case ST_NAMECHARACTER: - return "NAMECHARACTER"; - case ST_SERIALNUMBER: - return "SERIALNUMBER"; - case ST_GENERATORTEXT: - return "GENERATORTEXT"; - case ST_FRAMELABEL: - return "FRAMELABEL"; - case ST_SOUNDSTREAMHEAD2: - return "SOUNDSTREAMHEAD2"; - case ST_DEFINEMORPHSHAPE: - return "DEFINEMORPHSHAPE"; - case ST_DEFINEFONT2: - return "DEFINEFONT2"; - case ST_TEMPLATECOMMAND: - return "TEMPLATECOMMAND"; - case ST_GENERATOR3: - return "GENERATOR3"; - case ST_EXTERNALFONT: - return "EXTERNALFONT"; - case ST_REFLEX: - return "REFLEX"; + case ST_END: + return "END"; + case ST_SHOWFRAME: + return "SHOWFRAME"; + case ST_DEFINESHAPE: + return "DEFINESHAPE"; + case ST_FREECHARACTER: + return "FREECHARACTER"; + case ST_PLACEOBJECT: + return "PLACEOBJECT"; + case ST_REMOVEOBJECT: + return "REMOVEOBJECT"; + case ST_DEFINEBITS: + return "DEFINEBITS"; + case ST_DEFINEBUTTON: + return "DEFINEBUTTON"; + case ST_JPEGTABLES: + return "JPEGTABLES"; + case ST_SETBACKGROUNDCOLOR: + return "SETBACKGROUNDCOLOR"; + case ST_DEFINEFONT: + return "DEFINEFONT"; + case ST_DEFINETEXT: + return "DEFINETEXT"; + case ST_DOACTION: + return "DOACTION"; + case ST_DEFINEFONTINFO: + return "DEFINEFONTINFO"; + case ST_DEFINESOUND: + return "DEFINESOUND"; + case ST_STARTSOUND: + return "STARTSOUND"; + case ST_DEFINEBUTTONSOUND: + return "DEFINEBUTTONSOUND"; + case ST_SOUNDSTREAMHEAD: + return "SOUNDSTREAMHEAD"; + case ST_SOUNDSTREAMBLOCK: + return "SOUNDSTREAMBLOCK"; + case ST_DEFINEBITSLOSSLESS: + return "DEFINEBITSLOSSLESS"; + case ST_DEFINEBITSJPEG2: + return "DEFINEBITSJPEG2"; + case ST_DEFINESHAPE2: + return "DEFINESHAPE2"; + case ST_DEFINEBUTTONCXFORM: + return "DEFINEBUTTONCXFORM"; + case ST_PROTECT: + return "PROTECT"; + case ST_PLACEOBJECT2: + return "PLACEOBJECT2"; + case ST_REMOVEOBJECT2: + return "REMOVEOBJECT2"; + case ST_DEFINESHAPE3: + return "DEFINESHAPE3"; + case ST_DEFINETEXT2: + return "DEFINETEXT2"; + case ST_DEFINEBUTTON2: + return "DEFINEBUTTON2"; + case ST_DEFINEBITSJPEG3: + return "DEFINEBITSJPEG3"; + case ST_DEFINEBITSLOSSLESS2: + return "DEFINEBITSLOSSLESS2"; + case ST_DEFINESPRITE: + return "DEFINESPRITE"; + case ST_NAMECHARACTER: + return "NAMECHARACTER"; + case ST_SERIALNUMBER: + return "SERIALNUMBER"; + case ST_GENERATORTEXT: + return "GENERATORTEXT"; + case ST_FRAMELABEL: + return "FRAMELABEL"; + case ST_SOUNDSTREAMHEAD2: + return "SOUNDSTREAMHEAD2"; + case ST_DEFINEMORPHSHAPE: + return "DEFINEMORPHSHAPE"; + case ST_DEFINEFONT2: + return "DEFINEFONT2"; + case ST_TEMPLATECOMMAND: + return "TEMPLATECOMMAND"; + case ST_GENERATOR3: + return "GENERATOR3"; + case ST_EXTERNALFONT: + return "EXTERNALFONT"; + case ST_REFLEX: + return "REFLEX"; } return 0; } diff --git a/lib/modules/swfobject.c b/lib/modules/swfobject.c index fe32e77..1b58108 100644 --- a/lib/modules/swfobject.c +++ b/lib/modules/swfobject.c @@ -19,41 +19,41 @@ #define PF_NAME 0x20 #define PF_CLIPACTION 0x40 -int ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name) +int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name) { U8 flags; if (!t) return -1; flags = (id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(name?PF_NAME:0)|((m||cx)&&(!id)?PF_MOVE:0); - SetU8(t,flags); - SetU16(t,depth); - if (flags&PF_CHAR) SetU16(t,id); - if (flags&PF_MATRIX) SetMatrix(t,m); - if (flags&PF_CXFORM) SetCXForm(t,cx,(cx->a0!=256)||(cx->a1)); - if (flags&PF_RATIO) SetU16(t,0); - if (flags&PF_NAME) SetString(t,name); + swf_SetU8(t,flags); + swf_SetU16(t,depth); + if (flags&PF_CHAR) swf_SetU16(t,id); + if (flags&PF_MATRIX) swf_SetMatrix(t,m); + if (flags&PF_CXFORM) swf_SetCXForm(t,cx,(cx->a0!=256)||(cx->a1)); + if (flags&PF_RATIO) swf_SetU16(t,0); + if (flags&PF_NAME) swf_SetString(t,name); return 0; } -int PlaceObject(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U16 clipaction) +int swf_ObjectPlaceClip(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U16 clipaction) { U8 flags; if (!t) return -1; flags = (id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(name?PF_NAME:0)| ((m||cx)&&(!id)?PF_MOVE:0)|(clipaction?PF_CLIPACTION:0); - SetU8(t,flags); - SetU16(t,depth); - if (flags&PF_CHAR) SetU16(t,id); - if (flags&PF_MATRIX) SetMatrix(t,m); - if (flags&PF_CXFORM) SetCXForm(t,cx,(cx->a0!=256)||(cx->a1)); - if (flags&PF_RATIO) SetU16(t,0); - if (flags&PF_NAME) SetString(t,name); - if (flags&PF_CLIPACTION) SetU16(t, clipaction); + swf_SetU8(t,flags); + swf_SetU16(t,depth); + if (flags&PF_CHAR) swf_SetU16(t,id); + if (flags&PF_MATRIX) swf_SetMatrix(t,m); + if (flags&PF_CXFORM) swf_SetCXForm(t,cx,(cx->a0!=256)||(cx->a1)); + if (flags&PF_RATIO) swf_SetU16(t,0); + if (flags&PF_NAME) swf_SetString(t,name); + if (flags&PF_CLIPACTION) swf_SetU16(t, clipaction); return 0; } -int ObjectMove(TAG * t,U16 depth,MATRIX * m,CXFORM * cx) -{ return ObjectPlace(t,0,depth,m,cx,NULL); +int swf_ObjectMove(TAG * t,U16 depth,MATRIX * m,CXFORM * cx) +{ return swf_ObjectPlace(t,0,depth,m,cx,NULL); } diff --git a/lib/modules/swfshape.c b/lib/modules/swfshape.c index a8ff956..f107f92 100644 --- a/lib/modules/swfshape.c +++ b/lib/modules/swfshape.c @@ -23,7 +23,7 @@ #define FILL_TILED 0x40 // Bitmap #define FILL_CLIPPED 0x41 -void ShapeFree(SHAPE * s) +void swf_ShapeFree(SHAPE * s) { if (s) { if (s->linestyle.data) free(s->linestyle.data); s->linestyle.data = NULL; @@ -37,7 +37,7 @@ void ShapeFree(SHAPE * s) free(s); } -int NewShape(SHAPE * * s) +int swf_ShapeNew(SHAPE * * s) { SHAPE * sh; if (!s) return -1; sh = (SHAPE *)malloc(sizeof(SHAPE)); s[0] = sh; @@ -45,84 +45,84 @@ int NewShape(SHAPE * * s) return sh?0:-1; } -int GetSimpleShape(TAG * t,SHAPE * * s) // without Linestyle/Fillstyle Record +int swf_GetSimpleShape(TAG * t,SHAPE * * s) // without Linestyle/Fillstyle Record { SHAPE * sh; int bitl, len; int end; U32 pos; - if (FAILED(NewShape(s))) return -1; + if (FAILED(swf_ShapeNew(s))) return -1; sh = s[0]; - ResetBitmask(t); - sh->bits.fill = (U16)GetBits(t,4); - sh->bits.line = (U16)GetBits(t,4); - bitl = 0; end = 0; pos = GetTagPos(t); + swf_ResetBitmask(t); + sh->bits.fill = (U16)swf_GetBits(t,4); + sh->bits.line = (U16)swf_GetBits(t,4); + bitl = 0; end = 0; pos = swf_GetTagPos(t); while (!end) - { int edge = GetBits(t,1); bitl+=1; + { int edge = swf_GetBits(t,1); bitl+=1; if (edge) { bitl+=1; - if (GetBits(t,1)) // Line - { U16 nbits = GetBits(t,4)+2; + if (swf_GetBits(t,1)) // Line + { U16 nbits = swf_GetBits(t,4)+2; bitl+=5; - if (GetBits(t,1)) // x/y Line - { GetBits(t,nbits); - GetBits(t,nbits); + if (swf_GetBits(t,1)) // x/y Line + { swf_GetBits(t,nbits); + swf_GetBits(t,nbits); bitl+=nbits*2; } else // hline/vline - { GetBits(t,nbits+1); + { swf_GetBits(t,nbits+1); bitl+=nbits+1; } } else // Curve - { U16 nbits = GetBits(t,4)+2; + { U16 nbits = swf_GetBits(t,4)+2; bitl+=4; - GetBits(t,nbits); - GetBits(t,nbits); - GetBits(t,nbits); - GetBits(t,nbits); + swf_GetBits(t,nbits); + swf_GetBits(t,nbits); + swf_GetBits(t,nbits); + swf_GetBits(t,nbits); bitl+=4*nbits; } } else - { U16 flags = GetBits(t,5); bitl+=5; + { U16 flags = swf_GetBits(t,5); bitl+=5; if (flags) { if (flags&SF_MOVETO) - { U16 nbits = GetBits(t,5); bitl+=5; - GetBits(t,nbits); - GetBits(t,nbits); + { U16 nbits = swf_GetBits(t,5); bitl+=5; + swf_GetBits(t,nbits); + swf_GetBits(t,nbits); bitl+=2*nbits; } if (flags&SF_FILL0) - { GetBits(t,sh->bits.fill); + { swf_GetBits(t,sh->bits.fill); bitl+=sh->bits.fill; } if (flags&SF_FILL1) - { GetBits(t,sh->bits.fill); + { swf_GetBits(t,sh->bits.fill); bitl+=sh->bits.fill; } if (flags&SF_LINE) - { GetBits(t,sh->bits.line); + { swf_GetBits(t,sh->bits.line); bitl+=sh->bits.line; } if (flags&SF_NEWSTYLE) - { fprintf(stderr,"Can't process extended styles in shape.\n"); + { fprintf(stderr,"RFXSWF: Can't process extended styles in shape.\n"); } } else end = 1; } } - SetTagPos(t,pos); + swf_SetTagPos(t,pos); len = (bitl+7)/8; if (sh->data) free(sh->data); @@ -130,98 +130,98 @@ int GetSimpleShape(TAG * t,SHAPE * * s) // without Linestyle/Fillstyle Record if (sh->data) { sh->bitlen = bitl; - GetBlock(t,sh->data,len); + swf_GetBlock(t,sh->data,len); } else return -1; return len; } -int SetSimpleShape(TAG * t,SHAPE * s) // without Linestyle/Fillstyle Record +int swf_SetSimpleShape(TAG * t,SHAPE * s) // without Linestyle/Fillstyle Record { int l; if (!s) return -1; l = (s->bitlen+7)/8; if (t) - { ResetBitcount(t); + { swf_ResetBitcount(t); - SetBits(t,s->bits.fill,4); - SetBits(t,s->bits.line,4); - SetBlock(t,s->data,l); + swf_SetBits(t,s->bits.fill,4); + swf_SetBits(t,s->bits.line,4); + swf_SetBlock(t,s->data,l); - ResetBitcount(t); + swf_ResetBitcount(t); } return l+1; } -int SetFillStyle(TAG * t,FILLSTYLE * f) +int swf_SetFillStyle(TAG * t,FILLSTYLE * f) { if ((!t)||(!f)) return -1; - SetU8(t,f->type); + swf_SetU8(t,f->type); // no gradients yet! switch (f->type) { case FILL_SOLID: - if (GetTagID(t)!=ST_DEFINESHAPE3) SetRGB(t,&f->color); - else SetRGBA(t,&f->color); + if (swf_GetTagID(t)!=ST_DEFINESHAPE3) swf_SetRGB(t,&f->color); + else swf_SetRGBA(t,&f->color); break; case FILL_TILED: case FILL_CLIPPED: - SetU16(t,f->id_bitmap); - SetMatrix(t,&f->m); + swf_SetU16(t,f->id_bitmap); + swf_SetMatrix(t,&f->m); break; } return 0; } -int SetLineStyle(TAG * t,LINESTYLE * l) +int swf_SetLineStyle(TAG * t,LINESTYLE * l) { if ((!l)||(!t)) return -1; - SetU16(t,l->width); + swf_SetU16(t,l->width); - if (GetTagID(t)!=ST_DEFINESHAPE3) SetRGB(t,&l->color); - else SetRGBA(t,&l->color); + if (swf_GetTagID(t)!=ST_DEFINESHAPE3) swf_SetRGB(t,&l->color); + else swf_SetRGBA(t,&l->color); return 0; } -int SetShapeStyleCount(TAG * t,U16 n) +int swf_SetShapeStyleCount(TAG * t,U16 n) { if (n>254) - { SetU8(t,0xff); - SetU16(t,n); + { swf_SetU8(t,0xff); + swf_SetU16(t,n); return 3; } else - { SetU8(t,n); + { swf_SetU8(t,n); return 1; } } -int SetShapeStyles(TAG * t,SHAPE * s) +int swf_SetShapeStyles(TAG * t,SHAPE * s) { int i,l; if (!s) return -1; l = 0; - l += SetShapeStyleCount(t,s->fillstyle.n); + l += swf_SetShapeStyleCount(t,s->fillstyle.n); for (i=0;ifillstyle.n;i++) - l+=SetFillStyle(t,&s->fillstyle.data[i]); + l+=swf_SetFillStyle(t,&s->fillstyle.data[i]); - l += SetShapeStyleCount(t,s->linestyle.n); + l += swf_SetShapeStyleCount(t,s->linestyle.n); for (i=0;ilinestyle.n;i++) - l+=SetLineStyle(t,&s->linestyle.data[i]); + l+=swf_SetLineStyle(t,&s->linestyle.data[i]); return l; } -int ShapeCountBits(SHAPE * s,U8 * fbits,U8 * lbits) +int swf_ShapeCountBits(SHAPE * s,U8 * fbits,U8 * lbits) { if (!s) return -1; - s->bits.fill = CountBits(s->fillstyle.n,0); - s->bits.line = CountBits(s->linestyle.n,0); + s->bits.fill = swf_CountBits(s->fillstyle.n,0); + s->bits.line = swf_CountBits(s->linestyle.n,0); if (fbits) fbits[0] = s->bits.fill; if (lbits) lbits[0] = s->bits.line; @@ -229,23 +229,23 @@ int ShapeCountBits(SHAPE * s,U8 * fbits,U8 * lbits) return 0; } -int SetShapeBits(TAG * t,SHAPE * s) +int swf_SetShapeBits(TAG * t,SHAPE * s) { if ((!t)||(!s)) return -1; - ResetBitcount(t); - SetBits(t,s->bits.fill,4); - SetBits(t,s->bits.line,4); + swf_ResetBitcount(t); + swf_SetBits(t,s->bits.fill,4); + swf_SetBits(t,s->bits.line,4); return 0; } -int SetShapeHeader(TAG * t,SHAPE * s) +int swf_SetShapeHeader(TAG * t,SHAPE * s) { int res; - res = SetShapeStyles(t,s); - if (res>=0) res = ShapeCountBits(s,NULL,NULL); - if (res>=0) res = SetShapeBits(t,s); + res = swf_SetShapeStyles(t,s); + if (res>=0) res = swf_ShapeCountBits(s,NULL,NULL); + if (res>=0) res = swf_SetShapeBits(t,s); return res; } -int ShapeExport(int handle,SHAPE * s) // without Linestyle/Fillstyle Record +int swf_ShapeExport(int handle,SHAPE * s) // without Linestyle/Fillstyle Record { int l; if (!s) return 0; @@ -266,7 +266,7 @@ int ShapeExport(int handle,SHAPE * s) // without Linestyle/Fillstyle Record return l; } -int ShapeImport(int handle,SHAPE * * shape) +int swf_ShapeImport(int handle,SHAPE * * shape) { SHAPE * s; if (handle<0) return -1; @@ -299,7 +299,7 @@ int ShapeImport(int handle,SHAPE * * shape) return 0; } -int ShapeAddFillStyle(SHAPE * s,U8 type,MATRIX * m,RGBA * color,U16 id_bitmap) +int swf_ShapeAddFillStyle(SHAPE * s,U8 type,MATRIX * m,RGBA * color,U16 id_bitmap) { RGBA def_c; MATRIX def_m; @@ -313,7 +313,7 @@ int ShapeAddFillStyle(SHAPE * s,U8 type,MATRIX * m,RGBA * color,U16 id_bitmap) } if (!m) { m = &def_m; - GetMatrix(NULL,m); + swf_GetMatrix(NULL,m); } // handle memory @@ -339,15 +339,15 @@ int ShapeAddFillStyle(SHAPE * s,U8 type,MATRIX * m,RGBA * color,U16 id_bitmap) return (++s->fillstyle.n); } -int ShapeAddSolidFillStyle(SHAPE * s,RGBA * color) -{ return ShapeAddFillStyle(s,FILL_SOLID,NULL,color,0); +int swf_ShapeAddSolidFillStyle(SHAPE * s,RGBA * color) +{ return swf_ShapeAddFillStyle(s,FILL_SOLID,NULL,color,0); } -int ShapeAddBitmapFillStyle(SHAPE * s,MATRIX * m,U16 id_bitmap,int clip) -{ return ShapeAddFillStyle(s,clip?FILL_CLIPPED:FILL_TILED,m,NULL,id_bitmap); +int swf_ShapeAddBitmapFillStyle(SHAPE * s,MATRIX * m,U16 id_bitmap,int clip) +{ return swf_ShapeAddFillStyle(s,clip?FILL_CLIPPED:FILL_TILED,m,NULL,id_bitmap); } -int ShapeAddLineStyle(SHAPE * s,U16 width,RGBA * color) +int swf_ShapeAddLineStyle(SHAPE * s,U16 width,RGBA * color) { RGBA def; if (!s) return -1; if (!color) @@ -372,18 +372,18 @@ int ShapeAddLineStyle(SHAPE * s,U16 width,RGBA * color) return (++s->linestyle.n); } -int ShapeSetMove(TAG * t,SHAPE * s,S32 x,S32 y) +int swf_ShapeSetMove(TAG * t,SHAPE * s,S32 x,S32 y) { U8 b; if (!t) return -1; - SetBits(t,0,1); - SetBits(t,SF_MOVETO,5); + swf_SetBits(t,0,1); + swf_SetBits(t,SF_MOVETO,5); - b = CountBits(x,0); - b = CountBits(y,b); + b = swf_CountBits(x,0); + b = swf_CountBits(y,b); - SetBits(t,b,5); - SetBits(t,x,b); - SetBits(t,y,b); + swf_SetBits(t,b,5); + swf_SetBits(t,x,b); + swf_SetBits(t,y,b); if (s) { s->px = x; @@ -392,15 +392,15 @@ int ShapeSetMove(TAG * t,SHAPE * s,S32 x,S32 y) return 0; } -int ShapeSetStyle(TAG * t,SHAPE * s,U16 line,U16 fill0,U16 fill1) +int swf_ShapeSetStyle(TAG * t,SHAPE * s,U16 line,U16 fill0,U16 fill1) { if ((!t)||(!s)) return -1; - SetBits(t,0,1); - SetBits(t,(line?SF_LINE:0)|(fill0?SF_FILL0:0)|(fill1?SF_FILL1:0),5); + swf_SetBits(t,0,1); + swf_SetBits(t,(line?SF_LINE:0)|(fill0?SF_FILL0:0)|(fill1?SF_FILL1:0),5); - if (fill0) SetBits(t,fill0,s->bits.fill); - if (fill1) SetBits(t,fill1,s->bits.fill); - if (line) SetBits(t,line ,s->bits.line); + if (fill0) swf_SetBits(t,fill0,s->bits.fill); + if (fill1) swf_SetBits(t,fill1,s->bits.fill); + if (line) swf_SetBits(t,line ,s->bits.line); return 0; } @@ -413,49 +413,49 @@ int ShapeSetStyle(TAG * t,SHAPE * s,U16 line,U16 fill0,U16 fill1) */ #define FILL_RESET 0x8000 #define LINE_RESET 0x8000 -int ShapeSetAll(TAG * t,SHAPE * s,S32 x,S32 y,U16 line,U16 fill0,U16 fill1) + +int swf_ShapeSetAll(TAG * t,SHAPE * s,S32 x,S32 y,U16 line,U16 fill0,U16 fill1) { U8 b; if ((!t)||(!s)) return -1; - SetBits(t,0,1); - SetBits(t,SF_MOVETO|(line?SF_LINE:0)|(fill0?SF_FILL0:0)|(fill1?SF_FILL1:0),5); + swf_SetBits(t,0,1); + swf_SetBits(t,SF_MOVETO|(line?SF_LINE:0)|(fill0?SF_FILL0:0)|(fill1?SF_FILL1:0),5); - b = CountBits(x,0); - b = CountBits(y,b); - SetBits(t,b,5); - SetBits(t,x,b); - SetBits(t,y,b); + b = swf_CountBits(x,0); + b = swf_CountBits(y,b); + swf_SetBits(t,b,5); + swf_SetBits(t,x,b); + swf_SetBits(t,y,b); s->px = x; s->py = y; - if (fill0) SetBits(t,fill0,s->bits.fill); - if (fill1) SetBits(t,fill1,s->bits.fill); - if (line) SetBits(t,line ,s->bits.line); + if (fill0) swf_SetBits(t,fill0,s->bits.fill); + if (fill1) swf_SetBits(t,fill1,s->bits.fill); + if (line) swf_SetBits(t,line ,s->bits.line); return 0; } -int ShapeSetEnd(TAG * t) +int swf_ShapeSetEnd(TAG * t) { if (!t) return -1; - SetBits(t,0,6); - ResetBitcount(t); + swf_SetBits(t,0,6); + swf_ResetBitcount(t); return 0; } -int ShapeSetLine(TAG * t,SHAPE * s,S32 x,S32 y) +int swf_ShapeSetLine(TAG * t,SHAPE * s,S32 x,S32 y) { U8 b; if (!t) return -1; - SetBits(t,3,2); // Straight Edge + swf_SetBits(t,3,2); // Straight Edge if ((!s)||((x!=0)&&(y!=0))) - { b = CountBits(x,2); - b = CountBits(y,b); - if(b<2) - b=2; - SetBits(t, b-2, 4); - SetBits(t,1,1); - SetBits(t,x,b); - SetBits(t,y,b); + { b = swf_CountBits(x,2); + b = swf_CountBits(y,b); + if (b<2) b=2; + swf_SetBits(t, b-2, 4); + swf_SetBits(t,1,1); + swf_SetBits(t,x,b); + swf_SetBits(t,y,b); if (s) { s->px += x; s->py += y; @@ -464,42 +464,42 @@ int ShapeSetLine(TAG * t,SHAPE * s,S32 x,S32 y) } if (x==0) - { b = CountBits(y,2); + { b = swf_CountBits(y,2); if(b<2) - b=2; - SetBits(t, b-2, 4); - SetBits(t,1,2); - SetBits(t,y,b); + b=2; + swf_SetBits(t, b-2, 4); + swf_SetBits(t,1,2); + swf_SetBits(t,y,b); s->py += y; } else - { b = CountBits(x,2); + { b = swf_CountBits(x,2); if(b<2) - b=2; - SetBits(t, b-2, 4); - SetBits(t,0,2); - SetBits(t,x,b); + b=2; + swf_SetBits(t, b-2, 4); + swf_SetBits(t,0,2); + swf_SetBits(t,x,b); s->px += x; } return 0; } -int ShapeSetCurve(TAG * t,SHAPE * s,S32 x,S32 y,S32 ax,S32 ay) +int swf_ShapeSetCurve(TAG * t,SHAPE * s,S32 x,S32 y,S32 ax,S32 ay) { U8 b; if (!t) return -1; - SetBits(t,2,2); + swf_SetBits(t,2,2); - b = CountBits(ax,2); - b = CountBits(ay,b); - b = CountBits(x,b); - b = CountBits(y,b); + b = swf_CountBits(ax,2); + b = swf_CountBits(ay,b); + b = swf_CountBits(x,b); + b = swf_CountBits(y,b); - SetBits(t,b-2,4); - SetBits(t,x,b); - SetBits(t,y,b); - SetBits(t,ax,b); - SetBits(t,ay,b); + swf_SetBits(t,b-2,4); + swf_SetBits(t,x,b); + swf_SetBits(t,y,b); + swf_SetBits(t,ax,b); + swf_SetBits(t,ay,b); if (s) { s->px += x+ax; @@ -508,22 +508,22 @@ int ShapeSetCurve(TAG * t,SHAPE * s,S32 x,S32 y,S32 ax,S32 ay) return 0; } -int ShapeSetCircle(TAG * t,SHAPE * s,S32 x,S32 y,S32 rx,S32 ry) +int swf_ShapeSetCircle(TAG * t,SHAPE * s,S32 x,S32 y,S32 rx,S32 ry) { double C1 = 0.2930; double C2 = 0.4140; double begin = 0.7070; if (!t) return -1; - ShapeSetMove(t,s,x+begin*rx,y+begin*ry); - ShapeSetCurve(t,s, -C1*rx, C1*ry, -C2*rx, 0); - ShapeSetCurve(t,s, -C2*rx, 0, -C1*rx, -C1*ry); - ShapeSetCurve(t,s, -C1*rx, -C1*ry, 0, -C2*ry); - ShapeSetCurve(t,s, 0, -C2*ry, C1*rx, -C1*ry); - ShapeSetCurve(t,s, C1*rx, -C1*ry, C2*rx, 0); - ShapeSetCurve(t,s, C2*rx, 0, C1*rx, C1*ry); - ShapeSetCurve(t,s, C1*rx, C1*ry, 0, C2*ry); - ShapeSetCurve(t,s, 0, C2*ry, -C1*rx, C1*ry); + swf_ShapeSetMove(t,s,x+begin*rx,y+begin*ry); + swf_ShapeSetCurve(t,s, -C1*rx, C1*ry, -C2*rx, 0); + swf_ShapeSetCurve(t,s, -C2*rx, 0, -C1*rx, -C1*ry); + swf_ShapeSetCurve(t,s, -C1*rx, -C1*ry, 0, -C2*ry); + swf_ShapeSetCurve(t,s, 0, -C2*ry, C1*rx, -C1*ry); + swf_ShapeSetCurve(t,s, C1*rx, -C1*ry, C2*rx, 0); + swf_ShapeSetCurve(t,s, C2*rx, 0, C1*rx, C1*ry); + swf_ShapeSetCurve(t,s, C1*rx, C1*ry, 0, C2*ry); + swf_ShapeSetCurve(t,s, 0, C2*ry, -C1*rx, C1*ry); return 0; } diff --git a/lib/modules/swftext.c b/lib/modules/swftext.c index ef46afd..78b3bce 100644 --- a/lib/modules/swftext.c +++ b/lib/modules/swftext.c @@ -24,44 +24,44 @@ #define FF_SHIFTJIS 0x10 #define FF_UNICODE 0x20 -int FontEnumerate(SWF * swf,void (*FontCallback) (U16,U8*)) +int swf_FontEnumerate(SWF * swf,void (*FontCallback) (U16,U8*)) { int n; TAG * t; if (!swf) return -1; - t = swf->FirstTag; + t = swf->firstTag; n = 0; while (t) - { if (GetTagID(t)==ST_DEFINEFONTINFO) + { if (swf_GetTagID(t)==ST_DEFINEFONTINFO) { n++; if (FontCallback) { U16 id; int l; U8 s[257]; - SaveTagPos(t); - SetTagPos(t,0); + swf_SaveTagPos(t); + swf_SetTagPos(t,0); - id = GetU16(t); - l = GetU8(t); - GetBlock(t,s,l); + id = swf_GetU16(t); + l = swf_GetU8(t); + swf_GetBlock(t,s,l); s[l] = 0; (FontCallback)(id,s); - RestoreTagPos(t); + swf_RestoreTagPos(t); } } - t = NextTag(t); + t = swf_NextTag(t); } return n; } -int FontExtract_DefineFont(int id,SWFFONT * f,TAG * t,SHAPE * * shapes) +int swf_FontExtract_DefineFont(int id,SWFFONT * f,TAG * t,SHAPE * * shapes) { U16 fid; - SaveTagPos(t); - SetTagPos(t,0); + swf_SaveTagPos(t); + swf_SetTagPos(t,0); - fid = GetU16(t); + fid = swf_GetU16(t); if ((!id)||(id==fid)) { U16 ofs[MAX_CHAR_PER_FONT]; int n,i; @@ -69,45 +69,45 @@ int FontExtract_DefineFont(int id,SWFFONT * f,TAG * t,SHAPE * * shapes) id = fid; f->id = fid; - ofs[0] = GetU16(t); + ofs[0] = swf_GetU16(t); n = ofs[0]/2; - for (i=1;iname) free(f->name); f->name = (U8*)malloc(l+1); if (f->name) - { GetBlock(t,f->name,l); + { swf_GetBlock(t,f->name,l); f->name[l] = 0; } else - { RestoreTagPos(t); + { swf_RestoreTagPos(t); return -1; } } - f->flags = GetU8(t); + f->flags = swf_GetU8(t); i = 0; while (shapes[i]) - { U16 code = ((f->flags&FF_WIDECODES)?GetU16(t):GetU8(t))%MAX_CHAR_PER_FONT; + { U16 code = ((f->flags&FF_WIDECODES)?swf_GetU16(t):swf_GetU8(t))%MAX_CHAR_PER_FONT; f->glyph[code].shape = shapes[i]; f->glyph[code].gid = i; @@ -117,14 +117,14 @@ int FontExtract_DefineFontInfo(int id,SWFFONT * f,TAG * t,SHAPE * * shapes) } } - RestoreTagPos(t); + swf_RestoreTagPos(t); return id; } #define FEDTJ_PRINT 0x01 #define FEDTJ_MODIFY 0x02 -int FontExtract_DefineText(int id,SWFFONT * f,TAG * t,int jobs) +int swf_FontExtract_DefineText(int id,SWFFONT * f,TAG * t,int jobs) { U16 cid; SRECT r; MATRIX m; @@ -133,37 +133,37 @@ int FontExtract_DefineText(int id,SWFFONT * f,TAG * t,int jobs) fid = 0; - SaveTagPos(t); - SetTagPos(t,0); + swf_SaveTagPos(t); + swf_SetTagPos(t,0); - cid = GetU16(t); - GetRect(t,&r); - GetMatrix(t,&m); - gbits = GetU8(t); - abits = GetU8(t); + cid = swf_GetU16(t); + swf_GetRect(t,&r); + swf_GetMatrix(t,&m); + gbits = swf_GetU8(t); + abits = swf_GetU8(t); - flags = GetU8(t); + flags = swf_GetU8(t); while(flags) { if (flags&TF_TEXTCONTROL) - { if (flags&TF_HASFONT) fid = GetU16(t); + { if (flags&TF_HASFONT) fid = swf_GetU16(t); if (flags&TF_HASCOLOR) - { GetU8(t); // rgb - GetU8(t); - GetU8(t); - if (GetTagID(t)==ST_DEFINETEXT2) GetU8(t); + { swf_GetU8(t); // rgb + swf_GetU8(t); + swf_GetU8(t); + if (swf_GetTagID(t)==ST_DEFINETEXT2) swf_GetU8(t); } - if (flags&TF_HASXOFFSET) GetS16(t); - if (flags&TF_HASYOFFSET) GetS16(t); - if (flags&TF_HASFONT) GetU16(t); + if (flags&TF_HASXOFFSET) swf_GetS16(t); + if (flags&TF_HASYOFFSET) swf_GetS16(t); + if (flags&TF_HASFONT) swf_GetU16(t); } else { int i; for (i=0;icodes[glyph]; if (jobs&FEDTJ_PRINT) printf("%c",code); @@ -173,14 +173,14 @@ int FontExtract_DefineText(int id,SWFFONT * f,TAG * t,int jobs) } if ((id==fid)&&(jobs&FEDTJ_PRINT)) printf("\n"); } - flags = GetU8(t); + flags = swf_GetU8(t); } - RestoreTagPos(t); + swf_RestoreTagPos(t); return id; } -int FontExtract(SWF * swf,int id,SWFFONT * * font) +int swf_FontExtract(SWF * swf,int id,SWFFONT * * font) { TAG * t; SWFFONT * f; SHAPE * shapes[MAX_CHAR_PER_FONT]; @@ -193,36 +193,36 @@ int FontExtract(SWF * swf,int id,SWFFONT * * font) memset(shapes,0x00,sizeof(shapes)); memset(f,0x00,sizeof(SWFFONT)); - t = swf->FirstTag; + t = swf->firstTag; while (t) { int nid = 0; - switch (GetTagID(t)) + switch (swf_GetTagID(t)) { case ST_DEFINEFONT: - nid = FontExtract_DefineFont(id,f,t,shapes); + nid = swf_FontExtract_DefineFont(id,f,t,shapes); break; case ST_DEFINEFONTINFO: - nid = FontExtract_DefineFontInfo(id,f,t,shapes); + nid = swf_FontExtract_DefineFontInfo(id,f,t,shapes); break; case ST_DEFINETEXT: case ST_DEFINETEXT2: - nid = FontExtract_DefineText(id,f,t,FEDTJ_MODIFY); + nid = swf_FontExtract_DefineText(id,f,t,FEDTJ_MODIFY); break; } if (nid>0) id = nid; - t = NextTag(t); + t = swf_NextTag(t); } return 0; } -int FontIsItalic(SWFFONT * f) { return f->flags&FF_ITALIC; } -int FontIsBold(SWFFONT * f) { return f->flags&FF_BOLD; } +int swf_FontIsItalic(SWFFONT * f) { return f->flags&FF_ITALIC; } +int swf_FontIsBold(SWFFONT * f) { return f->flags&FF_BOLD; } -int FontSetID(SWFFONT * f,U16 id) { if (!f) return -1; f->id = id; return 0; } +int swf_FontSetID(SWFFONT * f,U16 id) { if (!f) return -1; f->id = id; return 0; } -int FontReduce(SWFFONT * f,FONTUSAGE * use) +int swf_FontReduce(SWFFONT * f,FONTUSAGE * use) { int i,j; if ((!f)||(!use)) return -1; @@ -237,7 +237,7 @@ int FontReduce(SWFFONT * f,FONTUSAGE * use) j++; } else - { ShapeFree(f->glyph[i].shape); + { swf_ShapeFree(f->glyph[i].shape); f->glyph[i].shape = 0; f->glyph[i].gid = 0; f->glyph[i].advance = 0; @@ -247,13 +247,13 @@ int FontReduce(SWFFONT * f,FONTUSAGE * use) return j; } -int FontInitUsage(FONTUSAGE * use) +int swf_FontInitUsage(FONTUSAGE * use) { if (!use) return -1; memset(&use->code,0x00,sizeof(use->code)); return 0; } -int FontUse(FONTUSAGE * use,U8 * s) +int swf_FontUse(FONTUSAGE * use,U8 * s) { if ((!use)||(!s)) return -1; while (s[0]) { use->code[s[0]] = 1; @@ -262,49 +262,49 @@ int FontUse(FONTUSAGE * use,U8 * s) return 0; } -int FontSetDefine(TAG * t,SWFFONT * f) +int swf_FontSetDefine(TAG * t,SWFFONT * f) { U16 ofs[MAX_CHAR_PER_FONT]; int p,i,j; if ((!t)||(!f)) return -1; - ResetBitcount(t); - SetU16(t,f->id); + swf_ResetBitcount(t); + swf_SetU16(t,f->id); p = 0; j = 0; for (i=0;iglyph[i].shape) { ofs[j++] = p; - p+=SetSimpleShape(NULL,f->glyph[i].shape); + p+=swf_SetSimpleShape(NULL,f->glyph[i].shape); } - for (i=0;iglyph[i].shape) - SetSimpleShape(t,f->glyph[i].shape); + swf_SetSimpleShape(t,f->glyph[i].shape); - ResetBitcount(t); + swf_ResetBitcount(t); return 0; } -int FontSetInfo(TAG * t,SWFFONT * f) +int swf_FontSetInfo(TAG * t,SWFFONT * f) { int l,i; if ((!t)||(!f)) return -1; - ResetBitcount(t); - SetU16(t,f->id); + swf_ResetBitcount(t); + swf_SetU16(t,f->id); l = strlen(f->name); if (l>255) l = 255; - SetU8(t,l); - SetBlock(t,f->name,l); - SetU8(t,f->flags&0xfe); // no Wide-Codes + swf_SetU8(t,l); + swf_SetBlock(t,f->name,l); + swf_SetU8(t,f->flags&0xfe); // no Wide-Codes for (i=0;iglyph[i].shape) - SetU8(t,i); + swf_SetU8(t,i); return 0; } -int FontExport(int handle,SWFFONT * f) +int swf_FontExport(int handle,SWFFONT * f) { int l; int i; if (!f) return 0; @@ -335,7 +335,7 @@ int FontExport(int handle,SWFFONT * f) for (i=0;iglyph[i].shape) - { int ll = ShapeExport(handle,f->glyph[i].shape); + { int ll = swf_ShapeExport(handle,f->glyph[i].shape); if (ll<0) return -1; l+=ll; } @@ -385,7 +385,7 @@ int FontImport(int handle,SWFFONT * * font) for (i=0;iglyph[i].shape) - { if (ShapeImport(handle,&f->glyph[i].shape)<0) goto fehler; + { if (swf_ShapeImport(handle,&f->glyph[i].shape)<0) goto fehler; } } @@ -395,19 +395,19 @@ int FontImport(int handle,SWFFONT * * font) fehler: if (f) for (;iglyph[i].shape = NULL; - FontFree(f); + swf_FontFree(f); font[0] = NULL; return -1; } -int TextPrintDefineText(TAG * t,SWFFONT * f) -{ int id = GetTagID(t); - if ((id==ST_DEFINETEXT)||(id==ST_DEFINETEXT2)) FontExtract_DefineText(f->id,f,t,FEDTJ_PRINT); +int swf_TextPrintDefineText(TAG * t,SWFFONT * f) +{ int id = swf_GetTagID(t); + if ((id==ST_DEFINETEXT)||(id==ST_DEFINETEXT2)) swf_FontExtract_DefineText(f->id,f,t,FEDTJ_PRINT); else return -1; return 0; } -void LayoutFree(SWFLAYOUT * l) +void swf_LayoutFree(SWFLAYOUT * l) { if (l) { if (l->kerning.data) free(l->kerning.data); l->kerning.data = NULL; @@ -415,52 +415,52 @@ void LayoutFree(SWFLAYOUT * l) free(l); } -void FontFree(SWFFONT * f) +void swf_FontFree(SWFFONT * f) { if (f) { int i; if (f->name) free(f->name); - if (f->layout) LayoutFree(f->layout); + if (f->layout) swf_LayoutFree(f->layout); f->name = NULL; f->layout = NULL; for (i=0;iglyph[i].shape) - { ShapeFree(f->glyph[i].shape); + { swf_ShapeFree(f->glyph[i].shape); f->glyph[i].shape = NULL; } } free(f); } -int TextSetInfoRecord(TAG * t,SWFFONT * font,U16 size,RGBA * color,S16 dx,S16 dy) +int swf_TextSetInfoRecord(TAG * t,SWFFONT * font,U16 size,RGBA * color,S16 dx,S16 dy) { U8 flags; if (!t) return -1; flags = TF_TEXTCONTROL|(font?TF_HASFONT:0)|(color?TF_HASCOLOR:0)|(dx?TF_HASXOFFSET:0)|(dy?TF_HASYOFFSET:0); - SetU8(t,flags); - if (font) SetU16(t,font->id); + swf_SetU8(t,flags); + if (font) swf_SetU16(t,font->id); if (color) - { if (GetTagID(t)==ST_DEFINETEXT2) SetRGBA(t,color); - else SetRGB(t,color); + { if (swf_GetTagID(t)==ST_DEFINETEXT2) swf_SetRGBA(t,color); + else swf_SetRGB(t,color); } - if (dx) SetS16(t,dx); - if (dy) SetS16(t,dy); - if (font) SetU16(t,size); + if (dx) swf_SetS16(t,dx); + if (dy) swf_SetS16(t,dy); + if (font) swf_SetU16(t,size); return 0; } -int TextCountBits(SWFFONT * font,U8 * s,int scale,U8 * gbits,U8 * abits) +int swf_TextCountBits(SWFFONT * font,U8 * s,int scale,U8 * gbits,U8 * abits) { U16 g,a; if ((!s)||(!font)||((!gbits)&&(!abits))) return -1; g = a = 0; while(s[0]) - { g = CountBits(font->glyph[s[0]].gid,g); - a = CountBits((((U32)font->glyph[s[0]].advance)*scale)/100,a); + { g = swf_CountBits(font->glyph[s[0]].gid,g); + a = swf_CountBits((((U32)font->glyph[s[0]].advance)*scale)/100,a); s++; } @@ -470,25 +470,25 @@ int TextCountBits(SWFFONT * font,U8 * s,int scale,U8 * gbits,U8 * abits) return 0; } -int TextSetCharRecord(TAG * t,SWFFONT * font,U8 * s,int scale,U8 gbits,U8 abits) +int swf_TextSetCharRecord(TAG * t,SWFFONT * font,U8 * s,int scale,U8 gbits,U8 abits) { int l,i; if ((!t)||(!font)||(!s)) return -1; l = strlen(s); if (l>0x7f) l = 0x7f; - SetU8(t,l); + swf_SetU8(t,l); for (i=0;iglyph[s[i]].gid,gbits); - SetBits(t,(((U32)font->glyph[s[i]].advance)*scale)/100,abits); + { swf_SetBits(t,font->glyph[s[i]].gid,gbits); + swf_SetBits(t,(((U32)font->glyph[s[i]].advance)*scale)/100,abits); } - ResetBitcount(t); + swf_ResetBitcount(t); return 0; } -U32 TextGetWidth(SWFFONT * font,U8 * s,int scale) +U32 swf_TextGetWidth(SWFFONT * font,U8 * s,int scale) { U32 res = 0; if (font&&s) @@ -498,6 +498,5 @@ U32 TextGetWidth(SWFFONT * font,U8 * s,int scale) } if (scale) res = (res*scale)/100; } - return res; } diff --git a/lib/modules/swftools.c b/lib/modules/swftools.c index b926346..bbbfee3 100644 --- a/lib/modules/swftools.c +++ b/lib/modules/swftools.c @@ -14,19 +14,19 @@ // Matrix & Math tools for SWF files #define S64 long long -SFIXED SP(SFIXED a1,SFIXED a2,SFIXED b1,SFIXED b2) +SFIXED RFXSWF_SP(SFIXED a1,SFIXED a2,SFIXED b1,SFIXED b2) { S64 a; a = (S64)a1*(S64)b1+(S64)a2*(S64)b2; return (SFIXED)(a>>16); } -SFIXED QFIX(int zaehler,int nenner) // bildet Quotient von zwei INTs in SFIXED +SFIXED RFXSWF_QFIX(int zaehler,int nenner) // bildet Quotient von zwei INTs in SFIXED { S64 z = zaehler<<16; S64 a = z/(S64)nenner; return (SFIXED)a; } #undef S64 -MATRIX * MatrixJoin(MATRIX * d,MATRIX * s1,MATRIX * s2) +MATRIX * swf_MatrixJoin(MATRIX * d,MATRIX * s1,MATRIX * s2) { if (!d) return NULL; if (!s1) return (s2)?(MATRIX *)memcpy(d,s2,sizeof(MATRIX)):NULL; @@ -35,17 +35,17 @@ MATRIX * MatrixJoin(MATRIX * d,MATRIX * s1,MATRIX * s2) d->tx = s1->tx + s2->tx; d->ty = s1->ty + s2->ty; - d->sx = SP(s1->sx,s1->r1,s2->sx,s2->r0); - d->sy = SP(s1->r0,s1->sy,s2->r1,s2->sy); - d->r0 = SP(s1->r0,s1->sy,s2->sx,s2->r0); - d->r1 = SP(s1->sx,s1->r1,s2->r1,s2->sy); + d->sx = RFXSWF_SP(s1->sx,s1->r1,s2->sx,s2->r0); + d->sy = RFXSWF_SP(s1->r0,s1->sy,s2->r1,s2->sy); + d->r0 = RFXSWF_SP(s1->r0,s1->sy,s2->sx,s2->r0); + d->r1 = RFXSWF_SP(s1->sx,s1->r1,s2->r1,s2->sy); //DumpMatrix(NULL,d); return d; } -MATRIX * MatrixMapTriangle(MATRIX * m,int dx,int dy,int x0,int y0, +MATRIX * swf_MatrixMapTriangle(MATRIX * m,int dx,int dy,int x0,int y0, int x1,int y1,int x2,int y2) { int dx1 = x1 - x0; int dy1 = y1 - y0; @@ -57,23 +57,23 @@ MATRIX * MatrixMapTriangle(MATRIX * m,int dx,int dy,int x0,int y0, m->tx = x0; m->ty = y0; - m->sx = QFIX(dx1,dx); - m->sy = QFIX(dy2,dy); - m->r0 = QFIX(dy1,dx); - m->r1 = QFIX(dx2,dy); + m->sx = RFXSWF_QFIX(dx1,dx); + m->sy = RFXSWF_QFIX(dy2,dy); + m->r0 = RFXSWF_QFIX(dy1,dx); + m->r1 = RFXSWF_QFIX(dx2,dy); return m; } -U16 GetDefineID(TAG * t) +U16 swf_GetDefineID(TAG * t) // up to SWF 4.0 { U32 oldTagPos; U16 id = 0; - oldTagPos = GetTagPos(t); - SetTagPos(t,0); + oldTagPos = swf_GetTagPos(t); + swf_SetTagPos(t,0); - switch (GetTagID(t)) + switch (swf_GetTagID(t)) { case ST_DEFINESHAPE: case ST_DEFINESHAPE2: case ST_DEFINESHAPE3: @@ -94,39 +94,39 @@ U16 GetDefineID(TAG * t) case ST_DEFINETEXT2: case ST_DEFINESOUND: case ST_DEFINESPRITE: - id = GetU16(t); + id = swf_GetU16(t); break; } - SetTagPos(t,oldTagPos); + swf_SetTagPos(t,oldTagPos); return id; } -U16 GetPlaceID(TAG * t) +U16 swf_GetPlaceID(TAG * t) // up to SWF 4.0 { U32 oldTagPos; U16 id = 0; - oldTagPos = GetTagPos(t); - SetTagPos(t,0); + oldTagPos = swf_GetTagPos(t); + swf_SetTagPos(t,0); - switch (GetTagID(t)) + switch (swf_GetTagID(t)) { case ST_PLACEOBJECT: case ST_REMOVEOBJECT: case ST_STARTSOUND: - id = GetU16(t); + id = swf_GetU16(t); break; case ST_PLACEOBJECT2: - { U8 flags = GetU8(t); - U16 d = GetU16(t); - id = (flags&PF_CHAR)?GetU16(t):id; + { U8 flags = swf_GetU8(t); + U16 d = swf_GetU16(t); + id = (flags&PF_CHAR)?swf_GetU16(t):id; } break; } - SetTagPos(t,oldTagPos); + swf_SetTagPos(t,oldTagPos); return id; } @@ -171,90 +171,90 @@ int spritetagids[] = -1 }; -char isAllowedSpriteTag (TAG*tag) +U8 swf_isAllowedSpriteTag(TAG * tag) { int id = tag->id; int t=0; while(spritetagids[t]>=0) { - if(spritetagids[t] == id) - return 1; - t++; + if(spritetagids[t] == id) + return 1; + t++; } return 0; } -char isDefiningTag (TAG*tag) +U8 swf_isDefiningTag(TAG * tag) { int id = tag->id; int t=0; while(definingtagids[t]>=0) { - if(definingtagids[t] == id) - return 1; - t++; + if(definingtagids[t] == id) + return 1; + t++; } return 0; } -U16 GetDepth(TAG * t) +U16 swf_GetDepth(TAG * t) // up to SWF 4.0 { U16 depth = 0; U32 oldTagPos; - oldTagPos = GetTagPos(t); - SetTagPos(t,0); + oldTagPos = swf_GetTagPos(t); + swf_SetTagPos(t,0); - switch (GetTagID(t)) + switch (swf_GetTagID(t)) { case ST_PLACEOBJECT: case ST_REMOVEOBJECT: - GetU16(t); //id - depth = GetU16(t); + swf_GetU16(t); //id + depth = swf_GetU16(t); break; case ST_REMOVEOBJECT2: - depth = GetU16(t); + depth = swf_GetU16(t); break; case ST_PLACEOBJECT2: - { U8 flags = GetU8(t); - depth = GetU16(t); + { U8 flags = swf_GetU8(t); + depth = swf_GetU16(t); } break; } - SetTagPos(t,oldTagPos); + swf_SetTagPos(t,oldTagPos); return depth; } -char* GetName(TAG * t) +char* swf_GetTagName(TAG * t) { char* name = 0; U32 oldTagPos; MATRIX m; CXFORM c; - oldTagPos = GetTagPos(t); - SetTagPos(t,0); - switch(GetTagID(t)) + oldTagPos = swf_GetTagPos(t); + swf_SetTagPos(t,0); + switch(swf_GetTagID(t)) { case ST_FRAMELABEL: - name = &t->data[GetTagPos(t)]; + name = &t->data[swf_GetTagPos(t)]; break; case ST_PLACEOBJECT2: { - U8 flags = GetU8(t); - GetU16(t); //depth; - if(flags&PF_CHAR) - GetU16(t); //id - if(flags&PF_MATRIX) - GetMatrix(t, &m); - if(flags&PF_CXFORM) - GetCXForm(t, &c, 1); - if(flags&PF_RATIO) - GetU16(t); - if(flags&PF_NAME) { - ResetBitmask(t); - name = &t->data[GetTagPos(t)]; - } + U8 flags = swf_GetU8(t); + swf_GetU16(t); //depth; + if(flags&PF_CHAR) + swf_GetU16(t); //id + if(flags&PF_MATRIX) + swf_GetMatrix(t, &m); + if(flags&PF_CXFORM) + swf_GetCXForm(t, &c, 1); + if(flags&PF_RATIO) + swf_GetU16(t); + if(flags&PF_NAME) { + swf_ResetBitmask(t); + name = &t->data[swf_GetTagPos(t)]; + } } break; } - SetTagPos(t,oldTagPos); + swf_SetTagPos(t,oldTagPos); return name; } diff --git a/lib/old_rfxswf.h b/lib/old_rfxswf.h index f893ae4..475c321 100644 --- a/lib/old_rfxswf.h +++ b/lib/old_rfxswf.h @@ -19,4 +19,5 @@ #define DataSize dataWritePos #define bitcount bitWritePos #define bitmask bitWritePos + */ diff --git a/lib/rfxswf.c b/lib/rfxswf.c index 7079c94..801171f 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -48,34 +48,34 @@ // inline wrapper functions -TAG * NextTag(TAG * t) { return t->next; } -TAG * PrevTag(TAG * t) { return t->prev; } -int GetFrameNo(TAG * t) { return t->frame; } -U16 GetTagID(TAG * t) { return t->id; } -U32 GetDataSize(TAG * t) { return t->len; } -U8* GetDataSizePtr(TAG * t) { return &(t->data[t->len]); } -U32 GetTagPos(TAG * t) { return t->pos; } +TAG * swf_NextTag(TAG * t) { return t->next; } +TAG * swf_PrevTag(TAG * t) { return t->prev; } +int swf_GetFrameNo(TAG * t) { return t->frame; } +U16 swf_GetTagID(TAG * t) { return t->id; } +U32 swf_GetDataSize(TAG * t) { return t->len; } +U8* swf_GetDataSizePtr(TAG * t) { return &(t->data[t->len]); } +U32 swf_GetTagPos(TAG * t) { return t->pos; } // Basic Data Access Functions -#define ResetBitmask(tag) if (tag->bitmask) { tag->pos++; tag->bitmask = 0; } -#define ResetBitcount(tag) if (tag->bitcount) { tag->bitcount = 0; } +#define swf_ResetBitmask(tag) if (tag->bitmask) { tag->pos++; tag->bitmask = 0; } +#define swf_ResetBitcount(tag) if (tag->bitcount) { tag->bitcount = 0; } // for future purpose: avoid high level lib functions to change tagpos/bitcount -#define SaveTagPos(tag) -#define RestoreTagPos(tag) +#define swf_SaveTagPos(tag) +#define swf_RestoreTagPos(tag) -void SetTagPos(TAG * t,U32 pos) -{ ResetBitmask(t); +void swf_SetTagPos(TAG * t,U32 pos) +{ swf_ResetBitmask(t); if (pos<=t->len) t->pos = pos; #ifdef DEBUG_RFXSWF else fprintf(stderr,"SetTagPos() out of bounds: TagID = %i\n",t->id); #endif } -U8 GetU8(TAG * t) -{ ResetBitmask(t); +U8 swf_GetU8(TAG * t) +{ swf_ResetBitmask(t); #ifdef DEBUG_RFXSWF if (t->pos>=t->len) { fprintf(stderr,"GetU8() out of bounds: TagID = %i\n",t->id); @@ -85,9 +85,9 @@ U8 GetU8(TAG * t) return t->data[t->pos++]; } -U16 GetU16(TAG * t) +U16 swf_GetU16(TAG * t) { U16 res; - ResetBitmask(t); + swf_ResetBitmask(t); #ifdef DEBUG_RFXSWF if (t->pos>(t->len-2)) { fprintf(stderr,"GetU16() out of bounds: TagID = %i\n",t->id); @@ -99,9 +99,9 @@ U16 GetU16(TAG * t) return res; } -U32 GetU32(TAG * t) +U32 swf_GetU32(TAG * t) { U32 res; - ResetBitmask(t); + swf_ResetBitmask(t); #ifdef DEBUG_RFXSWF if (t->pos>(t->len-4)) { fprintf(stderr,"GetU32() out of bounds: TagID = %i\n",t->id); @@ -114,20 +114,20 @@ U32 GetU32(TAG * t) return res; } -int GetBlock(TAG * t,U8 * b,int l) +int swf_GetBlock(TAG * t,U8 * b,int l) // returns number of bytes written (<=l) // b = NULL -> skip data -{ ResetBitmask(t); +{ swf_ResetBitmask(t); if ((t->len-t->pos)len-t->pos; if (b && l) memcpy(b,&t->data[t->pos],l); t->pos+=l; return l; } -int SetBlock(TAG * t,U8 * b,int l) +int swf_SetBlock(TAG * t,U8 * b,int l) // Appends Block to the end of Tagdata, returns size { U32 newlen = t->len + l; - ResetBitcount(t); + swf_ResetBitcount(t); if (newlen>t->memsize) { U32 newmem = MEMSIZE(newlen); U8 * newdata = (U8*)((t->data)?realloc(t->data,newmem):malloc(newmem)); @@ -147,34 +147,34 @@ int SetBlock(TAG * t,U8 * b,int l) return l; } -int SetU8(TAG * t,U8 v) -{ ResetBitcount(t); - if ((t->len+1)>t->memsize) return (SetBlock(t,&v,1)==1)?0:-1; +int swf_SetU8(TAG * t,U8 v) +{ swf_ResetBitcount(t); + if ((t->len+1)>t->memsize) return (swf_SetBlock(t,&v,1)==1)?0:-1; t->data[t->len++] = v; return 0; } -int SetU16(TAG * t,U16 v) +int swf_SetU16(TAG * t,U16 v) { U8 a[2]; a[0] = v&0xff; a[1] = v>>8; - ResetBitcount(t); - if ((t->len+2)>t->memsize) return (SetBlock(t,a,2)==2)?0:-1; + swf_ResetBitcount(t); + if ((t->len+2)>t->memsize) return (swf_SetBlock(t,a,2)==2)?0:-1; t->data[t->len++] = a[0]; t->data[t->len++] = a[1]; return 0; } -int SetU32(TAG * t,U32 v) +int swf_SetU32(TAG * t,U32 v) { U8 a[4]; a[0] = v&0xff; // to ensure correct handling of non-intel byteorder a[1] = (v>>8)&0xff; a[2] = (v>>16)&0xff; a[3] = (v>>24)&0xff; - ResetBitcount(t); - if ((t->len+4)>t->memsize) return (SetBlock(t,a,4)==4)?0:-1; + swf_ResetBitcount(t); + if ((t->len+4)>t->memsize) return (swf_SetBlock(t,a,4)==4)?0:-1; t->data[t->len++] = a[0]; t->data[t->len++] = a[1]; t->data[t->len++] = a[2]; @@ -182,7 +182,7 @@ int SetU32(TAG * t,U32 v) return 0; } -U32 GetBits(TAG * t,int nbits) +U32 swf_GetBits(TAG * t,int nbits) { U32 res = 0; if (!nbits) return 0; if (!t->bitmask) t->bitmask = 0x80; @@ -205,18 +205,18 @@ U32 GetBits(TAG * t,int nbits) return res; } -S32 GetSBits(TAG * t,int nbits) -{ U32 res = GetBits(t,nbits); +S32 swf_GetSBits(TAG * t,int nbits) +{ U32 res = swf_GetBits(t,nbits); if (res&(1<<(nbits-1))) res|=(0xffffffff<bitcount) - { if (FAILED(SetU8(t,0))) return -1; + { if (FAILED(swf_SetU8(t,0))) return -1; t->bitcount = 0x80; } if (v&bm) t->data[t->len-1] |= t->bitcount; @@ -229,28 +229,28 @@ int SetBits(TAG * t,U32 v,int nbits) // Advanced Data Access Functions -int SetRGB(TAG * t,RGBA * col) +int swf_SetRGB(TAG * t,RGBA * col) { if (!t) return -1; if (col) - { SetU8(t,col->r); - SetU8(t,col->g); - SetU8(t,col->b); - } else SetBlock(t,NULL,3); + { swf_SetU8(t,col->r); + swf_SetU8(t,col->g); + swf_SetU8(t,col->b); + } else swf_SetBlock(t,NULL,3); return 0; } -int SetRGBA(TAG * t,RGBA * col) +int swf_SetRGBA(TAG * t,RGBA * col) { if (!t) return -1; if (col) - { SetU8(t,col->r); - SetU8(t,col->g); - SetU8(t,col->b); - SetU8(t,col->a); - } else SetBlock(t,NULL,4); + { swf_SetU8(t,col->r); + swf_SetU8(t,col->g); + swf_SetU8(t,col->b); + swf_SetU8(t,col->a); + } else swf_SetBlock(t,NULL,4); return 0; } -int CountBits(U32 v,int nbits) +int swf_CountBits(U32 v,int nbits) { int n = 33; U32 m = 0x80000000; if (!v) n = 0; else @@ -271,36 +271,36 @@ int CountBits(U32 v,int nbits) return (n>nbits)?n:nbits; } -int GetRect(TAG * t,SRECT * r) +int swf_GetRect(TAG * t,SRECT * r) { int nbits; SRECT dummy; if (!r) r = &dummy; - nbits = (int) GetBits(t,5); - r->xmin = GetSBits(t,nbits); - r->xmax = GetSBits(t,nbits); - r->ymin = GetSBits(t,nbits); - r->ymax = GetSBits(t,nbits); + nbits = (int) swf_GetBits(t,5); + r->xmin = swf_GetSBits(t,nbits); + r->xmax = swf_GetSBits(t,nbits); + r->ymin = swf_GetSBits(t,nbits); + r->ymax = swf_GetSBits(t,nbits); return 0; } -int SetRect(TAG * t,SRECT * r) +int swf_SetRect(TAG * t,SRECT * r) { int nbits; - nbits = CountBits(r->xmin,0); - nbits = CountBits(r->xmax,nbits); - nbits = CountBits(r->ymin,nbits); - nbits = CountBits(r->ymax,nbits); + nbits = swf_CountBits(r->xmin,0); + nbits = swf_CountBits(r->xmax,nbits); + nbits = swf_CountBits(r->ymin,nbits); + nbits = swf_CountBits(r->ymax,nbits); - SetBits(t,nbits,5); - SetBits(t,r->xmin,nbits); - SetBits(t,r->xmax,nbits); - SetBits(t,r->ymin,nbits); - SetBits(t,r->ymax,nbits); + swf_SetBits(t,nbits,5); + swf_SetBits(t,r->xmin,nbits); + swf_SetBits(t,r->xmax,nbits); + swf_SetBits(t,r->ymin,nbits); + swf_SetBits(t,r->ymax,nbits); return 0; } -int GetMatrix(TAG * t,MATRIX * m) +int swf_GetMatrix(TAG * t,MATRIX * m) { MATRIX dummy; int nbits; @@ -313,30 +313,30 @@ int GetMatrix(TAG * t,MATRIX * m) return -1; } - ResetBitmask(t); + swf_ResetBitmask(t); - if (GetBits(t,1)) - { nbits = GetBits(t,5); - m->sx = GetSBits(t,nbits); - m->sy = GetSBits(t,nbits); + if (swf_GetBits(t,1)) + { nbits = swf_GetBits(t,5); + m->sx = swf_GetSBits(t,nbits); + m->sy = swf_GetSBits(t,nbits); } else m->sx = m->sy = 0x10000; - if (GetBits(t,1)) - { nbits = GetBits(t,5); - m->r0 = GetSBits(t,nbits); - m->r1 = GetSBits(t,nbits); + if (swf_GetBits(t,1)) + { nbits = swf_GetBits(t,5); + m->r0 = swf_GetSBits(t,nbits); + m->r1 = swf_GetSBits(t,nbits); } else m->r0 = m->r1 = 0x0; - nbits = GetBits(t,5); - m->tx = GetSBits(t,nbits); - m->ty = GetSBits(t,nbits); + nbits = swf_GetBits(t,5); + m->tx = swf_GetSBits(t,nbits); + m->ty = swf_GetSBits(t,nbits); return 0; } -int SetMatrix(TAG * t,MATRIX * m) +int swf_SetMatrix(TAG * t,MATRIX * m) { int nbits; MATRIX ma; @@ -347,38 +347,38 @@ int SetMatrix(TAG * t,MATRIX * m) ma.tx = ma.ty = 0; } - ResetBitcount(t); + swf_ResetBitcount(t); - if ((m->sx==0x10000)&&(m->sy==0x10000)) SetBits(t,0,1); + if ((m->sx==0x10000)&&(m->sy==0x10000)) swf_SetBits(t,0,1); else - { SetBits(t,1,1); - nbits = CountBits(m->sx,0); - nbits = CountBits(m->sy,nbits); - SetBits(t,nbits,5); - SetBits(t,m->sx,nbits); - SetBits(t,m->sy,nbits); + { swf_SetBits(t,1,1); + nbits = swf_CountBits(m->sx,0); + nbits = swf_CountBits(m->sy,nbits); + swf_SetBits(t,nbits,5); + swf_SetBits(t,m->sx,nbits); + swf_SetBits(t,m->sy,nbits); } - if ((!m->r0)&&(!m->r1)) SetBits(t,0,1); + if ((!m->r0)&&(!m->r1)) swf_SetBits(t,0,1); else - { SetBits(t,1,1); - nbits = CountBits(m->r0,0); - nbits = CountBits(m->r1,nbits); - SetBits(t,nbits,5); - SetBits(t,m->r0,nbits); - SetBits(t,m->r1,nbits); + { swf_SetBits(t,1,1); + nbits = swf_CountBits(m->r0,0); + nbits = swf_CountBits(m->r1,nbits); + swf_SetBits(t,nbits,5); + swf_SetBits(t,m->r0,nbits); + swf_SetBits(t,m->r1,nbits); } - nbits = CountBits(m->tx,0); - nbits = CountBits(m->ty,nbits); - SetBits(t,nbits,5); - SetBits(t,m->tx,nbits); - SetBits(t,m->ty,nbits); + nbits = swf_CountBits(m->tx,0); + nbits = swf_CountBits(m->ty,nbits); + swf_SetBits(t,nbits,5); + swf_SetBits(t,m->tx,nbits); + swf_SetBits(t,m->ty,nbits); return 0; } -int GetCXForm(TAG * t,CXFORM * cx,U8 alpha) //FIXME: alpha should be type bool +int swf_GetCXForm(TAG * t,CXFORM * cx,U8 alpha) //FIXME: alpha should be type bool { CXFORM cxf; int hasadd; int hasmul; @@ -391,31 +391,31 @@ int GetCXForm(TAG * t,CXFORM * cx,U8 alpha) //FIXME: alpha should be type bool if (!t) return 0; - ResetBitmask(t); - hasadd = GetBits(t,1); - hasmul = GetBits(t,1); - nbits = GetBits(t,4); + swf_ResetBitmask(t); + hasadd = swf_GetBits(t,1); + hasmul = swf_GetBits(t,1); + nbits = swf_GetBits(t,4); if (hasmul) - { cx->r0 = (S16)GetSBits(t,nbits); - cx->g0 = (S16)GetSBits(t,nbits); - cx->b0 = (S16)GetSBits(t,nbits); + { cx->r0 = (S16)swf_GetSBits(t,nbits); + cx->g0 = (S16)swf_GetSBits(t,nbits); + cx->b0 = (S16)swf_GetSBits(t,nbits); if (alpha) - cx->a0 = (S16)GetSBits(t,nbits); + cx->a0 = (S16)swf_GetSBits(t,nbits); } if (hasadd) - { cx->r1 = (S16)GetSBits(t,nbits); - cx->g1 = (S16)GetSBits(t,nbits); - cx->b1 = (S16)GetSBits(t,nbits); + { cx->r1 = (S16)swf_GetSBits(t,nbits); + cx->g1 = (S16)swf_GetSBits(t,nbits); + cx->b1 = (S16)swf_GetSBits(t,nbits); if (alpha) - cx->a1 = (S16)GetSBits(t,nbits); + cx->a1 = (S16)swf_GetSBits(t,nbits); } return 0; } -int SetCXForm(TAG * t,CXFORM * cx,U8 alpha) +int swf_SetCXForm(TAG * t,CXFORM * cx,U8 alpha) { CXFORM cxf; int hasadd; int hasmul; @@ -438,43 +438,43 @@ int SetCXForm(TAG * t,CXFORM * cx,U8 alpha) hasadd = cx->a1|cx->r1|cx->g1|cx->b1; if (hasmul) - { if (alpha) nbits = CountBits((S32)cx->a0,nbits); - nbits = CountBits((S32)cx->r0,nbits); - nbits = CountBits((S32)cx->g0,nbits); - nbits = CountBits((S32)cx->b0,nbits); + { if (alpha) nbits = swf_CountBits((S32)cx->a0,nbits); + nbits = swf_CountBits((S32)cx->r0,nbits); + nbits = swf_CountBits((S32)cx->g0,nbits); + nbits = swf_CountBits((S32)cx->b0,nbits); } if (hasadd) - { if (alpha) nbits = CountBits((S32)cx->a1,nbits); - nbits = CountBits((S32)cx->r1,nbits); - nbits = CountBits((S32)cx->g1,nbits); - nbits = CountBits((S32)cx->b1,nbits); + { if (alpha) nbits = swf_CountBits((S32)cx->a1,nbits); + nbits = swf_CountBits((S32)cx->r1,nbits); + nbits = swf_CountBits((S32)cx->g1,nbits); + nbits = swf_CountBits((S32)cx->b1,nbits); } - ResetBitcount(t); - SetBits(t,hasadd?1:0,1); - SetBits(t,hasmul?1:0,1); - SetBits(t,nbits,4); + swf_ResetBitcount(t); + swf_SetBits(t,hasadd?1:0,1); + swf_SetBits(t,hasmul?1:0,1); + swf_SetBits(t,nbits,4); if (hasmul) - { SetBits(t,cx->r0,nbits); - SetBits(t,cx->g0,nbits); - SetBits(t,cx->b0,nbits); - if (alpha) SetBits(t,cx->a0,nbits); + { swf_SetBits(t,cx->r0,nbits); + swf_SetBits(t,cx->g0,nbits); + swf_SetBits(t,cx->b0,nbits); + if (alpha) swf_SetBits(t,cx->a0,nbits); } if (hasadd) - { SetBits(t,cx->r1,nbits); - SetBits(t,cx->g1,nbits); - SetBits(t,cx->b1,nbits); - if (alpha) SetBits(t,cx->a1,nbits); + { swf_SetBits(t,cx->r1,nbits); + swf_SetBits(t,cx->g1,nbits); + swf_SetBits(t,cx->b1,nbits); + if (alpha) swf_SetBits(t,cx->a1,nbits); } return 0; } -int GetPoint(TAG * t,SPOINT * p) { return 0; } -int SetPoint(TAG * t,SPOINT * p) { return 0; } +int swf_GetPoint(TAG * t,SPOINT * p) { return 0; } +int swf_SetPoint(TAG * t,SPOINT * p) { return 0; } // Tag List Manipulating Functions @@ -489,9 +489,9 @@ int RFXSWF_UpdateFrame(TAG * t,S8 delta) return res; } -#define UpdateFrame(a,b) RFXSWF_UpdateFrame(a,b) +#define swf_UpdateFrame(a,b) RFXSWF_UpdateFrame(a,b) -TAG * InsertTag(TAG * after,U16 id) // updates frames, if nescessary +TAG * swf_InsertTag(TAG * after,U16 id) // updates frames, if nescessary { TAG * t; t = (TAG *)malloc(sizeof(TAG)); @@ -507,16 +507,16 @@ TAG * InsertTag(TAG * after,U16 id) // updates frames, if nescessary after->next = t; if (t->next) t->next->prev = t; - if (id==ST_SHOWFRAME) UpdateFrame(t->next,+1); + if (id==ST_SHOWFRAME) swf_UpdateFrame(t->next,+1); } } return t; } -int DeleteTag(TAG * t) +int swf_DeleteTag(TAG * t) { if (!t) return -1; - if (t->id==ST_SHOWFRAME) UpdateFrame(t->next,-1); + if (t->id==ST_SHOWFRAME) swf_UpdateFrame(t->next,-1); if (t->prev) t->prev->next = t->next; if (t->next) t->next->prev = t->prev; @@ -581,7 +581,7 @@ TAG * RFXSWF_ReadTag(int handle,TAG * prev) return t; } -int DefineSprite_GetRealSize(TAG * t); +int RFXSWF_DefineSprite_GetRealSize(TAG * t); int RFXSWF_WriteTag(int handle,TAG * t) // returns tag length in bytes (incl. Header), -1 = Error @@ -592,7 +592,7 @@ int RFXSWF_WriteTag(int handle,TAG * t) if (!t) return -1; - len = (t->id==ST_DEFINESPRITE)?DefineSprite_GetRealSize(t):t->len; + len = (t->id==ST_DEFINESPRITE)?RFXSWF_DefineSprite_GetRealSize(t):t->len; short_tag = len<0x3f; @@ -637,23 +637,23 @@ int RFXSWF_WriteTag(int handle,TAG * t) return t->len+(short_tag?2:6); } -int DefineSprite_GetRealSize(TAG * t) +int RFXSWF_DefineSprite_GetRealSize(TAG * t) // Sprite Handling: Helper function to pack DefineSprite-Tag { U32 len = t->len; do - { t = NextTag(t); + { t = swf_NextTag(t); if (t->id!=ST_DEFINESPRITE) len += RFXSWF_WriteTag(-1,t); else t = NULL; } while (t&&(t->id!=ST_END)); return len; } -#define ReadTag(a,b) RFXSWF_ReadTag(a,b) -#define WriteTag(a,b) RFXSWF_WriteTag(a,b) +#define swf_ReadTag(a,b) RFXSWF_ReadTag(a,b) +#define swf_WriteTag(a,b) RFXSWF_WriteTag(a,b) // Movie Functions -int ReadSWF(int handle,SWF * swf) // Reads SWF to memory (malloc'ed), returns length or <0 if fails +int swf_ReadSWF(int handle,SWF * swf) // Reads SWF to memory (malloc'ed), returns length or <0 if fails { if (!swf) return -1; memset(swf,0x00,sizeof(SWF)); @@ -667,29 +667,29 @@ int ReadSWF(int handle,SWF * swf) // Reads SWF to memory (malloc'ed), retu if ((t1.len=read(handle,b,32))<21) return -1; t1.data = (U8*)b; - if (GetU8(&t1)!=(U8)'F') return -1; - if (GetU8(&t1)!=(U8)'W') return -1; - if (GetU8(&t1)!=(U8)'S') return -1; + if (swf_GetU8(&t1)!=(U8)'F') return -1; + if (swf_GetU8(&t1)!=(U8)'W') return -1; + if (swf_GetU8(&t1)!=(U8)'S') return -1; - swf->FileVersion = GetU8(&t1); - swf->FileSize = GetU32(&t1); - GetRect(&t1,&swf->MovieSize); - swf->FrameRate = GetU16(&t1); - swf->FrameCount = GetU16(&t1); + swf->fileVersion = swf_GetU8(&t1); + swf->fileSize = swf_GetU32(&t1); + swf_GetRect(&t1,&swf->movieSize); + swf->frameRate = swf_GetU16(&t1); + swf->frameCount = swf_GetU16(&t1); - GetU8(&t1); - lseek(handle,GetTagPos(&t1)-1,SEEK_SET); + swf_GetU8(&t1); + lseek(handle,swf_GetTagPos(&t1)-1,SEEK_SET); // reda tags and connect to list t = &t1; - while (t) t = ReadTag(handle,t); - swf->FirstTag = t1.next; + while (t) t = swf_ReadTag(handle,t); + swf->firstTag = t1.next; t1.next->prev = NULL; } return 0; } -int WriteSWF(int handle,SWF * swf) // Writes SWF to file, returns length or <0 if fails +int swf_WriteSWF(int handle,SWF * swf) // Writes SWF to file, returns length or <0 if fails { U32 len; TAG * t; @@ -699,22 +699,22 @@ int WriteSWF(int handle,SWF * swf) // Writes SWF to file, returns length or #ifdef INSERT_RFX_TAG - if (NextTag(swf->FirstTag)) - if (GetTagID(NextTag(swf->FirstTag))!=ST_REFLEX) - SetBlock(InsertTag(swf->FirstTag,ST_REFLEX),"rfx",3); + if (swf_NextTag(swf->firstTag)) + if (swf_GetTagID(swf_NextTag(swf->firstTag))!=ST_REFLEX) + swf_SetBlock(swf_InsertTag(swf->firstTag,ST_REFLEX),"rfx",3); #endif // INSERT_RFX_TAG // Count Frames + File Size len = 0; - t = swf->FirstTag; - swf->FrameCount = 0; + t = swf->firstTag; + swf->frameCount = 0; while(t) - { len += WriteTag(-1,t); - if (t->id==ST_SHOWFRAME) swf->FrameCount++; - t = NextTag(t); + { len += swf_WriteTag(-1,t); + if (t->id==ST_SHOWFRAME) swf->frameCount++; + t = swf_NextTag(t); } { TAG t1; @@ -725,20 +725,20 @@ int WriteSWF(int handle,SWF * swf) // Writes SWF to file, returns length or t1.data = (U8*)b; t1.memsize = 64; - SetU8(&t1,'F'); - SetU8(&t1,'W'); - SetU8(&t1,'S'); - SetU8(&t1,swf->FileVersion); + swf_SetU8(&t1,'F'); + swf_SetU8(&t1,'W'); + swf_SetU8(&t1,'S'); + swf_SetU8(&t1,swf->fileVersion); - SetU32(&t1,0); // Keep space for filesize - SetRect(&t1,&swf->MovieSize); - SetU16(&t1,swf->FrameRate); - SetU16(&t1,swf->FrameCount); + swf_SetU32(&t1,0); // Keep space for filesize + swf_SetRect(&t1,&swf->movieSize); + swf_SetU16(&t1,swf->frameRate); + swf_SetU16(&t1,swf->frameCount); - l = GetDataSize(&t1); - swf->FileSize = l+len; + l = swf_GetDataSize(&t1); + swf->fileSize = l+len; t1.len = 4; // bad & ugly trick ! - SetU32(&t1,swf->FileSize); + swf_SetU32(&t1,swf->fileSize); if (handle>=0) { @@ -753,21 +753,21 @@ int WriteSWF(int handle,SWF * swf) // Writes SWF to file, returns length or return -1; } - t = swf->FirstTag; + t = swf->firstTag; while (t) - { if (WriteTag(handle,t)<0) return -1; - t = NextTag(t); + { if (swf_WriteTag(handle,t)<0) return -1; + t = swf_NextTag(t); } } } - return (int)swf->FileSize; + return (int)swf->fileSize; } int WriteCGI(SWF * swf) { int len; char s[1024]; - len = WriteSWF(-1,swf); + len = swf_WriteSWF(-1,swf); if (len<0) return -1; @@ -778,11 +778,11 @@ int WriteCGI(SWF * swf) "\n",len); write(fileno(stdout),s,strlen(s)); - return WriteSWF(fileno(stdout),swf); + return swf_WriteSWF(fileno(stdout),swf); } -void FreeTags(SWF * swf) // Frees all malloc'ed memory for tags -{ TAG * t = swf->FirstTag; +void swf_FreeTags(SWF * swf) // Frees all malloc'ed memory for tags +{ TAG * t = swf->firstTag; while (t) { TAG * tnew = t->next; diff --git a/lib/rfxswf.h b/lib/rfxswf.h index fc9afd5..731222e 100644 --- a/lib/rfxswf.h +++ b/lib/rfxswf.h @@ -17,7 +17,6 @@ #include #include #include "../config.h" -#include "old_rfxswf.h" #define DEBUG_RFXSWF @@ -98,76 +97,76 @@ typedef struct _ActionTAG typedef struct _SWF -{ U8 FileVersion; - U32 FileSize; // valid after load and save - SRECT MovieSize; - U16 FrameRate; - U16 FrameCount; // valid after load and save - TAG * FirstTag; +{ U8 fileVersion; + U32 fileSize; // valid after load and save + SRECT movieSize; + U16 frameRate; + U16 frameCount; // valid after load and save + TAG * firstTag; } SWF, * LPSWF; // Basic Functions -int ReadSWF(int handle,SWF * swf); // Reads SWF to memory (malloc'ed), returns length or <0 if fails -int WriteSWF(int handle,SWF * swf); // Writes SWF to file, returns length or <0 if fails -int WriteCGI(SWF * swf); // Outputs SWF with valid CGI header to stdout -void FreeTags(SWF * swf); // Frees all malloc'ed memory for swf +int swf_ReadSWF(int handle,SWF * swf); // Reads SWF to memory (malloc'ed), returns length or <0 if fails +int swf_WriteSWF(int handle,SWF * swf); // Writes SWF to file, returns length or <0 if fails +int swf_WriteCGI(SWF * swf); // Outputs SWF with valid CGI header to stdout +void swf_FreeTags(SWF * swf); // Frees all malloc'ed memory for swf -TAG * InsertTag(TAG * after,U16 id); // updates frames, if necessary -int DeleteTag(TAG * t); +TAG * swf_InsertTag(TAG * after,U16 id); // updates frames, if necessary +int swf_DeleteTag(TAG * t); -void SetTagPos(TAG * t,U32 pos); // resets Bitcount -U32 GetTagPos(TAG * t); +void swf_SetTagPos(TAG * t,U32 pos); // resets Bitcount +U32 swf_GetTagPos(TAG * t); -TAG * NextTag(TAG * t); -TAG * PrevTag(TAG * t); +TAG * swf_NextTag(TAG * t); +TAG * swf_PrevTag(TAG * t); -int GetFrameNo(TAG * t); // should be renamed to TagGetFrame -U16 GetTagID(TAG * t); // ... TagGetID -U32 GetDataSize(TAG * t); // ... TagGetDataSize -U8* GetDataSizePtr(TAG * t); +int swf_GetFrameNo(TAG * t); // should be renamed to TagGetFrame +U16 swf_GetTagID(TAG * t); // ... TagGetID +U32 swf_GetDataSize(TAG * t); // ... TagGetDataSize +U8* swf_GetDataSizePtr(TAG * t); -U32 GetBits(TAG * t,int nbits); -S32 GetSBits(TAG * t,int nbits); -int SetBits(TAG * t,U32 v,int nbits); +U32 swf_GetBits(TAG * t,int nbits); +S32 swf_GetSBits(TAG * t,int nbits); +int swf_SetBits(TAG * t,U32 v,int nbits); -int GetBlock(TAG * t,U8 * b,int l); // resets Bitcount -int SetBlock(TAG * t,U8 * b,int l); +int swf_GetBlock(TAG * t,U8 * b,int l); // resets Bitcount +int swf_SetBlock(TAG * t,U8 * b,int l); -U8 GetU8(TAG * t); // resets Bitcount -U16 GetU16(TAG * t); -U32 GetU32(TAG * t); +U8 swf_GetU8(TAG * t); // resets Bitcount +U16 swf_GetU16(TAG * t); +U32 swf_GetU32(TAG * t); -int SetU8(TAG * t,U8 v); // resets Bitcount -int SetU16(TAG * t,U16 v); -int SetU32(TAG * t,U32 v); +int swf_SetU8(TAG * t,U8 v); // resets Bitcount +int swf_SetU16(TAG * t,U16 v); +int swf_SetU32(TAG * t,U32 v); -int GetPoint(TAG * t,SPOINT * p); // resets Bitcount -int GetRect(TAG * t,SRECT * r); -int GetMatrix(TAG * t,MATRIX * m); -int GetCXForm(TAG * t,CXFORM * cx,U8 alpha); +int swf_GetPoint(TAG * t,SPOINT * p); // resets Bitcount +int swf_GetRect(TAG * t,SRECT * r); +int swf_GetMatrix(TAG * t,MATRIX * m); +int swf_GetCXForm(TAG * t,CXFORM * cx,U8 alpha); -int SetPoint(TAG * t,SPOINT * p); // resets Bitcount -int SetRect(TAG * t,SRECT * r); -int SetMatrix(TAG * t,MATRIX * m); -int SetCXForm(TAG * t,CXFORM * cx,U8 alpha); -int SetRGB(TAG * t,RGBA * col); -int SetRGBA(TAG * t,RGBA * col); +int swf_SetPoint(TAG * t,SPOINT * p); // resets Bitcount +int swf_SetRect(TAG * t,SRECT * r); +int swf_SetMatrix(TAG * t,MATRIX * m); +int swf_SetCXForm(TAG * t,CXFORM * cx,U8 alpha); +int swf_SetRGB(TAG * t,RGBA * col); +int swf_SetRGBA(TAG * t,RGBA * col); // Function Macros -#define GetS8(tag) ((S8)GetU8(tag)) -#define GetS16(tag) ((S16)GetU16(tag)) -#define GetS32(tag) ((S32)GetU32(tag)) -#define GetCoord(tag) ((SCOORD)GetU32(tag)) -#define GetFixed(tag) ((SFIXED)GetU32(tag)) +#define swf_GetS8(tag) ((S8)swf_GetU8(tag)) +#define swf_GetS16(tag) ((S16)swf_GetU16(tag)) +#define swf_GetS32(tag) ((S32)swf_GetU32(tag)) +#define swf_GetCoord(tag) ((SCOORD)swf_GetU32(tag)) +#define swf_GetFixed(tag) ((SFIXED)swf_GetU32(tag)) -#define SetS8(tag,v) SetU8(tag,(U8)v) -#define SetS16(tag,v) SetU16(tag,(U16)v) -#define SetS32(tag,v) SetU32(tag,(U32)v) -#define SetCoord(tag,v) SetU32(tag,(U32)v) -#define SetFixed(tag,v) SetU32(tag,(U32)v) -#define SetString(t,s) SetBlock(t,s,strlen(s)+1) +#define swf_SetS8(tag,v) swf_SetU8(tag,(U8)v) +#define swf_SetS16(tag,v) swf_SetU16(tag,(U16)v) +#define swf_SetS32(tag,v) swf_SetU32(tag,(U32)v) +#define swf_SetCoord(tag,v) swf_SetU32(tag,(U32)v) +#define swf_SetFixed(tag,v) swf_SetU32(tag,(U32)v) +#define swf_SetString(t,s) swf_SetBlock(t,s,strlen(s)+1) #define FAILED(b) ((b)<0) #define SUCCEDED(b) ((b)>=0) @@ -225,10 +224,10 @@ int SetRGBA(TAG * t,RGBA * col); // swfdump.c -void DumpHeader(FILE * f,SWF * swf); -void DumpMatrix(FILE * f,MATRIX * m); -void DumpTag(FILE * f,TAG * t); -char* getTagName(TAG*tag); +void swf_DumpHeader(FILE * f,SWF * swf); +void swf_DumpMatrix(FILE * f,MATRIX * m); +void swf_DumpTag(FILE * f,TAG * t); +char* swf_TagGetName(TAG*tag); // swfshape.c @@ -270,29 +269,29 @@ typedef struct _SHAPE // NEVER access a Shape-Struct directly ! // Shapes -int NewShape(SHAPE ** s); -void ShapeFree(SHAPE * s); +int swf_ShapeNew(SHAPE ** s); +void swf_ShapeFree(SHAPE * s); -int GetSimpleShape(TAG * t,SHAPE ** s); // without Linestyle/Fillstyle Record -int SetSimpleShape(TAG * t,SHAPE * s); // without Linestyle/Fillstyle Record +int swf_GetSimpleShape(TAG * t,SHAPE ** s); // without Linestyle/Fillstyle Record +int swf_SetSimpleShape(TAG * t,SHAPE * s); // without Linestyle/Fillstyle Record -int ShapeAddLineStyle(SHAPE * s,U16 width,RGBA * color); -int ShapeAddSolidFillStyle(SHAPE * s,RGBA * color); -int ShapeAddBitmapFillStyle(SHAPE * s,MATRIX * m,U16 id_bitmap,int clip); +int swf_ShapeAddLineStyle(SHAPE * s,U16 width,RGBA * color); +int swf_ShapeAddSolidFillStyle(SHAPE * s,RGBA * color); +int swf_ShapeAddBitmapFillStyle(SHAPE * s,MATRIX * m,U16 id_bitmap,int clip); -int SetShapeStyles(TAG * t,SHAPE * s); -int ShapeCountBits(SHAPE * s,U8 * fbits,U8 * lbits); -int SetShapeBits(TAG * t,SHAPE * s); -int SetShapeHeader(TAG * t,SHAPE * s); // one call for upper three functions +int swf_SetShapeStyles(TAG * t,SHAPE * s); +int swf_ShapeCountBits(SHAPE * s,U8 * fbits,U8 * lbits); +int swf_SetShapeBits(TAG * t,SHAPE * s); +int swf_SetShapeHeader(TAG * t,SHAPE * s); // one call for upper three functions -int ShapeSetMove(TAG * t,SHAPE * s,S32 x,S32 y); -int ShapeSetStyle(TAG * t,SHAPE * s,U16 line,U16 fill0,U16 fill1); -int ShapeSetAll(TAG * t,SHAPE * s,S32 x,S32 y,U16 line,U16 fill0,U16 fill1); +int swf_ShapeSetMove(TAG * t,SHAPE * s,S32 x,S32 y); +int swf_ShapeSetStyle(TAG * t,SHAPE * s,U16 line,U16 fill0,U16 fill1); +int swf_ShapeSetAll(TAG * t,SHAPE * s,S32 x,S32 y,U16 line,U16 fill0,U16 fill1); -int ShapeSetLine(TAG * t,SHAPE * s,S32 x,S32 y); -int ShapeSetCurve(TAG * t,SHAPE * s,S32 x,S32 y,S32 ax,S32 ay); -int ShapeSetCircle(TAG * t,SHAPE * s,S32 x,S32 y,S32 rx,S32 ry); -int ShapeSetEnd(TAG * t); +int swf_ShapeSetLine(TAG * t,SHAPE * s,S32 x,S32 y); +int swf_ShapeSetCurve(TAG * t,SHAPE * s,S32 x,S32 y,S32 ax,S32 ay); +int swf_ShapeSetCircle(TAG * t,SHAPE * s,S32 x,S32 y,S32 rx,S32 ry); +int swf_ShapeSetEnd(TAG * t); // swffont.c @@ -332,37 +331,37 @@ typedef struct _FONTUSAGE { U8 code[MAX_CHAR_PER_FONT]; } FONTUSAGE, * LPFONTUSAGE; -int FontEnumerate(SWF * swf,void (*FontCallback) (U16,U8*)); +int swf_FontEnumerate(SWF * swf,void (*FontCallback) (U16,U8*)); // -> void fontcallback(U16 id,U8 * name); returns number of defined fonts -int FontExtract(SWF * swf,int id,SWFFONT ** f); +int swf_FontExtract(SWF * swf,int id,SWFFONT ** f); // Fetches all available information from DefineFont, DefineFontInfo, DefineText, ... // id = FontID, id=0 -> Extract first Font -int FontIsItalic(SWFFONT * f); -int FontIsBold(SWFFONT * f); +int swf_FontIsItalic(SWFFONT * f); +int swf_FontIsBold(SWFFONT * f); -int FontSetID(SWFFONT * f,U16 id); -int FontReduce(SWFFONT * f,FONTUSAGE * use); +int swf_FontSetID(SWFFONT * f,U16 id); +int swf_FontReduce(SWFFONT * f,FONTUSAGE * use); -int FontInitUsage(FONTUSAGE * use); -int FontUse(FONTUSAGE * use,U8 * s); +int swf_FontInitUsage(FONTUSAGE * use); +int swf_FontUse(FONTUSAGE * use,U8 * s); -int FontSetDefine(TAG * t,SWFFONT * f); -int FontSetInfo(TAG * t,SWFFONT * f); +int swf_FontSetDefine(TAG * t,SWFFONT * f); +int swf_FontSetInfo(TAG * t,SWFFONT * f); -int FontExport(int handle,SWFFONT * f); -int FontImport(int handle,SWFFONT * * f); +int swf_FontExport(int handle,SWFFONT * f); +int swf_FontImport(int handle,SWFFONT * * f); -void FontFree(SWFFONT * f); +void swf_FontFree(SWFFONT * f); -U32 TextGetWidth(SWFFONT * font,U8 * s,int scale); -int TextCountBits(SWFFONT * font,U8 * s,int scale,U8 * gbits,U8 * abits); +U32 swf_TextGetWidth(SWFFONT * font,U8 * s,int scale); +int swf_TextCountBits(SWFFONT * font,U8 * s,int scale,U8 * gbits,U8 * abits); -int TextSetInfoRecord(TAG * t,SWFFONT * font,U16 size,RGBA * color,S16 dx,S16 dy); -int TextSetCharRecord(TAG * t,SWFFONT * font,U8 * s,int scale,U8 gbits,U8 abits); +int swf_TextSetInfoRecord(TAG * t,SWFFONT * font,U16 size,RGBA * color,S16 dx,S16 dy); +int swf_TextSetCharRecord(TAG * t,SWFFONT * font,U8 * s,int scale,U8 gbits,U8 abits); -int TextPrintDefineText(TAG * t,SWFFONT * f); +int swf_TextPrintDefineText(TAG * t,SWFFONT * f); // Prints text defined in tag t with font f to stdout @@ -370,9 +369,9 @@ int TextPrintDefineText(TAG * t,SWFFONT * f); // Always use ST_PLACEOBJECT2 !!! -int ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name); -int PlaceObject(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U16 clipaction); -int ObjectMove(TAG * t,U16 depth,MATRIX * m,CXFORM * cx); +int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name); +int swf_ObjectPlaceClip(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U16 clipaction); +int swf_ObjectMove(TAG * t,U16 depth,MATRIX * m,CXFORM * cx); // swfbutton.c @@ -416,21 +415,21 @@ int ObjectMove(TAG * t,U16 depth,MATRIX * m,CXFORM * cx); #define BF_TRACKMENU 0x01 -int ButtonSetRecord(TAG * t,U8 state,U16 id,U16 layer,MATRIX * m,CXFORM * cx); -int ButtonSetCondition(TAG * t,U16 condition); // for DefineButton2 -int ButtonSetFlags(TAG * t,U8 flags); // necessary for DefineButton2 -int ButtonPostProcess(TAG * t,int anz_action); // Set all offsets in DefineButton2-Tags (how many conditions to process) +int swf_ButtonSetRecord(TAG * t,U8 state,U16 id,U16 layer,MATRIX * m,CXFORM * cx); +int swf_ButtonSetCondition(TAG * t,U16 condition); // for DefineButton2 +int swf_ButtonSetFlags(TAG * t,U8 flags); // necessary for DefineButton2 +int swf_ButtonPostProcess(TAG * t,int anz_action); // Set all offsets in DefineButton2-Tags (how many conditions to process) // swfbits.c typedef int JPEGBITS,* LPJPEGBITS; // cover libjpeg structures -JPEGBITS * SetJPEGBitsStart(TAG * t,int width,int height,int quality); -int SetJPEGBitsLines(JPEGBITS * jpegbits,U8 ** data,int n); -int SetJPEGBitsLine(JPEGBITS * jpegbits,U8 * data); -int SetJPEGBitsFinish(JPEGBITS * jpegbits); +JPEGBITS * swf_SetJPEGBitsStart(TAG * t,int width,int height,int quality); +int swf_SetJPEGBitsLines(JPEGBITS * jpegbits,U8 ** data,int n); +int swf_SetJPEGBitsLine(JPEGBITS * jpegbits,U8 * data); +int swf_SetJPEGBitsFinish(JPEGBITS * jpegbits); -int SetJPEGBits(TAG * t,char * fname,int quality); // paste jpg file into swf stream +int swf_SetJPEGBits(TAG * t,char * fname,int quality); // paste jpg file into swf stream #define BYTES_PER_SCANLINE(width) ((width+3)&0xfffffffc) @@ -446,30 +445,30 @@ int SetJPEGBits(TAG * t,char * fname,int quality); // paste jpg file into swf st #define BM32_GREEN 0x00ff0000 #define BM32_RED 0x0000ff00 -int SetLosslessBits(TAG * t,U16 width,U16 height,void * bitmap,U8 bitmap_flags); -int SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * palette,U16 ncolors); -int SetLosslessBitsGrayscale(TAG * t,U16 width,U16 height,U8 * bitmap); +int swf_SetLosslessBits(TAG * t,U16 width,U16 height,void * bitmap,U8 bitmap_flags); +int swf_SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * palette,U16 ncolors); +int swf_SetLosslessBitsGrayscale(TAG * t,U16 width,U16 height,U8 * bitmap); // swftools.c -char isDefiningTag(TAG * t); -char isAllowedSpriteTag(TAG * t); -U16 GetDefineID(TAG * t); -U16 GetPlaceID(TAG * t); //PLACEOBJECT, PLACEOBJECT2 (sometimes), REMOVEOBJECT -U16 GetDepth(TAG * t); //PLACEOBJECT,PLACEOBJECT2,REMOVEOBJECT,REMOVEOBJECT2 -char* GetName(TAG * t); //PLACEOBJECT2, FRAMELABEL -MATRIX * MatrixJoin(MATRIX * d,MATRIX * s1,MATRIX * s2); -MATRIX * MatrixMapTriangle(MATRIX * m,int dx,int dy, +U8 swf_isDefiningTag(TAG * t); +U8 swf_isAllowedSpriteTag(TAG * t); +U16 swf_GetDefineID(TAG * t); +U16 swf_GetPlaceID(TAG * t); //PLACEOBJECT, PLACEOBJECT2 (sometimes), REMOVEOBJECT +U16 swf_GetDepth(TAG * t); //PLACEOBJECT,PLACEOBJECT2,REMOVEOBJECT,REMOVEOBJECT2 +char* swf_GetTagName(TAG * t); //PLACEOBJECT2, FRAMELABEL +MATRIX * swf_MatrixJoin(MATRIX * d,MATRIX * s1,MATRIX * s2); +MATRIX * swf_MatrixMapTriangle(MATRIX * m,int dx,int dy, int x0,int y0,int x1,int y1,int x2,int y2); // swfcgi.c -void uncgi(); // same behaviour as Steven Grimm's uncgi-library +void swf_uncgi(); // same behaviour as Steven Grimm's uncgi-library // swfaction.c -ActionTAG* GetActions(TAG*tag); -void DumpActions(ActionTAG*atag, char*prefix); +ActionTAG* swf_GetActions(TAG*tag); +void swf_DumpActions(ActionTAG*atag, char*prefix); #endif diff --git a/pdf2swf/Makefile.in b/pdf2swf/Makefile.in index 487e1ab..b8e0ec4 100644 --- a/pdf2swf/Makefile.in +++ b/pdf2swf/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -102,7 +102,7 @@ DIST_COMMON = Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best DEP_FILES = .deps/pdf2swf.P .deps/pdfswf.P .deps/spline.P \ .deps/swfoutput.P diff --git a/pdf2swf/fonts/Makefile.in b/pdf2swf/fonts/Makefile.in index aefcc13..a6876ff 100644 --- a/pdf2swf/fonts/Makefile.in +++ b/pdf2swf/fonts/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -76,7 +76,7 @@ DIST_COMMON = Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index 1890e97..3fd1379 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -88,7 +88,7 @@ void moveto(TAG*tag, plotxy p0) int rx = (int)(p0.x*20); int ry = (int)(p0.y*20); if(rx!=swflastx || ry!=swflasty) { - ShapeSetMove (tag, shape, rx,ry); + swf_ShapeSetMove (tag, shape, rx,ry); } swflastx=rx; swflasty=ry; @@ -101,7 +101,7 @@ void lineto(TAG*tag, plotxy p0) int ry = ((int)(p0.y*20)-swflasty); /* we can't skip this for rx=0,ry=0, those are plots */ - ShapeSetLine (tag, shape, rx,ry); + swf_ShapeSetLine (tag, shape, rx,ry); swflastx+=rx; swflasty+=ry; } @@ -117,7 +117,7 @@ void splineto(TAG*tag, plotxy control,plotxy end) int ey = ((int)(end.y*20)-swflasty); swflastx += ex; swflasty += ey; - ShapeSetCurve(tag, shape, cx,cy,ex,ey); + swf_ShapeSetCurve(tag, shape, cx,cy,ex,ey); } /* write a line, given two points and the transformation @@ -145,8 +145,8 @@ void spline(TAG*tag,plotxy p0,plotxy p1,plotxy p2,plotxy p3,struct swfmatrix*m) num = approximate(p0,p1,p2,p3,q); for(t=0;tid != ST_DEFINEFONT && - tag->id != ST_DEFINESHAPE && - tag->id != ST_DEFINESHAPE2 && - tag->id != ST_DEFINESHAPE3) + tag->id != ST_DEFINESHAPE && + tag->id != ST_DEFINESHAPE2 && + tag->id != ST_DEFINESHAPE3) { - logf(" internal error: drawpath needs a shape tag, not %d\n",tag->id); - exit(1); + logf(" internal error: drawpath needs a shape tag, not %d\n",tag->id); + exit(1); } int log = 0; @@ -171,75 +171,75 @@ void drawpath(TAG*tag, T1_OUTLINE*outline, struct swfmatrix*m) while (outline) { - x += (outline->dest.x/(float)0xffff); - y += (outline->dest.y/(float)0xffff); - if(outline->type == T1_PATHTYPE_MOVE) - { - if(((int)(lastx*20) != (int)(firstx*20) || - (int)(lasty*20) != (int)(firsty*20)) && - fill && !init) - { - plotxy p0; - plotxy p1; - p0.x=lastx; - p0.y=lasty; - p1.x=firstx; - p1.y=firsty; - if(log) printf("fix: %f,%f -> %f,%f\n",p0.x,p0.y,p1.x,p1.y); - line(tag, p0, p1, m); - } - firstx=x; - firsty=y; - init = 0; - } - else if(outline->type == T1_PATHTYPE_LINE) - { - plotxy p0; - plotxy p1; - p0.x=lastx; - p0.y=lasty; - p1.x=x; - p1.y=y; - if(log) printf("line: %f,%f -> %f,%f\n",p0.x,p0.y,p1.x,p1.y); - line(tag, p0,p1,m); - } - else if(outline->type == T1_PATHTYPE_BEZIER) - { - plotxy p0; - plotxy p1; - plotxy p2; - plotxy p3; - T1_BEZIERSEGMENT*o2 = (T1_BEZIERSEGMENT*)outline; - p0.x=x; - p0.y=y; - p1.x=o2->C.x/(float)0xffff+lastx; - p1.y=o2->C.y/(float)0xffff+lasty; - p2.x=o2->B.x/(float)0xffff+lastx; - p2.y=o2->B.y/(float)0xffff+lasty; - p3.x=lastx; - p3.y=lasty; - if(log) printf("spline: %f,%f -> %f,%f\n",p3.x,p3.y,p0.x,p0.y); - spline(tag,p0,p1,p2,p3,m); - } - else { - logf(" drawpath: unknown outline type:%d\n", outline->type); - } - lastx=x; - lasty=y; - outline = outline->link; + x += (outline->dest.x/(float)0xffff); + y += (outline->dest.y/(float)0xffff); + if(outline->type == T1_PATHTYPE_MOVE) + { + if(((int)(lastx*20) != (int)(firstx*20) || + (int)(lasty*20) != (int)(firsty*20)) && + fill && !init) + { + plotxy p0; + plotxy p1; + p0.x=lastx; + p0.y=lasty; + p1.x=firstx; + p1.y=firsty; + if(log) printf("fix: %f,%f -> %f,%f\n",p0.x,p0.y,p1.x,p1.y); + line(tag, p0, p1, m); + } + firstx=x; + firsty=y; + init = 0; + } + else if(outline->type == T1_PATHTYPE_LINE) + { + plotxy p0; + plotxy p1; + p0.x=lastx; + p0.y=lasty; + p1.x=x; + p1.y=y; + if(log) printf("line: %f,%f -> %f,%f\n",p0.x,p0.y,p1.x,p1.y); + line(tag, p0,p1,m); + } + else if(outline->type == T1_PATHTYPE_BEZIER) + { + plotxy p0; + plotxy p1; + plotxy p2; + plotxy p3; + T1_BEZIERSEGMENT*o2 = (T1_BEZIERSEGMENT*)outline; + p0.x=x; + p0.y=y; + p1.x=o2->C.x/(float)0xffff+lastx; + p1.y=o2->C.y/(float)0xffff+lasty; + p2.x=o2->B.x/(float)0xffff+lastx; + p2.y=o2->B.y/(float)0xffff+lasty; + p3.x=lastx; + p3.y=lasty; + if(log) printf("spline: %f,%f -> %f,%f\n",p3.x,p3.y,p0.x,p0.y); + spline(tag,p0,p1,p2,p3,m); + } + else { + logf(" drawpath: unknown outline type:%d\n", outline->type); + } + lastx=x; + lasty=y; + outline = outline->link; } if(((int)(lastx*20) != (int)(firstx*20) || - (int)(lasty*20) != (int)(firsty*20)) && - fill) + (int)(lasty*20) != (int)(firsty*20)) && + fill) { - plotxy p0; - plotxy p1; - p0.x=lastx; - p0.y=lasty; - p1.x=firstx; - p1.y=firsty; - if(log) printf("fix: %f,%f -> %f,%f\n",p0.x,p0.y,p1.x,p1.y); - line(tag, p0, p1, m); + plotxy p0; + plotxy p1; + p0.x=lastx; + p0.y=lasty; + p1.x=firstx; + p1.y=firsty; + if(log) printf("fix: %f,%f -> %f,%f\n",p0.x,p0.y,p1.x,p1.y); + line(tag, p0, p1, m); } } @@ -250,7 +250,7 @@ int colorcompare(RGBA*a,RGBA*b) a->g!=b->g || a->b!=b->b || a->a!=b->a) { - return 0; + return 0; } return 1; } @@ -287,124 +287,124 @@ void putcharacters(TAG*tag) int advancebits=1; if(tag->id != ST_DEFINETEXT && - tag->id != ST_DEFINETEXT2) { - logf(" internal error: putcharacters needs an text tag, not %d\n",tag->id); - exit(1); + tag->id != ST_DEFINETEXT2) { + logf(" internal error: putcharacters needs an text tag, not %d\n",tag->id); + exit(1); } if(!chardatapos) { - logf(" putcharacters called with zero characters"); + logf(" putcharacters called with zero characters"); } for(pass = 0; pass < 2; pass++) { - charstorepos = 0; - lastfontid = -1; - lastx = CHARMIDX; - lasty = CHARMIDY; - lastsize = -1; - - if(pass==1) - { - advancebits++; // add sign bit - SetU8(tag, glyphbits); - SetU8(tag, advancebits); + charstorepos = 0; + lastfontid = -1; + lastx = CHARMIDX; + lasty = CHARMIDY; + lastsize = -1; + + if(pass==1) + { + advancebits++; // add sign bit + swf_SetU8(tag, glyphbits); + swf_SetU8(tag, advancebits); } - for(t=0;t<=chardatapos;t++) - { - if(lastfontid != chardata[t].fontid || - lastx!=chardata[t].x || - lasty!=chardata[t].y || - !colorcompare(&color, &chardata[t].color) || - charstorepos==127 || - lastsize != chardata[t].size || - t == chardatapos) - { - if(charstorepos && pass==0) - { - int s; - for(s=0;s=(1<=(1<bitcount = 0; - SetBits(tag, 0, 1); // GLYPH Record - SetBits(tag, charstorepos, 7); // number of glyphs - int s; - for(s=0;sbitcount = 0; - TextSetInfoRecord(tag, newfont, chardata[t].size, newcolor, newx,newy); - } - - lastfontid = chardata[t].fontid; - lastx = chardata[t].x; - lasty = chardata[t].y; - lastsize = chardata[t].size; - } - - if(t==chardatapos) - break; - - int advance; - int nextt = t==chardatapos-1?t:t+1; - int rel = chardata[nextt].x-chardata[t].x; - if(rel>=0 && (rel<(1<<(advancebits-1)) || pass==0)) { - advance = rel; - lastx=chardata[nextt].x; - } - else { - advance = 0; - lastx=chardata[t].x; - } - charids[charstorepos] = chardata[t].charid; - charadvance[charstorepos] = advance; - charstorepos ++; - } + for(t=0;t<=chardatapos;t++) + { + if(lastfontid != chardata[t].fontid || + lastx!=chardata[t].x || + lasty!=chardata[t].y || + !colorcompare(&color, &chardata[t].color) || + charstorepos==127 || + lastsize != chardata[t].size || + t == chardatapos) + { + if(charstorepos && pass==0) + { + int s; + for(s=0;s=(1<=(1<bitcount = 0; + swf_SetBits(tag, 0, 1); // GLYPH Record + swf_SetBits(tag, charstorepos, 7); // number of glyphs + int s; + for(s=0;sbitcount = 0; + swf_TextSetInfoRecord(tag, newfont, chardata[t].size, newcolor, newx,newy); + } + + lastfontid = chardata[t].fontid; + lastx = chardata[t].x; + lasty = chardata[t].y; + lastsize = chardata[t].size; + } + + if(t==chardatapos) + break; + + int advance; + int nextt = t==chardatapos-1?t:t+1; + int rel = chardata[nextt].x-chardata[t].x; + if(rel>=0 && (rel<(1<<(advancebits-1)) || pass==0)) { + advance = rel; + lastx=chardata[nextt].x; + } + else { + advance = 0; + lastx=chardata[t].x; + } + charids[charstorepos] = chardata[t].charid; + charadvance[charstorepos] = advance; + charstorepos ++; + } } chardatapos = 0; } void putcharacter(struct swfoutput*obj, int fontid, int charid, - int x,int y, int size) + int x,int y, int size) { if(chardatapos == CHARDATAMAX) { - endtext(); - starttext(obj); + endtext(); + starttext(obj); } chardata[chardatapos].fontid = fontid; chardata[chardatapos].charid = charid; @@ -421,70 +421,70 @@ void drawchar(struct swfoutput*obj, SWFFont*font, char*character, swfmatrix*m) { int usefonts=1; if(m->m12!=0 || m->m21!=0) - usefonts=0; + usefonts=0; if(m->m11 != m->m22) - usefonts=0; + usefonts=0; if(usefonts && ! drawonlyshapes) { - int charid = font->getSWFCharID(character); - if(shapeid>=0) - endshape(); - if(textid<0) - starttext(obj); - putcharacter(obj, font->swfid, charid,(int)(m->m13*20),(int)(m->m23*20), - (int)(m->m11*20/2+0.5)); //where does the /2 come from? + int charid = font->getSWFCharID(character); + if(shapeid>=0) + endshape(); + if(textid<0) + starttext(obj); + putcharacter(obj, font->swfid, charid,(int)(m->m13*20),(int)(m->m23*20), + (int)(m->m11*20/2+0.5)); //where does the /2 come from? } else { - T1_OUTLINE*outline = font->getOutline(character); - char* charname = character; - - if(!outline) { - logf(" Didn't find %s in current charset (%s)", - character,font->getName()); - return; - } - - swfmatrix m2=*m; - m2.m11/=100; - m2.m21/=100; - m2.m12/=100; - m2.m22/=100; - - if(textid>=0) - endtext(); - if(shapeid<0) - startshape(obj); - - if(!lastwasfill) - ShapeSetStyle(tag,shape,0x8000,fillstyleid,0); - lastwasfill = 1; - - int lf = fill; - fill = 1; - drawpath(tag, outline, &m2); - fill = lf; + T1_OUTLINE*outline = font->getOutline(character); + char* charname = character; + + if(!outline) { + logf(" Didn't find %s in current charset (%s)", + character,font->getName()); + return; + } + + swfmatrix m2=*m; + m2.m11/=100; + m2.m21/=100; + m2.m12/=100; + m2.m22/=100; + + if(textid>=0) + endtext(); + if(shapeid<0) + startshape(obj); + + if(!lastwasfill) + swf_ShapeSetStyle(tag,shape,0x8000,fillstyleid,0); + lastwasfill = 1; + + int lf = fill; + fill = 1; + drawpath(tag, outline, &m2); + fill = lf; } } /* draw a curved polygon. */ void swfoutput_drawpath(swfoutput*output, T1_OUTLINE*outline, - struct swfmatrix*m) + struct swfmatrix*m) { if(textid>=0) - endtext(); + endtext(); if(shapeid<0) - startshape(output); + startshape(output); if(lastwasfill && !fill) { - ShapeSetStyle(tag,shape,linestyleid,0x8000,0); + swf_ShapeSetStyle(tag,shape,linestyleid,0x8000,0); lastwasfill = 0; } if(!lastwasfill && fill) { - ShapeSetStyle(tag,shape,0x8000,fillstyleid,0); + swf_ShapeSetStyle(tag,shape,0x8000,fillstyleid,0); lastwasfill = 1; } @@ -496,7 +496,7 @@ void swfoutput_drawpath(swfoutput*output, T1_OUTLINE*outline, SWFFont::SWFFont(char*name, int id, char*filename) { if(!T1_GetFontName(id)) - T1_LoadFont(id); + T1_LoadFont(id); this->name = strdup(T1_GetFontFileName(id)); this->fontid = strdup(name); @@ -506,11 +506,11 @@ SWFFont::SWFFont(char*name, int id, char*filename) int t=0, outlinepos=0; char*map[256]; while(a[t]) - t++; + t++; this->charnum = t; if(!t) - return; + return; logf(" Font %s(%d): Storing %d outlines.\n", name, id, t); outline = (T1_OUTLINE**)malloc(t*sizeof(T1_OUTLINE*)); @@ -528,32 +528,32 @@ SWFFont::SWFFont(char*name, int id, char*filename) t=0; while(*a) { - map[t] = *a; - a++; - t++; - if(t==256 || !*a) { - int s; - for(s=t;s<256;s++) - map[s] = ".notdef"; - - int ret = T1_ReencodeFont(id, map); - if(ret) { - T1_DeleteFont(id); - T1_LoadFont(id); - int ret = T1_ReencodeFont(id, map); - if(ret) - fprintf(stderr,"Can't reencode font: (%s) ret:%d\n",filename, ret); - } - - // parsecharacters - for(s=0;soutline[outlinepos] = T1_CopyOutline(T1_GetCharOutline(id, s, 100.0, 0)); - this->charname[outlinepos] = strdup(T1_GetCharName(id, s)); - outlinepos++; - } - t=0; - } + map[t] = *a; + a++; + t++; + if(t==256 || !*a) { + int s; + for(s=t;s<256;s++) + map[s] = ".notdef"; + + int ret = T1_ReencodeFont(id, map); + if(ret) { + T1_DeleteFont(id); + T1_LoadFont(id); + int ret = T1_ReencodeFont(id, map); + if(ret) + fprintf(stderr,"Can't reencode font: (%s) ret:%d\n",filename, ret); + } + + // parsecharacters + for(s=0;soutline[outlinepos] = T1_CopyOutline(T1_GetCharOutline(id, s, 100.0, 0)); + this->charname[outlinepos] = strdup(T1_GetCharName(id, s)); + outlinepos++; + } + t=0; + } } } @@ -564,48 +564,48 @@ SWFFont::~SWFFont() int*ptr = (int*)malloc(swfcharpos*sizeof(int)); for(t=0;t Font %s has %d used characters",fontid, usednum); - TAG*ftag = InsertTag(swf.FirstTag,ST_DEFINEFONT); - SetU16(ftag, this->swfid); - int initpos = GetDataSize(ftag); - swfmatrix m; - m.m11 = m.m22 = 1; - m.m21 = m.m12 = 0; - m.m13 = CHARMIDX; - m.m23 = CHARMIDY; - for(t=0;tdata[ptr[t]] = GetDataSize(ftag)-initpos; - swflastx=0; - swflasty=0; - SetU8(ftag,0x10); //0 fill bits, 0 linestyle bits - SHAPE s; - s.bits.fill = 1; - s.bits.line = 0; - ShapeSetStyle(ftag,&s,0,1,0); - int lastfill = fill; - fill = 1; - storefont = 1; - drawpath(ftag, outline[swfcharid2char[t]],&m); - storefont = 0; - fill = lastfill; - ShapeSetEnd(ftag); - } + logf(" Font %s has %d used characters",fontid, usednum); + TAG*ftag = swf_InsertTag(swf.firstTag,ST_DEFINEFONT); + swf_SetU16(ftag, this->swfid); + int initpos = swf_GetDataSize(ftag); + swfmatrix m; + m.m11 = m.m22 = 1; + m.m21 = m.m12 = 0; + m.m13 = CHARMIDX; + m.m23 = CHARMIDY; + for(t=0;tdata[ptr[t]] = swf_GetDataSize(ftag)-initpos; + swflastx=0; + swflasty=0; + swf_SetU8(ftag,0x10); //0 fill bits, 0 linestyle bits + SHAPE s; + s.bits.fill = 1; + s.bits.line = 0; + swf_ShapeSetStyle(ftag,&s,0,1,0); + int lastfill = fill; + fill = 1; + storefont = 1; + drawpath(ftag, outline[swfcharid2char[t]],&m); + storefont = 0; + fill = lastfill; + swf_ShapeSetEnd(ftag); + } } free(ptr); free(outline); for(t=0;tcharnum;t++) { - if(!strcmp(this->charname[t],name)) { - if(!used[t]) - { - swfcharid2char[swfcharpos] = t; - char2swfcharid[t] = swfcharpos; - swfcharpos++; - used[t] = 1; - } - return outline[t]; - } + if(!strcmp(this->charname[t],name)) { + if(!used[t]) + { + swfcharid2char[swfcharpos] = t; + char2swfcharid[t] = swfcharpos; + swfcharpos++; + used[t] = 1; + } + return outline[t]; + } } return 0; } @@ -634,15 +634,15 @@ int SWFFont::getSWFCharID(char*name) { int t; for(t=0;tcharnum;t++) { - if(!strcmp(this->charname[t],name)) { - if(!used[t]) - { - swfcharid2char[swfcharpos] = t; - char2swfcharid[t] = swfcharpos++; - used[t] = 1; - } - return char2swfcharid[t]; - } + if(!strcmp(this->charname[t],name)) { + if(!used[t]) + { + swfcharid2char[swfcharpos] = t; + char2swfcharid[t] = swfcharpos++; + used[t] = 1; + } + return char2swfcharid[t]; + } } logf(" Didn't find character '%s' in font '%s'", name, this->name); return 0; @@ -664,23 +664,23 @@ void swfoutput_setfont(struct swfoutput*obj, char*fontid, int t1id, char*filenam { fontlist_t*last=0,*iterator; if(obj->font && !strcmp(obj->font->fontid,fontid)) - return; + return; iterator = fontlist; while(iterator) { - if(!strcmp(iterator->font->fontid,fontid)) - break; - last = iterator; - iterator = iterator->next; + if(!strcmp(iterator->font->fontid,fontid)) + break; + last = iterator; + iterator = iterator->next; } if(iterator) { - obj->font = iterator->font; - return ; + obj->font = iterator->font; + return ; } if(t1id<0) { - logf(" internal error: t1id:%d, fontid:%s\n", t1id,fontid); + logf(" internal error: t1id:%d, fontid:%s\n", t1id,fontid); } SWFFont*font = new SWFFont(fontid, t1id, filename); @@ -689,9 +689,9 @@ void swfoutput_setfont(struct swfoutput*obj, char*fontid, int t1id, char*filenam iterator->next = 0; if(last) - last->next = iterator; + last->next = iterator; else - fontlist = iterator; + fontlist = iterator; obj->font = font; } @@ -699,9 +699,9 @@ int swfoutput_queryfont(struct swfoutput*obj, char*fontid) { fontlist_t *iterator = fontlist; while(iterator) { - if(!strcmp(iterator->font->fontid,fontid)) - return 1; - iterator = iterator->next; + if(!strcmp(iterator->font->fontid,fontid)) + return 1; + iterator = iterator->next; } return 0; } @@ -715,9 +715,9 @@ void swfoutput_setfontmatrix(struct swfoutput*obj,double m11,double m12, obj->fontm12 == m12 && obj->fontm21 == m21 && obj->fontm22 == m22) - return; + return; // if(textid>=0) -// endtext(); +// endtext(); obj->fontm11 = m11; obj->fontm12 = m12; obj->fontm21 = m21; @@ -754,19 +754,19 @@ void swfoutput_init(struct swfoutput* obj, char*_filename, int _sizex, int _size memset(&swf,0x00,sizeof(SWF)); - swf.FileVersion = 4; - swf.FrameRate = 0x0040; // 1 frame per 4 seconds - swf.MovieSize.xmax = 20*sizex; - swf.MovieSize.ymax = 20*sizey; + swf.fileVersion = 4; + swf.frameRate = 0x0040; // 1 frame per 4 seconds + swf.movieSize.xmax = 20*sizex; + swf.movieSize.ymax = 20*sizey; - swf.FirstTag = InsertTag(NULL,ST_SETBACKGROUNDCOLOR); - tag = swf.FirstTag; + swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR); + tag = swf.firstTag; rgb.r = 0xff; rgb.g = 0xff; rgb.b = 0xff; - SetRGB(tag,&rgb); - if(flag_protected) - tag = InsertTag(tag, ST_PROTECT); + swf_SetRGB(tag,&rgb); + if(flag_protected) // good practice! /r + tag = swf_InsertTag(tag, ST_PROTECT); depth = 1; startdepth = depth; } @@ -784,30 +784,30 @@ void startshape(struct swfoutput*obj) if(textid>=0) endtext(); - tag = InsertTag(tag,ST_DEFINESHAPE); + tag = swf_InsertTag(tag,ST_DEFINESHAPE); - NewShape(&shape); - linestyleid = ShapeAddLineStyle(shape,obj->linewidth,&obj->strokergb); + swf_ShapeNew(&shape); + linestyleid = swf_ShapeAddLineStyle(shape,obj->linewidth,&obj->strokergb); rgb.r = obj->fillrgb.r; rgb.g = obj->fillrgb.g; rgb.b = obj->fillrgb.b; - fillstyleid = ShapeAddSolidFillStyle(shape,&obj->fillrgb); + fillstyleid = swf_ShapeAddSolidFillStyle(shape,&obj->fillrgb); shapeid = ++currentswfid; - SetU16(tag,shapeid); // ID + swf_SetU16(tag,shapeid); // ID r.xmin = 0; r.ymin = 0; r.xmax = 20*sizex; r.ymax = 20*sizey; - SetRect(tag,&r); + swf_SetRect(tag,&r); - SetShapeStyles(tag,shape); - ShapeCountBits(shape,NULL,NULL); - SetShapeBits(tag,shape); + swf_SetShapeStyles(tag,shape); + swf_ShapeCountBits(shape,NULL,NULL); + swf_SetShapeBits(tag,shape); - ShapeSetAll(tag,shape,/*x*/0,/*y*/0,linestyleid,0,0); + swf_ShapeSetAll(tag,shape,/*x*/0,/*y*/0,linestyleid,0,0); swflastx=swflasty=0; lastwasfill = 0; } @@ -818,16 +818,16 @@ void starttext(struct swfoutput*obj) MATRIX m; if(shapeid>=0) endshape(); - tag = InsertTag(tag,ST_DEFINETEXT); + tag = swf_InsertTag(tag,ST_DEFINETEXT); textid = ++currentswfid; - SetU16(tag, textid); + swf_SetU16(tag, textid); r.xmin = 0; r.ymin = 0; r.xmax = 20*sizex; r.ymax = 20*sizey; - SetRect(tag,&r); + swf_SetRect(tag,&r); m.sx = 65536; m.sy = 65536; @@ -836,28 +836,28 @@ void starttext(struct swfoutput*obj) m.tx = 0; m.ty = 0; - SetMatrix(tag,&m); + swf_SetMatrix(tag,&m); swflastx=swflasty=0; } void endshape() { if(shapeid<0) - return; - ShapeSetEnd(tag); - tag = InsertTag(tag,ST_PLACEOBJECT2); - ObjectPlace(tag,shapeid,/*depth*/depth++,NULL,NULL,NULL); + return; + swf_ShapeSetEnd(tag); + tag = swf_InsertTag(tag,ST_PLACEOBJECT2); + swf_ObjectPlace(tag,shapeid,/*depth*/depth++,NULL,NULL,NULL); shapeid = -1; } void endtext() { if(textid<0) - return; + return; putcharacters(tag); - SetU8(tag,0); - tag = InsertTag(tag,ST_PLACEOBJECT2); - ObjectPlace(tag,textid,/*depth*/depth++,NULL,NULL,NULL); + swf_SetU8(tag,0); + tag = swf_InsertTag(tag,ST_PLACEOBJECT2); + swf_ObjectPlace(tag,textid,/*depth*/depth++,NULL,NULL,NULL); textid = -1; } @@ -868,8 +868,8 @@ void endpage(struct swfoutput*obj) if(textid>=0) endtext(); while(clippos) - swfoutput_endclip(obj); - tag = InsertTag(tag,ST_SHOWFRAME); + swfoutput_endclip(obj); + tag = swf_InsertTag(tag,ST_SHOWFRAME); } void swfoutput_newpage(struct swfoutput*obj) @@ -877,8 +877,8 @@ void swfoutput_newpage(struct swfoutput*obj) endpage(obj); for(depth--;depth>=startdepth;depth--) { - tag = InsertTag(tag,ST_REMOVEOBJECT2); - SetU16(tag,depth); + tag = swf_InsertTag(tag,ST_REMOVEOBJECT2); + swf_SetU16(tag,depth); } depth = 1; @@ -892,16 +892,16 @@ void swfoutput_destroy(struct swfoutput* obj) endpage(obj); fontlist_t *tmp,*iterator = fontlist; while(iterator) { - delete iterator->font; - iterator->font = 0; - tmp = iterator; - iterator = iterator->next; - delete tmp; + delete iterator->font; + iterator->font = 0; + tmp = iterator; + iterator = iterator->next; + delete tmp; } T1_CloseLib(); if(!filename) - return; + return; if(filename) fi = open(filename, O_CREAT|O_TRUNC|O_WRONLY, 0777); else @@ -912,9 +912,9 @@ void swfoutput_destroy(struct swfoutput* obj) exit(1); } - tag = InsertTag(tag,ST_END); + tag = swf_InsertTag(tag,ST_END); - if FAILED(WriteSWF(fi,&swf)) + if FAILED(swf_WriteSWF(fi,&swf)) logf(" WriteSWF() failed.\n"); if(filename) close(fi); @@ -969,7 +969,7 @@ void swfoutput_setstrokecolor(swfoutput* obj, u8 r, u8 g, u8 b, u8 a) void swfoutput_setlinewidth(struct swfoutput*obj, double linewidth) { if(obj->linewidth == (u16)(linewidth*20)) - return; + return; if(shapeid>=0) endshape(); @@ -986,18 +986,18 @@ void swfoutput_startclip(swfoutput*obj, T1_OUTLINE*outline, struct swfmatrix*m) if(clippos >= 127) { - logf(" Too many clip levels."); - clippos --; + logf(" Too many clip levels."); + clippos --; } startshape(obj); int olddrawmode = drawmode; swfoutput_setdrawmode(obj, DRAWMODE_CLIP); swfoutput_drawpath(obj, outline, m); - ShapeSetEnd(tag); + swf_ShapeSetEnd(tag); swfoutput_setdrawmode(obj, olddrawmode); - tag = InsertTag(tag,ST_PLACEOBJECT2); + tag = swf_InsertTag(tag,ST_PLACEOBJECT2); cliptags[clippos] = tag; clipshapes[clippos] = shapeid; clipdepths[clippos] = depth++; @@ -1013,19 +1013,19 @@ void swfoutput_endclip(swfoutput*obj) endshape(); if(!clippos) { - logf(" Invalid end of clipping region"); - return; + logf(" Invalid end of clipping region"); + return; } clippos--; - PlaceObject(cliptags[clippos],clipshapes[clippos],clipdepths[clippos],NULL,NULL,NULL,depth++); + swf_ObjectPlaceClip(cliptags[clippos],clipshapes[clippos],clipdepths[clippos],NULL,NULL,NULL,depth++); } void drawimage(struct swfoutput*obj, int bitid, int sizex,int sizey, - double x1,double y1, - double x2,double y2, - double x3,double y3, - double x4,double y4) + double x1,double y1, + double x2,double y2, + double x3,double y3, + double x4,double y4) { RGBA rgb; SRECT r; @@ -1066,21 +1066,21 @@ void drawimage(struct swfoutput*obj, int bitid, int sizex,int sizey, /* shape */ myshapeid = ++currentswfid; - tag = InsertTag(tag,ST_DEFINESHAPE); - NewShape(&shape); + tag = swf_InsertTag(tag,ST_DEFINESHAPE); + swf_ShapeNew(&shape); //lsid = ShapeAddLineStyle(shape,obj->linewidth,&obj->strokergb); //fsid = ShapeAddSolidFillStyle(shape,&obj->fillrgb); - fsid = ShapeAddBitmapFillStyle(shape,&m,bitid,0); - SetU16(tag, myshapeid); + fsid = swf_ShapeAddBitmapFillStyle(shape,&m,bitid,0); + swf_SetU16(tag, myshapeid); r.xmin = (int)(xmin*20); r.ymin = (int)(ymin*20); r.xmax = (int)(xmax*20); r.ymax = (int)(ymax*20); - SetRect(tag,&r); - SetShapeStyles(tag,shape); - ShapeCountBits(shape,NULL,NULL); - SetShapeBits(tag,shape); - ShapeSetAll(tag,shape,/*x*/0,/*y*/0,lsid,fsid,0); + swf_SetRect(tag,&r); + swf_SetShapeStyles(tag,shape); + swf_ShapeCountBits(shape,NULL,NULL); + swf_SetShapeBits(tag,shape); + swf_ShapeSetAll(tag,shape,/*x*/0,/*y*/0,lsid,fsid,0); swflastx = swflasty = 0; moveto(tag, p1); lineto(tag, p2); @@ -1093,18 +1093,18 @@ void drawimage(struct swfoutput*obj, int bitid, int sizex,int sizey, ShapeSetLine (tag, shape, x*20,0); ShapeSetLine (tag, shape, 0,-y*20); ShapeSetLine (tag, shape, -x*20,0);*/ - ShapeSetEnd(tag); + swf_ShapeSetEnd(tag); /* instance */ - tag = InsertTag(tag,ST_PLACEOBJECT2); - ObjectPlace(tag,myshapeid,/*depth*/depth++,NULL,NULL,NULL); + tag = swf_InsertTag(tag,ST_PLACEOBJECT2); + swf_ObjectPlace(tag,myshapeid,/*depth*/depth++,NULL,NULL,NULL); } int swfoutput_drawimagejpeg(struct swfoutput*obj, char*filename, int sizex,int sizey, - double x1,double y1, - double x2,double y2, - double x3,double y3, - double x4,double y4) + double x1,double y1, + double x2,double y2, + double x3,double y3, + double x4,double y4) { if(shapeid>=0) endshape(); @@ -1112,19 +1112,19 @@ int swfoutput_drawimagejpeg(struct swfoutput*obj, char*filename, int sizex,int s endtext(); int bitid = ++currentswfid; - tag = InsertTag(tag,ST_DEFINEBITSJPEG2); - SetU16(tag, bitid); - SetJPEGBits(tag, filename, jpegquality); + tag = swf_InsertTag(tag,ST_DEFINEBITSJPEG2); + swf_SetU16(tag, bitid); + swf_SetJPEGBits(tag, filename, jpegquality); drawimage(obj, bitid, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4); return bitid; } int swfoutput_drawimagelossless(struct swfoutput*obj, RGBA*mem, int sizex,int sizey, - double x1,double y1, - double x2,double y2, - double x3,double y3, - double x4,double y4) + double x1,double y1, + double x2,double y2, + double x3,double y3, + double x4,double y4) { if(shapeid>=0) endshape(); @@ -1132,19 +1132,19 @@ int swfoutput_drawimagelossless(struct swfoutput*obj, RGBA*mem, int sizex,int si endtext(); int bitid = ++currentswfid; - tag = InsertTag(tag,ST_DEFINEBITSLOSSLESS); - SetU16(tag, bitid); - SetLosslessBits(tag,sizex,sizey,mem, BMF_32BIT); + tag = swf_InsertTag(tag,ST_DEFINEBITSLOSSLESS); + swf_SetU16(tag, bitid); + swf_SetLosslessBits(tag,sizex,sizey,mem, BMF_32BIT); drawimage(obj, bitid, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4); return bitid; } int swfoutput_drawimagelossless256(struct swfoutput*obj, U8*mem, RGBA*pal, int sizex,int sizey, - double x1,double y1, - double x2,double y2, - double x3,double y3, - double x4,double y4) + double x1,double y1, + double x2,double y2, + double x3,double y3, + double x4,double y4) { if(shapeid>=0) endshape(); @@ -1152,19 +1152,19 @@ int swfoutput_drawimagelossless256(struct swfoutput*obj, U8*mem, RGBA*pal, int s endtext(); int bitid = ++currentswfid; - tag = InsertTag(tag,ST_DEFINEBITSLOSSLESS2); - SetU16(tag, bitid); - SetLosslessBitsIndexed(tag,sizex,sizey,mem, pal, 256); + tag = swf_InsertTag(tag,ST_DEFINEBITSLOSSLESS2); + swf_SetU16(tag, bitid); + swf_SetLosslessBitsIndexed(tag,sizex,sizey,mem, pal, 256); drawimage(obj, bitid, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4); return bitid; } void swfoutput_drawimageagain(struct swfoutput*obj, int id, int sizex,int sizey, - double x1,double y1, - double x2,double y2, - double x3,double y3, - double x4,double y4) + double x1,double y1, + double x2,double y2, + double x3,double y3, + double x4,double y4) { if(shapeid>=0) endshape(); diff --git a/pdf2swf/xpdf/Makefile.in b/pdf2swf/xpdf/Makefile.in index a7eef64..48759d7 100644 --- a/pdf2swf/xpdf/Makefile.in +++ b/pdf2swf/xpdf/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -93,7 +93,7 @@ DIST_COMMON = Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best DEP_FILES = .deps/Array.P .deps/Catalog.P .deps/Decrypt.P .deps/Dict.P \ .deps/Error.P .deps/FontEncoding.P .deps/FontFile.P .deps/FormWidget.P \ diff --git a/src/jpeg2swf.c b/src/jpeg2swf.c index 4781b48..6483a82 100644 --- a/src/jpeg2swf.c +++ b/src/jpeg2swf.c @@ -1,432 +1,432 @@ -/* jpeg2swf.c - - JPEG to SWF converter tool - - Part of the swftools package. - - Copyright (c) 2001 Rainer Böhme - - This file is distributed under the GPL, see file COPYING for details - -*/ - -#include -#include -#include -#include -#include "../lib/rfxswf.h" -#include "../lib/args.h" // not really a header ;-) - -#define MAX_INPUT_FILES 1024 -#define VERBOSE(x) (global.verbose>=x) - -struct -{ int quality; - int framerate; - int max_image_width; - int max_image_height; - int force_width; - int force_height; - int nfiles; - int verbose; - char * files[MAX_INPUT_FILES]; - char * outfile; -} global; - -TAG * MovieStart(SWF * swf,int framerate,int dx,int dy) -{ TAG * t; - RGBA rgb; - - memset(swf,0x00,sizeof(SWF)); - - swf->FileVersion = 4; - swf->FrameRate = (25600/framerate); - swf->MovieSize.xmax = dx*20; - swf->MovieSize.ymax = dy*20; - - t = swf->FirstTag = InsertTag(NULL,ST_SETBACKGROUNDCOLOR); - - rgb.r = rgb.g = rgb.b = rgb.a = 0x00; - SetRGB(t,&rgb); - - return t; -} - -int MovieFinish(SWF * swf,TAG * t,char * sname) -{ int handle, so = fileno(stdout); - t = InsertTag(t,ST_END); - - if ((!isatty(so))&&(!sname)) handle = so; - else - { if (!sname) sname = "out.swf"; - handle = open(sname,O_RDWR|O_CREAT|O_TRUNC,0666); - } - if FAILED(WriteSWF(handle,swf)) if (VERBOSE(1)) fprintf(stderr,"Unable to write output file: %s\n",sname); - if (handle!=so) close(handle); - - FreeTags(swf); - return 0; -} - -TAG * MovieAddFrame(SWF * swf,TAG * t,char * sname,int quality,int id) -{ SHAPE * s; - SRECT r; - MATRIX m; - int fs; - - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; - LPJPEGBITS out; - FILE * f; - U8 * scanline; - - if ((f=fopen(sname,"rb"))==NULL) - { if (VERBOSE(1)) fprintf(stderr,"Read access failed: %s\n",sname); - return t; - } - - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - jpeg_stdio_src(&cinfo,f); - jpeg_read_header(&cinfo, TRUE); - jpeg_start_decompress(&cinfo); - - t = InsertTag(t,ST_DEFINEBITSJPEG2); - - SetU16(t,id); // id - - out = SetJPEGBitsStart(t,cinfo.output_width,cinfo.output_height,quality); - scanline = (U8*)malloc(4*cinfo.output_width); - - if (scanline) - { int y; - U8 * js = scanline; - for (y=0;yMovieSize.xmax-(int)cinfo.output_width*20)/2; - m.ty = (swf->MovieSize.ymax-(int)cinfo.output_height*20)/2; - ObjectPlace(t,id+1,1,&m,NULL,NULL); - - t = InsertTag(t,ST_SHOWFRAME); - - jpeg_finish_decompress(&cinfo); - fclose(f); - - return t; -} - -int CheckInputFile(char * fname,char ** realname) -{ struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; - FILE * f; - char * s = malloc(strlen(fname)+5); - - if (!s) exit(2); - (*realname) = s; - strcpy(s,fname); - - // Check whether file exists (with typical extensions) - - if ((f=fopen(s,"rb"))==NULL) - { sprintf(s,"%s.jpg",fname); - if ((f=fopen(s,"rb"))==NULL) - { sprintf(s,"%s.jpeg",fname); - if ((f=fopen(s,"rb"))==NULL) - { sprintf(s,"%s.JPG",fname); - if ((f=fopen(s,"rb"))==NULL) - { sprintf(s,"%s.JPEG",fname); - if ((f=fopen(s,"rb"))==NULL) - return -1; - } - } - } - } - - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - jpeg_stdio_src(&cinfo,f); - jpeg_read_header(&cinfo, TRUE); - - // Get image dimensions - - if (global.max_image_width100)) - { if (VERBOSE(1)) fprintf(stderr,"Error: You must specify a valid quality between 1 and 100.\n"); - exit(1); - } - res = 1; - break; - - case 'r': - if (val) global.framerate = atoi(val); - if ((global.framerate<1)||(global.framerate>5000)) - { if (VERBOSE(1)) fprintf(stderr,"Error: You must specify a valid framerate between 1 and 10000.\n"); - exit(1); - } - res = 1; - break; - - case 'o': - if (val) global.outfile = val; res = 1; break; - - case 'v': - if (val) global.verbose = atoi(val); res = 1; break; - - case 'X': - if (val) global.force_width = atoi(val); res = 1; break; - - case 'Y': - if (val) global.force_height = atoi(val); res = 1; break; - - case 'V': - printf("jpeg2swf - part of %s %s\n", PACKAGE, VERSION);exit(0); - - default: - res = -1; - break; - } - - if (res<0) - { if (VERBOSE(1)) fprintf(stderr,"Unknown option: -v%s\n",arg); - return 0; - } - return res; -} - -struct options_t options[] = -{{"q","quality"}, - {"o","output"}, - {"r","rate"}, - {"v","verbose"}, - {"X","width"}, - {"Y","height"}, - {"V","version"} -}; - -int args_callback_longoption(char*name,char*val) { - return args_long2shortoption(options, name, val); -} - -int args_callback_command(char*arg,char*next) // actually used as filename -{ char * s; - if (CheckInputFile(arg,&s)<0) - { if (VERBOSE(1)) fprintf(stderr, "Unable to open input file: %s\n",arg); - free(s); - } - else - { global.files[global.nfiles] = s; - global.nfiles++; - if (global.nfiles>=MAX_INPUT_FILES) - { if (VERBOSE(1)) fprintf(stderr, "Error: Too many input files.\n"); - exit(1); - } - } - return 0; -} - -void args_callback_usage(char*name) -{ fprintf(stderr,"Usage: %s imagefiles[.jpg]|[.jpeg] [...] [-options [value]]\n",name); - fprintf(stderr,"-q quality (quality) Set JPEG compression quality (1-100)\n"); - fprintf(stderr,"-r framerate (rate) Set movie framerate (100/sec)\n"); - fprintf(stderr,"-o outputfile (output) Set name for SWF output file\n"); - fprintf(stderr,"-v level (verbose) Set verbose level (0=quiet, 1=default, 2=debug)\n"); - fprintf(stderr,"-X pixel (width) Force movie width to scale (default: autodetect)\n"); - fprintf(stderr,"-Y pixel (height) Force movie height to scale (default: autodetect)\n"); - fprintf(stderr,"-V (version) Print version information and exit\n"); -} - - -int main(int argc, char ** argv) -{ SWF swf; - TAG * t; - - memset(&global,0x00,sizeof(global)); - - global.quality = 60; - global.framerate = 100; - global.verbose = 1; - - processargs(argc, argv); - - if (VERBOSE(2)) fprintf(stderr,"Processing %i file(s)...\n",global.nfiles); - - t = MovieStart(&swf,global.framerate, - global.force_width?global.force_width:global.max_image_width, - global.force_height?global.force_height:global.max_image_height); - - { int i; - for (i=0;i + + This file is distributed under the GPL, see file COPYING for details + +*/ + +#include +#include +#include +#include +#include "../lib/rfxswf.h" +#include "../lib/args.h" // not really a header ;-) + +#define MAX_INPUT_FILES 1024 +#define VERBOSE(x) (global.verbose>=x) + +struct +{ int quality; + int framerate; + int max_image_width; + int max_image_height; + int force_width; + int force_height; + int nfiles; + int verbose; + char * files[MAX_INPUT_FILES]; + char * outfile; +} global; + +TAG * MovieStart(SWF * swf,int framerate,int dx,int dy) +{ TAG * t; + RGBA rgb; + + memset(swf,0x00,sizeof(SWF)); + + swf->fileVersion = 4; + swf->frameRate = (25600/framerate); + swf->movieSize.xmax = dx*20; + swf->movieSize.ymax = dy*20; + + t = swf->firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR); + + rgb.r = rgb.g = rgb.b = rgb.a = 0x00; + swf_SetRGB(t,&rgb); + + return t; +} + +int MovieFinish(SWF * swf,TAG * t,char * sname) +{ int handle, so = fileno(stdout); + t = swf_InsertTag(t,ST_END); + + if ((!isatty(so))&&(!sname)) handle = so; + else + { if (!sname) sname = "out.swf"; + handle = open(sname,O_RDWR|O_CREAT|O_TRUNC,0666); + } + if FAILED(swf_WriteSWF(handle,swf)) if (VERBOSE(1)) fprintf(stderr,"Unable to write output file: %s\n",sname); + if (handle!=so) close(handle); + + swf_FreeTags(swf); + return 0; +} + +TAG * MovieAddFrame(SWF * swf,TAG * t,char * sname,int quality,int id) +{ SHAPE * s; + SRECT r; + MATRIX m; + int fs; + + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + LPJPEGBITS out; + FILE * f; + U8 * scanline; + + if ((f=fopen(sname,"rb"))==NULL) + { if (VERBOSE(1)) fprintf(stderr,"Read access failed: %s\n",sname); + return t; + } + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + jpeg_stdio_src(&cinfo,f); + jpeg_read_header(&cinfo, TRUE); + jpeg_start_decompress(&cinfo); + + t = swf_InsertTag(t,ST_DEFINEBITSJPEG2); + + swf_SetU16(t,id); // id + + out = swf_SetJPEGBitsStart(t,cinfo.output_width,cinfo.output_height,quality); + scanline = (U8*)malloc(4*cinfo.output_width); + + if (scanline) + { int y; + U8 * js = scanline; + for (y=0;ymovieSize.xmax-(int)cinfo.output_width*20)/2; + m.ty = (swf->movieSize.ymax-(int)cinfo.output_height*20)/2; + swf_ObjectPlace(t,id+1,1,&m,NULL,NULL); + + t = swf_InsertTag(t,ST_SHOWFRAME); + + jpeg_finish_decompress(&cinfo); + fclose(f); + + return t; +} + +int CheckInputFile(char * fname,char ** realname) +{ struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + FILE * f; + char * s = malloc(strlen(fname)+5); + + if (!s) exit(2); + (*realname) = s; + strcpy(s,fname); + + // Check whether file exists (with typical extensions) + + if ((f=fopen(s,"rb"))==NULL) + { sprintf(s,"%s.jpg",fname); + if ((f=fopen(s,"rb"))==NULL) + { sprintf(s,"%s.jpeg",fname); + if ((f=fopen(s,"rb"))==NULL) + { sprintf(s,"%s.JPG",fname); + if ((f=fopen(s,"rb"))==NULL) + { sprintf(s,"%s.JPEG",fname); + if ((f=fopen(s,"rb"))==NULL) + return -1; + } + } + } + } + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + jpeg_stdio_src(&cinfo,f); + jpeg_read_header(&cinfo, TRUE); + + // Get image dimensions + + if (global.max_image_width100)) + { if (VERBOSE(1)) fprintf(stderr,"Error: You must specify a valid quality between 1 and 100.\n"); + exit(1); + } + res = 1; + break; + + case 'r': + if (val) global.framerate = atoi(val); + if ((global.framerate<1)||(global.framerate>5000)) + { if (VERBOSE(1)) fprintf(stderr,"Error: You must specify a valid framerate between 1 and 10000.\n"); + exit(1); + } + res = 1; + break; + + case 'o': + if (val) global.outfile = val; res = 1; break; + + case 'v': + if (val) global.verbose = atoi(val); res = 1; break; + + case 'X': + if (val) global.force_width = atoi(val); res = 1; break; + + case 'Y': + if (val) global.force_height = atoi(val); res = 1; break; + + case 'V': + printf("jpeg2swf - part of %s %s\n", PACKAGE, VERSION);exit(0); + + default: + res = -1; + break; + } + + if (res<0) + { if (VERBOSE(1)) fprintf(stderr,"Unknown option: -v%s\n",arg); + return 0; + } + return res; +} + +struct options_t options[] = +{{"q","quality"}, + {"o","output"}, + {"r","rate"}, + {"v","verbose"}, + {"X","width"}, + {"Y","height"}, + {"V","version"} +}; + +int args_callback_longoption(char*name,char*val) { + return args_long2shortoption(options, name, val); +} + +int args_callback_command(char*arg,char*next) // actually used as filename +{ char * s; + if (CheckInputFile(arg,&s)<0) + { if (VERBOSE(1)) fprintf(stderr, "Unable to open input file: %s\n",arg); + free(s); + } + else + { global.files[global.nfiles] = s; + global.nfiles++; + if (global.nfiles>=MAX_INPUT_FILES) + { if (VERBOSE(1)) fprintf(stderr, "Error: Too many input files.\n"); + exit(1); + } + } + return 0; +} + +void args_callback_usage(char*name) +{ fprintf(stderr,"Usage: %s imagefiles[.jpg]|[.jpeg] [...] [-options [value]]\n",name); + fprintf(stderr,"-q quality (quality) Set JPEG compression quality (1-100)\n"); + fprintf(stderr,"-r framerate (rate) Set movie framerate (100/sec)\n"); + fprintf(stderr,"-o outputfile (output) Set name for SWF output file\n"); + fprintf(stderr,"-v level (verbose) Set verbose level (0=quiet, 1=default, 2=debug)\n"); + fprintf(stderr,"-X pixel (width) Force movie width to scale (default: autodetect)\n"); + fprintf(stderr,"-Y pixel (height) Force movie height to scale (default: autodetect)\n"); + fprintf(stderr,"-V (version) Print version information and exit\n"); +} + + +int main(int argc, char ** argv) +{ SWF swf; + TAG * t; + + memset(&global,0x00,sizeof(global)); + + global.quality = 60; + global.framerate = 100; + global.verbose = 1; + + processargs(argc, argv); + + if (VERBOSE(2)) fprintf(stderr,"Processing %i file(s)...\n",global.nfiles); + + t = MovieStart(&swf,global.framerate, + global.force_width?global.force_width:global.max_image_width, + global.force_height?global.force_height:global.max_image_height); + + { int i; + for (i=0;i - - This file is distributed under the GPL, see file COPYING for details */ - -#define HAVE_STAT - -#ifdef HAVE_SYS_STAT_H -#include -#else -#undef HAVE_STAT -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#else -#undef HAVE_STAT -#endif - -#include -#include -#include -#include "../lib/rfxswf.h" -#include "../lib/args.h" - -char * filename = 0; - -/* idtab stores the ids which are defined in the file. This allows us - to detect errors in the file. (i.e. ids which are defined more than - once */ -char idtab[65536]; -int action = 0; - -struct options_t options[] = -{ - {"a","action"}, - {"v","verbose"}, - {"V","version"}, - {0,0} -}; - - -int args_callback_option(char*name,char*val) -{ - if(!strcmp(name, "V")) { - printf("swfdump - part of %s %s\n", PACKAGE, VERSION); - exit(0); - } - else if(name[0]=='a') { - action = 1; - return 0; - } - else { - printf("Unknown option: -%s\n", name); - } - - return 0; -} -int args_callback_longoption(char*name,char*val) -{ - return args_long2shortoption(options, name, val); -} -void args_callback_usage(char*name) -{ - printf("Usage: %s [-a] file.swf\n", name); - printf("-h , --help\t\t\t Print help and exit\n"); - printf("-a , --action\t\t\t Disassemble action tags\n"); - printf("-V , --version\t\t\t Print program version and exit\n"); -} -int args_callback_command(char*name,char*val) -{ - if(filename) { - fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n", - filename, name); - } - filename = name; - return 0; -} - -int main (int argc,char ** argv) -{ - SWF swf; - TAG*tag; -#ifdef HAVE_STAT - struct stat statbuf; -#endif - int f; - char prefix[128]; - prefix[0] = 0; - memset(idtab,0,65536); - - processargs(argc, argv); - - if(!filename) - { - fprintf(stderr, "You must supply a filename.\n"); - return 1; - } - - f = open(filename,O_RDONLY); - - if (f<0) - { - perror("Couldn't open file: "); - exit(1); - } - if FAILED(ReadSWF(f,&swf)) - { - fprintf(stderr, "%s is not a valid SWF file or contains errors.\n",filename); - close(f); - exit(1); - } - -#ifdef HAVE_STAT - fstat(f, &statbuf); - if(statbuf.st_size != swf.FileSize) - fprintf(stderr, "Error: Real Filesize (%d) doesn't match header Filesize (%d)", - statbuf.st_size, swf.FileSize); -#endif - - close(f); - - printf("[HEADER] File version: %d\n", swf.FileVersion); - printf("[HEADER] File size: %ld\n", swf.FileSize); - printf("[HEADER] Frame rate: %f\n",swf.FrameRate/256.0); - printf("[HEADER] Frame count: %d\n",swf.FrameCount); - printf("[HEADER] Movie width: %.3f\n",(swf.MovieSize.xmax-swf.MovieSize.xmin)/20.0); - printf("[HEADER] Movie height: %.3f\n",(swf.MovieSize.ymax-swf.MovieSize.ymin)/20.0); - - tag = swf.FirstTag; - - while(tag) { - char*name = getTagName(tag); - if(!name) { - fprintf(stderr, "Error: Unknown tag:0x%03x\n", tag->id); - tag = tag->next; - continue; - } - printf("[%03x] %9ld %s%s", tag->id, tag->len, prefix, getTagName(tag)); - - if(isDefiningTag(tag)) { - U16 id = GetDefineID(tag); - printf(" defines id %04x", id); - if(idtab[id]) - fprintf(stderr, "Error: Id %04x is defined more than once.\n", id); - idtab[id] = 1; - } - else if(tag->id == ST_PLACEOBJECT || - tag->id == ST_PLACEOBJECT2) { - printf(" places id %04x at depth %04x", GetPlaceID(tag), GetDepth(tag)); - if(GetName(tag)) - printf(" name \"%s\"",GetName(tag)); - } - else if(tag->id == ST_REMOVEOBJECT) { - printf(" removes id %04x from depth %04x", GetPlaceID(tag), GetDepth(tag)); - } - else if(tag->id == ST_REMOVEOBJECT2) { - printf(" removes object from depth %04x", GetDepth(tag)); - } - - printf("\n"); - - if(tag->id == ST_DEFINESPRITE) { - sprintf(prefix, " "); - } - else if(tag->id == ST_END) { - *prefix = 0; - } - else if(tag->id == ST_DOACTION && action) { - char myprefix[128]; - ActionTAG*actions; - sprintf(myprefix, " %s", prefix); - - actions = GetActions(tag); - - DumpActions(actions, myprefix); - } - tag = tag->next; - } - - FreeTags(&swf); - return 0; -} - +/* swfdump.c + Shows the structure of a swf file + + Part of the swftools package. + + Copyright (c) 2001 Matthias Kramm + + This file is distributed under the GPL, see file COPYING for details */ + +#define HAVE_STAT + +#ifdef HAVE_SYS_STAT_H +#include +#else +#undef HAVE_STAT +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#else +#undef HAVE_STAT +#endif + +#include +#include +#include +#include "../lib/rfxswf.h" +#include "../lib/args.h" + +char * filename = 0; + +/* idtab stores the ids which are defined in the file. This allows us + to detect errors in the file. (i.e. ids which are defined more than + once */ +char idtab[65536]; +int action = 0; + +struct options_t options[] = +{ + {"a","action"}, + {"v","verbose"}, + {"V","version"}, + {0,0} +}; + + +int args_callback_option(char*name,char*val) +{ + if(!strcmp(name, "V")) { + printf("swfdump - part of %s %s\n", PACKAGE, VERSION); + exit(0); + } + else if(name[0]=='a') { + action = 1; + return 0; + } + else { + printf("Unknown option: -%s\n", name); + } + + return 0; +} +int args_callback_longoption(char*name,char*val) +{ + return args_long2shortoption(options, name, val); +} +void args_callback_usage(char*name) +{ + printf("Usage: %s [-a] file.swf\n", name); + printf("-h , --help\t\t\t Print help and exit\n"); + printf("-a , --action\t\t\t Disassemble action tags\n"); + printf("-V , --version\t\t\t Print program version and exit\n"); +} +int args_callback_command(char*name,char*val) +{ + if(filename) { + fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n", + filename, name); + } + filename = name; + return 0; +} + +int main (int argc,char ** argv) +{ + SWF swf; + TAG*tag; +#ifdef HAVE_STAT + struct stat statbuf; +#endif + int f; + char prefix[128]; + prefix[0] = 0; + memset(idtab,0,65536); + + processargs(argc, argv); + + if(!filename) + { + fprintf(stderr, "You must supply a filename.\n"); + return 1; + } + + f = open(filename,O_RDONLY); + + if (f<0) + { + perror("Couldn't open file: "); + exit(1); + } + if FAILED(swf_ReadSWF(f,&swf)) + { + fprintf(stderr, "%s is not a valid SWF file or contains errors.\n",filename); + close(f); + exit(1); + } + +#ifdef HAVE_STAT + fstat(f, &statbuf); + if(statbuf.st_size != swf.fileSize) + fprintf(stderr, "Error: Real Filesize (%d) doesn't match header Filesize (%d)", + statbuf.st_size, swf.fileSize); +#endif + + close(f); + + printf("[HEADER] File version: %d\n", swf.fileVersion); + printf("[HEADER] File size: %ld\n", swf.fileSize); + printf("[HEADER] Frame rate: %f\n",swf.frameRate/256.0); + printf("[HEADER] Frame count: %d\n",swf.frameCount); + printf("[HEADER] Movie width: %.3f\n",(swf.movieSize.xmax-swf.movieSize.xmin)/20.0); + printf("[HEADER] Movie height: %.3f\n",(swf.movieSize.ymax-swf.movieSize.ymin)/20.0); + + tag = swf.firstTag; + + while(tag) { + char*name = swf_TagGetName(tag); + if(!name) { + fprintf(stderr, "Error: Unknown tag:0x%03x\n", tag->id); + tag = tag->next; + continue; + } + printf("[%03x] %9ld %s%s", tag->id, tag->len, prefix, swf_TagGetName(tag)); + + if(swf_isDefiningTag(tag)) { + U16 id = swf_GetDefineID(tag); + printf(" defines id %04x", id); + if(idtab[id]) + fprintf(stderr, "Error: Id %04x is defined more than once.\n", id); + idtab[id] = 1; + } + else if(tag->id == ST_PLACEOBJECT || + tag->id == ST_PLACEOBJECT2) { + printf(" places id %04x at depth %04x", swf_GetPlaceID(tag), swf_GetDepth(tag)); + if(swf_TagGetName(tag)) + printf(" name \"%s\"",swf_TagGetName(tag)); + } + else if(tag->id == ST_REMOVEOBJECT) { + printf(" removes id %04x from depth %04x", swf_GetPlaceID(tag), swf_GetDepth(tag)); + } + else if(tag->id == ST_REMOVEOBJECT2) { + printf(" removes object from depth %04x", swf_GetDepth(tag)); + } + + printf("\n"); + + if(tag->id == ST_DEFINESPRITE) { + sprintf(prefix, " "); + } + else if(tag->id == ST_END) { + *prefix = 0; + } + else if(tag->id == ST_DOACTION && action) { + char myprefix[128]; + ActionTAG*actions; + sprintf(myprefix, " %s", prefix); + + actions = swf_GetActions(tag); + + swf_DumpActions(actions, myprefix); + } + tag = tag->next; + } + + swf_FreeTags(&swf); + return 0; +} + diff --git a/src/swfstrings.c b/src/swfstrings.c index de967bd..aae32dd 100644 --- a/src/swfstrings.c +++ b/src/swfstrings.c @@ -1,93 +1,93 @@ -/* swfstrings.c - Scans a swf file for strings - - Part of the swftools package. - - Copyright (c) 2000,2001 Rainer Böhme - - This file is distributed under the GPL, see file COPYING for details */ - -#include -#include -#include "../lib/rfxswf.h" -#include "../lib/args.h" - -char * filename = 0; - -struct options_t options[] = -{ - {"v","verbose"}, - {"V","version"}, - {0,0} -}; - -int args_callback_option(char*name,char*val) -{ - if(!strcmp(name, "V")) { - printf("swfstrings - part of %s %s\n", PACKAGE, VERSION); - exit(0); - } -} -int args_callback_longoption(char*name,char*val) -{ - return args_long2shortoption(options, name, val); -} -void args_callback_usage(char*name) -{ - printf("\nreflex SWF Text Scan Utility\n(w) 2000 by Rainer Boehme \n\nUsage: %s filename.swf\n", name); - exit(0); -} -int args_callback_command(char*name,char*val) -{ - if(filename) { - fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n", - filename, name); - } - filename = name; - return 0; -} - -SWF swf; - -void fontcallback(U16 id,U8 * name) -{ LPSWFFONT font; - LPTAG t; - - FontExtract(&swf,id,&font); - printf("#< %s %s %s>\n",name,FontIsBold(font)?"bold":"",FontIsItalic(font)?"italic":""); - - t = swf.FirstTag; - - while (t) - { TextPrintDefineText(t,font); - t = NextTag(t); - } - - FontFree(font); -} - -int main (int argc,char ** argv) -{ int f; - - processargs(argc, argv); - if(!filename) - exit(0); - - f = open(filename,O_RDONLY); - if (f>=0) - { if FAILED(ReadSWF(f,&swf)) - { fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",filename); - close(f); - } - else - { close(f); - FontEnumerate(&swf,&fontcallback); - FreeTags(&swf); - } - } else { - fprintf(stderr,"File not found: %s\n",argv[1]); - } - - return 0; -} - +/* swfstrings.c + Scans a swf file for strings + + Part of the swftools package. + + Copyright (c) 2000,2001 Rainer Böhme + + This file is distributed under the GPL, see file COPYING for details */ + +#include +#include +#include "../lib/rfxswf.h" +#include "../lib/args.h" + +char * filename = 0; + +struct options_t options[] = +{ + {"v","verbose"}, + {"V","version"}, + {0,0} +}; + +int args_callback_option(char*name,char*val) +{ + if(!strcmp(name, "V")) { + printf("swfstrings - part of %s %s\n", PACKAGE, VERSION); + exit(0); + } +} +int args_callback_longoption(char*name,char*val) +{ + return args_long2shortoption(options, name, val); +} +void args_callback_usage(char*name) +{ + printf("\nreflex SWF Text Scan Utility\n(w) 2000 by Rainer Boehme \n\nUsage: %s filename.swf\n", name); + exit(0); +} +int args_callback_command(char*name,char*val) +{ + if(filename) { + fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n", + filename, name); + } + filename = name; + return 0; +} + +SWF swf; + +void fontcallback(U16 id,U8 * name) +{ LPSWFFONT font; + LPTAG t; + + swf_FontExtract(&swf,id,&font); + printf("#< %s %s %s>\n",name,swf_FontIsBold(font)?"bold":"",swf_FontIsItalic(font)?"italic":""); + + t = swf.firstTag; + + while (t) + { swf_TextPrintDefineText(t,font); + t = swf_NextTag(t); + } + + swf_FontFree(font); +} + +int main (int argc,char ** argv) +{ int f; + + processargs(argc, argv); + if(!filename) + exit(0); + + f = open(filename,O_RDONLY); + if (f>=0) + { if FAILED(swf_ReadSWF(f,&swf)) + { fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",filename); + close(f); + } + else + { close(f); + swf_FontEnumerate(&swf,&fontcallback); + swf_FreeTags(&swf); + } + } else { + fprintf(stderr,"File not found: %s\n",argv[1]); + } + + return 0; +} + -- 1.7.10.4