phroxy

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

commit 5b689675cc8bd3a8c3dd5fa25f8671035ab2b293
parent 5f318d5ec96f8ca1d8d51c6a4f19581048299a09
Author: Willy Goiffon <dev@z3bra.org>
Date:   Fri, 11 Sep 2020 22:50:11 +0200

Move formatting/settings to config.h

Diffstat:
Aconfig.def.h | 11+++++++++++
Mmakefile | 5+++++
Mmkfile | 5+++++
Mphroxy.c | 12+-----------
4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -0,0 +1,11 @@ +const char *host = "z3bra.org"; +const char *foot = "</pre></body></html>"; +const char *head = + "<!DOCTYPE HTML>" + "<html><head>" + "<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"; + diff --git a/makefile b/makefile @@ -5,6 +5,11 @@ all: phroxy phroxy: phroxy.o ${LD} ${LDFLAGS} -o $@ phroxy.o +phroxy.o: config.h + +config.h: config.def.h + cp config.def.h config.h + install: phroxy phroxy.8 mkdir -p ${DESTDIR}${PREFIX}/bin mkdir -p ${DESTDIR}${MANDIR}/man1 diff --git a/mkfile b/mkfile @@ -5,6 +5,11 @@ all:V: phroxy phroxy: phroxy.o $LD $LDFLAGS -o $target $prereq +phroxy.o: config.h + +%.h: %.def.h + cp $stem.def.h $stem.h + %.o: %.c $CC $CPPFLAGS $CFLAGS -c $stem.c diff --git a/phroxy.c b/phroxy.c @@ -12,7 +12,7 @@ #include <sys/socket.h> #include <sys/socket.h> -const char *host = "z3bra.org"; +#include "config.h" void * xreallocarray(void *m, const size_t n, const size_t s) @@ -211,16 +211,6 @@ htmlize(char *data, size_t len, size_t *newsize) size_t hlen; char *html = NULL; - char *foot = "</pre></body></html>"; - char *head = - "<!DOCTYPE HTML>" - "<html><head>" - "<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"; - hlen = len + strlen(head) + strlen(foot); html = malloc(hlen); if (!html)