1** README for file(1) Command ** 2@(#) $File: README,v 1.42 2009/02/14 15:16:24 christos Exp $ 3 4E-mail: [email protected] 5Mailing List: [email protected] 6 7Phone: Do not even think of telephoning me about this program. Send cash first! 8 9This is Release 5.x of Ian Darwin's (copyright but distributable) 10file(1) command. This version is the standard "file" command for Linux, 11*BSD, and other systems. (See "patchlevel.h" for the exact release number). 12 13The major changes for 5.x are CDF file parsing, indirect magic, and 14overhaul in mime and ascii encoding handling. 15 16The major feature of 4.x is the refactoring of the code into a library, 17and the re-write of the file command in terms of that library. The library 18itself, libmagic can be used by 3rd party programs that wish to identify 19file types without having to fork() and exec() file. The prime contributor 20for 4.0 was M\xe5ns Rullg\xe5rd. 21 22UNIX is a trademark of UNIX System Laboratories. 23 24The prime contributor to Release 3.8 was Guy Harris, who put in megachanges 25including byte-order independence. 26 27The prime contributor to Release 3.0 was Christos Zoulas, who put 28in hundreds of lines of source code changes, including his own 29ANSIfication of the code (I liked my own ANSIfication better, but 30his (__P()) is the "Berkeley standard" way of doing it, and I wanted UCB 31to include the code...), his HP-like "indirection" (a feature of 32the HP file command, I think), and his mods that finally got the 33uncompress (-z) mode finished and working. 34 35This release has compiled in numerous environments; see PORTING 36for a list and problems. 37 38This fine freeware file(1) follows the USG (System V) model of the file 39command, rather than the Research (V7) version or the V7-derived 4.[23] 40Berkeley one. That is, the file /etc/magic contains much of the ritual 41information that is the source of this program's power. My version 42knows a little more magic (including tar archives) than System V; the 43/etc/magic parsing seems to be compatible with the (poorly documented) 44System V /etc/magic format (with one exception; see the man page). 45 46In addition, the /etc/magic file is built from a subdirectory 47for easier(?) maintenance. I will act as a clearinghouse for 48magic numbers assigned to all sorts of data files that 49are in reasonable circulation. Send your magic numbers, 50in magic(5) format please, to the maintainer, Christos Zoulas. 51 52COPYING - read this first. 53README - read this second (you are currently reading this file). 54INSTALL - read on how to install 55 56src/apprentice.c - parses /etc/magic to learn magic 57src/apptype.c - used for OS/2 specific application type magic 58src/asprintf.c - replacement for OS's that don't have it. 59src/ascmagic.c - third & last set of tests, based on hardwired assumptions. 60src/cdf.c - parser for Microsoft Compound Document Files 61src/cdf_time.c - time converter for CDF. 62src/compress.c - handles decompressing files to look inside. 63src/encoding.c - handles unicode encodings 64src/file.c - the main program 65src/file.h - header file 66src/fsmagic.c - first set of tests the program runs, based on filesystem info 67src/funcs.c - utilility functions 68src/getopt_long.c - used for OS/2 specific application type magic 69src/is_tar.c, tar.h - knows about tarchives (courtesy John Gilmore). 70src/names.h - header file for ascmagic.c 71src/magic.c - the libmagic api 72src/print.c - print results, errors, warnings. 73src/readcdf.c - CDF wrapper. 74src/readelf.[ch] - Stand-alone elf parsing code. 75src/softmagic.c - 2nd set of tests, based on /etc/magic 76src/strlcat.c - used for OS/2 specific application type magic 77src/strlcpy.c - used for OS/2 specific application type magic 78src/vasprintf.c - used for OS/2 specific application type magic 79doc/file.1 - man page for the command 80doc/magic.4 - man page for the magic file, courtesy Guy Harris. 81 Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile. 82Magdir - directory of /etc/magic pieces 83 84------------------------------------------------------------------------------ 85 86If you submit a new magic entry please make sure you read the following 87guidelines: 88 89- Initial match is preferably at least 32 bits long, and is a _unique_ match 90- If this is not feasible, use additional check 91- Match of <= 16 bits are not accepted 92- Delay printing string as much as possible, don't print output too early 93- Avoid printf arbitrary byte as string, which can be a source of 94 crash and buffer overflow 95 96- Provide complete information with entry: 97 * One line short summary 98 * Optional long description 99 * File extension, if applicable 100 * Full name and contact method (for discussion when entry has problem) 101 * Further reference, such as documentation of format 102 103------------------------------------------------------------------------------ 104 105You can download the latest version of file from: 106 107 ftp://ftp.astron.com/pub/file/ 108 109If your gzip sometimes fails to decompress things complaining about a short 110file, apply this patch [which is going to be in the next version of gzip]: 111*** - Tue Oct 29 02:06:35 1996 112--- util.c Sun Jul 21 21:51:38 1996 113*** 106,111 **** 114--- 108,114 ---- 115 116 if (insize == 0) { 117 if (eof_ok) return EOF; 118+ flush_window(); 119 read_error(); 120 } 121 bytes_in += (ulg)insize; 122 123Parts of this software were developed at SoftQuad Inc., developers 124of SGML/HTML/XML publishing software, in Toronto, Canada. 125SoftQuad was swallowed up by Corel in 2002 126and does not exist any longer. 127 128From: Kees Zeelenberg 129 130An MS-Windows (Win32) port of File-4.17 is available from 131http://gnuwin32.sourceforge.net/ 132 133File is an implementation of the Unix File(1) command. 134It knows the 'magic number' of several thousands of file types. 135