diff options
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 72817028..535ae4a0 100644 --- a/plugins/common.h.in +++ b/plugins/common.h.in @@ -87,6 +87,22 @@ # define strtoul(a,b,c) (unsigned long)atol((a)) #endif +#ifndef HAVE_ASPRINTF +int asprintf(char **strp, const char *fmt, ...); +#endif + +#ifndef HAVE_VASPRINTF +/* int vasprintf(char **strp, const char *fmt, va_list ap); */ +#endif + +#ifndef HAVE_SNPRINTF +int snprintf(char *str, size_t size, const char *format, ...); +#endif + +#ifndef HAVE_VSNPRINTF +int vsnprintf(char *str, size_t size, const char *format, va_list ap); +#endif + /* * * Standard Values diff --git a/plugins/utils.c b/plugins/utils.c index a4519f25..bf1d2047 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -44,6 +44,8 @@ int is_percentage (char *); int is_option (char *str); +double delta_time (struct timeval tv); + void strip (char *); char *strscpy (char *dest, const char *src); char *strscat (char *dest, const char *src); @@ -315,13 +317,21 @@ is_option (char *str) +#ifndef HAVE_GETTIMEOFDAY +int +gettimeofday (struct timeval *tv, struct timezone *tz) +{ + tv->tv_usec = 0; + tv->tv_sec = (long) time ((time_t) 0); +} +#endif + + double delta_time (struct timeval tv) { struct timeval now; - struct timezone tz; - double et; gettimeofday (&now, NULL); return ((double)(now.tv_sec - tv.tv_sec) + (double)(now.tv_usec - tv.tv_usec) / (double)1000000); @@ -366,8 +376,6 @@ strip (char *buffer) char * strscpy (char *dest, const char *src) { - size_t len; - if (src == NULL) return NULL; diff --git a/plugins/utils.h.in b/plugins/utils.h.in index d88d0cb0..2b668f3c 100644 --- a/plugins/utils.h.in +++ b/plugins/utils.h.in @@ -46,16 +46,15 @@ int is_percentage (char *); int is_option (char *); /* generalized timer that will do milliseconds if available */ -#ifndef HAVE_GETTIMEOFDAY +#ifndef HAVE_STRUCT_TIMEVAL struct timeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */ }; +#endif -#define gettimeofday (tvp,tz) {\ - tvp->tv_usec=0;\ - tvp->tv_sec=(long)time();\ -} +#ifndef HAVE_GETTIMEOFDAY +int gettimeofday(struct timeval *tv, struct timezone *tz); #endif double delta_time (struct timeval tv); |