diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-11-08 07:20:05 (GMT) |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-11-08 07:20:05 (GMT) |
commit | 1c4dd10d70ba9ed6dead6cc56cd0f572627cf619 (patch) | |
tree | 62485f23a5478eb8a6ad6b2de1eac322bf195662 /plugins | |
parent | 34ba941736b434a6c1453feec35d04ed7b0a59e5 (diff) | |
download | monitoring-plugins-1c4dd10d70ba9ed6dead6cc56cd0f572627cf619.tar.gz |
patches required to build on solaris with asprintf and gettimeofday
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@174 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/common.h.in | 16 | ||||
-rw-r--r-- | plugins/utils.c | 16 | ||||
-rw-r--r-- | plugins/utils.h.in | 9 |
3 files changed, 32 insertions, 9 deletions
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 | ||
91 | int 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 | ||
99 | int snprintf(char *str, size_t size, const char *format, ...); | ||
100 | #endif | ||
101 | |||
102 | #ifndef HAVE_VSNPRINTF | ||
103 | int 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 | ||
45 | int is_option (char *str); | 45 | int is_option (char *str); |
46 | 46 | ||
47 | double delta_time (struct timeval tv); | ||
48 | |||
47 | void strip (char *); | 49 | void strip (char *); |
48 | char *strscpy (char *dest, const char *src); | 50 | char *strscpy (char *dest, const char *src); |
49 | char *strscat (char *dest, const char *src); | 51 | char *strscat (char *dest, const char *src); |
@@ -315,13 +317,21 @@ is_option (char *str) | |||
315 | 317 | ||
316 | 318 | ||
317 | 319 | ||
320 | #ifndef HAVE_GETTIMEOFDAY | ||
321 | int | ||
322 | gettimeofday (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 | ||
319 | double | 331 | double |
320 | delta_time (struct timeval tv) | 332 | delta_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) | |||
366 | char * | 376 | char * |
367 | strscpy (char *dest, const char *src) | 377 | strscpy (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 *); | |||
46 | int is_option (char *); | 46 | int 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 |
50 | struct timeval { | 50 | struct 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;\ | 57 | int gettimeofday(struct timeval *tv, struct timezone *tz); |
57 | tvp->tv_sec=(long)time();\ | ||
58 | } | ||
59 | #endif | 58 | #endif |
60 | 59 | ||
61 | double delta_time (struct timeval tv); | 60 | double delta_time (struct timeval tv); |