From 5b5f3f450fa6e39305002e2cbeedcbe123d63618 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 8 Mar 2016 18:46:34 +0000 Subject: [PATCH] * Ensured the bin directory is created [issue #1]; * Fixed all compiler warnings with gcc 5.2.1; * Fixed version substitution in header file. --- src/Makefile | 18 +++++++++++------- src/gild.c | 2 +- src/{gild.h => gild.h.src} | 9 +++++---- src/log.c | 4 ++-- 4 files changed, 19 insertions(+), 14 deletions(-) rename src/{gild.h => gild.h.src} (93%) diff --git a/src/Makefile b/src/Makefile index 7a50c46..ecd12e6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,26 +6,30 @@ CFLAGS= -g LD= gcc LDFLAGS= -g HOMEDIR= /usr/local/etc/gild -TARGETS= ../bin/gild -COMPONENTS = gild.o wrapper.o config.o log.o +BINDIR= ../bin +TARGETS= $(BINDIR)/gild +COMPONENTS = gild.h gild.o wrapper.o config.o log.o +VERSION= $(shell git describe) all: $(TARGETS) .c.o: $(CC) $(CFLAGS) -c $< +gild.h: gild.h.src + sed "s?@Revision@?$(VERSION)?" gild.h.src > gild.h + ../bin/gild: $(COMPONENTS) gild.h Makefile $(LD) $(LDFLAGS) -o gild $(COMPONENTS) - mv gild ../bin + test -d $(BINDIR) || mkdir $(BINDIR) + mv gild $(BINDIR) clean: - rm core $(COMPONENTS) $(TARGETS) + rm -f core $(COMPONENTS) $(TARGETS) install: $(TARGETS) install --strip $(TARGETS) $(HOMEDIR) install gild.conf $(HOMEDIR) cd handlers; make install -version: $(TARGETS) - cvs commit gild.c wrapper.c config.c log.c Makefile gild.h \ - gild.conf handlers + diff --git a/src/gild.c b/src/gild.c index 5fbb963..e3a6539 100644 --- a/src/gild.c +++ b/src/gild.c @@ -27,7 +27,7 @@ extern handler * handlers; void error( int severity) /* log the current contents of errorBuff and then if severity is bad die */ { - log( severity, errorBuff); + log_message( severity, errorBuff); switch ( severity) { diff --git a/src/gild.h b/src/gild.h.src similarity index 93% rename from src/gild.h rename to src/gild.h.src index 289189a..be4da92 100644 --- a/src/gild.h +++ b/src/gild.h.src @@ -14,14 +14,15 @@ /* $Header$ */ +#include #include #include #include #include #include #include +#include #include -/* #include */ #include #include #include @@ -29,8 +30,8 @@ #define GILD_NAME "gild" -#define GILD_VERSION "$Revision$" -#define GILD_ID "gild $Revision$" +#define GILD_VERSION "@Revision@" +#define GILD_ID "gild @Revision@" #define CONFIG_PATH "/usr/local/etc/gild/gild.conf" #define DEFAULT_PORT_NO 8421 @@ -61,7 +62,7 @@ void error( int severity); handler * get_handler( char * match); /* find a handler whose pattern matches match, and return it's command */ -int log( int level, char *message); +int log_message( int level, char *message); /* hand this message over to the syslog daemon for recording */ int parse_config( char * path); diff --git a/src/log.c b/src/log.c index c3d405c..2744908 100644 --- a/src/log.c +++ b/src/log.c @@ -18,14 +18,14 @@ #include "gild.h" -int log( int level, char *message) +int log_message( int level, char *message) /* hand this message over to the syslog daemon for recording */ { #ifdef DEBUG fprintf( stderr, "%s: DEBUG: %s\n", GILD_ID, message); #else openlog( GILD_NAME, 0, LOG_DAEMON); - syslog( level, message); + syslog( level, "%s", message); closelog(); #endif }