#include "../rfxswf.h"
#include "../log.h"
#include "./pyutils.h"
-#include "./tag.h"
+#include "./tags.h"
#include "./taglist.h"
/*
mylog("+%08x(%d) f_load\n", (int)swf, swf->ob_refcnt);
memset(&swf->swf, 0, sizeof(SWF));
- swf->filename = strdup(filename);
if(!filename) {
PyErr_SetString(PyExc_Exception, setError("Couldn't open file %s", filename));
return 0;
}
+ swf->filename = strdup(filename);
fi = open(filename,O_RDONLY|O_BINARY);
if (fi<0) {
PyErr_SetString(PyExc_Exception, setError("Couldn't open file %s", filename));
return 0;
}
close(fi);
+ swf_FoldAll(&swf->swf);
swf->taglist = taglist_new2(swf->swf.firstTag);
+ if(swf->taglist == NULL) {
+ return NULL;
+ }
+
+ swf_FreeTags(&swf->swf);
swf->swf.firstTag = 0;
return (PyObject*)swf;
int fi;
char*filename = 0;
int compress = 0;
-
+
if(!self)
return NULL;
swf->compressed = 1;
swf->firstTag = taglist_getTAGs(swfo->taglist);
+ if(!swf->firstTag)
+ return NULL;
// fix the file, in case it is empty or not terminated properly
{
TAG*tag = swf->firstTag;
if(!tag)
tag = swf->firstTag = swf_InsertTag(0,ST_END);
- while(tag && tag->next)
+ while(tag && tag->next) {
tag = tag->next;
+ }
if(tag->id != ST_END) {
tag = swf_InsertTag(tag,ST_END);
}
}
}
close(fi);
-
+
+ swf_FreeTags(swf);
+ /*{ TAG * t = swf->firstTag;
+ while (t)
+ {
+ mylog("tag: %08x\n",t);
+ mylog(" id: %d (%s)\n", t->id, swf_TagGetName(t));
+ mylog(" data: %08x (%d bytes)\n", t->data, t->len);
+ mylog(" next: %08x\n", t->next);
+ TAG * tnew = t->next;
+ mylog("->free data\n");
+ if (t->data) free(t->data);
+ mylog("->free tag\n");
+ free(t);
+ t = tnew;
+ }
+ }*/
swf->firstTag = 0;
return PY_NONE;
if(!self || !PyArg_ParseTuple(args,""))
return NULL;
swf->swf.firstTag = taglist_getTAGs(swf->taglist);
+ if(!swf->swf.firstTag)
+ return NULL;
swf_WriteCGI(&swf->swf);
+ swf_FreeTags(&swf->swf);
swf->swf.firstTag = 0;
return PY_NONE;
}
return 0;
} else if(!strcmp(a, "tags")) {
PyObject* taglist;
- /*if (!PyArg_Parse(o, "O!", &TagListClass, &taglist));
- goto err;*/
- // TODO: check if it's really a taglist
taglist = o;
+ PY_ASSERT_TYPE(taglist,&TagListClass);
Py_DECREF(swf->taglist);
swf->taglist = taglist;
Py_INCREF(swf->taglist);
{"verbose", (PyCFunction)module_verbose, METH_KEYWORDS, "Set the module verbosity"},
{0,0,0,0}
};
-
+
void initSWF(void)
{
PyObject*module;
PyMethodDef* primitive_methods = primitive_getMethods();
- PyMethodDef* tag_methods = tag_getMethods();
+ PyMethodDef* tag_methods = tags_getMethods();
PyMethodDef* action_methods = action_getMethods();
PyMethodDef* swf_methods = swf_getMethods();
all_methods = addMethods(all_methods, LoggingMethods);
module = Py_InitModule("SWF", all_methods);
+
+ /* Python doesn't copy the PyMethodDef struct, so we need
+ to keep it around */
+ // free(all_methods)
}
+