| Copyright | Copyright (C) 2005 John Goerzen |
|---|---|
| License | BSD-3-Clause |
| Maintainer | Philippe <philippedev101\@gmail.com> |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Magic.Types
Description
The core types of the binding: the opaque Magic handle, the MagicException
error type (both defined in Magic.Internal), and the MagicParam tunables.
The flag bit-mask lives in Magic.Data.
Synopsis
- data Magic
- data MagicException = MagicException {
- magicErrorContext :: !Text
- magicErrorMessage :: !Text
- data MagicParam
Documentation
The magic handle: an opaque cookie obtained from magicOpen and passed to
the loading and querying functions.
Handles are closed (and their memory freed) automatically when they are garbage-collected; there is no need to close them explicitly.
Thread safety. Operations on a single handle are serialised by an internal
lock, so it is safe to share one handle across threads (concurrent calls simply
take turns). For genuine parallelism, use one handle per thread; distinct
handles are independent. Programs doing blocking work (loading databases,
examining files) should use the threaded runtime (-threaded).
data MagicException Source #
The exception raised when a libmagic operation fails. Carries the name of
the operation that failed and the message reported by libmagic.
Since: 2.0.0
Constructors
| MagicException | |
Fields
| |
Instances
| NFData MagicException Source # | |||||
Defined in Magic.Internal Methods rnf :: MagicException -> () | |||||
| Exception MagicException Source # | |||||
Defined in Magic.Internal Methods toException :: MagicException -> SomeException fromException :: SomeException -> Maybe MagicException displayException :: MagicException -> String backtraceDesired :: MagicException -> Bool | |||||
| Generic MagicException Source # | |||||
Defined in Magic.Internal Associated Types
| |||||
| Show MagicException Source # | |||||
Defined in Magic.Internal Methods showsPrec :: Int -> MagicException -> ShowS show :: MagicException -> String showList :: [MagicException] -> ShowS | |||||
| Eq MagicException Source # | |||||
Defined in Magic.Internal Methods (==) :: MagicException -> MagicException -> Bool (/=) :: MagicException -> MagicException -> Bool | |||||
| type Rep MagicException Source # | |||||
Defined in Magic.Internal type Rep MagicException = D1 ('MetaData "MagicException" "Magic.Internal" "magic-2.0.0-A9TYcUdA1HUI3Y62VpQyfB" 'False) (C1 ('MetaCons "MagicException" 'PrefixI 'True) (S1 ('MetaSel ('Just "magicErrorContext") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "magicErrorMessage") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text))) | |||||
data MagicParam Source #
Tunable limits that bound how hard libmagic works when examining data,
read and written with magicGetParam and magicSetParam (see
Magic.Operations). Lowering these (especially MagicParamBytesMax) is a way
to cap the effort spent on untrusted input. Defaults below are those documented
for libmagic 5.45.
Since: 1.1.2
Constructors
| MagicParamIndirMax | Maximum number of levels of recursion when following indirect magic. (Default: 15.) |
| MagicParamNameMax | Maximum length of a name used by name/use magic. (Default: 30.) |
| MagicParamElfPhnumMax | Maximum number of ELF program header sections processed. (Default: 128.) |
| MagicParamElfShnumMax | Maximum number of ELF section header sections processed. (Default: 32768.) |
| MagicParamElfNotesMax | Maximum number of ELF notes processed. (Default: 256.) |
| MagicParamRegexMax | Maximum length of a regex search. (Default: 8192.) |
| MagicParamBytesMax | Maximum number of bytes read from a file before giving up. (Default: 1048576, i.e. 1 MiB.) |
| MagicParamEncodingMax | Maximum number of bytes scanned when guessing a text encoding. |
| MagicParamElfShsizeMax | Maximum size of an ELF section processed. |
Instances
| NFData MagicParam Source # | |||||
Defined in Magic.Types Methods rnf :: MagicParam -> () | |||||
| Bounded MagicParam Source # | |||||
Defined in Magic.Types | |||||
| Enum MagicParam Source # | |||||
Defined in Magic.Types Methods succ :: MagicParam -> MagicParam pred :: MagicParam -> MagicParam toEnum :: Int -> MagicParam fromEnum :: MagicParam -> Int enumFrom :: MagicParam -> [MagicParam] enumFromThen :: MagicParam -> MagicParam -> [MagicParam] enumFromTo :: MagicParam -> MagicParam -> [MagicParam] enumFromThenTo :: MagicParam -> MagicParam -> MagicParam -> [MagicParam] | |||||
| Generic MagicParam Source # | |||||
Defined in Magic.Types Associated Types
| |||||
| Show MagicParam Source # | |||||
Defined in Magic.Types Methods showsPrec :: Int -> MagicParam -> ShowS show :: MagicParam -> String showList :: [MagicParam] -> ShowS | |||||
| Eq MagicParam Source # | |||||
Defined in Magic.Types | |||||
| Ord MagicParam Source # | |||||
Defined in Magic.Types Methods compare :: MagicParam -> MagicParam -> Ordering (<) :: MagicParam -> MagicParam -> Bool (<=) :: MagicParam -> MagicParam -> Bool (>) :: MagicParam -> MagicParam -> Bool (>=) :: MagicParam -> MagicParam -> Bool max :: MagicParam -> MagicParam -> MagicParam min :: MagicParam -> MagicParam -> MagicParam | |||||
| type Rep MagicParam Source # | |||||
Defined in Magic.Types type Rep MagicParam = D1 ('MetaData "MagicParam" "Magic.Types" "magic-2.0.0-A9TYcUdA1HUI3Y62VpQyfB" 'False) (((C1 ('MetaCons "MagicParamIndirMax" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MagicParamNameMax" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MagicParamElfPhnumMax" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MagicParamElfShnumMax" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "MagicParamElfNotesMax" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MagicParamRegexMax" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MagicParamBytesMax" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "MagicParamEncodingMax" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MagicParamElfShsizeMax" 'PrefixI 'False) (U1 :: Type -> Type))))) | |||||