summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authoralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-04-14 09:56:53 +0000
committeralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-04-14 09:56:53 +0000
commit3f4975b42affe14f0951f500835dfd3da69eb5ce (patch)
treeedad167770fab45338c3ca7aaf78f982e5edb223 /src/libs
parent0a80c5c1d8605f34a3512f618328127a46d899db (diff)
downloadzabbix-3f4975b42affe14f0951f500835dfd3da69eb5ce.tar.gz
zabbix-3f4975b42affe14f0951f500835dfd3da69eb5ce.tar.xz
zabbix-3f4975b42affe14f0951f500835dfd3da69eb5ce.zip
Support of IP range if discoveru rule definition.
git-svn-id: svn://svn.zabbix.com/trunk@4005 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/zbxcommon/misc.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/libs/zbxcommon/misc.c b/src/libs/zbxcommon/misc.c
index 6ce99085..5cd23756 100644
--- a/src/libs/zbxcommon/misc.c
+++ b/src/libs/zbxcommon/misc.c
@@ -235,6 +235,61 @@ int calculate_item_nextcheck(zbx_uint64_t itemid, int item_type, int delay, char
/******************************************************************************
* *
+ * Function: int_in_list *
+ * *
+ * Purpose: check if integer matches a list of integers *
+ * *
+ * Parameters: list - integers [i1-i2,i3,i4,i5-i6] (10-25,45,67-699 *
+ * value- value *
+ * *
+ * Return value: FAIL - out of period, SUCCEED - within the period *
+ * *
+ * Author: Alexei Vladishev *
+ * *
+ * Comments: *
+ * *
+ ******************************************************************************/
+int int_in_list(const char *list, int value)
+{
+ char tmp[MAX_STRING_LEN];
+ char *s;
+ int i1,i2;
+ int ret = FAIL;
+
+
+ zabbix_log( LOG_LEVEL_WARNING, "In int_in_list(list:%s,value:%d)", list, value);
+
+ strscpy(tmp,list);
+ s=(char *)strtok(tmp,",");
+ while(s!=NULL)
+ {
+ zabbix_log(LOG_LEVEL_WARNING,"Int [%s]", s);
+ if(sscanf(s,"%d-%d",&i1,&i2) == 2)
+ {
+ if(value>=i1 && value<=i2)
+ {
+ ret = SUCCEED;
+ break;
+ }
+ }
+ else
+ {
+ if(atoi(s) == value)
+ {
+ ret = SUCCEED;
+ break;
+ }
+ }
+ s=(char *)strtok(NULL,",");
+ }
+
+ zabbix_log( LOG_LEVEL_WARNING, "End int_in_list(ret:%s)", ret == SUCCEED?"SUCCEED":"FAIL");
+
+ return ret;
+}
+
+/******************************************************************************
+ * *
* Function: check_time_period *
* *
* Purpose: check if current time is within given period *