+#ifdef TRUST_FILES
+/*********************************************************************
+ *
+ * Function : trust_url FIXME: I should be called distrust_url
+ *
+ * Description : Calls is_untrusted_url to determine if the URL is trusted
+ * and if not, returns a HTTP 304 response with a reject message.
+ *
+ * Parameters :
+ * 1 : csp = Current client state (buffers, headers, etc...)
+ *
+ * Returns : NULL => trusted, else http_response.
+ *
+ *********************************************************************/
+struct http_response *trust_url(struct client_state *csp)
+{
+ struct http_response *rsp;
+ struct map *exports = NULL;
+ char buf[BUFFER_SIZE], *p = NULL;
+ struct url_spec **tl, *t;
+
+ /*
+ * Don't bother to work on trusted URLs
+ */
+ if (!is_untrusted_url(csp))
+ {
+ return NULL;
+ }
+
+ /*
+ * Else, prepare a response:
+ */
+ if (NULL == ( rsp = (struct http_response *)zalloc(sizeof(*rsp))))
+ {
+ return NULL;
+ }
+ exports = default_exports(csp, NULL);
+
+ /*
+ * Export the host, port, and referrer information
+ */
+ exports = map(exports, "hostport", 1, csp->http->hostport, 1);
+ exports = map(exports, "path", 1, csp->http->path, 1);
+ exports = map(exports, "hostport-html", 1, html_encode(csp->http->hostport), 0);
+ exports = map(exports, "path-html", 1, html_encode(csp->http->path), 0);
+
+ if (csp->referrer && strlen(csp->referrer) > 9)
+ {
+ exports = map(exports, "referrer", 1, csp->referrer + 9, 1);
+ exports = map(exports, "referrer-html", 1, html_encode(csp->referrer + 9), 0);
+ }
+ else
+ {
+ exports = map(exports, "referrer", 1, "unknown", 1);
+ exports = map(exports, "referrer-html", 1, "unknown", 1);
+ }
+
+ /*
+ * Export the trust list
+ */
+ for (tl = csp->config->trust_list; (t = *tl) ; tl++)
+ {
+ sprintf(buf, "<li>%s</li>\n", t->spec);
+ p = strsav(p, buf);
+ }
+ exports = map(exports, "trusted-referrers", 1, p, 0);
+ p = NULL;
+
+ /*
+ * Export the trust info, if available
+ */
+ if (csp->config->trust_info->next)
+ {
+ struct list *l;
+
+ for (l = csp->config->trust_info->next; l ; l = l->next)
+ {
+ sprintf(buf, "<li> <a href=%s>%s</a><br>\n",l->str, l->str);
+ p = strsav(p, buf);
+ }
+ exports = map(exports, "trust-info", 1, p, 0);
+ }
+ else
+ {
+ exports = map_block_killer(exports, "have-trust-info");
+ }
+
+ /*
+ * Export the force prefix or the force conditional block killer
+ */