((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/magic" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg")) (section 2 "magic" (toc)) (section 2 "Description" (p "libmagic bindings.") (p "Two modules are included, " (tt "libmagic") " and " (tt "magic") ":") (ul (li (tt "libmagic") " is a one-to-one binding to " (tt "libmagic.h") ", used exactly like the C library.") (li (tt "magic") " is a high-level wrapper, providing one procedure called " (tt "identify") ".")) (p "The following documentation applies to the " (tt "magic") " module.") (p "The source for this egg is available " (link "https://git.foldling.org/chicken-magic.git" "here") ".")) (section 2 "API" (p "One procedure is provided, " (tt "identify") ", that tries to do what you mean based on the type of its argument. Whenever libmagic returns an error, an exception of type " (tt "(exn magic)") " is raised.") (p "Note that this module loads libmagic's magic numbers database as soon as it's " (tt "require") "d (a.k.a. " (tt "use") "d). If you're not OK with this, use the low-level module.") (def (sig (procedure "(identify [object [flags]]) => string" (id identify))) (p (tt "identify") " returns a textual description of the file indicated by " (tt "object") ", or the contents of " (tt "(current-input-port)") " if no " (tt "object") " is specified.") (p "If " (tt "object") " is given, it may be any of the following types, with " (tt "identify") " returning a description of:") (ul (li (tt "blob") ": the contents of the blob.") (li (tt "string") ": the contents of the file indicated by the given filename.") (li (tt "integer") ": the contents of that file descriptor.") (li (tt "input-port") ": the contents of the port. This port must be backed by a file descriptor; if not, an error of type " (tt "(exn type)") " will be raised.")) (p "If " (tt "flags") " is given, it should be a symbol or list of symbols indicating the type of description to return. These correspond to the " (tt "MAGIC_*") " constants in " (tt "magic.h") ", and can be any combination of the following (though not all combinations make sense):") (ul (li (tt "apple")) (li (tt "compress")) (li (tt "device")) (li (tt "mime")) (li (tt "mime-encoding encoding")) (li (tt "mime-type type")) (li (tt "no-apptype")) (li (tt "no-cdf")) (li (tt "no-compress")) (li (tt "no-elf")) (li (tt "no-encoding")) (li (tt "no-soft")) (li (tt "no-tar")) (li (tt "no-text")) (li (tt "no-tokens")) (li (tt "none")) (li (tt "preserve-atime")) (li (tt "raw")) (li (tt "symlink"))) (p "For example:") (highlight scheme "(identify \"/usr/include/magic.h\") ; => \"C source, ASCII text\"\n(identify \"/usr/include/magic.h\" 'mime) ; => \"text/x-c; charset=us-ascii\"\n(identify \"/usr/include/magic.h\" '(preserve-atime no-text)) ; => \"data\"") (p "An unrecognized flag will raise an exception of type " (tt "(exn magic)") "."))) (section 2 "Author" (p (int-link "/users/evan-hanson" "Evan Hanson"))) (section 2 "License" (p "3-Clause BSD")))