changeset 1678:2b3cba462b23

vsource page add title element
author corvid <corvid@lavabit.com>
date Sun, 06 Jun 2010 18:38:36 +0000
parents 2adf63a0999b
children b974e9823aa1
files dpi/vsource.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dpi/vsource.c	Sun Jun 06 18:05:33 2010 +0000
+++ b/dpi/vsource.c	Sun Jun 06 18:38:36 2010 +0000
@@ -96,11 +96,14 @@
 /*
  * Send source as html text with line numbers
  */
-void send_html_text(Dsh *sh, int data_size)
+void send_html_text(Dsh *sh, const char *url, int data_size)
 {
    int bytes_read = 0, old_line = 0, line = 1;
    char *p, *q, *src_str, line_str[128];
 
+   if (strncmp(url, "dpi:/vsource/:", 14) == 0)
+      url += 14;
+
    /* Send HTTP header for plain text MIME type */
    a_Dpip_dsh_printf(sh, 0, "Content-type: text/html\n\n");
 
@@ -108,10 +111,11 @@
    a_Dpip_dsh_printf(sh, 0,
                      "\n"
                      "<html><head>\n"
+                     "<title>Source for %s</title>\n"
                      "<style type=\"text/css\">PRE {white-space: pre-wrap}\n"
                      "</style>\n"
                      "</head>\n"
-                     "<body id=\"dillo_vs\">\n<table cellpadding='0'>\n");
+                     "<body id=\"dillo_vs\">\n<table cellpadding='0'>\n", url);
 
    while (bytes_read < data_size &&
           (src_str = a_Dpip_dsh_read_token(sh, 1))) {
@@ -211,7 +215,7 @@
          /* Choose your flavour */
          //send_plain_text(sh, data_size);
          //send_numbered_text(sh, data_size);
-         send_html_text(sh, data_size);
+         send_html_text(sh, url, data_size);
       } else if (strcmp(cmd2, "DpiError") == 0) {
          /* Dillo detected an error (other failures just close the socket) */
          a_Dpip_dsh_printf(sh, 0, "Content-type: text/plain\n\n");