summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6f1fc7e)
raw | patch | inline | side by side (parent: 6f1fc7e)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 3 Jan 2003 03:24:17 +0000 (03:24 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 3 Jan 2003 03:24:17 +0000 (03:24 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@234 f882894a-f735-0410-b71e-b25c423dba1c
plugins/utils.c | patch | blob | history |
diff --git a/plugins/utils.c b/plugins/utils.c
index da9cceddd7fa8a95287124f76c7c348ecec3c36c..22020d72eb16c5958908e9fc885cf68be05d0e1b 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
int o1, o2, o3, o4;
char c[1];
+ if (!address)
+ return FALSE;
+
if (sscanf (address, "%d.%d.%d.%d%c", &o1, &o2, &o3, &o4, c) != 4)
return FALSE;
else if (o1 > 255 || o2 > 255 || o3 > 255 || o4 > 255)
int
is_hostname (char *s1)
{
- if (strlen (s1) > 63)
+ if (!s1 || strlen (s1) > 63) {
+ return FALSE;
+ }
+ if (strcspn (s1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789-.") != 0) {
return FALSE;
- if (strcspn
- (s1,
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789-.") !=
- 0) return FALSE;
- if (strspn (s1, "0123456789-.") == 1)
+ }
+ if (strspn (s1, "0123456789-.") == 1) {
return FALSE;
+ }
while ((s1 = index (s1, '.'))) {
s1++;
if (strspn (s1, "0123456789-.") == 1) {
- printf ("%s\n", s1);
return FALSE;
}
}
{
char tmp[1];
float x;
- if (sscanf (number, "%f%c", &x, tmp) == 1)
- return (TRUE);
- return (FALSE);
+
+ if (!number)
+ return FALSE;
+ else if (sscanf (number, "%f%c", &x, tmp) == 1)
+ return TRUE;
+ else
+ return FALSE;
}
int
is_positive (char *number)
{
if (is_numeric (number) && atof (number) > 0.0)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ else
+ return FALSE;
}
int
is_negative (char *number)
{
if (is_numeric (number) && atof (number) < 0.0)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ else
+ return FALSE;
}
int
is_nonnegative (char *number)
{
if (is_numeric (number) && atof (number) >= 0.0)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ else
+ return FALSE;
}
int
{
int x;
if (is_numeric (number) && (x = atof (number)) >= 0 && x <= 100)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ else
+ return FALSE;
}
int
{
long int n;
- if (strspn (number, "-0123456789 ") != strlen (number))
- return (FALSE);
+ if (!number || (strspn (number, "-0123456789 ") != strlen (number)))
+ return FALSE;
n = strtol (number, NULL, 10);
+
if (errno != ERANGE && n >= INT_MIN && n <= INT_MAX)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ else
+ return FALSE;
}
int
is_intpos (char *number)
{
if (is_integer (number) && atoi (number) > 0)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ else
+ return FALSE;
}
int
is_intneg (char *number)
{
if (is_integer (number) && atoi (number) < 0)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ else
+ return FALSE;
}
int
is_intnonneg (char *number)
{
if (is_integer (number) && atoi (number) >= 0)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ else
+ return FALSE;
}
int
{
int i;
if (is_integer (number) && (i = atoi (number)) >= 0 && i <= 100)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ else
+ return FALSE;
}
int
is_option (char *str)
{
- if (strspn (str, "-") == 1 || strspn (str, "-") == 2)
+ if (!str)
+ return FALSE;
+ else if (strspn (str, "-") == 1 || strspn (str, "-") == 2)
return TRUE;
- return FALSE;
+ else
+ return FALSE;
}