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
8eff7732
Commit
8eff7732
authored
Apr 01, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement and test formatters for %U
parent
e03aea6d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
20 deletions
+64
-20
format.c
src/format.c
+23
-20
format.h
src/format.h
+3
-0
test_format.c
src/test/test_format.c
+38
-0
No files found.
src/format.c
View file @
8eff7732
...
@@ -451,28 +451,31 @@ format_T_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, char **s, \
...
@@ -451,28 +451,31 @@ format_T_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, char **s, \
FORMAT_T
(
client
,
resp
)
FORMAT_T
(
client
,
resp
)
FORMAT_T
(
backend
,
beresp_body
)
FORMAT_T
(
backend
,
beresp_body
)
#if 0
#define FORMAT_U(dir, xurl) \
void \
#define FORMAT_U(dir, dx) \
format_U_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, \
static void \
char **s, size_t *len) \
format_U_##dir(logline_t *ll, char *name, enum VSL_tag_e tag, \
{ \
char **s, size_t *len) \
char *qs = NULL; \
{ \
(void) name; \
char *q = NULL; \
(void) tag; \
unsigned ulen; \
\
(void) name; \
logline_t *rec = get_tag(tx, SLT_##xurl); \
(void) tag; \
get_payload(rec); \
q = memchr(TAG(ll,SLT_##dx##URL).data, '?', TAG(ll,SLT_##dx##URL).len); \
*s = VSB_data(payload); \
if (q == NULL) \
qs = memchr(VSB_data(payload), '?', rec->len); \
ulen = TAG(ll,SLT_##dx##URL).len; \
if (qs == NULL) \
else \
*len = rec->len; \
ulen = q - TAG(ll,SLT_##dx##URL).data; \
else { \
*s = TAG(ll,SLT_##dx##URL).data; \
*qs = '\0'; \
*len = ulen; \
*len = qs - *s; \
} \
}
}
FORMAT_U(client, Rx)
FORMAT_U
(
client
,
ReqURL
)
FORMAT_U(backend, Tx)
FORMAT_U
(
backend
,
BereqURL
)
#if 0
#define FORMAT_u(dir, hx) \
#define FORMAT_u(dir, hx) \
static void \
static void \
...
...
src/format.h
View file @
8eff7732
...
@@ -91,3 +91,6 @@ formatter_f format_t;
...
@@ -91,3 +91,6 @@ formatter_f format_t;
formatter_f
format_T_client
;
formatter_f
format_T_client
;
formatter_f
format_T_backend
;
formatter_f
format_T_backend
;
formatter_f
format_U_client
;
formatter_f
format_U_backend
;
src/test/test_format.c
View file @
8eff7732
...
@@ -856,6 +856,43 @@ static const char
...
@@ -856,6 +856,43 @@ static const char
return
NULL
;
return
NULL
;
}
}
static
const
char
*
test_format_U
(
void
)
{
tx_t
tx
;
logline_t
rec
;
chunk_t
chunk
;
char
*
str
;
size_t
len
;
printf
(
"... testing format_U_*()
\n
"
);
init_tx_rec_chunk
(
&
tx
,
&
rec
,
&
chunk
);
MAN
(
chunk
.
data
);
set_record_data
(
&
rec
,
&
chunk
,
URL_QUERY_PAYLOAD
,
SLT_ReqURL
);
format_U_client
(
&
tx
,
NULL
,
SLT__Bogus
,
&
str
,
&
len
);
MASSERT
(
strcmp
(
str
,
"/foo"
)
==
0
);
MASSERT
(
len
==
4
);
rec
.
tag
=
SLT_BereqURL
;
format_U_backend
(
&
tx
,
NULL
,
SLT__Bogus
,
&
str
,
&
len
);
MASSERT
(
strcmp
(
str
,
"/foo"
)
==
0
);
MASSERT
(
len
==
4
);
set_record_data
(
&
rec
,
&
chunk
,
URL_PAYLOAD
,
SLT_ReqURL
);
format_U_client
(
&
tx
,
NULL
,
SLT__Bogus
,
&
str
,
&
len
);
MASSERT
(
strcmp
(
str
,
"/foo"
)
==
0
);
MASSERT
(
len
==
4
);
rec
.
tag
=
SLT_BereqURL
;
format_U_backend
(
&
tx
,
NULL
,
SLT__Bogus
,
&
str
,
&
len
);
MASSERT
(
strcmp
(
str
,
"/foo"
)
==
0
);
MASSERT
(
len
==
4
);
return
NULL
;
}
static
const
char
static
const
char
*
all_tests
(
void
)
*
all_tests
(
void
)
{
{
...
@@ -878,6 +915,7 @@ static const char
...
@@ -878,6 +915,7 @@ static const char
mu_run_test
(
test_format_s
);
mu_run_test
(
test_format_s
);
mu_run_test
(
test_format_t
);
mu_run_test
(
test_format_t
);
mu_run_test
(
test_format_T
);
mu_run_test
(
test_format_T
);
mu_run_test
(
test_format_U
);
return
NULL
;
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