diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-01-13 12:15:16 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-01-13 12:15:16 +0000 |
commit | 0c3386274ef5002dffc20337ef02407f24d7400c (patch) | |
tree | 1e78bac7844a548e56a642b35acfe1fd67342f71 /plugins/utils.c | |
parent | de5650f28e4e43a7264913953f95a75d8afe23f0 (diff) | |
download | monitoring-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.c | 37 |
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 @@ | |||
18 | #include <limits.h> | 18 | #include <limits.h> |
19 | 19 | ||
20 | extern int timeout_interval; | 20 | extern int timeout_interval; |
21 | extern const char *progname; | ||
21 | 22 | ||
22 | char *my_basename (char *); | ||
23 | void support (void); | 23 | void support (void); |
24 | char *clean_revstring (const char *); | 24 | char *clean_revstring (const char *); |
25 | void print_revision (char *, const char *); | 25 | void print_revision (const char *, const char *); |
26 | void terminate (int, const char *fmt, ...); | 26 | void terminate (int, const char *fmt, ...); |
27 | RETSIGTYPE timeout_alarm_handler (int); | 27 | RETSIGTYPE 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 | ||
70 | int | 68 | int |
71 | max_state(int a, int b) | 69 | max_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 | ||
87 | char * | 85 | void usage (char *msg) |
88 | my_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 | |||
92 | void usage2(char *msg, char *arg) | ||
93 | { | ||
94 | printf ("%s: %s - %s\n",progname,msg,arg); | ||
95 | print_usage (); | ||
96 | exit (STATE_UNKNOWN); | ||
97 | } | ||
98 | |||
99 | void | ||
100 | usage3 (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 | ||
117 | void | 128 | void |
118 | print_revision (char *command_name, const char *revision_string) | 129 | print_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" |