From c94d5959f51071041fe1a9802d5b021ecd4f6def Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Fri, 16 Jan 2009 22:22:32 -0800 Subject: [PATCH] new function swf_OpenSWF() --- lib/rfxswf.c | 13 +++++++++++++ lib/rfxswf.h | 1 + 2 files changed, 14 insertions(+) diff --git a/lib/rfxswf.c b/lib/rfxswf.c index de66911..de39599 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -1475,6 +1475,19 @@ int swf_ReadSWF2(reader_t*reader, SWF * swf) // Reads SWF to memory (malloc'ed return reader->pos; } +SWF* swf_OpenSWF(char*filename) +{ + int fi = open(filename, O_RDONLY|O_BINARY); + if(fi<0) { + fprintf(stderr, "Failed to open %s\n", filename); + return 0; + } + SWF* swf = rfx_alloc(sizeof(SWF)); + swf_ReadSWF(fi, swf); + close(fi); + return swf; +} + int swf_ReadSWF(int handle, SWF * swf) { reader_t reader; diff --git a/lib/rfxswf.h b/lib/rfxswf.h index 0abb8fc..ce4307f 100644 --- a/lib/rfxswf.h +++ b/lib/rfxswf.h @@ -164,6 +164,7 @@ typedef struct _SWF // Basic Functions +SWF* swf_OpenSWF(char*filename); int swf_ReadSWF2(reader_t*reader, SWF * swf); // Reads SWF via callback int swf_ReadSWF(int handle,SWF * swf); // Reads SWF to memory (malloc'ed), returns length or <0 if fails int swf_WriteSWF2(writer_t*writer, SWF * swf); // Writes SWF via callback, returns length or <0 if fails -- 1.7.10.4