libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 2184438b2d088ad0ffb54a763b045c0361b18a10
parent f35fdf4b7c6f09557a6ac72e3550bcdbf6936f47
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu,  9 May 2013 10:47:18 +0000

-bugfixes

Diffstat:
Msrc/examples/Makefile.am | 2+-
Msrc/examples/demo.c | 9+++++++--
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am @@ -43,7 +43,7 @@ if HAVE_POSTPROCESSOR noinst_PROGRAMS += \ post_example if HAVE_MAGIC -noinst_PROGRAMS += \ +bin_PROGRAMS = \ demo endif endif diff --git a/src/examples/demo.c b/src/examples/demo.c @@ -37,6 +37,7 @@ #include <dirent.h> #include <magic.h> #include <limits.h> +#include <ctype.h> /** * Number of threads to run in the thread pool. Should (roughly) match @@ -280,7 +281,7 @@ list_directory (struct ResponseDataContext *rdc, rdc->off += snprintf (&rdc->buf[rdc->off], rdc->buf_len - rdc->off, "<li><a href=\"/%s\">%s</a></li>\n", - de->d_name, + fullname, de->d_name); } (void) closedir (dir); @@ -472,6 +473,7 @@ process_upload_data (void *cls, size_t size) { struct UploadContext *uc = cls; + int i; if (0 == strcmp (key, "category")) return do_append (&uc->category, data, size); @@ -529,7 +531,10 @@ process_upload_data (void *cls, "%s/%s/%s", uc->language, uc->category, - filename); + filename); + for (i=strlen (fn)-1;i>=0;i--) + if (! isprint ((int) fn[i])) + fn[i] = '_'; uc->fd = open (fn, O_CREAT | O_EXCL #if O_LARGEFILE