magic-1.1.1: src/Magic/Data.hsc
-- AUTO-GENERATED FILE, DO NOT EDIT. GENERATED BY utils/genconsts.hs
{- |
Module : Magic.Data
Copyright : Copyright (C) 2005 John Goerzen
License : BSD-3-Clause
Maintainer : Philippe <philippedev101\@gmail.com>
Stability : provisional
Portability: portable
The 'MagicFlag' enumeration, mapping the C @libmagic@ @MAGIC_*@ constants
to Haskell.
-}
module Magic.Data (module Magic.Data) where
#include "magic.h"
-- | Flags that control how @libmagic@ examines a file and what it
-- reports. Combine them in the list passed to @magicOpen@ or
-- @magicSetFlags@.
data MagicFlag
= -- | No special handling; return a textual description (the default).
MagicNone
| -- | Print debugging messages to stderr.
MagicDebug
| -- | Follow symbolic links.
MagicSymlink
| -- | Look inside compressed files.
MagicCompress
| -- | Look at the contents of block or character special devices.
MagicDevices
| -- | Return a MIME type string instead of a textual description.
MagicMimeType
| -- | Return the MIME encoding (character set) instead of a textual description.
MagicMimeEncoding
| -- | Return both the MIME type and the encoding.
MagicMime
| -- | Return all matches, not just the first.
MagicContinue
| -- | Check the magic database for consistency and report problems.
MagicCheck
| -- | Preserve the access time of examined files.
MagicPreserveAtime
| -- | Do not translate unprintable characters to octal escapes.
MagicRaw
| -- | Treat errors while examining a file as real errors instead of embedding them in the result.
MagicError
| -- | A flag value returned by libmagic that these bindings do not
-- recognise, carrying its raw integer value.
UnknownMagicFlag Int
deriving (Show)
instance Enum MagicFlag where
toEnum (#{const MAGIC_NONE}) = MagicNone
toEnum (#{const MAGIC_DEBUG}) = MagicDebug
toEnum (#{const MAGIC_SYMLINK}) = MagicSymlink
toEnum (#{const MAGIC_COMPRESS}) = MagicCompress
toEnum (#{const MAGIC_DEVICES}) = MagicDevices
toEnum (#{const MAGIC_MIME_TYPE}) = MagicMimeType
toEnum (#{const MAGIC_MIME_ENCODING}) = MagicMimeEncoding
toEnum (#{const MAGIC_MIME}) = MagicMime
toEnum (#{const MAGIC_CONTINUE}) = MagicContinue
toEnum (#{const MAGIC_CHECK}) = MagicCheck
toEnum (#{const MAGIC_PRESERVE_ATIME}) = MagicPreserveAtime
toEnum (#{const MAGIC_RAW}) = MagicRaw
toEnum (#{const MAGIC_ERROR}) = MagicError
toEnum x = UnknownMagicFlag x
fromEnum MagicNone = (#{const MAGIC_NONE})
fromEnum MagicDebug = (#{const MAGIC_DEBUG})
fromEnum MagicSymlink = (#{const MAGIC_SYMLINK})
fromEnum MagicCompress = (#{const MAGIC_COMPRESS})
fromEnum MagicDevices = (#{const MAGIC_DEVICES})
fromEnum MagicMimeType = (#{const MAGIC_MIME_TYPE})
fromEnum MagicMimeEncoding = (#{const MAGIC_MIME_ENCODING})
fromEnum MagicMime = (#{const MAGIC_MIME})
fromEnum MagicContinue = (#{const MAGIC_CONTINUE})
fromEnum MagicCheck = (#{const MAGIC_CHECK})
fromEnum MagicPreserveAtime = (#{const MAGIC_PRESERVE_ATIME})
fromEnum MagicRaw = (#{const MAGIC_RAW})
fromEnum MagicError = (#{const MAGIC_ERROR})
fromEnum (UnknownMagicFlag x) = x
instance Ord MagicFlag where
compare x y = compare (fromEnum x) (fromEnum y)
instance Eq MagicFlag where
x == y = (fromEnum x) == (fromEnum y)