summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-01-13 12:15:16 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-01-13 12:15:16 (GMT)
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 22020d7..474206b 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -18,11 +18,11 @@
18#include <limits.h> 18#include <limits.h>
19 19
20extern int timeout_interval; 20extern int timeout_interval;
21extern const char *progname;
21 22
22char *my_basename (char *);
23void support (void); 23void support (void);
24char *clean_revstring (const char *); 24char *clean_revstring (const char *);
25void print_revision (char *, const char *); 25void print_revision (const char *, const char *);
26void terminate (int, const char *fmt, ...); 26void terminate (int, const char *fmt, ...);
27RETSIGTYPE timeout_alarm_handler (int); 27RETSIGTYPE timeout_alarm_handler (int);
28 28
@@ -57,8 +57,6 @@ char *strpcat (char *dest, const char *src, const char *str);
57#define STRLEN 64 57#define STRLEN 64
58#define TXTBLK 128 58#define TXTBLK 128
59 59
60#define max(a,b) ((a)>(b))?(a):(b)
61
62/* ************************************************************************** 60/* **************************************************************************
63 * max_state(STATE_x, STATE_y) 61 * max_state(STATE_x, STATE_y)
64 * compares STATE_x to STATE_y and returns result based on the following 62 * 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);
68 ****************************************************************************/ 66 ****************************************************************************/
69 67
70int 68int
71max_state(int a, int b) 69max_state (int a, int b)
72{ 70{
73 if (a == STATE_CRITICAL || b == STATE_CRITICAL) 71 if (a == STATE_CRITICAL || b == STATE_CRITICAL)
74 return STATE_CRITICAL; 72 return STATE_CRITICAL;
@@ -84,13 +82,26 @@ max_state(int a, int b)
84 return max (a, b); 82 return max (a, b);
85} 83}
86 84
87char * 85void usage (char *msg)
88my_basename (char *path)
89{ 86{
90 if (!strstr (path, "/")) 87 printf (msg);
91 return path; 88 print_usage ();
92 else 89 exit (STATE_UNKNOWN);
93 return 1 + strrchr (path, '/'); 90}
91
92void usage2(char *msg, char *arg)
93{
94 printf ("%s: %s - %s\n",progname,msg,arg);
95 print_usage ();
96 exit (STATE_UNKNOWN);
97}
98
99void
100usage3 (char *msg, char arg)
101{
102 printf ("%s: %s - %c\n", progname, msg, arg);
103 print_usage();
104 exit (STATE_UNKNOWN);
94} 105}
95 106
96 107
@@ -115,14 +126,14 @@ clean_revstring (const char *revstring)
115} 126}
116 127
117void 128void
118print_revision (char *command_name, const char *revision_string) 129print_revision (const char *command_name, const char *revision_string)
119{ 130{
120 char plugin_revision[STRLEN]; 131 char plugin_revision[STRLEN];
121 132
122 if (sscanf (revision_string, "$Revision: %[0-9.]", plugin_revision) != 1) 133 if (sscanf (revision_string, "$Revision: %[0-9.]", plugin_revision) != 1)
123 strncpy (plugin_revision, "N/A", STRLEN); 134 strncpy (plugin_revision, "N/A", STRLEN);
124 printf ("%s (nagios-plugins %s) %s\n", 135 printf ("%s (nagios-plugins %s) %s\n",
125 my_basename (command_name), VERSION, plugin_revision); 136 progname, VERSION, plugin_revision);
126 printf 137 printf
127 ("The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n" 138 ("The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n"
128 "copies of the plugins under the terms of the GNU General Public License.\n" 139 "copies of the plugins under the terms of the GNU General Public License.\n"