summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/compat.c (renamed from common/stringx.c)4
-rw-r--r--common/compat.h (renamed from common/stringx.h)8
-rw-r--r--configure.in7
-rw-r--r--daemon/Makefile.am2
-rw-r--r--daemon/config.c11
-rw-r--r--daemon/rrd-update.c1
-rw-r--r--daemon/rrdbotd.c3
-rw-r--r--daemon/snmp-engine.c1
-rw-r--r--daemon/snmp-help.c1
-rw-r--r--daemon/usuals.h2
10 files changed, 21 insertions, 19 deletions
diff --git a/common/stringx.c b/common/compat.c
index 3705cb9..9d2f53f 100644
--- a/common/stringx.c
+++ b/common/compat.c
@@ -98,8 +98,8 @@ stretrim(char* data)
char*
strtrim(char* data)
{
- data = (char*)trim_start(data);
- trim_end(data);
+ data = (char*)strbtrim(data);
+ stretrim(data);
return data;
}
diff --git a/common/stringx.h b/common/compat.h
index 3949d70..17967f4 100644
--- a/common/stringx.h
+++ b/common/compat.h
@@ -50,19 +50,19 @@ size_t strlcat(char* dst, const char* src, size_t siz);
#endif
#ifndef HAVE_STRCLN
-void strcln(char* data);
+void strcln(char* data, char ch);
#endif
#ifndef HAVE_STRBTRIM
-char* trim_start(const char* data);
+char* strbtrim(const char* data);
#endif
#ifndef HAVE_STRETRIM
-void trim_end(char* data);
+void stretrim(char* data);
#endif
#ifndef HAVE_STRTRIM
-char* trim_space(char* data);
+char* strtrim(char* data);
#endif
#ifndef HAVE_STRTOB
diff --git a/configure.in b/configure.in
index ba89937..6438116 100644
--- a/configure.in
+++ b/configure.in
@@ -35,7 +35,12 @@ AC_C_INLINE
dnl Check for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([rrd.h], , [echo "ERROR: rrd headers not found"])
-dnl TODO: AC_CHECK_HEADERS
+AC_CHECK_HEADERS([unistd.h stdio.h stddef.h stdlib.h assert.h errno.h stdarg.h string.h netdb.h], ,
+ [echo "ERROR: Required C header missing"; exit 1])
+
+AC_CHECK_FUNCS([strlcat strlcpy strtob])
+AC_CHECK_FUNCS([strerror getopt getaddrinfo], ,
+ [echo "ERROR: Required function missing"; exit 1])
AC_MSG_RESULT()
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 18b1217..fbc275d 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -5,7 +5,7 @@ rrdbotd_SOURCES = rrdbotd.c rrdbotd.h config.c usuals.h \
snmp-help.c snmp-engine.c rrd-update.c \
../common/server-mainloop.c ../common/server-mainloop.h \
../common/sock-any.h ../common/sock-any.c \
- ../common/stringx.h ../common/stringx.c \
+ ../common/compat.h ../common/compat.c \
../common/hash.h ../common/hash.c \
../mib/parse.c
rrdbotd_CFLAGS = -I${top_srcdir}/common/ -I${top_srcdir}/bsnmp/ -I${top_srcdir} \
diff --git a/daemon/config.c b/daemon/config.c
index 39c5a37..9b38bcb 100644
--- a/daemon/config.c
+++ b/daemon/config.c
@@ -42,7 +42,6 @@
#include <syslog.h>
#include <dirent.h>
-#include "stringx.h"
#include "rrdbotd.h"
/*
@@ -410,7 +409,7 @@ read_config_file(const char* configfile)
config[len + 1] = 0;
/* Remove nasty dos line endings */
- remove_cr(config);
+ strcln(config, '\r');
rb_messagex(LOG_DEBUG, "read config file: %s", configfile);
return config;
@@ -439,7 +438,7 @@ parse_config_file(const char* configfile, config_ctx *ctx)
p = next; /* Do this before cleaning below */
next = t + 1;
- t = trim_start(p);
+ t = strbtrim(p);
/* Continuation line (had spaces at start) */
if(p < t && *t)
@@ -482,7 +481,7 @@ parse_config_file(const char* configfile, config_ctx *ctx)
errx(2, "%s: invalid config header: %s", ctx->confname, p);
*t = 0;
- header = trim_space(p + 1);
+ header = strtrim(p + 1);
continue;
}
@@ -495,8 +494,8 @@ parse_config_file(const char* configfile, config_ctx *ctx)
*t = 0;
t++;
- name = trim_space(p);
- value = trim_space(t);
+ name = strtrim(p);
+ value = strtrim(t);
}
if(name && value)
diff --git a/daemon/rrd-update.c b/daemon/rrd-update.c
index d088e07..295eea6 100644
--- a/daemon/rrd-update.c
+++ b/daemon/rrd-update.c
@@ -43,7 +43,6 @@
#include <syslog.h>
#include <unistd.h>
-#include "stringx.h"
#include "rrdbotd.h"
#define MAX_NUMLEN 40
diff --git a/daemon/rrdbotd.c b/daemon/rrdbotd.c
index 94212b5..a9171e8 100644
--- a/daemon/rrdbotd.c
+++ b/daemon/rrdbotd.c
@@ -46,7 +46,6 @@
#include <bsnmp/asn1.h>
#include <bsnmp/snmp.h>
-#include "stringx.h"
#include "rrdbotd.h"
/* The default command line options */
@@ -172,7 +171,7 @@ rb_vmessage(int level, int err, const char* msg, va_list ap)
/* Cleanup the message a little */
strlcpy(buf, msg, MAX_MSGLEN);
- trim_end(buf);
+ stretrim(buf);
if(err)
{
diff --git a/daemon/snmp-engine.c b/daemon/snmp-engine.c
index c0af083..66cc047 100644
--- a/daemon/snmp-engine.c
+++ b/daemon/snmp-engine.c
@@ -43,7 +43,6 @@
#include <bsnmp/asn1.h>
#include <bsnmp/snmp.h>
-#include "stringx.h"
#include "rrdbotd.h"
#include "server-mainloop.h"
diff --git a/daemon/snmp-help.c b/daemon/snmp-help.c
index 4ae7cb1..31f8dc6 100644
--- a/daemon/snmp-help.c
+++ b/daemon/snmp-help.c
@@ -43,7 +43,6 @@
#include <bsnmp/asn1.h>
#include <bsnmp/snmp.h>
-#include "stringx.h"
#include "rrdbotd.h"
/* Whether we print warnings when loading MIBs or not */
diff --git a/daemon/usuals.h b/daemon/usuals.h
index f83a117..5fece3f 100644
--- a/daemon/usuals.h
+++ b/daemon/usuals.h
@@ -50,6 +50,8 @@
#include <errno.h>
#include <string.h>
+#include "compat.h"
+
#ifndef NULL
#define NULL 0
#endif