From 1c9cc347b096b2536b229ef0e0d1551090e8ed70 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 22 Apr 2014 13:57:51 +0200 Subject: redirect to project website if no file is given --- pacredir.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pacredir.c') diff --git a/pacredir.c b/pacredir.c index 21223ec..7c156c4 100644 --- a/pacredir.c +++ b/pacredir.c @@ -333,6 +333,14 @@ static int ahc_echo(void * cls, struct MHD_Connection * connection, const char * /* clear context pointer */ *ptr = NULL; + /* redirect to website if no file given */ + if (*basename == 0) { + http_code = MHD_HTTP_OK; + /* duplicate string so we can free it later */ + url = strdup(WEBSITE); + goto response; + } + /* process db file (and signature) request */ if ((strlen(basename) > 3 && strcmp(basename + strlen(basename) - 3, ".db") == 0) || (strlen(basename) > 7 && strcmp(basename + strlen(basename) - 7, ".db.sig") == 0)) { @@ -417,6 +425,7 @@ static int ahc_echo(void * cls, struct MHD_Connection * connection, const char * free(request); } +response: /* give response */ if (http_code == MHD_HTTP_OK) { write_log(stdout, "Redirecting to %s\n", url); -- cgit v1.2.3-54-g00ecf