1268515Sdelphij## README for file(1) Command ##
268349Sobrien
3300899Sdelphij    @(#) $File: README,v 1.50 2016/04/16 22:40:54 christos Exp $
4268515Sdelphij
5268515SdelphijMailing List: file@mx.gw.com  
6268515SdelphijMailing List archives: http://mx.gw.com/pipermail/file/  
7268515SdelphijBug tracker: http://bugs.gw.com/  
8186691SobrienE-mail: christos@astron.com
9186691Sobrien
10268515Sdelphij[![Build Status](https://travis-ci.org/file/file.png?branch=master)](https://travis-ci.org/file/file)
11268515Sdelphij
12186691SobrienPhone: Do not even think of telephoning me about this program. Send cash first!
13186691Sobrien
14192350SdelphijThis is Release 5.x of Ian Darwin's (copyright but distributable)
15234449Sobrienfile(1) command, an implementation of the Unix File(1) command.
16234449SobrienIt knows the 'magic number' of several thousands of file types.
17234449SobrienThis version is the standard "file" command for Linux,
1868349Sobrien*BSD, and other systems. (See "patchlevel.h" for the exact release number).
1968349Sobrien
20268515SdelphijYou can download the latest version of the original sources for file from:
21234449Sobrien
22234449Sobrien	ftp://ftp.astron.com/pub/file/
23234449Sobrien
24268515SdelphijA public read-only git repository of the same sources is available at:
25234449Sobrien
26268515Sdelphij	https://github.com/file/file
27234449Sobrien
28277592SdelphijThe major changes for 5.x are CDF file parsing, indirect magic, name/use
29277592Sdelphij(recursion) and overhaul in mime and ascii encoding handling.
30192350Sdelphij
31133359SobrienThe major feature of 4.x is the refactoring of the code into a library,
32133359Sobrienand the re-write of the file command in terms of that library. The library
33133359Sobrienitself, libmagic can be used by 3rd party programs that wish to identify
34133359Sobrienfile types without having to fork() and exec() file. The prime contributor
35268515Sdelphijfor 4.0 was Mans Rullgard.
36133359Sobrien
3768349SobrienUNIX is a trademark of UNIX System Laboratories.
3868349Sobrien
3968349SobrienThe prime contributor to Release 3.8 was Guy Harris, who put in megachanges
40103373Sobrienincluding byte-order independence.
4168349Sobrien
4268349SobrienThe prime contributor to Release 3.0 was Christos Zoulas, who put
4368349Sobrienin hundreds of lines of source code changes, including his own
4468349SobrienANSIfication of the code (I liked my own ANSIfication better, but
4568349Sobrienhis (__P()) is the "Berkeley standard" way of doing it, and I wanted UCB
4668349Sobriento include the code...), his HP-like "indirection" (a feature of
4768349Sobrienthe HP file command, I think), and his mods that finally got the
4868349Sobrienuncompress (-z) mode finished and working.
4968349Sobrien
5068349SobrienThis release has compiled in numerous environments; see PORTING
5168349Sobrienfor a list and problems.
5268349Sobrien
5368349SobrienThis fine freeware file(1) follows the USG (System V) model of the file
5468349Sobriencommand, rather than the Research (V7) version or the V7-derived 4.[23]
5568349SobrienBerkeley one. That is, the file /etc/magic contains much of the ritual
5668349Sobrieninformation that is the source of this program's power. My version
5768349Sobrienknows a little more magic (including tar archives) than System V; the
5868349Sobrien/etc/magic parsing seems to be compatible with the (poorly documented)
5968349SobrienSystem V /etc/magic format (with one exception; see the man page).
6068349Sobrien
6168349SobrienIn addition, the /etc/magic file is built from a subdirectory
6268349Sobrienfor easier(?) maintenance.  I will act as a clearinghouse for
6368349Sobrienmagic numbers assigned to all sorts of data files that
6468349Sobrienare in reasonable circulation. Send your magic numbers,
65133359Sobrienin magic(5) format please, to the maintainer, Christos Zoulas.
6668349Sobrien
67268515SdelphijCOPYING - read this first.  
68268515SdelphijREADME - read this second (you are currently reading this file).  
69191771SobrienINSTALL - read on how to install
70300899Sdelphijsrc/localtime_r.c
71300899Sdelphijsrc/magic.c
72300899Sdelphijsrc/magic.h
73300899Sdelphijsrc/mygetopt.h
74300899Sdelphijsrc/newtest2.c
75300899Sdelphijsrc/newtest3.c
76300899Sdelphijsrc/pread.c
77300899Sdelphijsrc/print.c
78300899Sdelphijsrc/readcdf.c
79300899Sdelphijsrc/readelf.c
80300899Sdelphijsrc/readelf.h
81300899Sdelphijsrc/regex.c
82300899Sdelphijsrc/regex2.c
83300899Sdelphijsrc/softmagic.c
84300899Sdelphijsrc/strcasestr.c
85300899Sdelphijsrc/strlcat.c
86300899Sdelphijsrc/strlcpy.c
87300899Sdelphijsrc/strndup.c
88300899Sdelphijsrc/tar.h
89300899Sdelphijsrc/teststrchr.c
90300899Sdelphijsrc/vasprintf.c
91300899Sdelphijsrc/x.c
92268515Sdelphijsrc/apprentice.c - parses /etc/magic to learn magic  
93268515Sdelphijsrc/apptype.c - used for OS/2 specific application type magic  
94268515Sdelphijsrc/ascmagic.c - third & last set of tests, based on hardwired assumptions.  
95277592Sdelphijsrc/asctime_r.c - replacement for OS's that don't have it.  
96277592Sdelphijsrc/asprintf.c - replacement for OS's that don't have it.  
97300899Sdelphijsrc/asctime_r.c - replacement for OS's that don't have it.  
98300899Sdelphijsrc/asprintf.c - replacement for OS's that don't have it.  
99277592Sdelphijsrc/cdf.[ch] - parser for Microsoft Compound Document Files  
100268515Sdelphijsrc/cdf_time.c - time converter for CDF.  
101268515Sdelphijsrc/compress.c - handles decompressing files to look inside.  
102277592Sdelphijsrc/ctime_r.c - replacement for OS's that don't have it.  
103300899Sdelphijsrc/der.[ch] - parser for Distinguished Encoding Rules
104300899Sdelphijsrc/dprintf.c - replacement for OS's that don't have it.
105277592Sdelphijsrc/elfclass.h - common code for elf 32/64.
106268515Sdelphijsrc/encoding.c - handles unicode encodings  
107268515Sdelphijsrc/file.c - the main program  
108268515Sdelphijsrc/file.h - header file  
109277592Sdelphijsrc/file_opts.h - list of options
110277592Sdelphijsrc/fmtcheck.c - replacement for OS's that don't have it.  
111268515Sdelphijsrc/fsmagic.c - first set of tests the program runs, based on filesystem info  
112268515Sdelphijsrc/funcs.c - utilility functions  
113277592Sdelphijsrc/getline.c - replacement for OS's that don't have it.  
114277592Sdelphijsrc/getopt_long.c - replacement for OS's that don't have it.  
115300899Sdelphijsrc/gmtime_r.c - replacement for OS's that don't have it.  
116300899Sdelphijsrc/is_tar.c, tar.h - knows about Tape ARchive format (courtesy John Gilmore).  
117300899Sdelphijsrc/localtime_r.c - replacement for OS's that don't have it.  
118277592Sdelphijsrc/magic.h.in - source file for magic.h
119300899Sdelphijsrc/mygetopt.h - replacement for OS's that don't have it.  
120268515Sdelphijsrc/magic.c - the libmagic api  
121300899Sdelphijsrc/names.h - header file for ascmagic.c  
122277592Sdelphijsrc/pread.c - replacement for OS's that don't have it.  
123268515Sdelphijsrc/print.c - print results, errors, warnings.  
124268515Sdelphijsrc/readcdf.c - CDF wrapper.  
125268515Sdelphijsrc/readelf.[ch] - Stand-alone elf parsing code.  
126268515Sdelphijsrc/softmagic.c - 2nd set of tests, based on /etc/magic  
127277592Sdelphijsrc/mygetopt.h - replacement for OS's that don't have it.  
128277592Sdelphijsrc/strcasestr.c - replacement for OS's that don't have it.  
129277592Sdelphijsrc/strlcat.c - replacement for OS's that don't have it.  
130277592Sdelphijsrc/strlcpy.c - replacement for OS's that don't have it.  
131277592Sdelphijsrc/tar.h - tar file definitions
132268515Sdelphijsrc/vasprintf.c - for systems that don't have it.  
133268515Sdelphijdoc/file.man - man page for the command  
134268515Sdelphijdoc/magic.man - man page for the magic file, courtesy Guy Harris.
13568349Sobrien	Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile.
136268515Sdelphij
137191771SobrienMagdir - directory of /etc/magic pieces
138186691Sobrien------------------------------------------------------------------------------
139186691Sobrien
140186691SobrienIf you submit a new magic entry please make sure you read the following
141186691Sobrienguidelines:
142186691Sobrien
143186691Sobrien- Initial match is preferably at least 32 bits long, and is a _unique_ match
144186691Sobrien- If this is not feasible, use additional check
145186691Sobrien- Match of <= 16 bits are not accepted
146186691Sobrien- Delay printing string as much as possible, don't print output too early
147186691Sobrien- Avoid printf arbitrary byte as string, which can be a source of
148186691Sobrien  crash and buffer overflow
149186691Sobrien
150186691Sobrien- Provide complete information with entry:
151186691Sobrien  * One line short summary
152186691Sobrien  * Optional long description
153186691Sobrien  * File extension, if applicable
154186691Sobrien  * Full name and contact method (for discussion when entry has problem)
155186691Sobrien  * Further reference, such as documentation of format
156186691Sobrien
157186691Sobrien------------------------------------------------------------------------------
158186691Sobrien
159133359SobrienParts of this software were developed at SoftQuad Inc., developers
160133359Sobrienof SGML/HTML/XML publishing software, in Toronto, Canada.
161234449SobrienSoftQuad was swallowed up by Corel in 2002 and does not exist any longer.
162