/* Parse an IPv4 address and store it into the sample.
* The output type is IPV4.
*/
-int map_parse_ip(const char *text, struct sample_data *smp)
+int map_parse_ip(const char *text, struct sample_data *data)
{
- if (!buf2ip(text, strlen(text), &smp->data.ipv4))
+ if (!buf2ip(text, strlen(text), &data->data.ipv4))
return 0;
- smp->type = SMP_T_IPV4;
+ data->type = SMP_T_IPV4;
return 1;
}
/* Parse an IPv6 address and store it into the sample.
* The output type is IPV6.
*/
-int map_parse_ip6(const char *text, struct sample_data *smp)
+int map_parse_ip6(const char *text, struct sample_data *data)
{
- if (!buf2ip6(text, strlen(text), &smp->data.ipv6))
+ if (!buf2ip6(text, strlen(text), &data->data.ipv6))
return 0;
- smp->type = SMP_T_IPV6;
+ data->type = SMP_T_IPV6;
return 1;
}
* overwritten because sample_conv_map() makes a const sample with this
* output.
*/
-int map_parse_str(const char *text, struct sample_data *smp)
+int map_parse_str(const char *text, struct sample_data *data)
{
- smp->data.str.str = (char *)text;
- smp->data.str.len = strlen(text);
- smp->data.str.size = smp->data.str.len + 1;
- smp->type = SMP_T_STR;
+ data->data.str.str = (char *)text;
+ data->data.str.len = strlen(text);
+ data->data.str.size = data->data.str.len + 1;
+ data->type = SMP_T_STR;
return 1;
}
* number is negative, or UINT if it is positive or null. The function returns
* zero (error) if the number is too large.
*/
-int map_parse_int(const char *text, struct sample_data *smp)
+int map_parse_int(const char *text, struct sample_data *data)
{
- smp->type = SMP_T_SINT;
- smp->data.sint = read_int64(&text, text + strlen(text));
+ data->type = SMP_T_SINT;
+ data->data.sint = read_int64(&text, text + strlen(text));
if (*text != '\0')
return 0;
return 1;
/* Match case. */
if (pat) {
/* Copy sample. */
- if (pat->smp) {
- smp->type = pat->smp->type;
+ if (pat->data) {
+ smp->type = pat->data->type;
smp->flags |= SMP_F_CONST;
- memcpy(&smp->data, &pat->smp->data, sizeof(smp->data));
+ memcpy(&smp->data, &pat->data->data, sizeof(smp->data));
return 1;
}
{
if (smp->data.sint) {
if (fill) {
- static_pattern.smp = NULL;
+ static_pattern.data = NULL;
static_pattern.ref = NULL;
static_pattern.type = 0;
static_pattern.ptr.str = NULL;
if (node) {
if (fill) {
elt = ebmb_entry(node, struct pattern_tree, node);
- static_pattern.smp = elt->smp;
+ static_pattern.data = elt->data;
static_pattern.ref = elt->ref;
static_pattern.sflags = PAT_SF_TREE;
static_pattern.type = SMP_T_STR;
if (node) {
if (fill) {
elt = ebmb_entry(node, struct pattern_tree, node);
- static_pattern.smp = elt->smp;
+ static_pattern.data = elt->data;
static_pattern.ref = elt->ref;
static_pattern.sflags = PAT_SF_TREE;
static_pattern.type = SMP_T_STR;
if (node) {
if (fill) {
elt = ebmb_entry(node, struct pattern_tree, node);
- static_pattern.smp = elt->smp;
+ static_pattern.data = elt->data;
static_pattern.ref = elt->ref;
static_pattern.sflags = PAT_SF_TREE;
static_pattern.type = SMP_T_IPV4;
if (node) {
if (fill) {
elt = ebmb_entry(node, struct pattern_tree, node);
- static_pattern.smp = elt->smp;
+ static_pattern.data = elt->data;
static_pattern.ref = elt->ref;
static_pattern.sflags = PAT_SF_TREE;
static_pattern.type = SMP_T_IPV6;
if (node) {
if (fill) {
elt = ebmb_entry(node, struct pattern_tree, node);
- static_pattern.smp = elt->smp;
+ static_pattern.data = elt->data;
static_pattern.ref = elt->ref;
static_pattern.sflags = PAT_SF_TREE;
static_pattern.type = SMP_T_IPV6;
if (node) {
if (fill) {
elt = ebmb_entry(node, struct pattern_tree, node);
- static_pattern.smp = elt->smp;
+ static_pattern.data = elt->data;
static_pattern.ref = elt->ref;
static_pattern.sflags = PAT_SF_TREE;
static_pattern.type = SMP_T_IPV4;
next = eb_next(node);
eb_delete(node);
elt = container_of(node, struct pattern_tree, node);
- free(elt->smp);
+ free(elt->data);
free(elt);
node = next;
}
struct pattern_list *pat, *tmp;
list_for_each_entry_safe(pat, tmp, &expr->patterns, list) {
- free(pat->pat.smp);
+ free(pat->pat.data);
free(pat);
}
list_for_each_entry_safe(pat, tmp, &expr->patterns, list) {
free(pat->pat.ptr.ptr);
- free(pat->pat.smp);
+ free(pat->pat.data);
free(pat);
}
list_for_each_entry_safe(pat, tmp, &expr->patterns, list) {
regex_free(pat->pat.ptr.ptr);
- free(pat->pat.smp);
+ free(pat->pat.data);
free(pat);
}
}
/* copy the pointer to sample associated to this node */
- node->smp = pat->smp;
+ node->data = pat->data;
node->ref = pat->ref;
/* FIXME: insert <addr>/<mask> into the tree here */
}
/* copy the pointer to sample associated to this node */
- node->smp = pat->smp;
+ node->data = pat->data;
node->ref = pat->ref;
/* FIXME: insert <addr>/<mask> into the tree here */
}
/* copy the pointer to sample associated to this node */
- node->smp = pat->smp;
+ node->data = pat->data;
node->ref = pat->ref;
/* copy the string */
}
/* copy the pointer to sample associated to this node */
- node->smp = pat->smp;
+ node->data = pat->data;
node->ref = pat->ref;
/* copy the string and the trailing zero */
/* Delete and free entry. */
LIST_DEL(&pat->list);
- free(pat->pat.smp);
+ free(pat->pat.data);
free(pat);
}
expr->revision = rdtsc();
/* Delete and free entry. */
ebmb_delete(node);
- free(elt->smp);
+ free(elt->data);
free(elt);
}
/* Delete and free entry. */
ebmb_delete(node);
- free(elt->smp);
+ free(elt->data);
free(elt);
}
expr->revision = rdtsc();
/* Delete and free entry. */
LIST_DEL(&pat->list);
free(pat->pat.ptr.ptr);
- free(pat->pat.smp);
+ free(pat->pat.data);
free(pat);
}
expr->revision = rdtsc();
/* Delete and free entry. */
ebmb_delete(node);
- free(elt->smp);
+ free(elt->data);
free(elt);
}
expr->revision = rdtsc();
/* Delete and free entry. */
LIST_DEL(&pat->list);
regex_free(pat->pat.ptr.ptr);
- free(pat->pat.smp);
+ free(pat->pat.data);
free(pat);
}
expr->revision = rdtsc();
const char *value, char **err)
{
struct pattern_expr *expr;
- struct sample_data **smp;
+ struct sample_data **data;
char *sample;
struct sample_data test;
if (!expr->pat_head->parse_smp)
continue;
- smp = pattern_find_smp(expr, elt);
- if (smp && *smp && !expr->pat_head->parse_smp(sample, *smp))
- *smp = NULL;
+ data = pattern_find_smp(expr, elt);
+ if (data && *data && !expr->pat_head->parse_smp(sample, *data))
+ *data = NULL;
}
return 1;
int pat_ref_push(struct pat_ref_elt *elt, struct pattern_expr *expr,
int patflags, char **err)
{
- struct sample_data *smp;
+ struct sample_data *data;
struct pattern pattern;
/* Create sample */
if (elt->sample && expr->pat_head->parse_smp) {
/* New sample. */
- smp = malloc(sizeof(*smp));
- if (!smp)
+ data = malloc(sizeof(*data));
+ if (!data)
return 0;
/* Parse value. */
- if (!expr->pat_head->parse_smp(elt->sample, smp)) {
+ if (!expr->pat_head->parse_smp(elt->sample, data)) {
memprintf(err, "unable to parse '%s'", elt->sample);
- free(smp);
+ free(data);
return 0;
}
}
else
- smp = NULL;
+ data = NULL;
/* initialise pattern */
memset(&pattern, 0, sizeof(pattern));
- pattern.smp = smp;
+ pattern.data = data;
pattern.ref = elt;
/* parse pattern */
if (!expr->pat_head->parse(elt->pattern, &pattern, expr->mflags, err)) {
- free(smp);
+ free(data);
return 0;
}
/* index pattern */
if (!expr->pat_head->index(expr, &pattern, err)) {
- free(smp);
+ free(data);
return 0;
}
if (!head->match) {
if (fill) {
- static_pattern.smp = NULL;
+ static_pattern.data = NULL;
static_pattern.ref = NULL;
static_pattern.sflags = 0;
static_pattern.type = SMP_T_SINT;
node = ebmb_next(node)) {
elt = container_of(node, struct pattern_tree, node);
if (elt->ref == ref)
- return &elt->smp;
+ return &elt->data;
}
for (node = ebmb_first(&expr->pattern_tree_2);
node = ebmb_next(node)) {
elt = container_of(node, struct pattern_tree, node);
if (elt->ref == ref)
- return &elt->smp;
+ return &elt->data;
}
list_for_each_entry(pat, &expr->patterns, list)
if (pat->pat.ref == ref)
- return &pat->pat.smp;
+ return &pat->pat.data;
return NULL;
}