Created
November 13, 2018 10:57
-
-
Save xuchunyang/096a85312a843135d574d6149c9ffc63 to your computer and use it in GitHub Desktop.
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
/* | |
~ $ ./file-mime-type foo.png | |
image/png | |
*/ | |
#include <magic.h> | |
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
magic_t cookie = magic_open (MAGIC_MIME_TYPE); | |
magic_load (cookie, NULL); | |
printf("%s\n", magic_file (cookie, argv[1])); | |
return 0; | |
} | |
/* Local Variables: */ | |
/* compile-command: "cc -std=c99 -Wall -Wpedantic file-mime-type.c -o file-mime-type -lmagic" */ | |
/* End: */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment