summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--acconfig.h5
-rw-r--r--configure.in54
-rw-r--r--plugins/common.h.in16
-rw-r--r--plugins/utils.c16
-rw-r--r--plugins/utils.h.in9
5 files changed, 66 insertions, 34 deletions
diff --git a/acconfig.h b/acconfig.h
index 55fb9a2..b283039 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -1,15 +1,20 @@
1#undef CGIURL 1#undef CGIURL
2#undef COMPILER_SUPPORTS_LL 2#undef COMPILER_SUPPORTS_LL
3#undef DF_COMMAND 3#undef DF_COMMAND
4#undef HAVE_ASPRINTF
4#undef HAVE_C99_VSNPRINTF 5#undef HAVE_C99_VSNPRINTF
5#undef HAVE_GETOPT_H 6#undef HAVE_GETOPT_H
6#undef HAVE_GETOPT_LONG 7#undef HAVE_GETOPT_LONG
8#undef HAVE_GETTIMEOFDAY
7#undef HAVE_LONGLONG 9#undef HAVE_LONGLONG
8#undef HAVE_PROC_LOADAVG 10#undef HAVE_PROC_LOADAVG
9#undef HAVE_PROC_MEMINFO 11#undef HAVE_PROC_MEMINFO
10#undef HAVE_SSL 12#undef HAVE_SSL
13#undef HAVE_SNPRINTF
11#undef HAVE_SWAP 14#undef HAVE_SWAP
12#undef HAVE_VA_COPY 15#undef HAVE_VA_COPY
16#undef HAVE_VASPRINTF
17#undef HAVE_VSNPRINTF
13#undef NSLOOKUP_COMMAND 18#undef NSLOOKUP_COMMAND
14#undef HOST_COMMAND 19#undef HOST_COMMAND
15#undef PACKAGE_VERSION 20#undef PACKAGE_VERSION
diff --git a/configure.in b/configure.in
index d759405..bdd4013 100644
--- a/configure.in
+++ b/configure.in
@@ -12,17 +12,6 @@ AM_CONFIG_HEADER(plugins/config.h plugins/common.h plugins/version.h plugins/net
12 12
13AC_PREFIX_DEFAULT(/usr/local/nagios) 13AC_PREFIX_DEFAULT(/usr/local/nagios)
14 14
15#AC_DEFUN(AC_HAVE_DECL,
16#[
17# AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
18# AC_TRY_COMPILE([$2],[int i = (int)$1],
19# ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
20# if test x"$ac_cv_have_$1_decl" = x"yes"; then
21# AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
22# fi
23#])
24
25
26dnl Figure out how to invoke "install" and what install options to use. 15dnl Figure out how to invoke "install" and what install options to use.
27 16
28AC_PROG_INSTALL 17AC_PROG_INSTALL
@@ -338,6 +327,28 @@ if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
338 AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf]) 327 AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
339fi 328fi
340 329
330#AC_HAVE_DECL(asprintf, [#include <stdio.h>])
331#AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
332#AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
333#AC_HAVE_DECL(snprintf, [#include <stdio.h>])
334
335AC_CHECK_FUNC(snprintf,
336 AC_DEFINE(HAVE_SNPRINTF,1,[Define if snprintf is present]),
337 LIBS="$LIBS -lsnprintf" DEPLIBS="$DEPLIBS libsnprintf.a")
338AC_CHECK_FUNC(vsnprintf,
339 AC_DEFINE(HAVE_VSNPRINTF,1,[Define if vsnprintf is present]),
340 LIBS="$LIBS -lsnprintf" DEPLIBS="$DEPLIBS libsnprintf.a")
341AC_CHECK_FUNC(vasprintf,
342 AC_DEFINE(HAVE_VASPRINTF,1,[Define if vasprintf is present]),
343 LIBS="$LIBS -lsnprintf" DEPLIBS="$DEPLIBS libsnprintf.a")
344AC_CHECK_FUNC(asprintf,
345 AC_DEFINE(HAVE_ASPRINTF,1,[Define if asprintf is present]),
346 LIBS="$LIBS -lsnprintf" DEPLIBS="$DEPLIBS libsnprintf.a")
347
348if test x"$ac_cv_HAVE_SNPRINTF" = x"no" -o x"$ac_cv_HAVE_VSNPRINTF" = x"no" -o x"$ac_cv_HAVE_VASPRINTF" = x"no" -o x"$ac_cv_HAVE_ASPRINTF" = x"no"; then
349 LIBS="$LIBS -lsnprintf" DEPLIBS="$DEPLIBS libsnprintf.a"
350fi
351
341dnl We used to not do long options unless a compatible lib was found 352dnl We used to not do long options unless a compatible lib was found
342dnl Now we provide code and make libgetopt if native is not suitable 353dnl Now we provide code and make libgetopt if native is not suitable
343AC_MSG_CHECKING(for getopt_long) 354AC_MSG_CHECKING(for getopt_long)
@@ -356,23 +367,16 @@ AC_TRY_COMPILE([#include <getopt.h>
356 367
357AC_CHECK_FUNCS(getopt_long_only,,LIBS="$LIBS -lgetopt" DEPLIBS="$DEPLIBS libgetopt.a") 368AC_CHECK_FUNCS(getopt_long_only,,LIBS="$LIBS -lgetopt" DEPLIBS="$DEPLIBS libgetopt.a")
358 369
359#AC_HAVE_DECL(asprintf, [#include <stdio.h>]) 370AC_TRY_COMPILE([#include <sys/time.h>],
360#AC_HAVE_DECL(vasprintf, [#include <stdio.h>]) 371 [struct timeval *foo;],
361#AC_HAVE_DECL(vsnprintf, [#include <stdio.h>]) 372 [AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])])
362#AC_HAVE_DECL(snprintf, [#include <stdio.h>])
363
364AC_CHECK_FUNC(snprintf,AC_DEFINE(HAVE_SNPRINTF,1,[Define if snprintf is present]))
365AC_CHECK_FUNC(vsnprintf,AC_DEFINE(HAVE_VSNPRINTF,1,[Define if vsnprintf is present]))
366AC_CHECK_FUNC(vasprintf,AC_DEFINE(HAVE_VASPRINTF,1,[Define if vasprintf is present]))
367AC_CHECK_FUNC(asprintf,AC_DEFINE(HAVE_ASPRINTF,1,[Define if asprintf is present]))
368
369if test x"$ac_cv_HAVE_SNPRINTF" = x"no" -o x"$ac_cv_HAVE_VSNPRINTF" = x"no" -o x"$ac_cv_HAVE_VASPRINTF" = x"no" -o x"$ac_cv_HAVE_ASPRINTF" = x"no"; then
370 LIBS="$LIBS -lsnprintf" DEPLIBS="$DEPLIBS libsnprintf.a"
371fi
372 373
374AC_TRY_COMPILE([#include <sys/time.h>],
375 [gettimeofday(NULL, NULL);],
376 AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]))
373 377
374dnl Checks for library functions. 378dnl Checks for library functions.
375AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul gettimeofday) 379AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul)
376 380
377AC_MSG_CHECKING(for type of socket size) 381AC_MSG_CHECKING(for type of socket size)
378AC_TRY_COMPILE([#include <stdlib.h> 382AC_TRY_COMPILE([#include <stdlib.h>
diff --git a/plugins/common.h.in b/plugins/common.h.in
index 7281702..535ae4a 100644
--- a/plugins/common.h.in
+++ b/plugins/common.h.in
@@ -87,6 +87,22 @@
87# define strtoul(a,b,c) (unsigned long)atol((a)) 87# define strtoul(a,b,c) (unsigned long)atol((a))
88#endif 88#endif
89 89
90#ifndef HAVE_ASPRINTF
91int asprintf(char **strp, const char *fmt, ...);
92#endif
93
94#ifndef HAVE_VASPRINTF
95/* int vasprintf(char **strp, const char *fmt, va_list ap); */
96#endif
97
98#ifndef HAVE_SNPRINTF
99int snprintf(char *str, size_t size, const char *format, ...);
100#endif
101
102#ifndef HAVE_VSNPRINTF
103int vsnprintf(char *str, size_t size, const char *format, va_list ap);
104#endif
105
90/* 106/*
91 * 107 *
92 * Standard Values 108 * Standard Values
diff --git a/plugins/utils.c b/plugins/utils.c
index a4519f2..bf1d204 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -44,6 +44,8 @@ int is_percentage (char *);
44 44
45int is_option (char *str); 45int is_option (char *str);
46 46
47double delta_time (struct timeval tv);
48
47void strip (char *); 49void strip (char *);
48char *strscpy (char *dest, const char *src); 50char *strscpy (char *dest, const char *src);
49char *strscat (char *dest, const char *src); 51char *strscat (char *dest, const char *src);
@@ -315,13 +317,21 @@ is_option (char *str)
315 317
316 318
317 319
320#ifndef HAVE_GETTIMEOFDAY
321int
322gettimeofday (struct timeval *tv, struct timezone *tz)
323{
324 tv->tv_usec = 0;
325 tv->tv_sec = (long) time ((time_t) 0);
326}
327#endif
328
329
318 330
319double 331double
320delta_time (struct timeval tv) 332delta_time (struct timeval tv)
321{ 333{
322 struct timeval now; 334 struct timeval now;
323 struct timezone tz;
324 double et;
325 335
326 gettimeofday (&now, NULL); 336 gettimeofday (&now, NULL);
327 return ((double)(now.tv_sec - tv.tv_sec) + (double)(now.tv_usec - tv.tv_usec) / (double)1000000); 337 return ((double)(now.tv_sec - tv.tv_sec) + (double)(now.tv_usec - tv.tv_usec) / (double)1000000);
@@ -366,8 +376,6 @@ strip (char *buffer)
366char * 376char *
367strscpy (char *dest, const char *src) 377strscpy (char *dest, const char *src)
368{ 378{
369 size_t len;
370
371 if (src == NULL) 379 if (src == NULL)
372 return NULL; 380 return NULL;
373 381
diff --git a/plugins/utils.h.in b/plugins/utils.h.in
index d88d0cb..2b668f3 100644
--- a/plugins/utils.h.in
+++ b/plugins/utils.h.in
@@ -46,16 +46,15 @@ int is_percentage (char *);
46int is_option (char *); 46int is_option (char *);
47 47
48/* generalized timer that will do milliseconds if available */ 48/* generalized timer that will do milliseconds if available */
49#ifndef HAVE_GETTIMEOFDAY 49#ifndef HAVE_STRUCT_TIMEVAL
50struct timeval { 50struct timeval {
51 long tv_sec; /* seconds */ 51 long tv_sec; /* seconds */
52 long tv_usec; /* microseconds */ 52 long tv_usec; /* microseconds */
53}; 53};
54#endif
54 55
55#define gettimeofday (tvp,tz) {\ 56#ifndef HAVE_GETTIMEOFDAY
56 tvp->tv_usec=0;\ 57int gettimeofday(struct timeval *tv, struct timezone *tz);
57 tvp->tv_sec=(long)time();\
58}
59#endif 58#endif
60 59
61double delta_time (struct timeval tv); 60double delta_time (struct timeval tv);