Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
c3b51339
Commit
c3b51339
authored
May 16, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a VSLQ_Name2Grouping function to parse -g arguments
parent
81898e08
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
16 deletions
+49
-16
varnishlog.c
bin/varnishlog/varnishlog.c
+7
-16
vsl.h
include/vapi/vsl.h
+11
-0
libvarnishapi.map
lib/libvarnishapi/libvarnishapi.map
+1
-0
vsl_arg.c
lib/libvarnishapi/vsl_arg.c
+30
-0
No files found.
bin/varnishlog/varnishlog.c
View file @
c3b51339
...
...
@@ -80,13 +80,12 @@ main(int argc, char * const *argv)
{
char
optchar
;
int
d_opt
=
0
;
char
*
g_arg
=
NULL
;
struct
VSL_data
*
vsl
;
struct
VSM_data
*
vsm
;
struct
VSL_cursor
*
c
;
struct
VSLQ
*
q
;
enum
VSL_grouping_e
grouping
=
VSL_g_vxid
;
int
grouping
=
VSL_g_vxid
;
int
i
;
vsl
=
VSL_New
();
...
...
@@ -101,7 +100,11 @@ main(int argc, char * const *argv)
break
;
case
'g'
:
/* Grouping mode */
g_arg
=
optarg
;
grouping
=
VSLQ_Name2Grouping
(
optarg
,
-
1
);
if
(
grouping
==
-
2
)
error
(
1
,
"Ambiguous grouping type: %s"
,
optarg
);
else
if
(
grouping
<
0
)
error
(
1
,
"Unknown grouping type: %s"
,
optarg
);
break
;
case
'n'
:
/* Instance name */
...
...
@@ -112,19 +115,7 @@ main(int argc, char * const *argv)
usage
();
}
}
if
(
g_arg
)
{
if
(
!
strcmp
(
g_arg
,
"raw"
))
grouping
=
VSL_g_raw
;
else
if
(
!
strcmp
(
g_arg
,
"vxid"
))
grouping
=
VSL_g_vxid
;
else
if
(
!
strcmp
(
g_arg
,
"request"
))
grouping
=
VSL_g_request
;
else
if
(
!
strcmp
(
g_arg
,
"session"
))
grouping
=
VSL_g_session
;
else
error
(
1
,
"Wrong -g argument: %s"
,
g_arg
);
}
assert
(
grouping
>=
0
&&
grouping
<=
VSL_g_session
);
/* Create cursor */
if
(
VSM_Open
(
vsm
))
...
...
include/vapi/vsl.h
View file @
c3b51339
...
...
@@ -99,6 +99,17 @@ int VSL_Name2Tag(const char *name, int l);
* -2: Multiple tags match substring
*/
int
VSLQ_Name2Grouping
(
const
char
*
name
,
int
l
);
/*
* Convert string to grouping (= enum VSL_grouping_e)
*
* Return values:
* >=0: Grouping value
* -1: No grouping type matches
* -2: Multiple grouping types match substring
*/
struct
VSL_data
*
VSL_New
(
void
);
int
VSL_Arg
(
struct
VSL_data
*
vsl
,
int
opt
,
const
char
*
arg
);
/*
...
...
lib/libvarnishapi/libvarnishapi.map
View file @
c3b51339
...
...
@@ -110,5 +110,6 @@ LIBVARNISHAPI_1.3 {
VSLQ_Delete;
VSLQ_Dispatch;
VSLQ_Flush;
VSLQ_Name2Grouping;
# Variables:
} LIBVARNISHAPI_1.0;
lib/libvarnishapi/vsl_arg.c
View file @
c3b51339
...
...
@@ -83,6 +83,36 @@ VSL_Name2Tag(const char *name, int l)
return
(
n
);
}
static
const
char
*
vsl_grouping
[]
=
{
[
VSL_g_raw
]
=
"raw"
,
[
VSL_g_vxid
]
=
"vxid"
,
[
VSL_g_request
]
=
"request"
,
[
VSL_g_session
]
=
"session"
,
};
int
VSLQ_Name2Grouping
(
const
char
*
name
,
int
l
)
{
int
i
,
n
;
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
)
{
/* Exact match */
return
(
i
);
}
if
(
n
==
-
1
)
n
=
i
;
else
n
=
-
2
;
}
}
return
(
n
);
}
static
int
vsl_ix_arg
(
struct
VSL_data
*
vsl
,
int
opt
,
const
char
*
arg
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment