Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/magic|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[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]] == magic [[toc:]] == Description libmagic bindings. Two modules are included, {{libmagic}} and {{magic}}: * {{libmagic}} is a one-to-one binding to {{libmagic.h}}, used exactly like the C library. * {{magic}} is a high-level wrapper, providing one procedure called {{identify}}. The following documentation applies to the {{magic}} module. The source for this egg is available [[https://git.foldling.org/chicken-magic.git|here]]. == API One procedure is provided, {{identify}}, that tries to do what you mean based on the type of its argument. Whenever libmagic returns an error, an exception of type {{(exn magic)}} is raised. Note that this module loads libmagic's magic numbers database as soon as it's {{require}}d (a.k.a. {{use}}d). If you're not OK with this, use the low-level module. <procedure>(identify [object [flags]]) => string</procedure> {{identify}} returns a textual description of the file indicated by {{object}}, or the contents of {{(current-input-port)}} if no {{object}} is specified. If {{object}} is given, it may be any of the following types, with {{identify}} returning a description of: * {{blob}}: the contents of the blob. * {{string}}: the contents of the file indicated by the given filename. * {{integer}}: the contents of that file descriptor. * {{input-port}}: the contents of the port. This port must be backed by a file descriptor; if not, an error of type {{(exn type)}} will be raised. If {{flags}} is given, it should be a symbol or list of symbols indicating the type of description to return. These correspond to the {{MAGIC_*}} constants in {{magic.h}}, and can be any combination of the following (though not all combinations make sense): * {{apple}} * {{compress}} * {{device}} * {{mime}} * {{mime-encoding encoding}} * {{mime-type type}} * {{no-apptype}} * {{no-cdf}} * {{no-compress}} * {{no-elf}} * {{no-encoding}} * {{no-soft}} * {{no-tar}} * {{no-text}} * {{no-tokens}} * {{none}} * {{preserve-atime}} * {{raw}} * {{symlink}} For example: <enscript highlight="scheme"> (identify "/usr/include/magic.h") ; => "C source, ASCII text" (identify "/usr/include/magic.h" 'mime) ; => "text/x-c; charset=us-ascii" (identify "/usr/include/magic.h" '(preserve-atime no-text)) ; => "data" </enscript> An unrecognized flag will raise an exception of type {{(exn magic)}}. == Author [[/users/evan-hanson|Evan Hanson]] == License 3-Clause BSD
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 7 by 0?