Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent
Commits
4f343c25
Commit
4f343c25
authored
Apr 03, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement and test the formatter for %{tag:X}x
parent
1d6f8f85
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
8 deletions
+52
-8
format.c
src/format.c
+11
-8
format.h
src/format.h
+2
-0
test_format.c
src/test/test_format.c
+39
-0
No files found.
src/format.c
View file @
4f343c25
...
...
@@ -636,18 +636,21 @@ format_VCL_Log(tx_t *tx, char *name, enum VSL_tag_e tag, char **s, size_t *len)
*
len
=
strlen
(
l
);
}
#if 0
static void
format_SLT(logline_t *ll, char *name, enum VSL_tag_e tag,
char **s, size_t *len)
void
format_SLT
(
tx_t
*
tx
,
char
*
name
,
enum
VSL_tag_e
tag
,
char
**
s
,
size_t
*
len
)
{
(
void
)
name
;
if (TAG(ll,tag).len)
RETURN_REC(TAG(ll,tag), s, len);
logline_t
*
rec
=
get_tag
(
tx
,
tag
);
if
(
rec
!=
NULL
)
{
get_payload
(
rec
);
*
s
=
VSB_data
(
payload
);
*
len
=
VSB_len
(
payload
);
}
}
#if 0
static void
format_incomplete(logline_t *ll, char *name, enum VSL_tag_e tag,
char **s, size_t *len)
...
...
src/format.h
View file @
4f343c25
...
...
@@ -98,3 +98,5 @@ formatter_f format_Xttfb_backend;
formatter_f
format_VCL_disp
;
formatter_f
format_VCL_Log
;
formatter_f
format_SLT
;
src/test/test_format.c
View file @
4f343c25
...
...
@@ -1212,6 +1212,44 @@ static const char
return
NULL
;
}
static
const
char
*
test_format_SLT
(
void
)
{
tx_t
tx
;
logline_t
rec
;
chunk_t
chunk
;
char
*
str
;
size_t
len
;
printf
(
"... testing format_SLT()
\n
"
);
init_tx_rec_chunk
(
&
tx
,
&
rec
,
&
chunk
);
MAN
(
chunk
.
data
);
set_record_data
(
&
rec
,
&
chunk
,
"no backend connection"
,
SLT_FetchError
);
format_SLT
(
&
tx
,
NULL
,
SLT_FetchError
,
&
str
,
&
len
);
MASSERT
(
strcmp
(
str
,
"no backend connection"
)
==
0
);
MASSERT
(
len
==
21
);
/* record not found */
str
=
NULL
;
len
=
0
;
rec
.
tag
=
SLT_BereqHeader
;
format_SLT
(
&
tx
,
NULL
,
SLT_FetchError
,
&
str
,
&
len
);
MAZ
(
str
);
MAZ
(
len
);
/* Binary tag with non-printables in the payload */
memcpy
(
chunk
.
data
,
"foo
\0\xFF
bar"
,
9
);
rec
.
len
=
9
;
rec
.
tag
=
SLT_Debug
;
format_SLT
(
&
tx
,
NULL
,
SLT_Debug
,
&
str
,
&
len
);
MASSERT
(
strcmp
(
str
,
"foo
\0\xFF
bar"
)
==
0
);
MASSERT
(
len
==
9
);
return
NULL
;
}
static
const
char
*
all_tests
(
void
)
{
...
...
@@ -1242,6 +1280,7 @@ static const char
mu_run_test
(
test_format_Xttfb
);
mu_run_test
(
test_format_VCL_disp
);
mu_run_test
(
test_format_VCL_Log
);
mu_run_test
(
test_format_SLT
);
return
NULL
;
}
...
...
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