From 22bd672d19c378f1e6124ee18e64e5a88cf53739 Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Fri, 22 Aug 2003 06:22:38 +0000 Subject: - bindtextdomain for gettext, a few other smale cleanups here and there git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@690 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index b0aa189..560ae0c 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c @@ -42,11 +42,6 @@ char **service; int passive = FALSE; int verbose = FALSE; - - - - - int main (int argc, char **argv) { @@ -61,8 +56,13 @@ main (int argc, char **argv) time_t local_time; FILE *fp = NULL; - asprintf (&remotecmd, "%s", ""); - asprintf (&comm, "%s", SSH_COMMAND); + remotecmd = strdup (""); + comm = strdup (SSH_COMMAND); + result_text = strdup (""); + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); /* process arguments */ if (process_arguments (argc, argv) == ERROR) @@ -71,7 +71,7 @@ main (int argc, char **argv) /* Set signal handling and alarm timeout */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { - printf ("Cannot catch SIGALRM"); + printf (_("Cannot catch SIGALRM")); return STATE_UNKNOWN; } alarm (timeout_interval); @@ -97,7 +97,7 @@ main (int argc, char **argv) } - /* get results from remote command */ + /* build up results from remote command in result_text */ while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) asprintf (&result_text, "%s%s", result_text, input_buffer); @@ -105,6 +105,8 @@ main (int argc, char **argv) /* WARNING if output found on stderr */ if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { printf ("%s\n", input_buffer); + while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) + printf ("%s\n", input_buffer); return STATE_WARNING; } (void) fclose (child_stderr); @@ -122,10 +124,10 @@ main (int argc, char **argv) exit (STATE_UNKNOWN); } - time (&local_time); + local_time = time (NULL); commands = 0; while (result_text && strlen(result_text) > 0) { - status_text = strstr (result_text, _("STATUS CODE: ")); + status_text = strstr (result_text, "STATUS CODE: "); if (status_text == NULL) { printf ("%s", result_text); return result; @@ -136,7 +138,7 @@ main (int argc, char **argv) if (eol != NULL) eol[0] = 0; if (service[commands] && status_text - && sscanf (status_text, _("STATUS CODE: %d"), &cresult) == 1) { + && sscanf (status_text, "STATUS CODE: %d", &cresult) == 1) { fprintf (fp, _("[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n"), (int) local_time, host_shortname, service[commands++], cresult, output); @@ -145,6 +147,7 @@ main (int argc, char **argv) } + /* print the first line from the remote command */ else { eol = strpbrk (result_text, "\r\n"); @@ -153,7 +156,8 @@ main (int argc, char **argv) printf ("%s\n", result_text); } - /* return error status from remote command */ + + /* return error status from remote command */ return result; } @@ -222,7 +226,8 @@ process_arguments (int argc, char **argv) case 't': /* timeout period */ if (!is_integer (optarg)) usage2 (_("timeout interval must be an integer"), optarg); - timeout_interval = atoi (optarg); + else + timeout_interval = atoi (optarg); break; case 'H': /* host */ if (!is_host (optarg)) @@ -382,6 +387,8 @@ execute additional commands as proxy\n")); To use passive mode, provide multiple '-C' options, and provide\n\ all of -O, -s, and -n options (servicelist order must match '-C'\n\ options)\n")); + + printf (_(UT_SUPPORT)); } diff --git a/plugins/check_dig.c b/plugins/check_dig.c index f376e30..dc4f89a 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c @@ -42,11 +42,6 @@ int server_port = DEFAULT_PORT; int warning_interval = -1; int critical_interval = -1; - - - - - int main (int argc, char **argv) { @@ -57,6 +52,10 @@ main (int argc, char **argv) output = strdup (""); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + /* Set signal handling and alarm */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) usage (_("Cannot catch SIGALRM\n")); @@ -280,6 +279,7 @@ print_help (void) print_revision (progname, revision); + printf (_("Copyright (c) 2000 Karl DeBisschop \n")); printf (_(COPYRIGHT), copyright, email); printf (_("Test the DNS service on the specified host using dig\n\n")); diff --git a/plugins/check_disk.c b/plugins/check_disk.c index c8cfecd..36f30a5 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -151,6 +151,10 @@ main (int argc, char **argv) output = strdup (""); details = strdup (""); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + mount_list = read_filesystem_list (0); if (process_arguments (argc, argv) != OK) diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 58c0a1b..328fc5f 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -82,6 +82,10 @@ main (int argc, char **argv) struct timeval tv; int multi_address; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + /* Set signal handling and alarm */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { printf (_("Cannot catch SIGALRM")); @@ -398,6 +402,7 @@ print_help (void) { print_revision (progname, revision); + printf (_("Copyright (c) 1999 Ethan Galstad \n")); printf (_(COPYRIGHT), copyright, email); print_usage (); diff --git a/plugins/check_dummy.c b/plugins/check_dummy.c index 3db5238..9ca7a3a 100644 --- a/plugins/check_dummy.c +++ b/plugins/check_dummy.c @@ -34,6 +34,10 @@ main (int argc, char **argv) { int result; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (argc != 2) usage (_("Incorrect number of arguments supplied\n")); else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) { diff --git a/plugins/check_fping.c b/plugins/check_fping.c index bb17830..0753cf3 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c @@ -69,6 +69,10 @@ main (int argc, char **argv) char *input_buffer = NULL; input_buffer = malloc (MAX_INPUT_BUFFER); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage (_("Could not parse arguments\n")); diff --git a/plugins/check_game.c b/plugins/check_game.c index d5de13d..dd16777 100644 --- a/plugins/check_game.c +++ b/plugins/check_game.c @@ -60,6 +60,10 @@ main (int argc, char **argv) char *p, *ret[QSTAT_MAX_RETURN_ARGS]; int i; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + result = process_arguments (argc, argv); if (result != OK) { diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c index edde341..72f6bd7 100644 --- a/plugins/check_hpjd.c +++ b/plugins/check_hpjd.c @@ -79,6 +79,10 @@ main (int argc, char **argv) errmsg = malloc(MAX_INPUT_BUFFER); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) != OK) usage (_("Invalid command arguments supplied\n")); @@ -374,6 +378,7 @@ print_help (void) { print_revision (progname, revision); + printf (_("Copyright (c) 1999 Ethan Galstad \n")); printf (_(COPYRIGHT), copyright, email); printf (_("\ diff --git a/plugins/check_http.c b/plugins/check_http.c index 2908c00..3ec9e49 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -815,7 +815,7 @@ redir (char *pos, char *status_line) else if (sscanf (pos, HD5, url) == 1) { /* relative url */ if ((url[0] != '/')) { - if (x = strrchr(url, '/')) + if ((x = strrchr(url, '/'))) *x = '\0'; asprintf (&server_url, "%s/%s", server_url, url); } diff --git a/plugins/check_ide-smart.c b/plugins/check_ide-smart.c index ecd8a4e..e1f1e74 100644 --- a/plugins/check_ide-smart.c +++ b/plugins/check_ide-smart.c @@ -396,6 +396,10 @@ main (int argc, char *argv[]) {"version", no_argument, 0, 'V'}, {0, 0, 0, 0} }; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + while (1) { o = getopt_long (argc, argv, "+d:iq10nhV", longopts, &longindex); diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index d2c6ae2..adfa966 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c @@ -64,6 +64,10 @@ main (int argc, char *argv[]) int t_diff; time_t time0, time1; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage (_("check_ldap: could not parse arguments\n")); diff --git a/plugins/check_load.c b/plugins/check_load.c index c12cad3..5811381 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c @@ -71,6 +71,10 @@ main (int argc, char **argv) float la1, la5, la15; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage ("failed processing arguments\n"); diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c index 849e636..5d429d7 100644 --- a/plugins/check_mrtg.c +++ b/plugins/check_mrtg.c @@ -53,6 +53,10 @@ main (int argc, char **argv) unsigned long maximum_value_rate = 0L; unsigned long value_rate = 0L; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) != OK) usage (_("Invalid command arguments supplied\n")); diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index a7afa52..d62bfc8 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c @@ -43,6 +43,10 @@ main (int argc, char **argv) MYSQL mysql; char *result = NULL; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) != OK) usage (_("Invalid command arguments supplied\n")); diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index 5b21ba1..27bb010 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c @@ -56,6 +56,10 @@ main (int argc, char **argv) char *procargs; int pos, cols; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage (_("Could not parse arguments\n")); diff --git a/plugins/check_nt.c b/plugins/check_nt.c index 3b2bd5e..c0d6c4e 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c @@ -96,6 +96,10 @@ int main(int argc, char **argv){ int uphours=0; int upminutes=0; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if(process_arguments(argc,argv)==ERROR) usage(_("Could not parse arguments\n")); diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c index 92a1f11..4ceb58f 100644 --- a/plugins/check_nwstat.c +++ b/plugins/check_nwstat.c @@ -117,6 +117,10 @@ main(int argc, char **argv) { unsigned long sap_entries=0; char uptime[MAX_INPUT_BUFFER]; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments(argc,argv)==ERROR) usage(_("Could not parse arguments\n")); diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c index 67fb5d1..581db50 100644 --- a/plugins/check_overcr.c +++ b/plugins/check_overcr.c @@ -79,6 +79,10 @@ main (int argc, char **argv) int uptime_hours = 0; int uptime_minutes = 0; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage ("Could not parse arguments\n"); diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index 6cd217e..16b9a96 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c @@ -128,6 +128,10 @@ main (int argc, char **argv) pgoptions = NULL; /* special options to start up the backend server */ pgtty = NULL; /* debugging tty for the backend server */ + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage ("Could not parse arguments"); diff --git a/plugins/check_ping.c b/plugins/check_ping.c index 7d9dd3b..191fbed 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c @@ -70,6 +70,10 @@ main (int argc, char **argv) int this_result = STATE_UNKNOWN; int i; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + addresses = malloc ((size_t)max_addr); if (process_arguments (argc, argv) == ERROR) diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 5313b97..8a3f7ac 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c @@ -103,6 +103,10 @@ main (int argc, char **argv) int result = STATE_UNKNOWN; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + asprintf (&metric_name, "PROCS"); metric = METRIC_PROCS; diff --git a/plugins/check_radius.c b/plugins/check_radius.c index 1e4fff7..d56222f 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c @@ -103,6 +103,10 @@ main (int argc, char **argv) UINT4 client_id; char *str; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage (_("Could not parse arguments\n")); diff --git a/plugins/check_real.c b/plugins/check_real.c index 3e8475a..05e39d7 100644 --- a/plugins/check_real.c +++ b/plugins/check_real.c @@ -61,6 +61,10 @@ main (int argc, char **argv) char buffer[MAX_INPUT_BUFFER]; char *status_line = NULL; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) != OK) usage (_("Invalid command arguments supplied\n")); diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index b35ebbc..8440aab 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -66,6 +66,10 @@ main (int argc, char **argv) char *helocmd = NULL; struct timeval tv; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) != OK) usage (_("Invalid command arguments supplied\n")); diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index af8f119..cb985ca 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -137,6 +137,10 @@ main (int argc, char **argv) char *p2 = NULL; char *show = NULL; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + labels = malloc (labels_size); unitv = malloc (unitv_size); for (i = 0; i < MAX_OIDS; i++) @@ -443,7 +447,8 @@ process_arguments (int argc, char **argv) case 't': /* timeout period */ if (!is_integer (optarg)) usage2 (_("Timeout Interval must be an integer"), optarg); - timeout_interval = atoi (optarg); + else + timeout_interval = atoi (optarg); break; /* Test parameters */ diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c index 26709a7..79e1701 100644 --- a/plugins/check_ssh.c +++ b/plugins/check_ssh.c @@ -48,6 +48,10 @@ main (int argc, char **argv) { int result; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage (_("Could not parse arguments\n")); diff --git a/plugins/check_swap.c b/plugins/check_swap.c index a4e7e81..3bbea77 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -71,6 +71,10 @@ main (int argc, char **argv) char str[32]; char *status; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + status = strdup(""); if (process_arguments (argc, argv) != OK) @@ -205,8 +209,6 @@ int process_arguments (int argc, char **argv) { int c = 0; /* option character */ - int wc = 0; /* warning counter */ - int cc = 0; /* critical counter */ int option = 0; static struct option longopts[] = { @@ -229,7 +231,7 @@ process_arguments (int argc, char **argv) break; switch (c) { - case 'w': /* warning time threshold */ + case 'w': /* warning size threshold */ if (is_intnonneg (optarg)) { warn_size = atoi (optarg); break; @@ -246,7 +248,7 @@ process_arguments (int argc, char **argv) else { usage (_("Warning threshold must be integer or percentage!\n")); } - case 'c': /* critical time threshold */ + case 'c': /* critical size threshold */ if (is_intnonneg (optarg)) { crit_size = atoi (optarg); break; diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index bf8ed8c..a660649 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -16,8 +16,8 @@ *****************************************************************************/ -/* progname changes depending on symlink called */ -char *progname = "check_tcp"; +/* progname "check_tcp" changes depending on symlink called */ +char *progname; const char *revision = "$Revision$"; const char *copyright = "1999-2003"; const char *email = "nagiosplug-devel@lists.sourceforge.net"; @@ -198,6 +198,7 @@ main (int argc, char **argv) PORT = 119; } else { + progname = strdup ("check_tcp"); usage (_("ERROR: Generic check_tcp called with unknown service\n")); } @@ -592,6 +593,7 @@ print_help (void) { print_revision (progname, revision); + printf (_("Copyright (c) 1999 Ethan Galstad \n")); printf (_(COPYRIGHT), copyright, email); printf (_("This plugin tests %s connections with the specified host.\n\n"), diff --git a/plugins/check_time.c b/plugins/check_time.c index e6c3c71..f73005d 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c @@ -55,6 +55,10 @@ main (int argc, char **argv) int sd; int result; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) != OK) usage (_("Invalid command arguments supplied\n")); diff --git a/plugins/check_udp.c b/plugins/check_udp.c index 5aaf3a7..c4fbbf8 100644 --- a/plugins/check_udp.c +++ b/plugins/check_udp.c @@ -45,6 +45,10 @@ main (int argc, char **argv) int result; char recv_buffer[MAX_INPUT_BUFFER]; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage ("\n"); diff --git a/plugins/check_ups.c b/plugins/check_ups.c index 7e7b36a..391c1db 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c @@ -79,8 +79,12 @@ main (int argc, char **argv) int result = STATE_OK; char *message; char temp_buffer[MAX_INPUT_BUFFER]; - double ups_utility_deviation = 0.0; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + ups_status = strdup ("N/A"); if (process_arguments (argc, argv) != OK) diff --git a/plugins/check_users.c b/plugins/check_users.c index 9f308bc..3705ee1 100644 --- a/plugins/check_users.c +++ b/plugins/check_users.c @@ -41,6 +41,10 @@ main (int argc, char **argv) int result = STATE_OK; char input_buffer[MAX_INPUT_BUFFER]; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + if (process_arguments (argc, argv) == ERROR) usage (_("Could not parse arguments\n")); diff --git a/plugins/negate.c b/plugins/negate.c index c24658a..874aea1 100644 --- a/plugins/negate.c +++ b/plugins/negate.c @@ -75,6 +75,10 @@ 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")); diff --git a/plugins/urlize.c b/plugins/urlize.c index f4bc67b..45766d0 100644 --- a/plugins/urlize.c +++ b/plugins/urlize.c @@ -45,6 +45,10 @@ main (int argc, char **argv) {0, 0, 0, 0} }; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + while (1) { c = getopt_long (argc, argv, "+hVu:", longopts, &option); -- cgit v0.10-9-g596f