Code

fix for (tracker id 1420741)
[nagiosplug.git] / plugins / negate.c
index c24658afce96e86451513b611434bb697c14c62c..d08c3a309e30b868cd6dc7a51c0655d48797c5ee 100644 (file)
@@ -13,6 +13,8 @@
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ $Id$
 
 @@-<article>
 
@@ -53,7 +55,7 @@
 
 const char *progname = "negate";
 const char *revision = "$Revision$";
-const char *copyright = "2002-2003";
+const char *copyright = "2002-2004";
 const char *email = "nagiosplug-devel@lists.sourceforge.net";
 
 #define DEFAULT_TIMEOUT 9
@@ -69,14 +71,20 @@ int validate_arguments (void);
 void print_help (void);
 void print_usage (void);
 
+
+
 int
 main (int argc, char **argv)
 {
        int found = 0, result = STATE_UNKNOWN;
        char *buf;
 
+       setlocale (LC_ALL, "");
+       bindtextdomain (PACKAGE, LOCALEDIR);
+       textdomain (PACKAGE);
+
        if (process_arguments (argc, argv) == ERROR)
-               usage (_("Could not parse arguments\n"));
+               usage4 (_("Could not parse arguments"));
 
        /* Set signal handling and alarm */
        if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR)
@@ -89,6 +97,7 @@ main (int argc, char **argv)
                die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), command_line);
 
        child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
+       
        if (child_stderr == NULL) {
                printf (_("Could not open stderr for %s\n"), command_line);
        }
@@ -101,7 +110,7 @@ main (int argc, char **argv)
 
        if (!found)
                die (STATE_UNKNOWN,
-                    _("%s problem - No data recieved from host\nCMD: %s\n"),\
+                    _("%s problem - No data received from host\nCMD: %s\n"),\
                     argv[0], command_line);
 
        /* close the pipe */
@@ -121,8 +130,6 @@ main (int argc, char **argv)
        else
                exit (result);
 }
-\f
-
 
 /******************************************************************************
 @@-
@@ -142,6 +149,8 @@ is a only a 'timeout' option.</para>
 -@@
 ******************************************************************************/
 
+
+
 /* process command-line arguments */
 int
 process_arguments (int argc, char **argv)
@@ -165,7 +174,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':     /* help */
-                       usage3 (_("Unknown argument"), optopt);
+                       usage2 (_("Unknown argument"), optarg);
                        break;
                case 'h':     /* help */
                        print_help ();
@@ -176,7 +185,7 @@ process_arguments (int argc, char **argv)
                        exit (EXIT_SUCCESS);
                case 't':     /* timeout period */
                        if (!is_integer (optarg))
-                               usage2 (_("Timeout Interval must be an integer"), optarg);
+                               usage2 (_("Timeout interval must be a positive integer"), optarg);
                        else
                                timeout_interval = atoi (optarg);
                        break;
@@ -203,6 +212,8 @@ process_arguments (int argc, char **argv)
 -@@
 ******************************************************************************/
 
+
+
 int
 validate_arguments ()
 {
@@ -221,19 +232,15 @@ validate_arguments ()
 
 
 
-
-
-\f
 void
 print_help (void)
 {
        print_revision (progname, revision);
 
-       printf (_(COPYRIGHT), copyright, email);
+       printf (COPYRIGHT, copyright, email);
 
        printf (_("\
-Negates the status of a plugin (returns OK for CRITICAL, and vice-versa).\n\
-\n"));
+Negates the status of a plugin (returns OK for CRITICAL, and vice-versa).\n\n"));
 
        print_usage ();
 
@@ -261,12 +268,8 @@ Otherwise, the output state of the wrapped plugin is unchanged.\n"));
 
 
 
-
-
 void
 print_usage (void)
 {
-       printf (_("Usage: %s [-t timeout] <definition of wrapped plugin>\n"),
-               progname);
-       printf (_(UT_HLP_VRS), progname, progname);
+       printf ("Usage: %s [-t timeout] <definition of wrapped plugin>\n",progname);
 }