]> 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 59bb854f496adc71cfb8cfe8550939918bc373be..7da5abdaaf6540421d8d2c185eac40e181fb79b0 100644 (file)
@@ -150,6 +150,7 @@ int ishtml(void);
 int    isrfc822(void);
 int    ismbox(void);
 int    islimbo(void);
+int    ismp3(void);
 int    ismung(void);
 int    isp9bit(void);
 int    isp9font(void);
@@ -195,6 +196,7 @@ int (*call[])(void) =
        ismsdos,        /* msdos exe (virus file attachement) */
        isicocur,               /* windows icon or cursor file */
        isface,         /* ascii face file */
+       ismp3,
 
        /* last resorts */
        ismung,         /* entropy compressed/encrypted */
@@ -588,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",
@@ -809,6 +811,7 @@ struct      FILE_STRING
        "\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",
@@ -1134,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
  */