MINOR: samples: rename some struct member from "smp" to "data"
This members contains data and not sample.
diff --git a/include/proto/map.h b/include/proto/map.h
index 21ff57c..a63bc85 100644
--- a/include/proto/map.h
+++ b/include/proto/map.h
@@ -25,10 +25,10 @@
#include <types/map.h>
/* maps output sample parser */
-int map_parse_ip(const char *text, struct sample_data *smp);
-int map_parse_ip6(const char *text, struct sample_data *smp);
-int map_parse_str(const char *text, struct sample_data *smp);
-int map_parse_int(const char *text, struct sample_data *smp);
+int map_parse_ip(const char *text, struct sample_data *data);
+int map_parse_ip6(const char *text, struct sample_data *data);
+int map_parse_str(const char *text, struct sample_data *data);
+int map_parse_int(const char *text, struct sample_data *data);
struct map_reference *map_get_reference(const char *reference);
diff --git a/include/types/pattern.h b/include/types/pattern.h
index 86d4bc8..a71c343 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -129,7 +129,7 @@
* "sample" with a tree entry. It is used with maps.
*/
struct pattern_tree {
- struct sample_data *smp;
+ struct sample_data *data;
struct pat_ref_elt *ref;
struct ebmb_node node;
};
@@ -168,7 +168,7 @@
} ptr; /* indirect values, allocated */
int len; /* data length when required */
int sflags; /* flags relative to the storage method. */
- struct sample_data *smp; /* used to store a pointer to sample value associated
+ struct sample_data *data; /* used to store a pointer to sample value associated
with the match. It is used with maps */
struct pat_ref_elt *ref;
};
@@ -212,7 +212,7 @@
/* This struct contain a list of pattern expr */
struct pattern_head {
int (*parse)(const char *text, struct pattern *pattern, int flags, char **err);
- int (*parse_smp)(const char *text, struct sample_data *smp);
+ int (*parse_smp)(const char *text, struct sample_data *data);
int (*index)(struct pattern_expr *, struct pattern *, char **);
void (*delete)(struct pattern_expr *, struct pat_ref_elt *);
void (*prune)(struct pattern_expr *);
diff --git a/src/dumpstats.c b/src/dumpstats.c
index b97318b..ea53d25 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -5696,7 +5696,7 @@
/* display return value */
if (appctx->ctx.map.display_flags == PAT_REF_MAP) {
- if (pat->smp && pat->ref && pat->ref->sample)
+ if (pat->data && pat->ref && pat->ref->sample)
chunk_appendf(&trash, ", value=\"%s\", type=\"%s\"", pat->ref->sample,
smp_to_type[appctx->ctx.map.desc->conv->out_type]);
else
diff --git a/src/hlua.c b/src/hlua.c
index ac9e631..d3c968d 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -1379,7 +1379,7 @@
}
pat = pattern_exec_match(&desc->pat, &smp, 1);
- if (!pat || !pat->smp) {
+ if (!pat || !pat->data) {
if (str)
lua_pushstring(L, "");
else
@@ -1388,7 +1388,7 @@
}
/* The Lua pattern must return a string, so we can't check the returned type */
- lua_pushlstring(L, pat->smp->data.str.str, pat->smp->data.str.len);
+ lua_pushlstring(L, pat->data->data.str.str, pat->data->data.str.len);
return 1;
}
diff --git a/src/map.c b/src/map.c
index cd5a519..a03853d 100644
--- a/src/map.c
+++ b/src/map.c
@@ -27,22 +27,22 @@
/* 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;
}
@@ -52,12 +52,12 @@
* 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;
}
@@ -65,10 +65,10 @@
* 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;
@@ -160,10 +160,10 @@
/* 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;
}
diff --git a/src/pattern.c b/src/pattern.c
index 9f34f73..297f45f 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -427,7 +427,7 @@
{
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;
@@ -464,7 +464,7 @@
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;
@@ -598,7 +598,7 @@
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;
@@ -874,7 +874,7 @@
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;
@@ -896,7 +896,7 @@
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;
@@ -916,7 +916,7 @@
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;
@@ -950,7 +950,7 @@
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;
@@ -1009,7 +1009,7 @@
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;
}
@@ -1020,7 +1020,7 @@
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);
}
@@ -1035,7 +1035,7 @@
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);
}
@@ -1050,7 +1050,7 @@
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);
}
@@ -1207,7 +1207,7 @@
}
/* 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 */
@@ -1235,7 +1235,7 @@
}
/* 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 */
@@ -1280,7 +1280,7 @@
}
/* copy the pointer to sample associated to this node */
- node->smp = pat->smp;
+ node->data = pat->data;
node->ref = pat->ref;
/* copy the string */
@@ -1321,7 +1321,7 @@
}
/* 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 */
@@ -1348,7 +1348,7 @@
/* Delete and free entry. */
LIST_DEL(&pat->list);
- free(pat->pat.smp);
+ free(pat->pat.data);
free(pat);
}
expr->revision = rdtsc();
@@ -1372,7 +1372,7 @@
/* Delete and free entry. */
ebmb_delete(node);
- free(elt->smp);
+ free(elt->data);
free(elt);
}
@@ -1392,7 +1392,7 @@
/* Delete and free entry. */
ebmb_delete(node);
- free(elt->smp);
+ free(elt->data);
free(elt);
}
expr->revision = rdtsc();
@@ -1411,7 +1411,7 @@
/* 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();
@@ -1439,7 +1439,7 @@
/* Delete and free entry. */
ebmb_delete(node);
- free(elt->smp);
+ free(elt->data);
free(elt);
}
expr->revision = rdtsc();
@@ -1458,7 +1458,7 @@
/* 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();
@@ -1606,7 +1606,7 @@
const char *value, char **err)
{
struct pattern_expr *expr;
- struct sample_data **smp;
+ struct sample_data **data;
char *sample;
struct sample_data test;
@@ -1637,9 +1637,9 @@
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;
@@ -1823,41 +1823,41 @@
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;
}
@@ -2334,7 +2334,7 @@
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;
@@ -2387,7 +2387,7 @@
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);
@@ -2395,12 +2395,12 @@
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;
}