diff options
author | Christos Zoulas <christos@zoulas.com> | 2011-05-13 22:11:44 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2011-05-13 22:11:44 +0000 |
commit | 7fcc6047a50bdc71cc904eaffd3488f79aa8804a (patch) | |
tree | 535a45501a38df1b90fbf93f9dafe21856289cae /doc | |
parent | d7410330297953fea0b3473cbba5d732b0ea018a (diff) | |
download | file-git-7fcc6047a50bdc71cc904eaffd3488f79aa8804a.tar.gz |
fixes from NetBSD
Diffstat (limited to 'doc')
-rw-r--r-- | doc/file.man | 155 | ||||
-rw-r--r-- | doc/libmagic.man | 97 | ||||
-rw-r--r-- | doc/magic.man | 35 |
3 files changed, 164 insertions, 123 deletions
diff --git a/doc/file.man b/doc/file.man index 7ce1cfbe..e652faa1 100644 --- a/doc/file.man +++ b/doc/file.man @@ -1,4 +1,4 @@ -.\" $File: file.man,v 1.93 2011/03/12 19:01:27 rrt Exp $ +.\" $File: file.man,v 1.94 2011/04/20 19:08:44 christos Exp $ .Dd April 20, 2011 .Dt FILE __CSECTION__ .Os @@ -9,20 +9,20 @@ .Nm .Bk -words .Op Fl bchiklLNnprsvz0 -.Op Fl -apple -.Op Fl -mime-encoding -.Op Fl -mime-type +.Op Fl Fl apple +.Op Fl Fl mime-encoding +.Op Fl Fl mime-type .Op Fl e Ar testname .Op Fl F Ar separator .Op Fl f Ar namefile .Op Fl m Ar magicfiles .Ar -.Ek -words +.Ek .Nm .Fl C .Op Fl m Ar magicfiles .Nm -.Op Fl -help +.Op Fl Fl help .Sh DESCRIPTION This manual page documents version __VERSION__ of the .Nm @@ -46,12 +46,12 @@ terminal), .Em executable (the file contains the result of compiling a program in a form understandable to some -.Dv UNIX +.Tn UNIX kernel or another), or .Em data meaning anything else (data is usually -.Sq binary +.Dq binary or non-printable). Exceptions are well-known file formats (core files, tar archives) that are known to contain binary data. @@ -59,12 +59,12 @@ When modifying magic files or the program itself, make sure to .Em "preserve these keywords" . Users depend on knowing that all the readable files in a directory have the word -.Sq text +.Dq text printed. Don't do as Berkeley did and change -.Sq shell commands text +.Dq shell commands text to -.Sq shell script . +.Dq shell script . .Pp The filesystem tests are based on examining the return from a .Xr stat 2 @@ -74,8 +74,7 @@ or if it's some sort of special file. Any known file types appropriate to the system you are running on (sockets, symbolic links, or named pipes (FIFOs) on those systems that implement them) -are intuited if they are defined in -the system header file +are intuited if they are defined in the system header file .In sys/stat.h . .Pp The magic tests are used to check for files with data in @@ -89,13 +88,14 @@ and possibly .In exec.h in the standard include directory. These files have a -.Sq "magic number" +.Dq "magic number" stored in a particular place near the beginning of the file that tells the -.Dv UNIX operating system +.Tn UNIX +operating system that the file is a binary executable, and which of several types thereof. The concept of a -.Sq "magic" +.Dq "magic" has been applied by extension to data files. Any file with some invariant identifier at a small fixed offset into the file can usually be described in this way. @@ -122,10 +122,10 @@ in each set. If a file passes any of these tests, its character set is reported. ASCII, ISO-8859-x, UTF-8, and extended-ASCII files are identified as -.Sq text +.Dq text because they will be mostly readable on nearly any terminal; UTF-16 and EBCDIC are only -.Sq character data +.Dq character data because, while they contain text, it is text that will require translation before it can be read. @@ -143,8 +143,8 @@ has determined the character set used in a text-type file, it will attempt to determine in what language the file is written. The language tests look for particular strings (cf. -.In names.h -) that can appear anywhere in the first few blocks of a file. +.In names.h ) +that can appear anywhere in the first few blocks of a file. For example, the keyword .Em .br indicates that the file is most likely a @@ -161,21 +161,21 @@ archives). .Pp Any file that cannot be identified as having been written in any of the character sets listed above is simply said to be -.Sq data . +.Dq data . .Sh OPTIONS .Bl -tag -width indent -.It Fl b , -brief +.It Fl b , Fl Fl brief Do not prepend filenames to output lines (brief mode). -.It Fl C , -compile +.It Fl C , Fl Fl compile Write a .Pa magic.mgc output file that contains a pre-parsed version of the magic file or directory. -.It Fl c , -checking-printout +.It Fl c , Fl Fl checking-printout Cause a checking printout of the parsed form of the magic file. This is usually used in conjunction with the .Fl m flag to debug a new magic file before installing it. -.It Fl e , -exclude Ar testname +.It Fl e , Fl Fl exclude Ar testname Exclude the test named in .Ar testname from the list of tests made to determine the file type. @@ -185,7 +185,8 @@ Valid test names are: .Dv EMX application type (only on EMX). .It ascii -Various types of text files (this test will try to guess the text encoding, irrespective of the setting of the +Various types of text files (this test will try to guess the text +encoding, irrespective of the setting of the .Sq encoding option). .It encoding @@ -203,12 +204,12 @@ Consults magic files. .It tar Examines tar files. .El -.It Fl F , -separator Ar separator +.It Fl F , Fl Fl separator Ar separator Use the specified string as the separator between the filename and the file result returned. Defaults to .Sq \&: . -.It Fl f , -files-from Ar namefile +.It Fl f , Fl Fl files-from Ar namefile Read the names of the files to be examined from .Ar namefile (one per line) @@ -219,73 +220,78 @@ or at least one filename argument must be present; to test the standard input, use .Sq - as a filename argument. -.It Fl h , -no-dereference +.It Fl h , Fl Fl no-dereference option causes symlinks not to be followed (on systems that support symbolic links). This is the default if the environment variable .Dv POSIXLY_CORRECT is not defined. -.It Fl i , -mime +.It Fl i , Fl Fl mime Causes the file command to output mime type strings rather than the more traditional human readable ones. Thus it may say .Sq text/plain; charset=us-ascii rather than -.Sq ASCII text . -In order for this option to work, file changes the way +.Dq ASCII text . +In order for this option to work, +.Nm +changes the way it handles files recognized by the command itself (such as many of the text file types, directories etc), and makes use of an alternative -.Sq magic +.Dq magic file. -(See the FILES section, below). -.It Fl -mime-type , -mime-encoding +(See the +.Sx FILES +section, below). +.It Fl Fl mime-type , Fl Fl mime-encoding Like .Fl i , but print only the specified element(s). -.It Fl k , -keep-going +.It Fl k , Fl Fl keep-going Don't stop at the first match, keep going. Subsequent matches will be have the string .Sq "\[rs]012\- " prepended. (If you want a newline, see the -.Sq "\-r" +.Fl r option.) -.It Fl l , -list +.It Fl l , Fl Fl list Print information about the strength of each magic pattern. -.It Fl L , -dereference +.It Fl L , Fl Fl dereference option causes symlinks to be followed, as the like-named option in .Xr ls 1 (on systems that support symbolic links). This is the default if the environment variable -.Dv POSIXLY_CORRECT +.Ev POSIXLY_CORRECT is defined. .It Fl l Shows sorted patterns list in the order which is used for the matching. -.It Fl m , -magic-file Ar magicfiles +.It Fl m , Fl Fl magic-file Ar magicfiles Specify an alternate list of files and directories containing magic. This can be a single item, or a colon-separated list. -If a compiled magic file is found alongside a file or directory, it will be used instead. -.It Fl N , -no-pad +If a compiled magic file is found alongside a file or directory, +it will be used instead. +.It Fl N , Fl Fl no-pad Don't pad filenames so that they align in the output. -.It Fl n , -no-buffer +.It Fl n , Fl Fl no-buffer Force stdout to be flushed after checking each file. This is only useful if checking a list of files. It is intended to be used by programs that want filetype output from a pipe. -.It Fl p , -preserve-date +.It Fl p , Fl Fl preserve-date On systems that support -.Xr utime 2 +.Xr utime 3 or .Xr utimes 2 , attempt to preserve the access time of files analyzed, to pretend that .Nm never read them. -.It Fl r , -raw +.It Fl r , Fl Fl raw Don't translate unprintable characters to \eooo. Normally .Nm translates unprintable characters to their octal representation. -.It Fl s , -special-files +.It Fl s , Fl Fl special-files Normally, .Nm only attempts to read and determine the type of argument files which @@ -305,11 +311,11 @@ This option also causes to disregard the file size as reported by .Xr stat 2 since on some systems it reports a zero size for raw disk partitions. -.It Fl v , -version +.It Fl v , Fl Fl version Print the version of the program and exit. -.It Fl z , -uncompress +.It Fl z , Fl Fl uncompress Try to look inside compressed files. -.It Fl 0 , -print0 +.It Fl 0 , Fl Fl print0 Output a null character .Sq \e0 after the end of the filename. @@ -329,7 +335,7 @@ Directory containing default magic files. .El .Sh ENVIRONMENT The environment variable -.Dv MAGIC +.Ev MAGIC can be used to set the default magic file name. If that variable is set, then .Nm @@ -337,7 +343,7 @@ will not attempt to open .Pa $HOME/.magic . .Nm adds -.Sq .mgc +.Dq Pa .mgc to the value of this variable as appropriate. However, .Pa file @@ -345,7 +351,7 @@ has to exist in order for .Pa file.mime to be considered. The environment variable -.Dv POSIXLY_CORRECT +.Ev POSIXLY_CORRECT controls (on systems that support symbolic links), whether .Nm will attempt to follow symlinks or not. @@ -359,10 +365,9 @@ and options. .Sh SEE ALSO .Xr magic __FSECTION__ , -.Xr strings 1 , -.Xr od 1 , .Xr hexdump 1 , -.Xr file 1posix +.Xr od 1 , +.Xr strings 1 , .Sh STANDARDS CONFORMANCE This program is believed to exceed the System V Interface Definition of FILE(CMD), as near as one can determine from the vague language @@ -378,12 +383,12 @@ is that this version treats any white space as a delimiter, so that spaces in pattern strings must be escaped. For example, .Bd -literal -offset indent ->10 string language impress\ (imPRESS data) +\*[Gt]10 string language impress\ (imPRESS data) .Ed .Pp in an existing magic file would have to be changed to .Bd -literal -offset indent ->10 string language\e impress (imPRESS data) +\*[Gt]10 string language\e impress (imPRESS data) .Ed .Pp In addition, in this version, if a pattern string contains a backslash, @@ -401,13 +406,13 @@ in an existing magic file would have to be changed to SunOS releases 3.2 and later from Sun Microsystems include a .Nm command derived from the System V one, but with some extensions. -My version differs from Sun's only in minor ways. +This version differs from Sun's only in minor ways. It includes the extension of the -.Sq & +.Sq \*[Am] operator, used as, for example, .Bd -literal -offset indent ->16 long&0x7fffffff >0 not stripped +\*[Gt]16 long\*[Am]0x7fffffff \*[Gt]0 not stripped .Ed .Sh MAGIC DIRECTORY The magic file entries have been collected from various sources, @@ -425,7 +430,7 @@ If your old command uses a magic file, keep the old magic file around for comparison purposes (rename it to -.Pa __MAGIC__.orig ). +.Pa __MAGIC__.orig ) . .Sh EXAMPLES .Bd -literal -offset indent $ file file.c file /dev/{wd0a,hda} @@ -478,13 +483,16 @@ John Gilmore revised the code extensively, making it better than the first version. Geoff Collyer found several inadequacies and provided some magic file entries. -Contributions by the `&' operator by Rob McMahon +Contributions by the +.Sq \*[Am] +operator by Rob McMahon, .Aq cudcv@warwick.ac.uk , 1989. .Pp -Guy Harris -.Aq guy@netapp.com +Guy Harris, +.Aq guy@netapp.com , made many changes from 1993 to the present. +1989. .Pp Primary development and maintenance from 1990 to the present by Christos Zoulas @@ -498,8 +506,9 @@ option to output mime type strings, using an alternative magic file and internal logic. .Pp Altered by Eric Fischer -.Aq enf@pobox.com -July, 2000, to identify character codes and attempt to identify the languages +.Aq enf@pobox.com , +July, 2000, +to identify character codes and attempt to identify the languages of non-ASCII files. .Pp Altered by Reuben Thomas @@ -521,9 +530,9 @@ Covered by the standard Berkeley Software Distribution copyright; see the file COPYING in the source distribution. .Pp The files -.Dv tar.h +.Pa tar.h and -.Dv is_tar.c +.Pa is_tar.c were written by John Gilmore from his public-domain .Xr tar 1 program, and are not covered by the above license. @@ -562,7 +571,7 @@ Don't complain when ~/.magic is not compiled. Add an option to print URLs for the sources of the file descriptions. .Sh AVAILABILITY You can obtain the original author's latest version by anonymous FTP -from -.Dv ftp.astron.com +on +.Pa ftp.astron.com in the directory -.Dv /pub/file/file-X.YZ.tar.gz +.Pa /pub/file/file-X.YZ.tar.gz . diff --git a/doc/libmagic.man b/doc/libmagic.man index ad4bcf5e..88b11e4b 100644 --- a/doc/libmagic.man +++ b/doc/libmagic.man @@ -1,4 +1,4 @@ -.\" $File: libmagic.man,v 1.22 2010/06/01 12:31:31 christos Exp $ +.\" $File: libmagic.man,v 1.23 2011/01/14 21:59:17 rrt Exp $ .\" .\" Copyright (c) Christos Zoulas 2003. .\" All Rights Reserved. @@ -38,7 +38,7 @@ .Nm magic_check , .Nm magic_compile , .Nm magic_load -.Nd Magic number recognition library. +.Nd Magic number recognition library .Sh LIBRARY .Lb libmagic .Sh SYNOPSIS @@ -56,15 +56,15 @@ .Ft const char * .Fn magic_file "magic_t cookie, const char *filename" .Ft const char * -.Fn magic_buffer "magic_t cookie, const void *buffer, size_t length" +.Fn magic_buffer "magic_t cookie" "const void *buffer" "size_t length" .Ft int -.Fn magic_setflags "magic_t cookie, int flags" +.Fn magic_setflags "magic_t cookie" "int flags" .Ft int -.Fn magic_check "magic_t cookie, const char *filename" +.Fn magic_check "magic_t cookie" "const char *filename" .Ft int -.Fn magic_compile "magic_t cookie, const char *filename" +.Fn magic_compile "magic_t cookie" "const char *filename" .Ft int -.Fn magic_load "magic_t cookie, const char *filename" +.Fn magic_load "magic_t cookie" "const char *filename" .Sh DESCRIPTION These functions operate on the magic database file @@ -74,8 +74,11 @@ in .Pp The function .Fn magic_open -creates a magic cookie pointer and returns it. It returns NULL if -there was an error allocating the magic cookie. The +creates a magic cookie pointer and returns it. +It returns +.Dv NULL +if there was an error allocating the magic cookie. +The .Ar flags argument specifies how the other magic functions should behave: .Bl -tag -width MAGIC_COMPRESS @@ -102,7 +105,7 @@ Return all matches, not just the first. Check the magic database for consistency and print warnings to stderr. .It Dv MAGIC_PRESERVE_ATIME On systems that support -.Xr utime 2 +.Xr utime 3 or .Xr utimes 2 , attempt to preserve the access time of files analysed. @@ -143,8 +146,9 @@ database and deallocates any resources used. .Pp The .Fn magic_error -function returns a textual explanation of the last error, or NULL if there was -no error. +function returns a textual explanation of the last error, or +.Dv NULL +if there was no error. .Pp The .Fn magic_errno @@ -156,16 +160,22 @@ The .Fn magic_file function returns a textual description of the contents of the .Ar filename -argument, or NULL if an error occurred. +argument, or +.Dv NULL +if an error occurred. If the .Ar filename -is NULL, then stdin is used. +is +.Dv NULL , +then stdin is used. .Pp The .Fn magic_descriptor function returns a textual description of the contents of the .Ar fd -argument, or NULL if an error occurred. +argument, or +.Dv NULL +if an error occurred. .Pp The .Fn magic_buffer @@ -179,7 +189,8 @@ The .Fn magic_setflags function sets the .Ar flags -described above. Note that using both MIME flags together can also +described above. +Note that using both MIME flags together can also return extra information on the charset. .Pp The @@ -187,16 +198,21 @@ The function can be used to check the validity of entries in the colon separated database files passed in as .Ar filename , -or NULL for the default database. It returns 0 on success and -1 on -failure. +or +.Dv NULL +for the default database. +It returns 0 on success and \-1 on failure. .Pp The .Fn magic_compile function can be used to compile the the colon separated list of database files passed in as .Ar filename , -or NULL for the default database. It returns 0 on success and -1 on -failure. The compiled files created are named from the +or +.Dv NULL +for the default database. +It returns 0 on success and \-1 on failure. +The compiled files created are named from the .Xr basename 1 of each file argument with .Dq .mgc @@ -207,11 +223,12 @@ The function must be used to load the the colon separated list of database files passed in as .Ar filename , -or NULL for the default database file -before any magic queries can performed. +or +.Dv NULL +for the default database file before any magic queries can performed. .Pp -The default database file is named by the MAGIC environment variable. If -that variable is not set, the default database file name is __MAGIC__. +The default database file is named by the MAGIC environment variable. +If that variable is not set, the default database file name is __MAGIC__. .Fn magic_load adds .Dq .mgc @@ -219,27 +236,35 @@ to the database filename as appropriate. .Sh RETURN VALUES The function .Fn magic_open -returns a magic cookie on success and NULL on failure setting errno to -an appropriate value. It will set errno to EINVAL if an unsupported -value for flags was given. +returns a magic cookie on success and +.Dv NULL +on failure setting errno to an appropriate value. +It will set errno to +.Er EINVAL +if an unsupported value for flags was given. The .Fn magic_load , .Fn magic_compile , and .Fn magic_check -functions return 0 on success and -1 on failure. +functions return 0 on success and \-1 on failure. The .Fn magic_file , and .Fn magic_buffer -functions return a string on success and NULL on failure. The +functions return a string on success and +.Dv NULL +on failure. +The .Fn magic_error function returns a textual description of the errors of the above -functions, or NULL if there was no error. +functions, or +.Dv NULL +if there was no error. Finally, .Fn magic_setflags -returns -1 on systems that don't support -.Xr utime 2 , +returns \-1 on systems that don't support +.Xr utime 3 , or .Xr utimes 2 when @@ -256,7 +281,7 @@ The compiled default magic database. .Xr file __CSECTION__ , .Xr magic __FSECTION__ .Sh AUTHORS -Måns Rullgård Initial libmagic implementation, -and configuration. -.br -Christos Zoulas API cleanup, error code and allocation handling. +.An M\(oans Rullg\(oard +Initial libmagic implementation, and configuration. +.An Christos Zoulas +API cleanup, error code and allocation handling. diff --git a/doc/magic.man b/doc/magic.man index 37b950eb..02780274 100644 --- a/doc/magic.man +++ b/doc/magic.man @@ -1,4 +1,4 @@ -.\" $File: magic.man,v 1.67 2011/04/15 22:08:52 christos Exp $ +.\" $File: magic.man,v 1.68 2011/04/20 19:08:44 christos Exp $ .Dd April 20, 2011 .Dt MAGIC __FSECTION__ .Os @@ -190,11 +190,12 @@ than UTC. Starting at the given offset, consult the magic database again. .It Dv regex A regular expression match in extended POSIX regular expression syntax -(like egrep). Regular expressions can take exponential time to -process, and their performance is hard to predict, so their use is -discouraged. When used in production environments, their performance -should be carefully checked. The type specification can be optionally -followed by +(like egrep). +Regular expressions can take exponential time to process, and their +performance is hard to predict, so their use is discouraged. +When used in production environments, their performance +should be carefully checked. +The type specification can be optionally followed by .Dv /[c][s] . The .Dq c @@ -213,15 +214,17 @@ and match the beginning and end of individual lines, respectively, not beginning and end of file. .It Dv search -A literal string search starting at the given offset. The same -modifier flags can be used as for string patterns. The modifier flags -(if any) must be followed by +A literal string search starting at the given offset. +The same modifier flags can be used as for string patterns. +The modifier flags (if any) must be followed by .Dv /number the range, that is, the number of positions at which the match will be -attempted, starting from the start offset. This is suitable for +attempted, starting from the start offset. +This is suitable for searching larger binary expressions with variable offsets, using .Dv \e -escapes for special characters. The offset works as for regex. +escapes for special characters. +The offset works as for regex. .It Dv default This is intended to be used with the test .Em x @@ -230,14 +233,18 @@ no other matches. .El .Pp Each top-level magic pattern (see below for an explanation of levels) -is classified as text or binary according to the types used. Types +is classified as text or binary according to the types used. +Types .Dq regex and .Dq search are classified as text tests, unless non-printable characters are used -in the pattern. All other tests are classified as binary. A top-level +in the pattern. +All other tests are classified as binary. +A top-level pattern is considered to be a test text when all its patterns are text -patterns; otherwise, it is considered to be a binary pattern. When +patterns; otherwise, it is considered to be a binary pattern. +When matching a file, binary patterns are tried first; if no match is found, and the file looks like text, then its encoding is determined and the text patterns are tried. |