Minor tweaks: turn the "http://address:port/0" URL of the topmost
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 1 Nov 2008 17:21:47 +0000 (17:21 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 1 Nov 2008 17:21:47 +0000 (17:21 +0000)
directory in the index into the natural "http://address:port/", and
also stop putting a self-link on the top-level page if the pathname
involved is "/".

git-svn-id: svn://svn.tartarus.org/sgt/agedu@8246 cda61777-01e9-0310-a592-d414129be87e

TODO
html.c
httpd.c

diff --git a/TODO b/TODO
index 51c00d2..0b6efba 100644 (file)
--- a/TODO
+++ b/TODO
@@ -37,9 +37,12 @@ Before it's non-embarrassingly releasable:
 
  - man page, licence.
 
-Future directions:
+Future possibilities:
 
  - IPv6 support in the HTTP server
+    * of course, Linux magic auth can still work in this context; we
+      merely have to be prepared to open one of /proc/net/tcp or
+      /proc/net/tcp6 as appropriate.
 
  - run-time configuration in the HTTP server
     * I think this probably works by having a configuration form, or
diff --git a/html.c b/html.c
index be13590..0d80eae 100644 (file)
--- a/html.c
+++ b/html.c
@@ -446,7 +446,7 @@ char *html_query(const void *t, unsigned long index,
      */
     htprintf(ctx, "<p align=center>\n<code>");
     q = path;
-    for (p = strchr(path, pathsep); p; p = strchr(p, pathsep)) {
+    for (p = strchr(path, pathsep); p && p[1]; p = strchr(p, pathsep)) {
        int doing_href = 0;
        char c, *zp;
 
@@ -466,6 +466,8 @@ char *html_query(const void *t, unsigned long index,
        trie_getpath(t, index2, path2);
        if (!strcmp(path, path2) && cfg->format) {
            snprintf(href, hreflen, cfg->format, index2);
+           if (!*href)                /* special case that we understand */
+               strcpy(href, "./");
            htprintf(ctx, "<a href=\"%s\">", href);
            doing_href = 1;
        }
diff --git a/httpd.c b/httpd.c
index d03e1c5..e71fef7 100644 (file)
--- a/httpd.c
+++ b/httpd.c
@@ -429,7 +429,7 @@ void run_httpd(const void *t, int authmask, const struct httpd_config *dcfg,
     socklen_t addrlen;
     struct html_config cfg = *incfg;
 
-    cfg.format = "%lu";
+    cfg.format = "%.0lu";
 
     /*
      * Establish the listening socket and retrieve its port