diff options
author | ftrvxmtrx <ftrvxmtrx@gmail.com> | 2013-01-21 01:05:00 +0100 |
---|---|---|
committer | ftrvxmtrx <ftrvxmtrx@gmail.com> | 2013-01-21 01:05:00 +0100 |
commit | de5fdbc0101e5f8f327868da7735b5726f1657c9 (patch) | |
tree | 827b85f1ad723cc80b99669dcd443b560ba8049d /sys/src/cmd/file.c | |
parent | d5c0fe22e3641d241a4fd1250896baa1fc413c51 (diff) |
file: detect tga images
Diffstat (limited to 'sys/src/cmd/file.c')
-rw-r--r-- | sys/src/cmd/file.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/src/cmd/file.c b/sys/src/cmd/file.c index cbc2227d8..dd0c69737 100644 --- a/sys/src/cmd/file.c +++ b/sys/src/cmd/file.c @@ -150,6 +150,7 @@ int ishtml(void); int isrfc822(void); int ismbox(void); int islimbo(void); +int istga(void); int ismp3(void); int ismung(void); int isp9bit(void); @@ -196,6 +197,7 @@ int (*call[])(void) = ismsdos, /* msdos exe (virus file attachement) */ isicocur, /* windows icon or cursor file */ isface, /* ascii face file */ + istga, ismp3, /* last resorts */ @@ -1198,6 +1200,26 @@ isas(void) } int +istga(void) +{ + uchar *p; + + p = buf; + if(nbuf < 14) + return 0; + if(((p[2]|(1<<3)) & (~3)) != (1<<3)) /* rle flag */ + return 0; + if(p[1] == 0 && ((p[2]&3) != 2 && (p[2]&3) != 3)) /* non color-mapped */ + return 0; + if(p[1] == 1 && ((p[2]&3) != 1 || p[7] == 0)) /* color-mapped */ + return 0; + if(p[16] != 8 && p[16] != 16 && p[16] != 24 && p[16] != 32) /* bpp */ + return 0; + print("%s\n", mime ? "image/tga" : "targa image"); + return 1; +} + +int ismp3(void) { uchar *p, *e; |