If the file is compressed, unpack it and look at the contents.
MAGIC_DEVICES
If the file is a block or character special device, then open the device and try to look in its contents.
MAGIC_MIME
Return a mime string, instead of a textual description.
MAGIC_CONTINUE
Return all matches, not just the first.
MAGIC_CHECK
Check the magic database for consistency and print warnings to stderr.
MAGIC_PRESERVE_ATIME
On systems that support utime(2) or utimes(2), attempt to preserve the access time of files analyzed.
MAGIC_RAW
Dont translate unprintable characters to a \ooo octal representation.
MAGIC_ERROR
Treat operating system errors while trying to open files and follow symlinks as real errors, instead of printing them in the magic buffer.
The magic_close function closes the magic(5) database and deallocates any resources used.
The magic_error function returns a textual explanation of the last error, or NULL if there was no error.
The magic_errno function returns the last operating system error number ( errno(3)) that was encountered by a system call.
The magic_file function returns a textual description of the contents of the filename argument, or NULL if an error occurred. If the filename is NULL, then stdin is used.
The magic_buffer function returns a textual description of the contents of the buffer argument with length bytes size.
The magic_setflags function, sets the flags described above.
The magic_check function can be used to check the validity of entries in the colon separated database files passed in as filename, or NULL for the default database. It returns 0 on success and -1 on failure.
The magic_compile function can be used to compile the the colon separated list of database files passed in as filename, or NULL for the default database. It returns 0 on success and -1 on failure. The compiled files created are named from the basename(1) of each file argument with ".mgc" appended to it.
The magic_load function must be used to load the the colon separated list of database files passed in as filename, or NULL for the default database file before any magic queries can performed.
The default database file is named by the MAGIC environment variable. If that variable is not set, the default database file name is /usr/share/misc/magic.
magic_load adds ".mime" and/or ".mgc" to the database filename as appropriate.