Code

AF indepedent routines introduced.
[nagiosplug.git] / plugins / utils.h.in
index e910c417b4d18d6864019a2e27437a8e4b105a29..0d947f42d1671dd4445acc3cb9efb1bfd2bc8b6f 100644 (file)
@@ -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);
 
@@ -28,7 +28,9 @@ int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
 /* Test input types */
 
 int is_host (char *);
-int is_dotted_quad (char *);
+int is_addr (char *);
+int is_inet_addr (char *);
+int is_inet6_addr (char *);
 int is_hostname (char *);
 
 int is_integer (char *);
@@ -46,23 +48,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 +71,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 +92,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'}