aboutsummaryrefslogtreecommitdiff
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-01-13 12:15:16 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-01-13 12:15:16 +0000
commit0c3386274ef5002dffc20337ef02407f24d7400c (patch)
tree1e78bac7844a548e56a642b35acfe1fd67342f71 /plugins/utils.c
parentde5650f28e4e43a7264913953f95a75d8afe23f0 (diff)
downloadmonitoring-plugins-0c3386274ef5002dffc20337ef02407f24d7400c.tar.gz
convert PROGANE from a define to a const char
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@238 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 22020d72..474206b9 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -18,11 +18,11 @@
#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);
@@ -57,8 +57,6 @@ char *strpcat (char *dest, const char *src, const char *str);
#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
@@ -68,7 +66,7 @@ char *strpcat (char *dest, const char *src, const char *str);
****************************************************************************/
int
-max_state(int a, int b)
+max_state (int a, int b)
{
if (a == STATE_CRITICAL || b == STATE_CRITICAL)
return STATE_CRITICAL;
@@ -84,13 +82,26 @@ max_state(int a, int b)
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);
}
@@ -115,14 +126,14 @@ clean_revstring (const char *revstring)
}
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"