- printf(" %d", data);data++;
- } break;
- case 'b': {
- printf(" %d", *(U16*)data);data+=2;
- } break;
- case 'p': {
- U8 type = *data++;
- if(type == 0) {
- printf(" String:\"%s\"", data);data+=strlen(data)+1;
- } else if (type == 1) {
- printf(" Double:\"%f\"", *(float*)data);data+=4;
- } else if (type == 2) {
- printf(" NULL");
- } else if (type == 4) {
- printf(" register:%d", data++);
- } else if (type == 5) {
- printf(" %s", data++?"true":"false");
- } else if (type == 6) {
- printf(" %f", *(double*)data); data+=8;
- } else if (type == 7) {
- printf(" %d", *(int*)data); data+=4;
- } else if (type == 8) {
- printf(" Lookup:%d", data++);
- }
- } break;
-
- }
- 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;t<nl;t++) {
+ if(data[t]<32)
+ printf("\\%d",data[t]);
+ else
+ printf("%c", data[t]);
+ }
+ printf("\"");
+ }
+ printf("\n");
+ atag = atag->next;
+ }
+}
+
+int swf_ActionEnumerateURLs(ActionTAG*atag, char*(*callback)(char*))
+{
+ U8 op;
+ int t;
+ U8*data;
+ char* cp;
+
+ while(atag)
+ {
+
+ for(t=0;t<definedactions;t++)
+ if(actions[t].op == atag->op)
+ 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://"?
+ 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.
+ }
+ }