diff options
Diffstat (limited to 'plugins/utils.h.in')
-rw-r--r-- | plugins/utils.h.in | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/plugins/utils.h.in b/plugins/utils.h.in index 46b152a3..e910c417 100644 --- a/plugins/utils.h.in +++ b/plugins/utils.h.in | |||
@@ -45,13 +45,31 @@ int is_percentage (char *); | |||
45 | 45 | ||
46 | int is_option (char *); | 46 | int is_option (char *); |
47 | 47 | ||
48 | /* generalized timer that will do milliseconds if available */ | ||
49 | #ifndef HAVE_GETTIMEOFDAY | ||
50 | struct timeval { | ||
51 | long tv_sec; /* seconds */ | ||
52 | long tv_usec; /* microseconds */ | ||
53 | }; | ||
54 | |||
55 | struct timezone { | ||
56 | int tz_minuteswest; /* minutes W of Greenwich */ | ||
57 | int tz_dsttime; /* type of dst correction */ | ||
58 | }; | ||
59 | |||
60 | #define gettimeofday (tvp,tz) {\ | ||
61 | tvp->tv_usec=0;\ | ||
62 | tvp->tv_sec=(long)time();\ | ||
63 | } | ||
64 | #endif | ||
65 | |||
48 | /* Handle strings safely */ | 66 | /* Handle strings safely */ |
49 | 67 | ||
50 | void strip (char *buffer); | 68 | void strip (char *buffer); |
51 | char *strscpy (char *dest, char *src); | 69 | char *strscpy (char *dest, char *src); |
52 | char *strscat (char *dest, char *src); | 70 | char *strscat (char *dest, char *src); |
53 | char *strnl (char *str); | 71 | char *strnl (char *str); |
54 | char *ssprintf (char *str, const char *fmt, ...); | 72 | char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */ |
55 | char *strpcpy (char *dest, const char *src, const char *str); | 73 | char *strpcpy (char *dest, const char *src, const char *str); |
56 | char *strpcat (char *dest, const char *src, const char *str); | 74 | char *strpcat (char *dest, const char *src, const char *str); |
57 | 75 | ||
@@ -61,15 +79,15 @@ int max_state(int, int); | |||
61 | #define max(a,b) ((a)>(b))?(a):(b) | 79 | #define max(a,b) ((a)>(b))?(a):(b) |
62 | 80 | ||
63 | #define usage(msg) {\ | 81 | #define usage(msg) {\ |
64 | printf(msg);\ | 82 | printf(msg);\ |
65 | print_usage();\ | 83 | print_usage();\ |
66 | exit(STATE_UNKNOWN);\ | 84 | exit(STATE_UNKNOWN);\ |
67 | } | 85 | } |
68 | 86 | ||
69 | #define usage2(msg,arg) {\ | 87 | #define usage2(msg,arg) {\ |
70 | printf("%s: %s - %s\n",PROGNAME,msg,arg);\ | 88 | printf("%s: %s - %s\n",PROGNAME,msg,arg);\ |
71 | print_usage();\ | 89 | print_usage();\ |
72 | exit(STATE_UNKNOWN);\ | 90 | exit(STATE_UNKNOWN);\ |
73 | } | 91 | } |
74 | 92 | ||
75 | #define state_text(a) \ | 93 | #define state_text(a) \ |
@@ -94,3 +112,4 @@ exit(STATE_UNKNOWN);\ | |||
94 | {"warning",required_argument,0,'w'},\ | 112 | {"warning",required_argument,0,'w'},\ |
95 | {"hostname",required_argument,0,'H'},\ | 113 | {"hostname",required_argument,0,'H'},\ |
96 | {"file",required_argument,0,'F'} | 114 | {"file",required_argument,0,'F'} |
115 | |||