MEDIUM: samples: Use the "struct sample_data" in the "struct sample"
This patch remove the struct information stored both in the struct
sample_data and in the striuct sample. Now, only thestruct sample_data
contains data, and the struct sample use the struct sample_data for storing
his own data.
diff --git a/src/payload.c b/src/payload.c
index 32c530c..4c140d0 100644
--- a/src/payload.c
+++ b/src/payload.c
@@ -35,8 +35,8 @@
smp->flags |= SMP_F_MAY_CHANGE;
return 0;
}
- smp->type = SMP_T_BOOL;
- smp->data.sint = 1;
+ smp->data.type = SMP_T_BOOL;
+ smp->data.data.sint = 1;
return 1;
}
@@ -50,8 +50,8 @@
if (!chn->buf)
return 0;
- smp->type = SMP_T_SINT;
- smp->data.sint = chn->buf->i;
+ smp->data.type = SMP_T_SINT;
+ smp->data.data.sint = chn->buf->i;
smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE;
return 1;
}
@@ -159,8 +159,8 @@
/* Elliptic curves extension */
if (ext_type == 10) {
- smp->type = SMP_T_BOOL;
- smp->data.sint = 1;
+ smp->data.type = SMP_T_BOOL;
+ smp->data.data.sint = 1;
smp->flags = SMP_F_VOLATILE;
return 1;
}
@@ -224,8 +224,8 @@
goto not_ssl_hello;
}
- smp->type = SMP_T_SINT;
- smp->data.sint = hs_type;
+ smp->data.type = SMP_T_SINT;
+ smp->data.data.sint = hs_type;
smp->flags = SMP_F_VOLATILE;
return 1;
@@ -338,8 +338,8 @@
/* OK that's enough. We have at least the whole message, and we have
* the protocol version.
*/
- smp->type = SMP_T_SINT;
- smp->data.sint = version;
+ smp->data.type = SMP_T_SINT;
+ smp->data.data.sint = version;
smp->flags = SMP_F_VOLATILE;
return 1;
@@ -492,9 +492,9 @@
name_len = (data[7] << 8) + data[8];
if (name_type == 0) { /* hostname */
- smp->type = SMP_T_STR;
- smp->data.str.str = (char *)data + 9;
- smp->data.str.len = name_len;
+ smp->data.type = SMP_T_STR;
+ smp->data.data.str.str = (char *)data + 9;
+ smp->data.data.str.len = name_len;
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
return 1;
}
@@ -528,7 +528,7 @@
return 0;
smp->flags = SMP_F_CONST;
- smp->type = SMP_T_STR;
+ smp->data.type = SMP_T_STR;
bleft = s->req.buf->i;
if (bleft <= 11)
@@ -580,8 +580,8 @@
}
/* data points to cookie value */
- smp->data.str.str = (char *)data;
- smp->data.str.len = 0;
+ smp->data.data.str.str = (char *)data;
+ smp->data.data.str.len = 0;
while (bleft > 0 && *data != '\r') {
data++;
@@ -594,7 +594,7 @@
if (data[0] != '\r' || data[1] != '\n')
goto not_cookie;
- smp->data.str.len = (char *)data - smp->data.str.str;
+ smp->data.data.str.len = (char *)data - smp->data.data.str.str;
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
return 1;
@@ -628,8 +628,8 @@
return 0;
smp->flags = SMP_F_VOLATILE;
- smp->type = SMP_T_SINT;
- smp->data.sint = ret;
+ smp->data.type = SMP_T_SINT;
+ smp->data.data.sint = ret;
return 1;
}
@@ -680,9 +680,9 @@
goto too_short;
/* init chunk as read only */
- smp->type = SMP_T_BIN;
+ smp->data.type = SMP_T_BIN;
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
- chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size);
+ chunk_initlen(&smp->data.data.str, chn->buf->p + buf_offset, 0, buf_size);
return 1;
too_short:
@@ -712,9 +712,9 @@
goto too_short;
/* init chunk as read only */
- smp->type = SMP_T_BIN;
+ smp->data.type = SMP_T_BIN;
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
- chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size ? buf_size : (chn->buf->i - buf_offset));
+ chunk_initlen(&smp->data.data.str, chn->buf->p + buf_offset, 0, buf_size ? buf_size : (chn->buf->i - buf_offset));
if (!buf_size && channel_may_recv(chn) && !channel_input_closed(chn))
smp->flags |= SMP_F_MAY_CHANGE;