Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-blobcode
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
0
Merge Requests
0
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
libvmod-blobcode
Commits
5f522459
Commit
5f522459
authored
Jan 11, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encapsulate access to the write position of a write buffer
parent
d75b8b02
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
vmod_convert.c
src/vmod_convert.c
+11
-8
wb.h
src/wb.h
+6
-0
No files found.
src/vmod_convert.c
View file @
5f522459
...
...
@@ -349,7 +349,7 @@ vmod_decode(VRT_CTX, VCL_ENUM decs, const char *p, ...) {
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
}
buf
=
wb
.
w
;
buf
=
wb
_buf
(
&
wb
)
;
va_start
(
ap
,
p
);
len
=
id_decode
(
dec
,
buf
,
wb_space
(
&
wb
),
p
,
ap
);
...
...
@@ -366,7 +366,7 @@ vmod_decode(VRT_CTX, VCL_ENUM decs, const char *p, ...) {
return
null_blob
;
}
wb_advance
(
&
wb
,
len
);
WS_ReleaseP
(
ctx
->
ws
,
wb
.
w
);
WS_ReleaseP
(
ctx
->
ws
,
wb
_buf
(
&
wb
)
);
b
->
priv
=
buf
;
b
->
len
=
len
;
b
->
free
=
NULL
;
...
...
@@ -387,16 +387,19 @@ vmod_encode(VRT_CTX, VCL_ENUM encs, VCL_BLOB b) {
switch
(
enc
)
{
case
IDENTITY
:
len
=
id_encode
(
enc
,
wb
.
w
,
wb_space
(
&
wb
),
b
->
priv
,
b
->
len
);
len
=
id_encode
(
enc
,
wb_buf
(
&
wb
),
wb_space
(
&
wb
),
b
->
priv
,
b
->
len
);
break
;
case
BASE64
:
case
BASE64URL
:
case
BASE64URLNOPAD
:
len
=
base64_encode
(
enc
,
wb
.
w
,
wb_space
(
&
wb
),
b
->
priv
,
b
->
len
);
len
=
base64_encode
(
enc
,
wb_buf
(
&
wb
),
wb_space
(
&
wb
),
b
->
priv
,
b
->
len
);
break
;
case
HEX
:
case
HEXLC
:
len
=
hex_encode
(
enc
,
wb
.
w
,
wb_space
(
&
wb
),
b
->
priv
,
b
->
len
);
len
=
hex_encode
(
enc
,
wb_buf
(
&
wb
),
wb_space
(
&
wb
),
b
->
priv
,
b
->
len
);
break
;
default:
WRONG
(
"Illegal encoding"
);
...
...
@@ -463,16 +466,16 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, const char *p, ...) {
switch
(
enc
)
{
case
IDENTITY
:
len
=
id_encode
(
enc
,
wb
.
w
,
wb_space
(
&
wb
),
buf
,
len
);
len
=
id_encode
(
enc
,
wb
_buf
(
&
wb
)
,
wb_space
(
&
wb
),
buf
,
len
);
break
;
case
HEX
:
case
HEXLC
:
len
=
hex_encode
(
enc
,
wb
.
w
,
wb_space
(
&
wb
),
buf
,
len
);
len
=
hex_encode
(
enc
,
wb
_buf
(
&
wb
)
,
wb_space
(
&
wb
),
buf
,
len
);
break
;
case
BASE64
:
case
BASE64URL
:
case
BASE64URLNOPAD
:
len
=
base64_encode
(
enc
,
wb
.
w
,
wb_space
(
&
wb
),
buf
,
len
);
len
=
base64_encode
(
enc
,
wb
_buf
(
&
wb
)
,
wb_space
(
&
wb
),
buf
,
len
);
break
;
default:
WRONG
(
"Illegal encoding"
);
...
...
src/wb.h
View file @
5f522459
...
...
@@ -16,6 +16,12 @@ wb_end(struct wb_s *wb) {
return
wb
->
ws
->
r
-
1
;
}
/* return the write position */
static
inline
char
*
wb_buf
(
struct
wb_s
*
wb
)
{
return
wb
->
w
;
}
/* return one byte less for the final zero byte */
static
inline
ssize_t
wb_space
(
struct
wb_s
*
wb
)
{
...
...
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