MINOR: pattern: make the pattern matching function return a pointer to the matched element

This feature will be used by the CLI to look up keys.
diff --git a/include/proto/pattern.h b/include/proto/pattern.h
index ee19392..8c9c1c7 100644
--- a/include/proto/pattern.h
+++ b/include/proto/pattern.h
@@ -58,7 +58,7 @@
  * associated to the matching patterned will be put there. The function returns
  * PAT_MATCH or PAT_NOMATCH.
  */
-enum pat_match_res pattern_exec_match(struct pattern_expr *expr, struct sample *smp, struct sample_storage **sample);
+enum pat_match_res pattern_exec_match(struct pattern_expr *expr, struct sample *smp, struct sample_storage **sample, struct pattern **pat, struct pat_idx_elt **elt);
 
 /*
  *
diff --git a/src/acl.c b/src/acl.c
index ef6b4a3..b033f2a 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -977,7 +977,7 @@
 					continue;
 				}
 
-				acl_res |= pat2acl(pattern_exec_match(&expr->pat, &smp, NULL));
+				acl_res |= pat2acl(pattern_exec_match(&expr->pat, &smp, NULL, NULL, NULL));
 				/*
 				 * OK now acl_res holds the result of this expression
 				 * as one of ACL_TEST_FAIL, ACL_TEST_MISS or ACL_TEST_PASS.
diff --git a/src/map.c b/src/map.c
index a13c5b7..b1fa7f6 100644
--- a/src/map.c
+++ b/src/map.c
@@ -467,7 +467,7 @@
 	desc = arg_p[0].data.map;
 
 	/* Execute the match function. */
-	ret = pattern_exec_match(desc->pat, smp, &sample);
+	ret = pattern_exec_match(desc->pat, smp, &sample, NULL, NULL);
 	if (ret != PAT_MATCH) {
 		if (!desc->def)
 			return 0;
diff --git a/src/pattern.c b/src/pattern.c
index 43011cd..c9e8978 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -1046,7 +1046,8 @@
  * PAT_NOMATCH or PAT_MATCH.
  */
 enum pat_match_res pattern_exec_match(struct pattern_expr *expr, struct sample *smp,
-                                      struct sample_storage **sample)
+                                      struct sample_storage **sample,
+                                      struct pattern **pat, struct pat_idx_elt **idx_elt)
 {
 	enum pat_match_res pat_res = PAT_NOMATCH;
 	struct pattern *pattern;
@@ -1079,6 +1080,8 @@
 				elt = ebmb_entry(node, struct pat_idx_elt, node);
 				if (sample)
 					*sample = elt->smp;
+				if (idx_elt)
+					*idx_elt = elt;
 			}
 		}
 
@@ -1090,6 +1093,8 @@
 				pat_res |= expr->match(smp, pattern);
 			if (sample)
 				*sample = pattern->smp;
+			if (pat)
+				*pat = pattern;
 		}
 	}