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
0d07107e
Commit
0d07107e
authored
May 22, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add VSL_Write* functions for writing binary log output.
parent
a09e2e08
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
0 deletions
+118
-0
vsl.h
include/vapi/vsl.h
+46
-0
libvarnishapi.map
lib/libvarnishapi/libvarnishapi.map
+4
-0
vsl.c
lib/libvarnishapi/vsl.c
+68
-0
No files found.
include/vapi/vsl.h
View file @
0d07107e
...
...
@@ -279,6 +279,52 @@ int VSL_PrintTransactions(struct VSL_data *vsl,
* !=0: Return value from either VSL_Next or VSL_Print
*/
FILE
*
VSL_WriteOpen
(
struct
VSL_data
*
vsl
,
const
char
*
name
,
int
append
,
int
unbuffered
);
/*
* Open file name for writing using the VSL_Write* functions. If
* append is true, the file will be opened for appending.
*
* Arguments:
* vsl: The VSL data context
* name: The file name
* append: If true, the file will be appended instead of truncated
* unbuf: If true, use unbuffered mode
*
* Return values:
* NULL: Error - see VSL_Error
* non-NULL: Success
*/
int
VSL_Write
(
struct
VSL_data
*
vsl
,
const
struct
VSL_cursor
*
c
,
void
*
fo
);
/*
* Write the currect record pointed to be c to the FILE* fo
*
* Return values:
* 0: Success
* -5: I/O error - see VSL_Error
*/
int
VSL_WriteAll
(
struct
VSL_data
*
vsl
,
struct
VSL_cursor
*
c
,
void
*
fo
);
/*
* Calls VSL_Next on c until c is exhausted. In turn calls
* VSL_Write on all records where VSL_Match returns true.
*
* Return values:
* 0: OK
* !=0: Return value from either VSL_Next or VSL_Write
*/
int
VSL_WriteTransactions
(
struct
VSL_data
*
vsl
,
struct
VSL_transaction
*
ptrans
[],
void
*
fo
);
/*
* Write all transactions in ptrans using VSL_WriteAll
* Return values:
* 0: OK
* !=0: Return value from either VSL_Next or VSL_Write
*/
struct
VSLQ
*
VSLQ_New
(
struct
VSL_data
*
vsl
,
struct
VSL_cursor
**
cp
,
enum
VSL_grouping_e
grouping
,
const
char
*
query
);
/*
...
...
lib/libvarnishapi/libvarnishapi.map
View file @
0d07107e
...
...
@@ -106,6 +106,10 @@ LIBVARNISHAPI_1.3 {
VSL_PrintTerse;
VSL_PrintAll;
VSL_PrintTransactions;
VSL_WriteOpen;
VSL_Write;
VSL_WriteAll;
VSL_WriteTransactions;
VSLQ_New;
VSLQ_Delete;
VSLQ_Dispatch;
...
...
lib/libvarnishapi/vsl.c
View file @
0d07107e
...
...
@@ -320,3 +320,71 @@ VSL_PrintTransactions(struct VSL_data *vsl, struct VSL_transaction *pt[],
return
(
0
);
}
FILE
*
VSL_WriteOpen
(
struct
VSL_data
*
vsl
,
const
char
*
name
,
int
append
,
int
unbuf
)
{
const
char
head
[]
=
VSL_FILE_ID
;
FILE
*
f
;
f
=
fopen
(
name
,
append
?
"a"
:
"w"
);
if
(
f
==
NULL
)
{
vsl_diag
(
vsl
,
"%s"
,
strerror
(
errno
));
return
(
NULL
);
}
if
(
unbuf
)
setbuf
(
f
,
NULL
);
if
(
0
==
ftell
(
f
))
fwrite
(
head
,
1
,
sizeof
head
,
f
);
return
(
f
);
}
int
VSL_Write
(
struct
VSL_data
*
vsl
,
const
struct
VSL_cursor
*
c
,
void
*
fo
)
{
size_t
r
;
CHECK_OBJ_NOTNULL
(
vsl
,
VSL_MAGIC
);
if
(
c
==
NULL
||
c
->
rec
.
ptr
==
NULL
)
return
(
0
);
if
(
fo
==
NULL
)
fo
=
stdout
;
r
=
fwrite
(
c
->
rec
.
ptr
,
sizeof
*
c
->
rec
.
ptr
,
VSL_NEXT
(
c
->
rec
.
ptr
)
-
c
->
rec
.
ptr
,
fo
);
if
(
r
==
0
)
return
(
-
5
);
return
(
0
);
}
int
VSL_WriteAll
(
struct
VSL_data
*
vsl
,
struct
VSL_cursor
*
c
,
void
*
fo
)
{
int
i
;
if
(
c
==
NULL
)
return
(
0
);
while
(
1
)
{
i
=
VSL_Next
(
c
);
if
(
i
<=
0
)
return
(
i
);
if
(
!
VSL_Match
(
vsl
,
c
))
continue
;
i
=
VSL_Write
(
vsl
,
c
,
fo
);
if
(
i
!=
0
)
return
(
i
);
}
}
int
VSL_WriteTransactions
(
struct
VSL_data
*
vsl
,
struct
VSL_transaction
*
pt
[],
void
*
fo
)
{
struct
VSL_transaction
*
t
;
int
i
;
if
(
pt
==
NULL
)
return
(
0
);
for
(
i
=
0
,
t
=
pt
[
0
];
i
==
0
&&
t
!=
NULL
;
t
=
*++
pt
)
i
=
VSL_WriteAll
(
vsl
,
t
->
c
,
fo
);
return
(
i
);
}
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