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
26ee57b5
Commit
26ee57b5
authored
Apr 01, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use the refactored version of get_hdr(), and restore the #if'd-out code
parent
c8235335
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
86 deletions
+20
-86
format.c
src/format.c
+19
-32
format.h
src/format.h
+0
-20
test_format.c
src/test/test_format.c
+1
-34
No files found.
src/format.c
View file @
26ee57b5
...
...
@@ -56,11 +56,11 @@ typedef struct compiled_fmt_t {
char
tags
[
MAX_VSL_TAG
];
}
compiled_fmt_t
;
#if 0
/* XXX: When FMT_Init is implemented, malloc to config.max_reclen */
static
char
scratch
[
DEFAULT_MAX_RECLEN
];
#if 0
static compiled_fmt_t cformat, bformat, zformat;
static char i_arg[BUFSIZ] = "";
...
...
@@ -116,10 +116,8 @@ get_tag(tx_t *tx, enum VSL_tag_e tag)
}
/*
* hdr_re is a pre-compiled regex of the form "^\s*%s\*s:\s*(.+)$",
* formatted with the header name in place of %s.
* Return the captured substring (the header payload) of the *last* record
* in tx that matches the tag and the regex.
* Return the header payload of the *last* record in tx that matches the
* tag and the header name.
*/
char
*
get_hdr
(
tx_t
*
tx
,
enum
VSL_tag_e
tag
,
const
char
*
hdr
)
...
...
@@ -148,18 +146,7 @@ get_hdr(tx_t *tx, enum VSL_tag_e tag, const char *hdr)
while
(
isspace
(
*
c
))
c
++
;
hdr_payload
=
c
;
#if 0
s = VRE_exec(hdr_re, VSB_data(payload), rec->len, 0, 0, ov, OV_SIZE,
NULL);
assert(s >= VRE_ERROR_NOMATCH && s != 0);
if (s == VRE_ERROR_NOMATCH)
continue;
assert(ov[2] >= 0 && ov[3] >= ov[2]);
hdr_payload = VSB_data(payload) + ov[2];
hdr_payload[ov[3]] = '\0';
#endif
}
return
hdr_payload
;
}
...
...
@@ -189,7 +176,7 @@ get_rec_fld(logline_t *rec, int n)
get_payload
(
rec
);
return
get_fld
(
VSB_data
(
payload
),
n
);
}
#if 0
double
get_tm
(
tx_t
*
tx
)
{
...
...
@@ -198,7 +185,7 @@ get_tm(tx_t *tx)
CHECK_OBJ_NOTNULL
(
tx
,
TX_MAGIC
);
ts = get_hdr(tx, SLT_Timestamp,
time_start_re
);
ts
=
get_hdr
(
tx
,
SLT_Timestamp
,
"Start"
);
if
(
ts
!=
NULL
&&
(
epochstr
=
get_fld
(
ts
,
0
))
!=
NULL
)
{
char
*
p
;
epocht
=
strtod
(
epochstr
,
&
p
);
...
...
@@ -239,13 +226,13 @@ format_b_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, char **s, \
FORMAT_b
(
client
,
ReqAcct
)
FORMAT_b
(
backend
,
BereqAcct
)
static void
format_DT(tx_t *tx,
vre_t *time_re
, int m, char **s, size_t *len)
static
inline
void
format_DT
(
tx_t
*
tx
,
const
char
*
ts
,
int
m
,
char
**
s
,
size_t
*
len
)
{
char
*
t
;
double
d
;
char *f = get_hdr(tx, SLT_Timestamp, t
ime_re
);
char
*
f
=
get_hdr
(
tx
,
SLT_Timestamp
,
t
s
);
t
=
get_fld
(
f
,
1
);
errno
=
0
;
d
=
strtod
(
t
,
NULL
);
...
...
@@ -265,11 +252,11 @@ format_D_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, char **s, \
(void) name; \
(void) tag; \
\
format_DT(tx,
time_##ts##_re, 1e6, s, len);
\
format_DT(tx,
(ts), 1e6, s, len);
\
}
FORMAT_D(client,
resp
)
FORMAT_D(backend,
beresp_body
)
FORMAT_D
(
client
,
"Resp"
)
FORMAT_D
(
backend
,
"BerespBody"
)
FORMAT
(
client
,
H
,
ReqProtocol
)
FORMAT
(
backend
,
H
,
BereqProtocol
)
...
...
@@ -390,13 +377,13 @@ format_r_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, \
logline_t *rec = get_tag(tx, SLT_##dx##Method); \
if (rec != NULL) { \
get_payload(rec); \
sprintf(scratch, VSB_data(payload)); \
sprintf(scratch, VSB_data(payload));
\
} \
else \
strcpy(scratch, "-"); \
strcat(scratch, " "); \
\
if ((str = get_hdr(tx, SLT_##dx##Header,
host_re)) != NULL) {
\
if ((str = get_hdr(tx, SLT_##dx##Header,
"Host")) != NULL) {
\
if (strncmp(str, "http://", 7) != 0) \
strcat(scratch, "http://"); \
strcat(scratch, str); \
...
...
@@ -459,11 +446,11 @@ format_T_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, char **s, \
(void) name; \
(void) tag; \
\
format_DT(tx, t
ime_##ts##_re, 1, s, len);
\
format_DT(tx, t
s, 1, s, len);
\
}
FORMAT_T(client,
resp
)
FORMAT_T(backend,
beresp_body
)
FORMAT_T
(
client
,
"Resp"
)
FORMAT_T
(
backend
,
"BerespBody"
)
#define FORMAT_U(dir, xurl) \
void \
...
...
@@ -498,7 +485,7 @@ format_u_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, \
(void) tag; \
char *hdr; \
\
if ((hdr = get_hdr(tx, SLT_##hx,
auth_re)) != NULL
\
if ((hdr = get_hdr(tx, SLT_##hx,
"Authorization")) != NULL
\
&& strcasecmp(get_fld(hdr, 0), "Basic") == 0) { \
char *c, *auth = get_fld(hdr, 1); \
VB64_init(); \
...
...
@@ -518,7 +505,7 @@ format_u_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, \
FORMAT_u
(
client
,
ReqHeader
)
FORMAT_u
(
backend
,
BereqHeader
)
#endif
#if 0
#define FORMAT_Xio(dir, io, hx) \
...
...
src/format.h
View file @
26ee57b5
...
...
@@ -34,24 +34,6 @@
/* XXX: init as fixed size with length max_reclen + 1 */
struct
vsb
*
payload
;
#if 0
/* XXX: init time_start_re as VRE_compile(TS_START_REGEX) */
#define TS_START_REGEX "^\\s*Start\\s*:\\s*(.+)$"
vre_t *time_start_re;
#define TS_RESP_REGEX "^\\s*Resp\\s*:\\s*(.+)$"
vre_t *time_resp_re;
#define TS_BERESP_BODY_REGEX "^\\s*BerespBody\\s*:\\s*(.+)$"
vre_t *time_beresp_body_re;
#define HOST_REGEX "^\\s*Host\\s*:\\s*(.+)$"
vre_t *host_re;
#define AUTH_REGEX "^\\s*Authorization\\s*:\\s*(.+)$"
vre_t *auth_re;
#endif
typedef
void
formatter_f
(
tx_t
*
tx
,
char
*
name
,
enum
VSL_tag_e
tag
,
char
**
s
,
size_t
*
len
);
...
...
@@ -60,7 +42,6 @@ logline_t *get_tag(tx_t *tx, enum VSL_tag_e tag);
char
*
get_hdr
(
tx_t
*
tx
,
enum
VSL_tag_e
tag
,
const
char
*
hdr
);
char
*
get_fld
(
const
char
*
str
,
int
n
);
char
*
get_rec_fld
(
logline_t
*
rec
,
int
n
);
#if 0
double
get_tm
(
tx_t
*
tx
);
formatter_f
format_b_client
;
...
...
@@ -103,4 +84,3 @@ formatter_f format_U_backend;
formatter_f
format_u_client
;
formatter_f
format_u_backend
;
#endif
src/test/test_format.c
View file @
26ee57b5
...
...
@@ -43,7 +43,6 @@
int
tests_run
=
0
;
#if 0
static
void
add_rec_chunk
(
tx_t
*
tx
,
logline_t
*
rec
,
chunk_t
*
chunk
)
{
...
...
@@ -72,7 +71,6 @@ set_record_data(logline_t *rec, chunk_t *chunk, const char *data,
if
(
tag
!=
SLT__Bogus
)
rec
->
tag
=
tag
;
}
#endif
/* N.B.: Always run the tests in this order */
static
const
char
...
...
@@ -85,34 +83,6 @@ static const char
payload
=
VSB_new
(
NULL
,
NULL
,
DEFAULT_MAX_RECLEN
+
1
,
VSB_FIXEDLEN
);
MAN
(
payload
);
#if 0
time_start_re = VRE_compile(TS_START_REGEX, VRE_CASELESS, &error,
&erroroffset);
VMASSERT(time_start_re != NULL,
"Error compiling " TS_START_REGEX ": %s (offset %d)",
error, erroroffset);
time_resp_re = VRE_compile(TS_RESP_REGEX, VRE_CASELESS, &error,
&erroroffset);
VMASSERT(time_resp_re != NULL,
"Error compiling " TS_RESP_REGEX ": %s (offset %d)",
error, erroroffset);
time_beresp_body_re = VRE_compile(TS_BERESP_BODY_REGEX, VRE_CASELESS,
&error, &erroroffset);
VMASSERT(time_beresp_body_re != NULL,
"Error compiling " TS_BERESP_BODY_REGEX ": %s (offset %d)",
error, erroroffset);
host_re = VRE_compile(HOST_REGEX, VRE_CASELESS, &error, &erroroffset);
VMASSERT(host_re != NULL, "Error compiling " HOST_REGEX ": %s (offset %d)",
error, erroroffset);
auth_re = VRE_compile(AUTH_REGEX, VRE_CASELESS, &error, &erroroffset);
VMASSERT(auth_re != NULL, "Error compiling " AUTH_REGEX ": %s (offset %d)",
error, erroroffset);
#endif
return
NULL
;
}
...
...
@@ -348,7 +318,6 @@ static const char
return
NULL
;
}
#if 0
static
const
char
*
test_format_get_tm
(
void
)
{
...
...
@@ -966,7 +935,6 @@ static const char
return
NULL
;
}
#endif
static
const
char
*
all_tests
(
void
)
...
...
@@ -977,7 +945,6 @@ static const char
mu_run_test
(
test_format_get_hdr
);
mu_run_test
(
test_format_get_fld
);
mu_run_test
(
test_format_get_rec_fld
);
#if 0
mu_run_test
(
test_format_get_tm
);
mu_run_test
(
test_format_b
);
mu_run_test
(
test_format_D
);
...
...
@@ -993,7 +960,7 @@ static const char
mu_run_test
(
test_format_T
);
mu_run_test
(
test_format_U
);
mu_run_test
(
test_format_u
);
#endif
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