···11+v1.3.1 2023-10-04
22+-----------------
33+44+* Add WebAssembly (wasm) mime type (@vouillon #28, fixes #27 reported by @glondu)
55+66+v1.3.0 2022-10-31
77+-----------------
88+99+* Allow an optional default if the MIME type is unknown (@hannesm, #25)
1010+* Add a function to map MIME type to file extensions (@DolphinChips, #24)
1111+* Fix documentation (@MisterDA, #23)
1212+1313+v1.2.0 2021-07-13
1414+-----------------
1515+1616+* Sync MIME types with latest from Apache (#22 @avsm)
1717+* Add `mjs` mapping to application/javascript manually (@avsm, request from @glondu)
1818+1919+v1.1.3 2021-01-04
2020+-----------------
2121+2222+* Fix build system for cross-compilation (@TheLortex, #19).
2323+* Fix README (@seliopou, #18).
2424+* Fix opam metadata (@CraigFe, #17).
2525+2626+v1.1.2 2019-08-12
2727+-----------------
2828+2929+* Actually port to dune by converting the `generator/` directory from
3030+ jbuild to dune (@avsm).
3131+3232+v1.1.1 2018-12-21
3333+-----------------
3434+3535+* Port build to Dune and fix the embedded compilation when
3636+ the repository is included as a subdirectory in a larger
3737+ Dune build.
3838+* Update opam metadata to 2.0 format.
3939+* Switch to using `dune-release` instead of `topkg` for releases.
4040+4141+v1.1.0 2017-06-20
4242+-----------------
4343+4444+* Support a `map_file` which maps filenames onto MIME types, using
4545+ a database based on GTKSourceView lang files. This adds support
4646+ for several `x-*` MIME type extensions as well which are unofficial
4747+ but useful, including ones for common programming languages.
4848+ (#4 by @zoggy)
4949+5050+* Sync mime.types with Apache SVN and note its source in the README.
5151+5252+v1.0.1 2017-05-25
5353+-----------------
5454+5555+* clarify LICENSE (ISC)
5656+* build and test against OCaml 4.03 and 4.04
5757+* build via jbuilder
5858+5959+v1.0.0 (2015-02-08)
6060+-------------------
6161+6262+* Initial public release.
+13
vendor/opam/magic-mime/LICENSE.md
···11+Copyright (c) 2015 Anil Madhavapeddy <anil@recoil.org>
22+33+Permission to use, copy, modify, and distribute this software for any
44+purpose with or without fee is hereby granted, provided that the above
55+copyright notice and this permission notice appear in all copies.
66+77+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
88+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
99+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1010+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1111+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1212+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
···11+## magic-mime -- map filenames to common MIME types
22+33+This library contains a database of MIME types that maps filename extensions
44+into MIME types suitable for use in many Internet protocols such as HTTP or
55+e-mail. It is generated from the `mime.types` file found in Unix systems, but
66+has no dependency on a filesystem since it includes the contents of the
77+database as an ML datastructure.
88+99+For example, here's how to lookup MIME types in the `utop` REPL:
1010+1111+ #require "magic-mime";;
1212+ Magic_mime.lookup "/foo/bar.txt";;
1313+ - : bytes = "text/plain"
1414+ Magic_mime.lookup "bar.css";;
1515+ - : bytes = "text/css"
1616+1717+### Internals
1818+1919+The following files need to be edited to add MIME types:
2020+2121+- mime.types: this is obtained by syncing from the Apache Foundation's
2222+ [mime.types](https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)
2323+ in the Apache Subversion repository.
2424+- x-mime.types: these are the extension types, so non-standard `x-` prefixes are used here.
2525+- file.types: full filenames of common occurrences that are useful to map onto a MIME type.
2626+ OCaml-specific things like `opam` files show up here.
2727+2828+## More information
2929+3030+* WWW: <https://github.com/mirage/ocaml-magic-mime>
3131+* E-mail: <mirageos-devel@lists.xenproject.org>
3232+* Issues <https://github.com/mirage/ocaml-magic-mime/issues>
3333+* Discourse: <https://discuss.ocaml.org> with the `mirageos` tag
···11+(*
22+ * Copyright (c) 2009-2015 Anil Madhavapeddy <anil@recoil.org>
33+ *
44+ * Permission to use, copy, modify, and distribute this software for any
55+ * purpose with or without fee is hereby granted, provided that the above
66+ * copyright notice and this permission notice appear in all copies.
77+ *
88+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
99+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1010+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1111+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1212+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1313+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1414+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515+ *)
1616+1717+(* Convert an Apache mime.types file into a static ML data structure. *)
1818+1919+open Printf
2020+open Str
2121+2222+let files = ref []
2323+2424+type mode =
2525+ | Regular
2626+ | Files
2727+ | Mime
2828+let mode = ref Regular
2929+3030+let set_mode mode' () = mode := mode'
3131+3232+let options = [
3333+ "--files", Arg.Unit (set_mode Files),
3434+ "Generate function mapping on filenames rather than on extensions" ;
3535+ "--mime", Arg.Unit (set_mode Mime),
3636+ "Generate function mapping MIME types to file extensions" ;
3737+ ]
3838+3939+let file_iter fn c =
4040+ try while true do fn (input_line c) done
4141+ with End_of_file -> ()
4242+4343+let _ =
4444+ Arg.parse options (fun s -> files := s :: !files)
4545+ (Printf.sprintf "Usage: %s [options]\nwhere options are:" Sys.argv.(0));
4646+ let mode = !mode in
4747+ let fun_name, default_arg, default =
4848+ match mode with
4949+ | Regular -> "map_extension", "?(default= \"application/octet-stream\")", "default"
5050+ | Files -> "map_file", "?(default= \"application/octet-stream\")", "default"
5151+ | Mime -> "map_mime", "", "[]"
5252+ in
5353+ let dup = Hashtbl.create 101 in
5454+ printf "(* This function is autogenerated by: %s *)\n" (String.concat " " (Array.to_list Sys.argv));
5555+ printf "let %s %s = function\n" fun_name default_arg;
5656+ List.iter (fun fname ->
5757+ let fin = open_in fname in
5858+ file_iter (fun l ->
5959+ match split (regexp "\t+") l with
6060+ | [] -> ()
6161+ | [_] -> ()
6262+ | [mime;_] when String.length mime > 0 && mime.[0] = '#' -> ()
6363+ | [mime;exts] -> begin
6464+ match mode with
6565+ | Mime ->
6666+ if not (Hashtbl.mem dup mime) then begin
6767+ let format_list oc l = List.map String.escaped l |> String.concat "\"; \"" |> fprintf oc "[\"%s\"]" in
6868+ printf " | \"%s\" -> %a\n" (String.escaped mime) format_list (split (regexp " +") exts);
6969+ Hashtbl.add dup mime ()
7070+ end
7171+ | _ ->
7272+ List.iter (fun e ->
7373+ if not (Hashtbl.mem dup e) then begin
7474+ printf " | \"%s\" -> \"%s\"\n" (String.escaped e) (String.escaped mime);
7575+ Hashtbl.add dup e ()
7676+ end
7777+ ) (split (regexp " +") exts)
7878+ end
7979+ | _ -> ()
8080+ ) fin;
8181+ close_in fin
8282+ ) (List.rev !files);
8383+ printf " | _ -> %s\n%!" default
+33
vendor/opam/magic-mime/magic-mime.opam
···11+opam-version: "2.0"
22+name: "magic-mime"
33+synopsis: "Map filenames to common MIME types"
44+description: """
55+This library contains a database of MIME types that maps filename extensions
66+into MIME types suitable for use in many Internet protocols such as HTTP or
77+e-mail. It is generated from the `mime.types` file found in Unix systems, but
88+has no dependency on a filesystem since it includes the contents of the
99+database as an ML datastructure.
1010+1111+For example, here's how to lookup MIME types in the [utop] REPL:
1212+1313+ #require "magic-mime";;
1414+ Magic_mime.lookup "/foo/bar.txt";;
1515+ - : bytes = "text/plain"
1616+ Magic_mime.lookup "bar.css";;
1717+ - : bytes = "text/css"
1818+"""
1919+maintainer: "Anil Madhavapeddy <anil@recoil.org>"
2020+authors: ["Anil Madhavapeddy" "Maxence Guesdon"]
2121+license: "ISC"
2222+homepage: "https://github.com/mirage/ocaml-magic-mime"
2323+doc: "https://mirage.github.io/ocaml-magic-mime/"
2424+bug-reports: "https://github.com/mirage/ocaml-magic-mime/issues"
2525+dev-repo: "git+https://github.com/mirage/ocaml-magic-mime.git"
2626+depends: [
2727+ "ocaml" {>= "4.03.0"}
2828+ "dune"
2929+]
3030+build: [
3131+ ["dune" "subst"] {dev}
3232+ ["dune" "build" "-p" name "-j" jobs]
3333+]
···11+(*
22+ * Copyright (c) 2009 Anil Madhavapeddy <anil@recoil.org>
33+ *
44+ * Permission to use, copy, modify, and distribute this software for any
55+ * purpose with or without fee is hereby granted, provided that the above
66+ * copyright notice and this permission notice appear in all copies.
77+ *
88+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
99+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1010+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1111+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1212+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1313+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1414+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515+ *)
1616+1717+(* Retrieve file extension, if any, or blank string otherwise *)
1818+let get_extension filename =
1919+ let rec search_dot i =
2020+ if i < 1 || filename.[i] = '/' then ""
2121+ else if filename.[i] = '.' then
2222+ String.sub filename (i+1) (String.length filename - i - 1)
2323+ else search_dot (i - 1) in
2424+ search_dot (String.length filename - 1)
2525+2626+(* Given a full filename, lookup its MIME type *)
2727+let lookup ?default filename =
2828+ match get_extension filename with
2929+ | "" -> Mime_types.map_file ?default filename
3030+ | ext -> Mime_types.map_extension ?default (String.lowercase_ascii ext)
3131+3232+let reverse_lookup mime =
3333+ let mime' =
3434+ let string_length = String.length mime in
3535+ let rec strip_parameters i =
3636+ if i = string_length || mime.[i] = ';' then
3737+ String.sub mime 0 i
3838+ else
3939+ strip_parameters (i + 1)
4040+ in
4141+ strip_parameters 0
4242+ in
4343+ Mime_types.map_mime mime'
+31
vendor/opam/magic-mime/src/magic_mime.mli
···11+(*
22+ * Copyright (c) 2009-2015 Anil Madhavapeddy <anil@recoil.org>
33+ *
44+ * Permission to use, copy, modify, and distribute this software for any
55+ * purpose with or without fee is hereby granted, provided that the above
66+ * copyright notice and this permission notice appear in all copies.
77+ *
88+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
99+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1010+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1111+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1212+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1313+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1414+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515+ *)
1616+1717+(** Convert file extensions to MIME types *)
1818+1919+val lookup : ?default:string -> string -> string
2020+(** [lookup ~default filename] will return a MIME type for the full [filename]
2121+ supplied by examining its extension and look it up by using
2222+ {!Mime_types.map_extension} or {!Mime_types.map_file} if there
2323+ is no file extension present. *)
2424+2525+(** Convert MIME types to file extensions *)
2626+2727+val reverse_lookup : string -> string list
2828+(** [reverse_lookup mime] will return a list of file extensions for the
2929+ MIME type supplied by stripping any parameters and looking it up by
3030+ using {!Mime_types.map_mime}.
3131+ If an unknown MIME type is supplied, empty list is returned. *)
+31
vendor/opam/magic-mime/src/mime_types.mli
···11+(*
22+ * Copyright (c) 2015 Anil Madhavapeddy <anil@recoil.org>
33+ *
44+ * Permission to use, copy, modify, and distribute this software for any
55+ * purpose with or without fee is hereby granted, provided that the above
66+ * copyright notice and this permission notice appear in all copies.
77+ *
88+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
99+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1010+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1111+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1212+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1313+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1414+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515+ *)
1616+1717+(** Database of file extensions to MIME types from RFC2045 onwards. *)
1818+1919+(** [map_extension ~default e] converts the file extension [e] into a MIME type,
2020+ defaulting to [default] (which is [application/octet-stream] by default) if
2121+ it is unknown. *)
2222+val map_extension : ?default:string -> string -> string
2323+2424+(** [map_file ~default f] converts the filename [f] into a MIME type,
2525+ defaulting to [default] (which is [application/octet-stream] by default) if
2626+ it is unknown. *)
2727+val map_file : ?default:string -> string -> string
2828+2929+(** [map_mime m] converts the MIME type [m] into a list of acceptable
3030+ file extensions, defaulting to an empty list if it is unknown. *)
3131+val map_mime : string -> string list
+49
vendor/opam/magic-mime/x-mime.types
···11+# Additional extensions
22+text/x-R r R Rhistory Rout Rout.save Rout.fail
33+text/x-autoconf ac
44+text/x-ada adb ads
55+text/x-asp asp
66+text/x-bibtex bib
77+text/x-c c
88+text/x-chdr h hh hp hpp h++
99+text/x-cpp cpp c++ cxxcc C
1010+text/x-csharp cs
1111+text/x-dsrc d
1212+text/x-diff diff path
1313+text/vnd.graphviz dot gv
1414+text/x-dtd dtd
1515+text/x-eiffel e eif
1616+text/x-erlang erl erh
1717+text/x-forth frt fs
1818+text/x-fortran f f90 f95 for
1919+text/x-fsharp fs
2020+text/x-gap g gd gi gap
2121+text/x-gtkrc gtkrc
2222+text/x-literate-haskell lhs
2323+text/x-haskell hs
2424+text/x-idl idl
2525+text/x-ini-file ini
2626+text/x-tex tex ltx sty cls dtx ins bbl
2727+text/x-libtool la lai lo
2828+text/x-lua lua
2929+text/x-makefile make mak mk
3030+text/x-markdown md mkd
3131+text/x-matlab m
3232+text/x-modelica mo mop
3333+text/x-nemerle n
3434+text/x-netrexx nrx
3535+text/x-objcsrc m
3636+text/x-objective-j j
3737+text/x-ocaml ml mli mll mly
3838+text/x-ocl ocl
3939+text/x-pascal p pas
4040+text/x-perl pl pm al perl t
4141+text/x-php php php3 php4 phtml
4242+text/x-gettext-translation po
4343+text/x-gettext-translation-template pot
4444+text/x-prolog prolog
4545+text/x-protobuf proto
4646+text/x-python py
4747+text/x-rpm-spec spec
4848+text/x-ruby rb rake
4949+text/x-scala scala