[Nagios-devel] [PATCH] bring contrib daemonchk.cgi building into shape.

Elan Ruusamäe glen at delfi.ee
Sun Dec 12 15:18:51 UTC 2010


also change internal functions visibility via static
---
 contrib/Makefile.in |   15 +++++++++------
 contrib/daemonchk.c |   35 ++++++++++++++++++-----------------
 2 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/contrib/Makefile.in b/contrib/Makefile.in
index 9b9ede2..addf145 100644
--- a/contrib/Makefile.in
+++ b/contrib/Makefile.in
@@ -9,6 +9,7 @@ CFLAGS=@CFLAGS@ @DEFS@
 LDFLAGS=@LDFLAGS@ @LIBS@
 
 # Source code directories
+SRC_INCLUDE=../include
 SRC_COMMON=../common
 SRC_CGI=../cgi
 
@@ -23,15 +24,15 @@ exec_prefix=@exec_prefix@
 CGIDIR=@sbindir@
 BINDIR=@bindir@
 
-CGIS=traceroute.cgi
+CGIS=traceroute.cgi daemonchk.cgi
 UTILS=mini_epn new_mini_epn convertcfg
 ALL=$(CGIS) $(UTILS)
 
 
 CGI_C=$(SRC_CGI)/getcgi.c
 CGI_O=$(SRC_CGI)/getcgi.o $(SNPRINTF_O)
-CGI_H=$(SRC_CGI)/getcgi.h
-COMMON_H=$(SRC_COMMON)/config.h $(SRC_COMMON)/common.h $(SRC_COMMON)/locations.h
+CGI_H=$(SRC_INCLUDE)/getcgi.h
+COMMON_H=$(SRC_INCLUDE)/config.h $(SRC_INCLUDE)/common.h $(SRC_INCLUDE)/locations.h
 
 ##############################################################################
 # standard targets (all, clean, distclean, devclean, install)
@@ -58,9 +59,11 @@ install:
 ##############################################################################
 # rules and dependencies for actual target programs
 
-daemonchk.cgi: 
-	@echo "This doesn't work with Nagios 2.x yet..."
-#	daemonchk.c $(CGI_O) $(CGI_H) $(COMMON_H)
+daemonchk.cgi: daemonchk.o $(CGI_O) $(CGI_H) $(COMMON_H)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(CGI_O)
+
+daemonchk.o: daemonchk.c
+	$(CC) $(CLFAGS) -c -o $@ $< -I$(SRC_INCLUDE)
 
 mini_epn: mini_epn.c
 	perl -MExtUtils::Embed -e xsinit
diff --git a/contrib/daemonchk.c b/contrib/daemonchk.c
index ad524cc..7ae59b8 100644
--- a/contrib/daemonchk.c
+++ b/contrib/daemonchk.c
@@ -1,8 +1,8 @@
-#include "../common/config.h"
-#include "../common/common.h"
-#include "../common/locations.h"
-#include "../cgi/cgiutils.h"
-#include "../cgi/getcgi.h"
+#include "config.h"
+#include "common.h"
+#include "locations.h"
+#include "cgiutils.h"
+#include "getcgi.h"
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
 #endif
@@ -11,13 +11,14 @@
 #define CHARLEN 256
 #define max(a,b) ((a)>(b))?(a):(b)
 
-void document_header(void);
-void document_footer(void);
-int process_cgivars(void);
+static void document_header(void);
+//static void document_footer(void);
+static int process_cgivars(void);
 
-char *strscpy(char *dest, const char *src);
-char *ssprintf(char *str, const char *fmt, ...);
-void terminate (int result, const char *fmt, ...);
+static char *strscpy(char *dest, const char *src);
+static char *ssprintf(char *str, const char *fmt, ...);
+static void terminate (int result, const char *fmt, ...);
+static void get_expire_time_string(time_t *raw_time,char *buffer,int buffer_length);
 
 int main (int argc, char **argv){
   FILE *fp;
@@ -138,7 +139,7 @@ int main (int argc, char **argv){
   
 }
 
-void document_header(void){
+static void document_header(void){
   char date_time[48];
   time_t current_time;
 
@@ -157,7 +158,7 @@ void document_header(void){
   return;
 }
 
-int process_cgivars(void){
+static int process_cgivars(void){
   char **variables;
   int error=FALSE;
   int x;
@@ -176,7 +177,7 @@ int process_cgivars(void){
 }
 
 /* get date/time string used in META tags for page expiration */
-void get_expire_time_string(time_t *raw_time,char *buffer,int buffer_length){
+static void get_expire_time_string(time_t *raw_time,char *buffer,int buffer_length){
   time_t t;
   struct tm *tm_ptr;
   int day;
@@ -206,7 +207,7 @@ void get_expire_time_string(time_t *raw_time,char *buffer,int buffer_length){
   return;
 }
 
-char *strscpy(char *dest, const char *src)
+static char *strscpy(char *dest, const char *src)
 {
 	int len;
 
@@ -225,7 +226,7 @@ char *strscpy(char *dest, const char *src)
 	return dest;
 }
 
-char *ssprintf(char *str, const char *fmt, ...)
+static char *ssprintf(char *str, const char *fmt, ...)
 {
 	va_list ap;
 	int nchars;
@@ -263,7 +264,7 @@ char *ssprintf(char *str, const char *fmt, ...)
 
 }
 
-void terminate (int result, const char *fmt, ...)
+static void terminate (int result, const char *fmt, ...)
 {
 	va_list ap;
 	va_start(ap,fmt);
-- 
1.7.3.3






More information about the Nagios-devel mailing list