summaryrefslogtreecommitdiffstats
path: root/src/libs/zbxcommon
diff options
context:
space:
mode:
authoralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-08 23:26:20 +0000
committeralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-08 23:26:20 +0000
commitd3fe02b7bbe894a89726f107fd8a593decae5027 (patch)
tree206fa89d7fcf8edfd5e24e5af6fdb7622e8300e0 /src/libs/zbxcommon
parent3aeadf322092f6e3bd0257c601114274760d3540 (diff)
downloadzabbix-d3fe02b7bbe894a89726f107fd8a593decae5027.tar.gz
zabbix-d3fe02b7bbe894a89726f107fd8a593decae5027.tar.xz
zabbix-d3fe02b7bbe894a89726f107fd8a593decae5027.zip
- [DEV-114] special processing of simple SNMP OIDs like ifDescr, ifInOctets, etc (Alexei)
- [DEV-114] monitoring of SNMP objects having flexible Index (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@5337 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxcommon')
-rw-r--r--src/libs/zbxcommon/str.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/libs/zbxcommon/str.c b/src/libs/zbxcommon/str.c
index 55f4bb2f..e802c4e7 100644
--- a/src/libs/zbxcommon/str.c
+++ b/src/libs/zbxcommon/str.c
@@ -1466,3 +1466,101 @@ int str_in_list(char *list, const char *value, const char delimiter)
}
return ret;
}
+
+/******************************************************************************
+ * *
+ * Function: get_key_param *
+ * *
+ * Purpose: return parameter by index (num) from parameter list (param) *
+ * to be used for keys: key[param1,param2] *
+ * *
+ * Parameters: *
+ * param - parameter list *
+ * num - requested parameter index *
+ * buf - pointer of output buffer *
+ * maxlem - size of output buffer *
+ * *
+ * Return value: *
+ * 1 - requested parameter missed *
+ * 0 - requested parameter found (value - 'buf' can be empty string) *
+ * *
+ * Author: Alexei Vladishev *
+ * *
+ * Comments: delimeter for parameters is ',' *
+ * *
+ ******************************************************************************/
+int get_key_param(char *param, int num, char *buf, int maxlen)
+{
+ int ret = 0;
+
+ char *pl, *pr;
+
+ pl = strchr(param, '[');
+ pr = strrchr(param, ']');
+
+ if(pl > pr)
+ return 1;
+
+ if(!pl || !pr || (pl && !pr) || (!pl && pr))
+ return 1;
+
+ if(pr != NULL)
+ pr[0] = 0;
+
+ ret = get_param(pl+1, num, buf, maxlen);
+
+ if(pr != NULL)
+ pr[0]=']';
+
+ return ret;
+}
+
+/******************************************************************************
+ * *
+ * Function: num_key_param *
+ * *
+ * Purpose: calculate count of parameters from parameter list (param) *
+ * to be used for keys: key[param1,param2] *
+ * *
+ * Parameters: *
+ * param - parameter list *
+ * *
+ * Return value: count of parameters *
+ * *
+ * Author: Alexei Vladishev *
+ * *
+ * Comments: delimeter vor parameters is ',' *
+ * *
+ ******************************************************************************/
+int num_key_param(char *param)
+{
+ int ret = 1;
+
+ char *pl, *pr;
+
+ if(param == NULL)
+ return 0;
+
+ pl = strchr(param, '[');
+ pr = strrchr(param, ']');
+
+ if(pl > pr)
+ return 0;
+
+ if(!pl || !pr || (pl && !pr) || (!pl && pr))
+ return 0;
+
+ if(pl != NULL)
+ pl[0] = 0;
+ if(pr != NULL)
+ pr[0] = 0;
+
+ ret = num_param(pl+1);
+
+ if(pl != NULL)
+ pl[0]='[';
+ if(pr != NULL)
+ pr[0]=']';
+
+ return ret;
+}