diff --git a/plugins/utils.c b/plugins/utils.c
index 22020d72eb16c5958908e9fc885cf68be05d0e1b..aaa9fe5ab7c74bdb4f9b703b4a892097b3e46e24 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
#include <limits.h>
extern int timeout_interval;
+extern const char *progname;
-char *my_basename (char *);
void support (void);
char *clean_revstring (const char *);
-void print_revision (char *, const char *);
+void print_revision (const char *, const char *);
void terminate (int, const char *fmt, ...);
RETSIGTYPE timeout_alarm_handler (int);
#define STRLEN 64
#define TXTBLK 128
-#define max(a,b) ((a)>(b))?(a):(b)
-
/* **************************************************************************
* max_state(STATE_x, STATE_y)
* compares STATE_x to STATE_y and returns result based on the following
* Note that numerically the above does not hold
****************************************************************************/
+#define max(a,b) (((a)>(b))?(a):(b))
+
int
-max_state(int a, int b)
+max_state (int a, int b)
{
if (a == STATE_CRITICAL || b == STATE_CRITICAL)
return STATE_CRITICAL;
return max (a, b);
}
-char *
-my_basename (char *path)
+void usage (char *msg)
{
- if (!strstr (path, "/"))
- return path;
- else
- return 1 + strrchr (path, '/');
+ printf (msg);
+ print_usage ();
+ exit (STATE_UNKNOWN);
+}
+
+void usage2(char *msg, char *arg)
+{
+ printf ("%s: %s - %s\n",progname,msg,arg);
+ print_usage ();
+ exit (STATE_UNKNOWN);
+}
+
+void
+usage3 (char *msg, char arg)
+{
+ printf ("%s: %s - %c\n", progname, msg, arg);
+ print_usage();
+ exit (STATE_UNKNOWN);
}
}
void
-print_revision (char *command_name, const char *revision_string)
+print_revision (const char *command_name, const char *revision_string)
{
char plugin_revision[STRLEN];
if (sscanf (revision_string, "$Revision: %[0-9.]", plugin_revision) != 1)
strncpy (plugin_revision, "N/A", STRLEN);
printf ("%s (nagios-plugins %s) %s\n",
- my_basename (command_name), VERSION, plugin_revision);
+ progname, VERSION, plugin_revision);
printf
("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"