-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from jmattaa/feat/file-extensions
feat: add file extensions to filetype detection
- Loading branch information
Showing
6 changed files
with
119 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
#include "filetypes/checktypes.h" | ||
|
||
const struct laser_magicnumber laser_archiveformats[] = { | ||
{(unsigned char[]){0x50, 0x4B, 0x03, 0x04}, 4}, // ZIP and stuff based on it | ||
{(unsigned char[]){0x1F, 0x8B}, 2}, // GZIP | ||
{(unsigned char[]){'u', 's', 't', 'a', 'r'}, 5}, // TAR | ||
{(unsigned char[]){0x42, 0x5A, 0x68}, 3}, // BZIP2 | ||
{(unsigned char[]){0xFD, 0x37, 0x7A, 0x58, 0x5A}, 5}, // XZ | ||
{(unsigned char[]){0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00}, | ||
7}, // RAR v1.5 to 4.0 | ||
{(unsigned char[]){0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00}, | ||
8}, // RAR v5+ | ||
const struct laser_filetype laser_archiveformats[] = { | ||
|
||
{ | ||
(unsigned char[]){0x50, 0x4B, 0x03, 0x04}, | ||
4, | ||
(const char *[]){"zip", "aar", "apk", "docx", "epub", "ipa", "jar", | ||
"kmz", "maff", "msix", "odp", "ods", "odt", "pk3", | ||
"pk4", "pptx", "usdz", "vsdx", "xlsx", "xpi"}, | ||
20, | ||
}, // ZIP and stuff based on it | ||
{(unsigned char[]){0x1F, 0x8B}, 2, (const char *[]){"gz"}, 1}, // GZIP | ||
{(unsigned char[]){'u', 's', 't', 'a', 'r'}, 5, (const char *[]){"tar"}, | ||
1}, // TAR | ||
{(unsigned char[]){0x42, 0x5A, 0x68}, 3, (const char *[]){"bz2"}, | ||
1}, // BZIP2 | ||
{(unsigned char[]){0xFD, 0x37, 0x7A, 0x58, 0x5A}, 5, (const char *[]){"xz"}, | ||
1}, // XZ | ||
{(unsigned char[]){0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00}, 7, | ||
(const char *[]){"rar"}, 1}, // RAR v1.5 to 4.0 | ||
{(unsigned char[]){0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00}, 8, | ||
(const char *[]){"rar"}, 1}, // RAR v5+ | ||
// ADD MORE ARCHIVES | ||
{NULL, 0}}; | ||
|
||
{NULL, 0, NULL, 0}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
#include "filetypes/checktypes.h" | ||
|
||
const struct laser_magicnumber laser_documentformats[] = { | ||
{(unsigned char[]){'%', 'P', 'D', 'F'}, 4}, // PDF | ||
{(unsigned char[]){0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1}, | ||
8}, // compound bin file from microsoft (doc, xls, ppt, msi, msg) | ||
{(unsigned char[]){0x41, 0x54, 0x26, 0x54, 0x46, 0x4F, 0x52, 0x4D}, | ||
8}, // DJVU | ||
const struct laser_filetype laser_documentformats[] = { | ||
{(unsigned char[]){'%', 'P', 'D', 'F'}, 4, (const char *[]){"pdf"}, | ||
1}, // PDF | ||
{(unsigned char[]){0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1}, 8, | ||
(const char *[]){"doc", "xls", "ppt", "msi", "msg"}, | ||
5}, // compound bin file from microsoft | ||
{(unsigned char[]){0x41, 0x54, 0x26, 0x54, 0x46, 0x4F, 0x52, 0x4D}, 8, | ||
(const char *[]){"djvu", "djv"}, 2}, // DJVU | ||
// ADD DOCUMENT TYPES | ||
{NULL, 0}}; | ||
|
||
{NULL, 0, NULL, 0}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
#include "filetypes/checktypes.h" | ||
|
||
const struct laser_magicnumber laser_mediaformats[] = { | ||
{(unsigned char[]){0xFF, 0xD8, 0xFF, 0xE0}, 4}, // JPEG | ||
{(unsigned char[]){0x89, 0x50, 0x4E, 0x47}, 4}, // PNG | ||
{(unsigned char[]){0x47, 0x49, 0x46, 0x38}, 4}, // GIF | ||
{(unsigned char[]){0x49, 0x44, 0x33}, 3}, // MP3 | ||
{(unsigned char[]){0x66, 0x74, 0x79, 0x70, 0x4D, 0x53, 0x4E, 0x56}, | ||
8}, // MP4 | ||
const struct laser_filetype laser_mediaformats[] = { | ||
{(unsigned char[]){0xFF, 0xD8, 0xFF, 0xE0}, 4, | ||
(const char *[]){"jpeg", "jpg"}, 2}, // JPEG | ||
{(unsigned char[]){0x89, 0x50, 0x4E, 0x47}, 4, (const char *[]){"png"}, | ||
1}, // PNG | ||
{(unsigned char[]){0x47, 0x49, 0x46, 0x38}, 4, (const char *[]){"gif"}, | ||
1}, // GIF | ||
{(unsigned char[]){0x49, 0x44, 0x33}, 3, (const char *[]){"mp3"}, 1}, // MP3 | ||
{(unsigned char[]){0x66, 0x74, 0x79, 0x70, 0x4D, 0x53, 0x4E, 0x56}, 8, | ||
(const char *[]){"mp4"}, 1}, // MP4 | ||
// ADD MORE MEDIA TYPES | ||
{NULL, 0}}; | ||
|
||
{NULL, 0, NULL, 0}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters