1 /* Pseudo about: protocol implementation */
2
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
6
7 #include "elinks.h"
8
9 #include "cache/cache.h"
10 #include "network/connection.h"
11 #include "protocol/about.h"
12 #include "protocol/protocol.h"
13 #include "protocol/uri.h"
14 #include "util/string.h"
15
16
17 #ifndef CONFIG_SMALL
18 struct about_page {
19 unsigned char *name;
20 unsigned char *string;
21 };
22
23 static const struct about_page about_pages[] = {
24 { "bloat",
25
26 "<html><body>"
27 "<p>Bloat? What bloat?</p>"
28 "</body></html>"
29
30 },
31 { "links",
32
33 "<html><body><pre>"
34 "/* D~~)w */\n"
35 "/* / | */\n"
36 "/* /'m_O / */\n"
37 "/* /'.\"//~~~~\\ */\n"
38 "/* `\\/`\\`--') , */\n"
39 "/* / `~~~ | */\n"
40 "/* | | */\n"
41 "/* | , */\n"
42 "/* `_'p~~~~~/ */\n"
43 "/* . ||_| */\n"
44 "/* ` . _|| | */\n"
45 "/* `, ((____| */\n"
46 "</pre></body></html>"
47
48 },
49 { "mozilla",
50
51 "<html><body text=\"white\" bgcolor=\"red\">"
52 "<p align=\"center\">And the <em>beste</em> shall meet "
53 "a <em>being</em> and the being shall wear signs "
54 "of EL and the signs shall have colour of enke. "
55 "And the being shall be of <em>Good Nature</em>. "
56 "From on high the beste hath looked down upon the being "
57 "and the being was <em>smal</em> compared to it. "
58 "Yet <em>faster</em> and <em>leaner</em> it hath been "
59 "and it would come through doors closed to the beste. "
60 "And there was truly great <em>respect</em> "
61 "twix the beste and the <em>smal being</em> "
62 "and they bothe have <em>served</em> to naciouns. "
63 "Yet only the <em>true believers</em> "
64 "would choose betwene them and the followers "
65 "of <em>mammon</em> stayed <em>blinded</em> to bothe.</p>"
66 "<p align=\"right\">from <em>The Book of Mozilla</em> "
67 "(Apocryphon of ELeasar), 12:24</p>"
68 "</body></html>"
69
70 },
71 { "fear",
72
73 "<html><body text=\"yellow\">"
74 "<p>I must not fear. Fear is the mind-killer. "
75 "Fear is the little-death that brings total obliteration. "
76 "I will face my fear. "
77 "I will permit it to pass over me and through me. "
78 "And when it has gone past I will turn the inner eye "
79 "to see its path. "
80 "Where the fear has gone there will be nothing. "
81 "Only I will remain.</p>"
82 "</body></html>"
83
84 },
85
86 { NULL, NULL }
87 };
88 #endif
89
90 void
about_protocol_handler(struct connection * conn)91 about_protocol_handler(struct connection *conn)
92 {
93 struct cache_entry *cached = get_cache_entry(conn->uri);
94
95 /* Only do this the first time */
96 if (cached && !cached->content_type) {
97 int len = 0;
98
99 #ifndef CONFIG_SMALL
100 {
101 const struct about_page *page = about_pages;
102
103 for (; page->name; page++) {
104 unsigned char *str;
105
106 if (strcmp(conn->uri->data, page->name))
107 continue;
108
109 str = page->string;
110 len = strlen(str);
111 add_fragment(cached, 0, str, len);
112 break;
113 }
114 }
115 #endif
116
117 normalize_cache_entry(cached, len);
118
119 /* Set content to known type */
120 mem_free_set(&cached->content_type, stracpy("text/html"));
121 }
122
123 conn->cached = cached;
124 abort_connection(conn, S_OK);
125 }
126