---
name: "xfmtype"
section: "1x"
platform: "linux"
package: "xfm"
version: "1.4.3-8"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/xfmtype/1x"
---

# xfmtype(1x)

xfm file type tester

## NAME

xfmtype - xfm file type tester

## SYNOPSIS

**xfmtype** -m *magic\_file* \[-f\] *filename* ...

## DESCRIPTION

The *xfmtype* program reads a magic configuration file and tests each file in its command line to tell its type according to the configuration file.

The format of the configuration file is the same as the [**magic**(5)](/magic/5.md) with the following additions and differences:

- **mode** type field.

  Similar to **long** type, but *offset* is ignored.  The test is performed against the **st\_mode** field of the *stat* structure obtained using [**stat**(2)](/stat/2.md) system call. This allows testing for  directories, fifos ... as well as for file permissions.

- **lmode** type field.

  Similar to **mode** type, but using [*lstat*(2)](/lstat/2.md) instead of [**stat**(2)](/stat/2.md). This allows testing for symbolic links.

- **builtin** type field.

  The test succeeds if the built-in type of the file is the same as the value field. The built-in type of the file is the type returned when all the tests fail. Currently these are the built-in types:

  ```

  "unreadable" The file could not be read.

  "empty" File size is zero.

  "special" Not a regular file.

  "ascii" The file looks like ascii.

  "data" None of the above.

  ```

- **regexp** type field.

  The *value* field must be a proper regular expression. The bytes starting at *offset* are matched against it. If the match succeeds, then a **regsub**(3) is performed on *message* yielding the final message. If the type field is of the form **regexp&nnn** where **nnn** is a possitive number, then that number controls the amount of data scanned for the matching, otherwise a compile defined value (currently 256) is used.

- **long** and **short** byte order.

  *xfmtype* always reads **long**s and **short**s using MSB-first order. This makes configuration files portable to all architectures, but some entries in original [**magic**(5)](/magic/5.md) files might be wrong.

- Continuation lines.

  If a line ends with a *backslash* character (*\\*), it is continued with the following line. The maximun length of a line is 1024 characters (counting also charaters in continuation lines).

## OPTIONS

- **-f *file***

  Consider the following argument as a file, even if it begins with \`-'.

- **-m *file***

  Specifies a configuration file. You can specify more than one configuration file with several **-m** flags. They are read in the order in which they are found. Configuration files do not have effect until they are encountered in the command line. So, files to test in the command line before that switch will not be affected by it.

## BUGS

Bad configuration lines cause undefined behavior. In general they are silently ignored, but that is not guaranteed.\
 There are no warning or error message except for the regular expression syntax.\
 There should be a syntax checking mode.\
 All of the above apply to *xfm* too.

## SEE ALSO

[**xfm**(1x)](/xfm/1x.md), [**file**(1)](/file/1.md), [**magic**(5)](/magic/5.md), [**stat**(2)](/stat/2.md), [**lstat**(2)](/lstat/2.md),

## COPYRIGHT

Copyright (c) 1995 CNM-US\
 Copyright (c) 1995 Juan D. Martin

## AUTHOR

Juan D. Martin (juando@cnm.us.es)
