mime.anubis
2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
*Project* The Anubis Project
*Title* MIME Types definition.
*Copyright* Copyright (c) Alain Prouté 2005.
*Authors* Alain Prouté
David René
read tools/base64.anubis
read tools/basis.anubis
read system/string.anubis
public type MIME:
mime(String type,
String sybtype,
List(String) file_extensions).
public define Bool
MIME x = MIME y
=
if x is mime(x_type, x_subtype, _) then
if y is mime(y_type, y_subtype, _) then
insensitive_equal(x_type, y_type) & insensitive_equal(x_subtype, y_subtype).
public define List(MIME)
known_mime_types
=
[
mime("application", "octet-stream", [".exe"]),
mime("application", "x-pdf", [".pdf"]),
mime("image", "bmp", [".bmp"]),
mime("image", "gif", [".gif"]),
mime("image", "jpeg", [".jpg", ".jpeg"]),
mime("image", "png", [".png"]),
mime("image", "x-icon", [".ico"]),
mime("text", "html", [".html", ".htm"]),
mime("text", "css", [".css"]),
mime("text", "javascript", [".js"]),
mime("text", "plain", [".txt", ".anubis", ".c", ".h", ".y", "/Makefile"]),
mime("text", "comma-separated-values", [".csv"]),
mime("application", "msword", [".doc"]),
mime("application", "octet-stream", [".emz", ".xml", ".mso", ".wmf", ".gz", ".rar", ".zip", ".card", ".ankh", ".adm", ".swf", ".downloaded"]),
mime("audio", "x-mpeg", [".mp3"]),
mime("video", "x-msvideo", [".avi"]),
mime("message", "rfc822", [".eml"]),
].
public define String
to_String
(
MIME mime_type
) =
if mime_type is mime(type, subtype, _) then
type + "/" + subtype.
public define String
to_MIME_text
(
String charset,
String text
)=
if length(text) > 0 then
with text2 = "=?"+charset+"?B?"+to_string(base64_encode(to_byte_array(text)))+"?=",
find_and_replace(text2, implode([13,10]), implode([13,10,32]))
else "".