summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 509f71f)
raw | patch | inline | side by side (parent: 509f71f)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Wed, 16 Oct 2002 04:56:19 +0000 (04:56 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Wed, 16 Oct 2002 04:56:19 +0000 (04:56 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@116 f882894a-f735-0410-b71e-b25c423dba1c
plugins/utils.c | patch | blob | history | |
plugins/utils.h.in | patch | blob | history |
diff --git a/plugins/utils.c b/plugins/utils.c
index d97ad48080d51f69bdf4497456e00147081078b3..6e52dab75e0759c501910d30ba3a16452acad595 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
+double
+delta_time (struct timeval *tv)
+{
+ struct timeval *pt;
+ struct timezone *tz;
+
+ gettimeofday (pt, tz);
+
+ return (pt->tv_sec - tv->tv_sec + (pt->tv_usec - tv->tv_usec) / 1000000);
+}
+
+
+
void
strip (char *buffer)
diff --git a/plugins/utils.h.in b/plugins/utils.h.in
index 46b152a3b743c38bc17229130c26331f3f1432e6..e910c417b4d18d6864019a2e27437a8e4b105a29 100644 (file)
--- a/plugins/utils.h.in
+++ b/plugins/utils.h.in
int is_option (char *);
+/* generalized timer that will do milliseconds if available */
+#ifndef HAVE_GETTIMEOFDAY
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* microseconds */
+};
+
+struct timezone {
+ int tz_minuteswest; /* minutes W of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
+#define gettimeofday (tvp,tz) {\
+ tvp->tv_usec=0;\
+ tvp->tv_sec=(long)time();\
+}
+#endif
+
/* Handle strings safely */
void strip (char *buffer);
char *strscpy (char *dest, char *src);
char *strscat (char *dest, char *src);
char *strnl (char *str);
-char *ssprintf (char *str, const char *fmt, ...);
+char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */
char *strpcpy (char *dest, const char *src, const char *str);
char *strpcat (char *dest, const char *src, const char *str);
#define max(a,b) ((a)>(b))?(a):(b)
#define usage(msg) {\
- printf(msg);\
- print_usage();\
-exit(STATE_UNKNOWN);\
+ printf(msg);\
+ print_usage();\
+ exit(STATE_UNKNOWN);\
}
#define usage2(msg,arg) {\
- printf("%s: %s - %s\n",PROGNAME,msg,arg);\
- print_usage();\
- exit(STATE_UNKNOWN);\
+ printf("%s: %s - %s\n",PROGNAME,msg,arg);\
+ print_usage();\
+ exit(STATE_UNKNOWN);\
}
#define state_text(a) \
{"warning",required_argument,0,'w'},\
{"hostname",required_argument,0,'H'},\
{"file",required_argument,0,'F'}
+