X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fabc.c;h=7d353245ed44fdbdf08bed930eadcf8770cb1fa2;hb=d5a67d6c3d1e97ebe9b30b26dd4c68cd7aa4c9c8;hp=27c43319e1ab7ab62e58e0aabcd51b66fb3aa27b;hpb=4e990c50e8224621ac557f21ed3bd937ba0bbff3;p=swftools.git diff --git a/lib/as3/abc.c b/lib/as3/abc.c index 27c4331..7d35324 100644 --- a/lib/as3/abc.c +++ b/lib/as3/abc.c @@ -28,124 +28,6 @@ char stringbuffer[2048]; -dict_t* dict_new() { - dict_t*d = malloc(sizeof(dict_t)); - memset(d, 0, sizeof(dict_t)); - return d; -} - -void dict_free(dict_t*dict) { - if(dict->d) - free(dict->d);dict->d = 0; - free(dict); -} - -const char*dict_getstr(dict_t*dict, int nr) { - if(nr > dict->num || nr<0) { - printf("error: reference to string %d in dict\n"); - return 0; - } - return dict->d[nr].name; -} -char*dict_getdata(dict_t*dict, int nr) { - if(nr > dict->num || nr<0) { - printf("error: reference to string %d in dict\n"); - return 0; - } - return dict->d[nr].data; -} -int dict_append(dict_t*dict, const char*name, void*data) { - while(dict->size <= dict->num) { - dict->size += 64; - if(!dict->d) { - dict->d = malloc(sizeof(dict_entry_t)*dict->size); - } else { - dict->d = realloc(dict->d, sizeof(dict_entry_t)*dict->size); - } - } - if(name) { - dict->d[dict->num].name = strdup(name); - } else { - dict->d[dict->num].name = 0; - } - dict->d[dict->num].data = data; - return dict->num++; -} -int dict_find(dict_t*dict, const char*name) -{ - if(!name) - name = ""; - int t; - for(t=0;tnum;t++) { - if(dict->d[t].name && !strcmp(dict->d[t].name,name)) - return t; - } - return -1; -} -int dict_find2(dict_t*dict, const char*name, void*data) -{ - if(!name) - name = ""; - int t; - for(t=0;tnum;t++) { - if(dict->d[t].name && !strcmp(dict->d[t].name,name) && dict->d[t].data == data) - return t; - } - return -1; -} -int dict_update(dict_t*dict, const char*name, void*data) { - int pos = dict_find(dict, name); - if(pos>=0) { - dict->d[pos].data = data; - return pos; - } - return dict_append(dict, name, data); -} -int dict_append_if_new(dict_t*dict, const char*name, void*data) { - int pos = dict_find(dict, name); - if(pos>=0) - return pos; - return dict_append(dict, name, data); -} -int dict_append_if_new2(dict_t*dict, const char*name, void*data) { - int pos = dict_find2(dict, name, data); - if(pos>=0) - return pos; - return dict_append(dict, name, data); -} - -typedef struct _commonlist { - void*entry; - struct _commonlist*next; - struct _commonlist*last[0]; -} commonlist_t; - -int list_length(void*_list) -{ - commonlist_t*l = (commonlist_t*)_list; - int n=0; - while(l) { - l = l->next; - n++; - } - return n; -} -void list_append(void*_list, void*entry) -{ - commonlist_t**list = (commonlist_t**)_list; - commonlist_t* n = 0; - if(!*list) { - n = malloc(sizeof(commonlist_t)+sizeof(commonlist_t*)); - *list = n; - } else { - n = malloc(sizeof(commonlist_t)); - (*list)->last[0]->next = n; - } - n->next = 0; - n->entry = entry; - (*list)->last[0] = n; -} - int swf_GetU30(TAG*tag) { U32 shift = 0; @@ -1019,13 +901,13 @@ int register_multiname(abc_file_t*pool, abc_multiname_t*n) if(!n) return 0; /* FIXME: might create duplicates */ - return dict_append_if_new2(pool->multinames, n->name, n); + return dict_append_if_new(pool->multinames, n->name, n); } int register_namespace(abc_file_t*pool, abc_namespace_t*ns) { /* FIXME: might create duplicates */ - return dict_append_if_new2(pool->namespaces, ns->name, ns); + return dict_append_if_new(pool->namespaces, ns->name, ns); } static inline abc_multiname_t*multiname_lookup(abc_file_t*pool, int i) @@ -1698,6 +1580,7 @@ void swf_AddButtonLinks(SWF*swf, char stop_each_frame, char events) if(!events) { abc_findpropstrict(h,"flash.net::navigateToURL"); abc_findpropstrict(h,"flash.net::URLRequest"); + // TODO: target _blank abc_pushstring(h,oldaction->data); //url abc_constructprop(h,"flash.net::URLRequest", 1); abc_callpropvoid(h,"flash.net::navigateToURL", 1);