Commit 26647ab0 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Export a grouping mode to string array from the API

parent ee9fbf50
......@@ -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)
......
......@@ -119,4 +119,5 @@ LIBVARNISHAPI_1.3 {
VSL_List2Tags;
VSM_N_Arg;
# Variables:
VSLQ_grouping;
} LIBVARNISHAPI_1.0;
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment