phroxy

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.z3bra.org/phroxy.git
Log | Files | Refs | LICENSE

commit 403dee6fb7818dbf5dc8df145436b03eb2841c9d
parent 9e05ae9780fcb1048c273226bcd03a72a3571c96
Author: Willy Goiffon <dev@z3bra.org>
Date:   Sat, 12 Sep 2020 00:14:46 +0200

Merge HTML header/footer into a format string

Diffstat:
Mconfig.def.h | 14++++++++------
Mphroxy.c | 4++--
2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,11 +1,13 @@ const char *http_host = "z3bra.org"; -const char *foot = "</pre></body></html>"; -const char *head = - "<!DOCTYPE HTML>" - "<html><head>" +const char *htmlfmt = + "<!DOCTYPE HTML>\n" + "<html><head>\n" "<meta charset=\"utf-8\">" "<meta name=\"viewport\" content=\"width=device-width\">" "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://z3bra.org/z3bra.css\">" - "<title>phroxy(8)</title>" - "</head><body><pre>\n"; + "<title>gopher proxy</title>\n" + "</head>\n" + "<body><pre>\n" + "%s\n" + "</pre></body></html>\n"; diff --git a/phroxy.c b/phroxy.c @@ -211,12 +211,12 @@ htmlize(char *data, size_t len, size_t *newsize) size_t hlen; char *html = NULL; - hlen = len + strlen(head) + strlen(foot); + hlen = len + strlen(htmlfmt); html = malloc(hlen); if (!html) return NULL; - snprintf(html, hlen, "%s%s%s", head, data, foot); + snprintf(html, hlen, htmlfmt, data); if (newsize) *newsize = hlen;