Commit 831ca47f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add numeric comparisons for HTTP headers: -lt, -le, -eq, -ne, -ge, -gt

	expect	resp.http.content-length -le 1024
parent 5c1d0826
......@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
......@@ -109,6 +110,18 @@ vtc_expect(struct vtclog *vl,
retval = strcmp(lhs, rhs) == 0;
} else if (!strcmp(cmp, "!=")) {
retval = strcmp(lhs, rhs) != 0;
} else if (!strcmp(cmp, "-lt")) {
retval = strtoul(lhs, NULL, 0) < strtoul(rhs, NULL, 0);
} else if (!strcmp(cmp, "-le")) {
retval = strtoul(lhs, NULL, 0) <= strtoul(rhs, NULL, 0);
} else if (!strcmp(cmp, "-eq")) {
retval = strtoul(lhs, NULL, 0) == strtoul(rhs, NULL, 0);
} else if (!strcmp(cmp, "-ne")) {
retval = strtoul(lhs, NULL, 0) != strtoul(rhs, NULL, 0);
} else if (!strcmp(cmp, "-ge")) {
retval = strtoul(lhs, NULL, 0) >= strtoul(rhs, NULL, 0);
} else if (!strcmp(cmp, "-gt")) {
retval = strtoul(lhs, NULL, 0) > strtoul(rhs, NULL, 0);
} else if (j) {
// fail inequality comparisons if either side is undef'ed
retval = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment