From 6c13003e4b90fb96f91c9010b98ae833af38b991 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 28 Oct 2013 13:21:57 +0100 Subject: move configuration to config.h --- .gitignore | 1 + Makefile | 6 +++++- config.def.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ pacredir.c | 19 +------------------ 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 config.def.h diff --git a/.gitignore b/.gitignore index 2e6e296..8ffca75 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *~ *.o pacredir +config.h avahi/pacdbserve.service README.html diff --git a/Makefile b/Makefile index 1bb8d07..3425dd1 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ CC := gcc MD := markdown INSTALL := install +CP := cp RM := rm SED := sed CFLAGS += -O2 -Wall -Werror @@ -19,10 +20,13 @@ endif all: pacredir pacdbserve README.html -pacredir: pacredir.c +pacredir: pacredir.c config.h $(CC) $(CFLAGS) -o pacredir pacredir.c \ -DVERSION="\"$(VERSION)\"" +config.h: + $(CP) config.def.h config.h + pacdbserve: avahi/pacdbserve.service.in $(SED) 's/%ARCH%/$(ARCH)/' avahi/pacdbserve.service.in > avahi/pacdbserve.service diff --git a/config.def.h b/config.def.h new file mode 100644 index 0000000..1863fb4 --- /dev/null +++ b/config.def.h @@ -0,0 +1,45 @@ +/* + * (C) 2013 by Christian Hesse + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + * + * This is an example code skeleton provided by vim-skeleton. + */ + +#ifndef _CONFIG_H +#define _CONFIG_H + +/* the binary needs to know its own architecture */ +#if defined __x86_64__ +# define ARCH "x86_64" +#elif defined __i386__ +# define ARCH "i686" +#else +# error Unknown architecture! +#endif + +/* This is used for default documents. Usually you will not see this anyway. */ +#define PAGE307 "307 temporary redirect" \ + "307 temporary redirect: " \ + "%s" +#define PAGE404 "404 Not Found" \ + "404 Not Found: %s" + +/* the port pacredir listens to */ +#define PORT 7077 + +/* avahi service names */ +#define PACSERVE "_pacserve._tcp" +#define PACDBSERVE "_pacdbserve_" ARCH "._tcp" + +/* this is where pacman stores its local copy of db files */ +#define SYNCPATH "/var/lib/pacman/sync" + +/* This defines when a host is queried again after a bad request + * default is 600 seconds (10 minutes) */ +#define BADTIME 60 * 10 + +#endif /* _CONFIG_H */ + +// vim: set syntax=c: diff --git a/pacredir.c b/pacredir.c index 888337b..2bd2943 100644 --- a/pacredir.c +++ b/pacredir.c @@ -24,24 +24,7 @@ #include #include -#if defined __x86_64__ -# define ARCH "x86_64" -#elif defined __i386__ -# define ARCH "i686" -#else -# error Unknown architecture! -#endif - -#define PAGE307 "307 temporary redirect" \ - "307 temporary redirect: " \ - "%s" -#define PAGE404 "404 Not Found" \ - "404 Not Found: %s" -#define PORT 7077 -#define PACSERVE "_pacserve._tcp" -#define PACDBSERVE "_pacdbserve_" ARCH "._tcp" -#define SYNCPATH "/var/lib/pacman/sync" -#define BADTIME 60 * 10 +#include "config.h" /* services */ struct services { -- cgit v1.2.3-70-g09d2