]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/file.c
mothra: never snarf the "Go:" box
[plan9front.git] / sys / src / cmd / file.c
index 0b1f88ee34951caa3b0b72d732e9c38ea577d964..7da5abdaaf6540421d8d2c185eac40e181fb79b0 100644 (file)
@@ -150,11 +150,13 @@ int       ishtml(void);
 int    isrfc822(void);
 int    ismbox(void);
 int    islimbo(void);
+int    ismp3(void);
 int    ismung(void);
 int    isp9bit(void);
 int    isp9font(void);
 int    isrtf(void);
 int    ismsdos(void);
+int    isicocur(void);
 int    iself(void);
 int    istring(void);
 int    isoffstr(void);
@@ -192,7 +194,9 @@ int (*call[])(void) =
        isp9bit,        /* plan 9 image (as from /dev/window) */
        isrtf,          /* rich text format */
        ismsdos,        /* msdos exe (virus file attachement) */
+       isicocur,               /* windows icon or cursor file */
        isface,         /* ascii face file */
+       ismp3,
 
        /* last resorts */
        ismung,         /* entropy compressed/encrypted */
@@ -586,7 +590,7 @@ Filemagic long0tab[] = {
        /* "pXc2 */
        0x32630070,     0xFFFF00FF,     "pac4 audio file\n",    OCTET,
        0xBA010000,     0xFFFFFFFF,     "mpeg system stream\n", OCTET,
-       0x43614c66,     0xFFFFFFFF,     "FLAC audio file\n",    OCTET,
+       0x43614c66,     0xFFFFFFFF,     "FLAC audio file\n",    "audio/flac",
        0x30800CC0,     0xFFFFFFFF,     "inferno .dis executable\n", OCTET,
        0x04034B50,     0xFFFFFFFF,     "zip archive\n", "application/zip",
        070707,         0xFFFF,         "cpio archive\n", "application/x-cpio",
@@ -800,12 +804,14 @@ struct    FILE_STRING
        "\377\330\377\340",     "jpeg",                         4,      "image/jpeg",
        "\377\330\377\341",     "jpeg",                         4,      "image/jpeg",
        "\377\330\377\333",     "jpeg",                         4,      "image/jpeg",
+       "\xff\xd8",             "jpeg",                         2,      "image/jpeg",
        "BM",                   "bmp",                          2,      "image/bmp", 
        "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1",     "microsoft office document",    8,      "application/doc",
        "<MakerFile ",          "FrameMaker file",              11,     "application/framemaker",
        "\033E\033",    "HP PCL printer data",          3,      OCTET,
        "\033%-12345X", "HPJCL file",           9,      "application/hpjcl",
        "ID3",                  "mp3 audio with id3",   3,      "audio/mpeg",
+       "OggS",                 "ogg audio",            4,      "audio/ogg",
        "\211PNG",              "PNG image",            4,      "image/png",
        "P3\n",                 "ppm",                          3,      "image/ppm",
        "P6\n",                 "ppm",                          3,      "image/ppm",
@@ -832,6 +838,8 @@ struct      FILE_STRING
        "subject=/C=",          "pem certificate with header", -1, "text/plain",
        "process snapshot ",    "process snapshot",     -1,     "application/snapfs",
        "d8:announce",          "torrent file",         11,     "application/x-bittorrent",
+       "[playlist]",           "playlist",             10,     "application/x-scpls",
+       "#EXTM3U",              "playlist",             7,      "audio/x-mpegurl",
        0,0,0,0
 };
 
@@ -871,7 +879,7 @@ struct offstr
        ulong   off;
        struct FILE_STRING;
 } offstrs[] = {
-       32*1024, "\001CD001\001",       "ISO9660 CD image",     7,      OCTET,
+       32*1024, "\001CD001\001",       "ISO9660 CD image",     7,      "application/x-iso9660-image",
        0, 0, 0, 0, 0
 };
 
@@ -1129,6 +1137,23 @@ isas(void)
        return 1;
 }
 
+int
+ismp3(void)
+{
+       uchar *p, *e;
+
+       p = buf;
+       e = p + nbuf-1;
+       while((p < e) && (p = memchr(p, 0xFF, e - p))){
+               if((p[1] & 0xFE) == 0xFA){
+                       print(mime ? "audio/mpeg\n" : "mp3 audio\n");
+                       return 1;
+               }
+               p++;
+       }
+       return 0;
+}
+
 /*
  * low entropy means encrypted
  */
@@ -1456,6 +1481,24 @@ ismsdos(void)
        return 0;
 }
 
+int
+isicocur(void)
+{
+       if(buf[0] || buf[1] || buf[3] || buf[9])
+               return 0;
+       if(buf[4] == 0x00 && buf[5] == 0x00)
+               return 0;
+       switch(buf[2]){
+       case 1:
+               print(mime ? "image/x-icon\n" : "Microsoft icon file\n");
+               return 1;
+       case 2:
+               print(mime ? "image/x-icon\n" : "Microsoft cursor file\n");
+               return 1;
+       }
+       return 0;
+}
+
 int
 iself(void)
 {