X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Futils.h.in;h=317ec46fba6cbd9ebc625b8b7a15e9129766be18;hb=782bc207d5697f539beb1fd3359ce81d22e26a54;hp=e910c417b4d18d6864019a2e27437a8e4b105a29;hpb=6cbf1dd4a321ced6dffa5ca590692d283731f987;p=nagiosplug.git diff --git a/plugins/utils.h.in b/plugins/utils.h.in index e910c41..317ec46 100644 --- a/plugins/utils.h.in +++ b/plugins/utils.h.in @@ -16,7 +16,7 @@ suite of plugins. */ char *my_basename (char *); void support (void); char *clean_revstring (const char *revstring); -void print_revision (char *, const char *); +void print_revision (const char *, const char *); void terminate (int result, char *msg, ...); extern RETSIGTYPE timeout_alarm_handler (int); @@ -46,23 +46,19 @@ 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 -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();\ -} +#ifndef HAVE_GETTIMEOFDAY +int gettimeofday(struct timeval *tv, struct timezone *tz); #endif +double delta_time (struct timeval tv); + /* Handle strings safely */ void strip (char *buffer); @@ -73,22 +69,14 @@ 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); -/* Handle comparisions for STATE_* */ -int max_state(int, int); +int max_state (int a, int b); -#define max(a,b) ((a)>(b))?(a):(b) +void usage (char *msg); +void usage2(char *msg, char *arg); +void usage3(char *msg, char arg); -#define usage(msg) {\ - printf(msg);\ - print_usage();\ - exit(STATE_UNKNOWN);\ -} -#define usage2(msg,arg) {\ - printf("%s: %s - %s\n",PROGNAME,msg,arg);\ - print_usage();\ - exit(STATE_UNKNOWN);\ -} +#define max(a,b) (((a)>(b))?(a):(b)) #define state_text(a) \ (a)==0?"OK":\ @@ -102,14 +90,12 @@ int max_state(int, int); most will or should. Therefore, for consistency, these very common options should have only these meanings throughout the overall suite */ -#define STD_OPTS "Vvht:c:w:H:F:" -#define STD_OPTS_LONG \ +#define STD_LONG_OPTS \ {"version",no_argument,0,'V'},\ {"verbose",no_argument,0,'v'},\ {"help",no_argument,0,'h'},\ {"timeout",required_argument,0,'t'},\ {"critical",required_argument,0,'c'},\ {"warning",required_argument,0,'w'},\ -{"hostname",required_argument,0,'H'},\ -{"file",required_argument,0,'F'} +{"hostname",required_argument,0,'H'}