CLEANUP: sample: generalize sample_fetch_string() as sample_fetch_as_type()

This modification makes possible to use sample_fetch_string() in more places,
where we might need to fetch sample values which are not plain strings. This
way we don't need to fetch string, and convert it into another type afterwards.

When using aliased types, the caller should explicitly check which exact type
was returned (e.g. SMP_T_IPV4 or SMP_T_IPV6 for SMP_T_ADDR).

All usages of sample_fetch_string() are converted to use new function.
diff --git a/src/sample.c b/src/sample.c
index 309ea11..330f08a 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -1338,8 +1338,9 @@
 /*
  * Process a fetch + format conversion as defined by the sample expression
  * <expr> on request or response considering the <opt> parameter. The output is
- * always of type string. If a stable sample can be fetched, or an unstable one
- * when <opt> contains SMP_OPT_FINAL, the sample is converted to a string and
+ * not explicitly set to <smp_type>, but shall be compatible with it as
+ * specified by 'sample_casts' table. If a stable sample can be fetched, or an
+ * unstable one when <opt> contains SMP_OPT_FINAL, the sample is converted and
  * returned without the SMP_F_MAY_CHANGE flag. If an unstable sample is found
  * and <opt> does not contain SMP_OPT_FINAL, then the sample is returned as-is
  * with its SMP_F_MAY_CHANGE flag so that the caller can check it and decide to
@@ -1355,9 +1356,9 @@
  *   smp      1        0     Not present yet, may appear later (eg: header)
  *   smp      1        1     never happens (either flag is cleared on output)
  */
-struct sample *sample_fetch_string(struct proxy *px, struct session *sess,
+struct sample *sample_fetch_as_type(struct proxy *px, struct session *sess,
                                    struct stream *strm, unsigned int opt,
-                                   struct sample_expr *expr)
+                                   struct sample_expr *expr, int smp_type)
 {
 	struct sample *smp = &temp_smp;
 
@@ -1369,13 +1370,12 @@
 		return NULL;
 	}
 
-	if (!sample_casts[smp->type][SMP_T_STR])
+	if (!sample_casts[smp->type][smp_type])
 		return NULL;
 
-	if (!sample_casts[smp->type][SMP_T_STR](smp))
+	if (!sample_casts[smp->type][smp_type](smp))
 		return NULL;
 
-	smp->type = SMP_T_STR;
 	smp->flags &= ~SMP_F_MAY_CHANGE;
 	return smp;
 }