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
29156901
Commit
29156901
authored
Apr 07, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consolidate the encode step of transcode
Patch by Nils Goroll
parent
8e1e5501
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
26 deletions
+11
-26
vmod_blobcode.c
src/vmod_blobcode.c
+11
-26
No files found.
src/vmod_blobcode.c
View file @
29156901
...
...
@@ -522,9 +522,9 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs,
const
char
*
restrict
const
p
,
va_list
ap
)
{
enum
encoding
dec
=
parse_encoding
(
decs
);
enum
encoding
enc
=
parse_encoding
(
encs
);
struct
wb_s
wb
;
ssize_t
len
;
va_list
aq
;
struct
vmod_priv
b
;
VCL_STRING
r
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
INIT_FINI
(
ctx
))
{
...
...
@@ -537,12 +537,11 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs,
AENC
(
enc
);
if
(
dec
==
IDENTITY
)
{
struct
vmod_priv
b
;
va_copy
(
aq
,
ap
);
const
struct
vmod_priv
*
bb
=
decode_id_inplace
(
&
b
,
n
,
p
,
aq
);
va_end
(
aq
);
if
(
bb
!=
NULL
)
{
VCL_STRING
r
=
encode
(
ctx
,
enc
,
bb
);
r
=
encode
(
ctx
,
enc
,
bb
);
return
(
r
);
}
}
...
...
@@ -558,13 +557,15 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs,
return
""
;
/* XXX: handle stack overflow? */
char
buf
[
l
];
b
.
free
=
NULL
;
b
.
priv
=
buf
;
errno
=
0
;
va_copy
(
aq
,
ap
);
len
=
func
[
dec
].
decode
(
dec
,
buf
,
l
,
n
,
p
,
aq
);
b
.
len
=
func
[
dec
].
decode
(
dec
,
buf
,
l
,
n
,
p
,
aq
);
va_end
(
aq
);
if
(
len
==
-
1
)
{
if
(
b
.
len
==
-
1
)
{
err_decode
(
ctx
,
p
);
return
NULL
;
}
...
...
@@ -574,28 +575,12 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs,
* legal, just return the concatenated string.
*/
if
(
n
==
-
1
&&
enc
==
dec
)
{
VCL_STRING
s
;
s
=
VRT_String
(
ctx
->
ws
,
NULL
,
p
,
ap
);
return
s
;
}
if
(
wb_create
(
ctx
->
ws
,
&
wb
)
==
NULL
)
{
ERRNOMEM
(
ctx
,
"cannot encode after decode"
);
return
NULL
;
r
=
VRT_String
(
ctx
->
ws
,
NULL
,
p
,
ap
);
return
r
;
}
len
=
func
[
enc
].
encode
(
enc
,
wb_buf
(
&
wb
),
wb_space
(
&
wb
),
buf
,
len
);
if
(
len
==
-
1
)
{
ERRNOMEM
(
ctx
,
"cannot encode after decode"
);
wb_reset
(
&
wb
);
return
NULL
;
}
if
(
len
==
0
)
{
wb_reset
(
&
wb
);
return
""
;
}
wb_advance
(
&
wb
,
len
);
return
wb_finish
(
&
wb
,
NULL
);
r
=
encode
(
ctx
,
enc
,
&
b
);
return
(
r
);
}
VCL_STRING
__match_proto__
(
td_blobcode_transcode
)
...
...
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