MEDIUM: chunks: make the chunk struct's fields match the buffer struct

Chunks are only a subset of a buffer (a non-wrapping version with no head
offset). Despite this we still carry a lot of duplicated code between
buffers and chunks. Replacing chunks with buffers would significantly
reduce the maintenance efforts. This first patch renames the chunk's
fields to match the name and types used by struct buffers, with the goal
of isolating the code changes from the declaration changes.

Most of the changes were made with spatch using this coccinelle script :

  @rule_d1@
  typedef chunk;
  struct chunk chunk;
  @@
  - chunk.str
  + chunk.area

  @rule_d2@
  typedef chunk;
  struct chunk chunk;
  @@
  - chunk.len
  + chunk.data

  @rule_i1@
  typedef chunk;
  struct chunk *chunk;
  @@
  - chunk->str
  + chunk->area

  @rule_i2@
  typedef chunk;
  struct chunk *chunk;
  @@
  - chunk->len
  + chunk->data

Some minor updates to 3 http functions had to be performed to take size_t
ints instead of ints in order to match the unsigned length here.
diff --git a/include/proto/action.h b/include/proto/action.h
index e3015ec..dcfdeac 100644
--- a/include/proto/action.h
+++ b/include/proto/action.h
@@ -52,7 +52,7 @@
 	char *end;
 	int l;
 
-	p = chk->str;
+	p = chk->area;
 	end = p + chk->size - 1;
 	list_for_each_entry(kw_list, keywords, list) {
 		for (i = 0; kw_list->kw[i].kw != NULL; i++) {
@@ -62,7 +62,7 @@
 			p += l;
 		}
 	}
-	if (p > chk->str)
+	if (p > chk->area)
 		*(p-2) = '\0';
 	else
 		*p = '\0';
diff --git a/include/proto/channel.h b/include/proto/channel.h
index d831fcc..10e3602 100644
--- a/include/proto/channel.h
+++ b/include/proto/channel.h
@@ -788,9 +788,9 @@
 {
 	int ret;
 
-	ret = ci_putblk(chn, chunk->str, chunk->len);
+	ret = ci_putblk(chn, chunk->area, chunk->data);
 	if (ret > 0)
-		chunk->len -= ret;
+		chunk->data -= ret;
 	return ret;
 }
 
diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h
index 0730160..d3b1f43 100644
--- a/include/proto/proto_http.h
+++ b/include/proto/proto_http.h
@@ -87,7 +87,7 @@
                           struct hdr_ctx *ctx);
 char *find_hdr_value_end(char *s, const char *e);
 char *extract_cookie_value(char *hdr, const char *hdr_end, char *cookie_name,
-                           size_t cookie_name_l, int list, char **value, int *value_l);
+                           size_t cookie_name_l, int list, char **value, size_t *value_l);
 int http_header_match2(const char *hdr, const char *end, const char *name, int len);
 int http_remove_header2(struct http_msg *msg, struct hdr_idx *idx, struct hdr_ctx *ctx);
 int http_header_add_tail2(struct http_msg *msg, struct hdr_idx *hdr_idx, const char *text, int len);
@@ -104,7 +104,7 @@
 			      enum h1_state state, struct proxy *other_end);
 unsigned int http_get_hdr(const struct http_msg *msg, const char *hname, int hlen,
 			  struct hdr_idx *idx, int occ,
-			  struct hdr_ctx *ctx, char **vptr, int *vlen);
+			  struct hdr_ctx *ctx, char **vptr, size_t *vlen);
 char *http_get_path(struct http_txn *txn);
 const char *get_reason(unsigned int status);
 
diff --git a/include/proto/sample.h b/include/proto/sample.h
index 94226d2..6cca99a 100644
--- a/include/proto/sample.h
+++ b/include/proto/sample.h
@@ -92,22 +92,22 @@
 		/* Fall through */
 
 	case SMP_T_STR:
-		if ((smp->data.u.str.len < 0) ||
-		    (smp->data.u.str.size && smp->data.u.str.len >= smp->data.u.str.size))
+		if ((smp->data.u.str.data < 0) ||
+		    (smp->data.u.str.size && smp->data.u.str.data >= smp->data.u.str.size))
 			return 0;
 
