removed % handling
[swftools.git] / src / swfdump.c
index e434ceb..8eaeb25 100644 (file)
@@ -58,6 +58,7 @@ static int showshapes = 0;
 static int hex = 0;
 static int used = 0;
 static int bbox = 0;
+static int cumulative = 0;
 
 static struct options_t options[] = {
 {"h", "help"},
@@ -105,6 +106,10 @@ int args_callback_option(char*name,char*val)
         html = 1;
         return 0;
     }
+    else if(name[0]=='c') {
+        cumulative = 1;
+        return 0;
+    }
     else if(name[0]=='E') {
         html = 1;
         xhtml = 1;
@@ -162,6 +167,7 @@ void args_callback_usage(char *name)
     printf("-D , --full                    Show everything. Same as -atp\n");
     printf("-V , --version                 Print version info and exit\n");
     printf("-e , --html                    Print out html code for embedding the file\n");
+    printf("-E , --xhtml                   Print out xhtml code for embedding the file\n");
     printf("-a , --action                  Disassemble action tags\n");
     printf("-t , --text                    Show text fields (like swfstrings).\n");
     printf("-s , --shapes                  Show shape coordinates/styles\n");
@@ -270,8 +276,12 @@ void textcallback(void*self, int*glyphs, int*ypos, int nr, int fontid, int fonts
            if(glyphs[t] >= fonts[font]->numchars  /*glyph is in range*/
                    || !fonts[font]->glyph2ascii /* font has ascii<->glyph mapping */
              ) a = glyphs[t];
-           else
-               a = fonts[font]->glyph2ascii[glyphs[t]];
+           else {
+               if(fonts[font]->glyph2ascii[glyphs[t]])
+                   a = fonts[font]->glyph2ascii[glyphs[t]];
+               else
+                   a = glyphs[t];
+           }
        } else {
            a = glyphs[t];
        }
@@ -561,12 +571,12 @@ void handlePlaceObject(TAG*tag, char*prefix)
 {
     TAG*tag2 = swf_InsertTag(0, ST_PLACEOBJECT2);
     U16 id, depth;
+    MATRIX matrix; 
+    CXFORM cxform;
 
     swf_SetTagPos(tag, 0);
     id = swf_GetU16(tag);
     depth = swf_GetU16(tag);
-    MATRIX matrix; 
-    CXFORM cxform;
     swf_GetMatrix(tag, &matrix);
     swf_GetCXForm(tag, &cxform, 0);
 
@@ -588,9 +598,15 @@ char* fillstyle2str(FILLSTYLE*style)
        case 0x10: case 0x12:
            sprintf(stylebuf, "GRADIENT (%d steps)", style->gradient.num);
            break;
-       case 0x40: case 0x41:
+       case 0x40: 
+           /* TODO: display information about that bitmap */
+           sprintf(stylebuf, "BITMAPt %d", style->id_bitmap);
+           /* TODO: show matrix */
+           break;
+       case 0x41:
            /* TODO: display information about that bitmap */
-           sprintf(stylebuf, "BITMAP %d", style->id_bitmap);
+           sprintf(stylebuf, "BITMAPc %d", style->id_bitmap);
+           /* TODO: show matrix */
            break;
        default:
            sprintf(stylebuf, "UNKNOWN[%02x]",style->type);
@@ -755,6 +771,7 @@ int main (int argc,char ** argv)
     char* framelabel = 0;
     char prefix[128];
     int filesize = 0;
+    int filepos = 0;
     prefix[0] = 0;
     memset(idtab,0,65536);
 
@@ -898,10 +915,14 @@ int main (int argc,char ** argv)
             //tag = tag->next;
             //continue;
         }
-       if(swf_TagGetName(tag)) {
-           printf("[%03x] %9ld %s%s", tag->id, tag->len, prefix, swf_TagGetName(tag));
+       if(!name) {
+           name = "UNKNOWN TAG";
+       }
+       if(cumulative) {
+           filepos += tag->len;
+           printf("[%03x] %9ld %9ld %s%s", tag->id, tag->len, filepos, prefix, swf_TagGetName(tag));
        } else {
-           printf("[%03x] %9ld %sUNKNOWN TAG %03x", tag->id, tag->len, prefix, tag->id);
+           printf("[%03x] %9ld %s%s", tag->id, tag->len, prefix, swf_TagGetName(tag));
        }
        
        if(tag->id == ST_FREECHARACTER) {
@@ -982,9 +1003,9 @@ int main (int argc,char ** argv)
        else if(tag->id == ST_FRAMELABEL) {
            int l = strlen(tag->data);
            printf(" \"%s\"", tag->data);
-           if(l < tag->len-1) {
+           if((l+1) < tag->len) {
                printf(" has %d extra bytes", tag->len-1-l);
-               if(tag ->len-1-l == 1 && tag->data[tag->len-1] == 1)
+               if(tag ->len - (l+1) == 1 && tag->data[tag->len-1] == 1)
                    printf(" (ANCHOR)");
            }
            if((framelabel && !issprite) ||