summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 45b8e69)
raw | patch | inline | side by side (parent: 45b8e69)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 8 Aug 2003 16:49:32 +0000 (16:49 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 8 Aug 2003 16:49:32 +0000 (16:49 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@666 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_disk.c | patch | blob | history | |
plugins/netutils.c | patch | blob | history | |
plugins/netutils.h | patch | blob | history |
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index f6966721dee309835d0eedf2fa40b4e8ef74fb26..bd060218a8aba6504220faeca8252b17a068c357 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
struct name_list **fstail = &fs_exclude_list;
struct name_list **dptail = &dp_exclude_list;
struct name_list *temp_list;
- unsigned long l;
int result = OK;
+ unsigned long l;
+
int option_index = 0;
static struct option long_options[] = {
{"timeout", required_argument, 0, 't'},
usage (_("Critical threshold must be integer or percentage!\n"));
}
case 'u':
+ if (units)
+ free(units);
if (! strcmp (optarg, "bytes")) {
mult = (uintmax_t)1;
units = strdup ("B");
} else {
die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
}
+ if (units == NULL)
+ die (STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units");
break;
case 'k': /* display mountpoint */
mult = 1024;
+ if (units)
+ free(units);
units = strdup ("kB");
break;
case 'm': /* display mountpoint */
mult = 1024 * 1024;
+ if (units)
+ free(units);
units = strdup ("kB");
break;
case 'l':
@@ -475,8 +484,10 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
return ERROR;
}
- if (units == NULL)
+ if (units == NULL) {
units = strdup ("MB");
+ mult = (uintmax_t)1024 * 1024;
+ }
return OK;
}
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 92fd14208c7a32b8f031cc03de5014cd7dbb8669..58b3fb485456593ebb9794e625e11f650047a45f 100644 (file)
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
/* connects to a host on a specified TCP port, sends a string,
and gets a response */
int
-process_tcp_request (char *server_address, int server_port,
- char *send_buffer, char *recv_buffer, int recv_size)
+process_tcp_request (const char *server_address, int server_port,
+ const char *send_buffer, char *recv_buffer, int recv_size)
{
int result;
/* connects to a host on a specified UDP port, sends a string, and gets a
response */
int
-process_udp_request (char *server_address, int server_port,
- char *send_buffer, char *recv_buffer, int recv_size)
+process_udp_request (const char *server_address, int server_port,
+ const char *send_buffer, char *recv_buffer, int recv_size)
{
int result;
response. loops on select-recv until timeout or eof to get all of a
multi-packet answer */
int
-process_tcp_request2 (char *server_address, int server_port,
- char *send_buffer, char *recv_buffer, int recv_size)
+process_tcp_request2 (const char *server_address, int server_port,
+ const char *send_buffer, char *recv_buffer, int recv_size)
{
int result;
/* connects to a host on a specified port, sends a string, and gets a
response */
int
-process_request (char *server_address, int server_port, int proto,
- char *send_buffer, char *recv_buffer, int recv_size)
+process_request (const char *server_address, int server_port, int proto,
+ const char *send_buffer, char *recv_buffer, int recv_size)
{
int result;
int send_result;
/* opens a connection to a remote host/tcp port */
int
-my_tcp_connect (char *host_name, int port, int *sd)
+my_tcp_connect (const char *host_name, int port, int *sd)
{
int result;
/* opens a connection to a remote host/udp port */
int
-my_udp_connect (char *host_name, int port, int *sd)
+my_udp_connect (const char *host_name, int port, int *sd)
{
int result;
/* opens a tcp or udp connection to a remote host */
int
-my_connect (char *host_name, int port, int *sd, int proto)
+my_connect (const char *host_name, int port, int *sd, int proto)
{
struct addrinfo hints;
struct addrinfo *res;
}
int
-is_host (char *address)
+is_host (const char *address)
{
if (is_addr (address) || is_hostname (address))
return (TRUE);
}
int
-is_addr (char *address)
+is_addr (const char *address)
{
#ifdef USE_IPV6
if (is_inet_addr (address) && address_family != AF_INET6)
}
int
-resolve_host_or_addr (char *address, int family)
+resolve_host_or_addr (const char *address, int family)
{
struct addrinfo hints;
struct addrinfo *res;
}
int
-is_inet_addr (char *address)
+is_inet_addr (const char *address)
{
return resolve_host_or_addr (address, AF_INET);
}
#ifdef USE_IPV6
int
-is_inet6_addr (char *address)
+is_inet6_addr (const char *address)
{
return resolve_host_or_addr (address, AF_INET6);
}
#endif
int
-is_hostname (char *s1)
+is_hostname (const char *s1)
{
#ifdef USE_IPV6
return resolve_host_or_addr (s1, address_family);
diff --git a/plugins/netutils.h b/plugins/netutils.h
index f5df7af6d45d470614e02111e2238dc187cfe745..c560f4492bdf62404840a1025dab592bee7d618d 100644 (file)
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn));
-int process_tcp_request2 (char *address, int port, char *sbuffer,
- char *rbuffer, int rsize);
-int process_tcp_request (char *address, int port, char *sbuffer,
- char *rbuffer, int rsize);
-int process_udp_request (char *address, int port, char *sbuffer,
- char *rbuffer, int rsize);
-int process_request (char *address, int port, int proto, char *sbuffer,
- char *rbuffer, int rsize);
+int process_tcp_request2 (const char *address, int port,
+ const char *sbuffer, char *rbuffer, int rsize);
+int process_tcp_request (const char *address, int port,
+ const char *sbuffer, char *rbuffer, int rsize);
+int process_udp_request (const char *address, int port,
+ const char *sbuffer, char *rbuffer, int rsize);
+int process_request (const char *address, int port, int proto,
+ const char *sbuffer, char *rbuffer, int rsize);
-int my_tcp_connect (char *address, int port, int *sd);
-int my_udp_connect (char *address, int port, int *sd);
-int my_connect (char *address, int port, int *sd, int proto);
+int my_tcp_connect (const char *address, int port, int *sd);
+int my_udp_connect (const char *address, int port, int *sd);
+int my_connect (const char *address, int port, int *sd, int proto);
-int is_host (char *);
-int is_addr (char *);
-int resolve_host_or_addr (char *, int);
-int is_inet_addr (char *);
+int is_host (const char *);
+int is_addr (const char *);
+int resolve_host_or_addr (const char *, int);
+int is_inet_addr (const char *);
#ifdef USE_IPV6
-int is_inet6_addr (char *);
+int is_inet6_addr (const char *);
#endif
-int is_hostname (char *);
+int is_hostname (const char *);
extern unsigned int socket_timeout;
extern int econn_refuse_state;