-		if (smp->data.u.str.str[smp->data.u.str.len] == 0)
+		if (smp->data.u.str.area[smp->data.u.str.data] == 0)
 			return 1;
 
 		if (!smp->data.u.str.size || (smp->flags & SMP_F_CONST))
 			return 0;
 
-		smp->data.u.str.str[smp->data.u.str.len] = 0;
+		smp->data.u.str.area[smp->data.u.str.data] = 0;
 		return 1;
 
 	case SMP_T_BIN:
-		return (smp->data.u.str.len >= 0) &&
-		       (!smp->data.u.str.size || smp->data.u.str.len <= smp->data.u.str.size);
+		return (smp->data.u.str.data >= 0) &&
+		       (!smp->data.u.str.size || smp->data.u.str.data <= smp->data.u.str.size);
 
 	default:
 		return 1;
@@ -145,18 +145,18 @@
 
 	case SMP_T_STR:
 		if (!smp->data.u.str.size ||
-		    smp->data.u.str.len < 0 ||
-		    smp->data.u.str.len >= smp->data.u.str.size)
+		    smp->data.u.str.data < 0 ||
+		    smp->data.u.str.data >= smp->data.u.str.size)
 			return 0;
 
-		if (smp->data.u.str.str[smp->data.u.str.len] != 0)
-			smp->data.u.str.str[smp->data.u.str.len] = 0;
+		if (smp->data.u.str.area[smp->data.u.str.data] != 0)
+			smp->data.u.str.area[smp->data.u.str.data] = 0;
 		return 1;
 
 	case SMP_T_BIN:
 		return smp->data.u.str.size &&
-		       smp->data.u.str.len >= 0 &&
-		       smp->data.u.str.len <= smp->data.u.str.size;
+		       smp->data.u.str.data >= 0 &&
+		       smp->data.u.str.data <= smp->data.u.str.size;
 
 	default:
 		return 1;
diff --git a/include/proto/spoe.h b/include/proto/spoe.h
index 002cf7d..299836b 100644
--- a/include/proto/spoe.h
+++ b/include/proto/spoe.h
@@ -180,18 +180,20 @@
 				*p++ = (smp->data.type == SMP_T_STR)
 					? SPOE_DATA_T_STR
 					: SPOE_DATA_T_BIN;
-				ret = spoe_encode_frag_buffer(chk->str, chk->len, &p, end);
+				ret = spoe_encode_frag_buffer(chk->area,
+							      chk->data, &p,
+							      end);
 				if (ret == -1)
 					return -1;
 			}
 			else {
 				/* The sample has been fragmented, encode remaining data */
-				ret = MIN(chk->len - *off, end - p);
-				memcpy(p, chk->str + *off, ret);
+				ret = MIN(chk->data - *off, end - p);
+				memcpy(p, chk->area + *off, ret);
 				p += ret;
 			}
 			/* Now update <*off> */
-			if (ret + *off != chk->len)
+			if (ret + *off != chk->data)
 				*off += ret;
 			else
 				*off = 0;
@@ -214,8 +216,8 @@
 				case HTTP_METH_CONNECT: m = "CONNECT"; len = 7; break;
 
 				default :
-					m   = smp->data.u.meth.str.str;
-					len = smp->data.u.meth.str.len;
+					m   = smp->data.u.meth.str.area;
+					len = smp->data.u.meth.str.data;
 			}
 			if (spoe_encode_buffer(m, len, &p, end) == -1)
 				return -1;
@@ -333,8 +335,8 @@
 			/* All the buffer must be decoded */
 			if (spoe_decode_buffer(&p, end, &str, &sz) == -1)
 				return -1;
-			smp->data.u.str.str = str;
-			smp->data.u.str.len = sz;
+			smp->data.u.str.area = str;
+			smp->data.u.str.data = sz;
 			smp->data.type = (type == SPOE_DATA_T_STR) ? SMP_T_STR : SMP_T_BIN;
 			break;
 	}