1## README for file(1) Command and the libmagic(3) library ## 2 3 @(#) $File: README,v 1.57 2019/02/06 00:20:56 christos Exp $ 4 5Mailing List: [email protected] 6Mailing List archives: http://mailman.astron.com/pipermail/file/ 7Bug tracker: http://bugs.astron.com/ 8E-mail: [email protected] 9Build Status: https://travis-ci.org/file/file 10 11Phone: Do not even think of telephoning me about this program. Send cash first! 12 13This is Release 5.x of Ian Darwin's (copyright but distributable) 14file(1) command, an implementation of the Unix File(1) command. 15It knows the 'magic number' of several thousands of file types. 16This version is the standard "file" command for Linux, 17*BSD, and other systems. (See "patchlevel.h" for the exact release number). 18 19You can download the latest version of the original sources for file from: 20 21 ftp://ftp.astron.com/pub/file/ 22 23A public read-only git repository of the same sources is available at: 24 25 https://github.com/file/file 26 27The major changes for 5.x are CDF file parsing, indirect magic, name/use 28(recursion) and overhaul in mime and ascii encoding handling. 29 30The major feature of 4.x is the refactoring of the code into a library, 31and the re-write of the file command in terms of that library. The library 32itself, libmagic can be used by 3rd party programs that wish to identify 33file types without having to fork() and exec() file. The prime contributor 34for 4.0 was Mans Rullgard. 35 36UNIX is a trademark of UNIX System Laboratories. 37 38The prime contributor to Release 3.8 was Guy Harris, who put in megachanges 39including byte-order independence. 40 41The prime contributor to Release 3.0 was Christos Zoulas, who put 42in hundreds of lines of source code changes, including his own 43ANSIfication of the code (I liked my own ANSIfication better, but 44his (__P()) is the "Berkeley standard" way of doing it, and I wanted UCB 45to include the code...), his HP-like "indirection" (a feature of 46the HP file command, I think), and his mods that finally got the 47uncompress (-z) mode finished and working. 48 49This release has compiled in numerous environments; see PORTING 50for a list and problems. 51 52This fine freeware file(1) follows the USG (System V) model of the file 53command, rather than the Research (V7) version or the V7-derived 4.[23] 54Berkeley one. That is, the file /etc/magic contains much of the ritual 55information that is the source of this program's power. My version 56knows a little more magic (including tar archives) than System V; the 57/etc/magic parsing seems to be compatible with the (poorly documented) 58System V /etc/magic format (with one exception; see the man page). 59 60In addition, the /etc/magic file is built from a subdirectory 61for easier(?) maintenance. I will act as a clearinghouse for 62magic numbers assigned to all sorts of data files that 63are in reasonable circulation. Send your magic numbers, 64in magic(5) format please, to the maintainer, Christos Zoulas. 65 66COPYING - read this first. 67README - read this second (you are currently reading this file). 68INSTALL - read on how to install 69src/apprentice.c - parses /etc/magic to learn magic 70src/apptype.c - used for OS/2 specific application type magic 71src/ascmagic.c - third & last set of tests, based on hardwired assumptions. 72src/asctime_r.c - replacement for OS's that don't have it. 73src/asprintf.c - replacement for OS's that don't have it. 74src/asctime_r.c - replacement for OS's that don't have it. 75src/asprintf.c - replacement for OS's that don't have it. 76src/buffer.c - buffer handling functions. 77src/cdf.[ch] - parser for Microsoft Compound Document Files 78src/cdf_time.c - time converter for CDF. 79src/compress.c - handles decompressing files to look inside. 80src/ctime_r.c - replacement for OS's that don't have it. 81src/der.[ch] - parser for Distinguished Encoding Rules 82src/dprintf.c - replacement for OS's that don't have it. 83src/elfclass.h - common code for elf 32/64. 84src/encoding.c - handles unicode encodings 85src/file.c - the main program 86src/file.h - header file 87src/file_opts.h - list of options 88src/fmtcheck.c - replacement for OS's that don't have it. 89src/fsmagic.c - first set of tests the program runs, based on filesystem info 90src/funcs.c - utilility functions 91src/getline.c - replacement for OS's that don't have it. 92src/getopt_long.c - replacement for OS's that don't have it. 93src/gmtime_r.c - replacement for OS's that don't have it. 94src/is_json.c - knows about JavaScript Object Notation format (RFC 8259). 95src/is_tar.c, tar.h - knows about Tape ARchive format (courtesy John Gilmore). 96src/localtime_r.c - replacement for OS's that don't have it. 97src/magic.h.in - source file for magic.h 98src/mygetopt.h - replacement for OS's that don't have it. 99src/magic.c - the libmagic api 100src/names.h - header file for ascmagic.c 101src/pread.c - replacement for OS's that don't have it. 102src/print.c - print results, errors, warnings. 103src/readcdf.c - CDF wrapper. 104src/readelf.[ch] - Stand-alone elf parsing code. 105src/softmagic.c - 2nd set of tests, based on /etc/magic 106src/mygetopt.h - replacement for OS's that don't have it. 107src/strcasestr.c - replacement for OS's that don't have it. 108src/strlcat.c - replacement for OS's that don't have it. 109src/strlcpy.c - replacement for OS's that don't have it. 110src/strndup.c - replacement for OS's that don't have it. 111src/tar.h - tar file definitions 112src/vasprintf.c - for systems that don't have it. 113doc/file.man - man page for the command 114doc/magic.man - man page for the magic file, courtesy Guy Harris. 115 Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile. 116 117Magdir - directory of /etc/magic pieces 118------------------------------------------------------------------------------ 119 120If you submit a new magic entry please make sure you read the following 121guidelines: 122 123- Initial match is preferably at least 32 bits long, and is a _unique_ match 124- If this is not feasible, use additional check 125- Match of <= 16 bits are not accepted 126- Delay printing string as much as possible, don't print output too early 127- Avoid printf arbitrary byte as string, which can be a source of 128 crash and buffer overflow 129 130- Provide complete information with entry: 131 * One line short summary 132 * Optional long description 133 * File extension, if applicable 134 * Full name and contact method (for discussion when entry has problem) 135 * Further reference, such as documentation of format 136 137------------------------------------------------------------------------------ 138 139gpg for dummies: 140 141$ gpg --verify file-X.YY.tar.gz.asc file-X.YY.tar.gz 142gpg: assuming signed data in `file-X.YY.tar.gz' 143gpg: Signature made WWW MMM DD HH:MM:SS YYYY ZZZ using DSA key ID KKKKKKKK 144 145To download the key: 146 147$ gpg --keyserver hkp://keys.gnupg.net --recv-keys KKKKKKKK 148 149------------------------------------------------------------------------------ 150 151 152Parts of this software were developed at SoftQuad Inc., developers 153of SGML/HTML/XML publishing software, in Toronto, Canada. 154SoftQuad was swallowed up by Corel in 2002 and does not exist any longer. 155