+
+ /* Value format is (counter:id:incr)?(postfix:reply|filter_name)
+ */
+ if (strncmp(value, "counter:", 8) == 0) {
+ char *end = NULL;
+ value += 8;
+ hook.counter = strtol(value, &end, 10);
+ if (end == value || *end != ':') {
+ err("hook %s, cannot read counter id", htokens[hook.type]);
+ return false;
+ } else if (hook.counter < 0 || hook.counter >= MAX_COUNTERS) {
+ err("hook %s, invalid counter id %d", htokens[hook.type], hook.counter);
+ return false;
+ }
+ value = end + 1;
+ hook.cost = strtol(value, &end, 10);
+ if (end == value || *end != ':') {
+ err("hook %s, cannot read counter increment", htokens[hook.type]);
+ return false;
+ } else if (hook.cost < 0) {
+ err("hook %s, invalid counter increment value %d", htokens[hook.type],
+ hook.cost);
+ return false;
+ }
+ value = end + 1;
+ } else {
+ hook.counter = -1;
+ hook.cost = 0;
+ }