[master] 26647ab Export a grouping mode to string array from the API

Martin Blix Grydeland martin at varnish-cache.org
Tue Nov 19 17:37:57 CET 2013


commit 26647ab038dbf4916c88ffd6a2d316ee9de12a27
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Fri Nov 15 16:24:37 2013 +0100

    Export a grouping mode to string array from the API

diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h
index 8fb008e..6d1308b 100644
--- a/include/vapi/vsl.h
+++ b/include/vapi/vsl.h
@@ -79,6 +79,7 @@ enum VSL_grouping_e {
 	VSL_g_vxid,
 	VSL_g_request,
 	VSL_g_session,
+	VSL_g__MAX,
 };
 
 typedef int VSLQ_dispatch_f(struct VSL_data *vsl,
@@ -170,6 +171,11 @@ int VSL_List2Tags(const char *list, int l, VSL_tagfind_f *func, void *priv);
 	 *     -3: Syntax error
 	 */
 
+extern const char *VSLQ_grouping[VSL_g__MAX];
+	/*
+	 * Grouping mode to string array.
+	 */
+
 int VSLQ_Name2Grouping(const char *name, int l);
 	/*
 	 * Convert string to grouping (= enum VSL_grouping_e)
diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map
index 34f3851..2abb178 100644
--- a/lib/libvarnishapi/libvarnishapi.map
+++ b/lib/libvarnishapi/libvarnishapi.map
@@ -119,4 +119,5 @@ LIBVARNISHAPI_1.3 {
 	VSL_List2Tags;
 	VSM_N_Arg;
 	# Variables:
+	VSLQ_grouping;
 } LIBVARNISHAPI_1.0;
diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c
index eb0eda1..880ac44 100644
--- a/lib/libvarnishapi/vsl_arg.c
+++ b/lib/libvarnishapi/vsl_arg.c
@@ -183,7 +183,7 @@ VSL_List2Tags(const char *list, int l, VSL_tagfind_f *func, void *priv)
 	return (t);
 }
 
-static const char * const vsl_grouping[] = {
+const char *VSLQ_grouping[VSL_g__MAX] = {
 	[VSL_g_raw]	= "raw",
 	[VSL_g_vxid]	= "vxid",
 	[VSL_g_request]	= "request",
@@ -198,9 +198,9 @@ VSLQ_Name2Grouping(const char *name, int l)
 	if (l == -1)
 		l = strlen(name);
 	n = -1;
-	for (i = 0; i < sizeof vsl_grouping / sizeof vsl_grouping[0]; i++) {
-		if (!strncasecmp(name, vsl_grouping[i], l)) {
-			if (strlen(vsl_grouping[i]) == l) {
+	for (i = 0; i < VSL_g__MAX; i++) {
+		if (!strncasecmp(name, VSLQ_grouping[i], l)) {
+			if (strlen(VSLQ_grouping[i]) == l) {
 				/* Exact match */
 				return (i);
 			}



More information about the varnish-commit mailing list