Code

standardize localization string
[nagiosplug.git] / plugins / utils.h
index b10f0e5af75f5c65254b0e0baaf36dd934c6df36..a3ddc0a27081305a593151b02daa007f25540e6f 100644 (file)
@@ -1,30 +1,36 @@
-/* header file for nagios plugins utils.c */
+/* Header file for nagios plugins utils.c */
 
-/* this file should be included in all plugins */
+/* This file should be included in all plugins */
 
-/* The purpose of this package is to provide safer alternantives to C
+/* The purpose of this package is to provide safer alternatives to C
 functions that might otherwise be vulnerable to hacking. This
 currently includes a standard suite of validation routines to be sure
 that an string argument acually converts to its intended type and a
 suite of string handling routine that do their own memory management
 in order to resist overflow attacks. In addition, a few functions are
-provided to standardize version and error reporting accross the entire
+provided to standardize version and error reporting across the entire
 suite of plugins. */
 
 /* Standardize version information, termination */
 
-char *my_basename (char *);
+/* $Id$ */
+
 void support (void);
 char *clean_revstring (const char *revstring);
 void print_revision (const char *, const char *);
-void die (int result, const char *fmt, ...);
-void terminate (int result, char *msg, ...);
-extern RETSIGTYPE timeout_alarm_handler (int);
+void die (int result, const char *fmt, ...) __attribute__((noreturn,format(printf, 2, 3)));
 
 /* Handle timeouts */
 
+#ifdef LOCAL_TIMEOUT_ALARM_HANDLER
+extern unsigned int timeout_interval;
+RETSIGTYPE timeout_alarm_handler (int);
+#else
+unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
+extern RETSIGTYPE timeout_alarm_handler (int);
+#endif
+
 time_t start_time, end_time;
-int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
 
 /* Test input types */
 
@@ -42,7 +48,7 @@ int is_percentage (char *);
 
 int is_option (char *);
 
-/* generalized timer that will do milliseconds if available */
+/* Generalized timer that will do milliseconds if available */
 #ifndef HAVE_STRUCT_TIMEVAL
 struct timeval {
        long tv_sec;        /* seconds */
@@ -55,26 +61,50 @@ int gettimeofday(struct timeval *tv, struct timezone *tz);
 #endif
 
 double delta_time (struct timeval tv);
+long deltime (struct timeval tv);
 
 /* Handle strings safely */
 
 void strip (char *buffer);
-char *strscpy (char *dest, char *src);
-char *strscat (char *dest, char *src);
+char *strscpy (char *dest, const char *src);
 char *strnl (char *str);
-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);
 
 int max_state (int a, int b);
 
-void usage (char *msg);
-void usage2(char *msg, char *arg);
-void usage3(char *msg, char arg);
+void usage (const char *msg) __attribute__((noreturn));
+void usage2(const char *msg, const char *arg) __attribute__((noreturn));
+void usage3(const char *msg, int arg) __attribute__((noreturn));
 
-char *state_text (int result);
+const char *state_text (int result);
 
 #define max(a,b) (((a)>(b))?(a):(b))
+#define min(a,b) (((a)<(b))?(a):(b))
+
+char *perfdata (const char *label,
+ long int val,
+ const char *uom,
+ int warnp,
+ long int warn,
+ int critp,
+ long int crit,
+ int minp,
+ long int minv,
+ int maxp,
+ long int maxv);
+
+char *fperfdata (const char *label,
+ double val,
+ const char *uom,
+ int warnp,
+ double warn,
+ int critp,
+ double crit,
+ int minp,
+ double minv,
+ int maxp,
+ double maxv);
 
 /* The idea here is that, although not every plugin will use all of these, 
    most will or should.  Therefore, for consistency, these very common 
@@ -92,6 +122,10 @@ char *state_text (int result);
 #define COPYRIGHT "Copyright (c) %s Nagios Plugin Development Team\n\
 \t<%s>\n\n"
 
+#define UT_HLP_VRS "\
+       %s (-h | --help) for detailed help\n\
+       %s (-V | --version) for version information\n"
+
 #define UT_HELP_VRSN "\
 \nOptions:\n\
  -h, --help\n\
@@ -124,3 +158,13 @@ char *state_text (int result);
 #define UT_TIMEOUT "\
  -t, --timeout=INTEGER\n\
     Seconds before connection times out (default: %d)\n"
+
+#define UT_SUPPORT "\n\
+Send email to nagios-users@lists.sourceforge.net if you have questions\n\
+regarding use of this software. To submit patches or suggest improvements,\n\
+send email to nagiosplug-devel@lists.sourceforge.net\n"
+
+#define UT_NOWARRANTY "\
+The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n\
+copies of the plugins under the terms of the GNU General Public License.\n\
+For more information about these matters, see the file named COPYING.\n"