Code

various fixes for localization
[nagiosplug.git] / plugins / check_dummy.c
1 /******************************************************************************
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; either version 2 of the License, or
6  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  GNU General Public License for more details.
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  $Id$
18  
19 ******************************************************************************/
21 const char *progname = "check_dummy";
22 const char *revision = "$Revision$";
23 const char *copyright = "1999-2004";
24 const char *email = "nagiosplug-devel@lists.sourceforge.net";
26 #include "common.h"
27 #include "utils.h"
29 void print_help (void);
30 void print_usage (void);
33 int
34 main (int argc, char **argv)
35 {
36         int result = STATE_UNKNOWN;
38         setlocale (LC_ALL, "");
39         bindtextdomain (PACKAGE, LOCALEDIR);
40         textdomain (PACKAGE);
42         if (argc < 2)
43                 usage4 (_("Could not parse arguments"));
44         else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
45                 print_revision (progname, revision);
46                 exit (STATE_OK);
47         }
48         else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
49                 print_help ();
50                 exit (STATE_OK);
51         }
52         else if (!is_integer (argv[1]))
53                 usage4 (_("Arguments to check_dummy must be an integer"));
54         else
55                 result = atoi (argv[1]);
57         switch (result) {
58         case STATE_OK:
59                 printf (_("OK"));
60                 break;
61         case STATE_WARNING:
62                 printf (_("WARNING"));
63                 break;
64         case STATE_CRITICAL:
65                 printf (_("CRITICAL"));
66                 break;
67         case STATE_UNKNOWN:
68                 printf (_("UNKNOWN"));
69                 break;
70         default:
71                 printf (_("Status %d is not a supported error state\n"), result);
72                 break;
73         }
75         if (argc >= 3) 
76                 printf (": %s", argv[2]);
78         printf("\n");
80         return result;
81 }
85 void
86 print_help (void)
87 {
88         print_revision (progname, revision);
90         printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
91         printf (COPYRIGHT, copyright, email);
93         printf (_("\
94 This plugin will simply return the state corresponding to the numeric value\n\
95 of the <state> argument with optional text.\n\n"));
97         print_usage ();
99         printf (_(UT_HELP_VRSN));
101         printf (_(UT_SUPPORT));
106 void
107 print_usage (void)
109         printf ("Usage: %s <integer state> [optional text]\n", progname);