From cfe942fb3391ae80e816272d7baa45be30e5e7ec Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 1 Nov 2008 17:21:47 +0000 Subject: [PATCH] Minor tweaks: turn the "http://address:port/0" URL of the topmost 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 | 5 ++++- html.c | 4 +++- httpd.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 51c00d2..0b6efba 100644 --- 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 --- a/html.c +++ b/html.c @@ -446,7 +446,7 @@ char *html_query(const void *t, unsigned long index, */ htprintf(ctx, "

\n"); 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, "", href); doing_href = 1; } diff --git a/httpd.c b/httpd.c index d03e1c5..e71fef7 100644 --- 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 -- 2.11.0