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
76a59341
Commit
76a59341
authored
Jan 22, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add the blob object interface
parent
a2326dfb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
0 deletions
+140
-0
blob.vtc
src/tests/blob.vtc
+56
-0
vmod_convert.c
src/vmod_convert.c
+80
-0
vmod_convert.vcc
src/vmod_convert.vcc
+4
-0
No files found.
src/tests/blob.vtc
0 → 100644
View file @
76a59341
# looks like -*- perl -*-
varnishtest
"blob object interface"
server
s1
{}
-
start
varnish
v1
-
arg
"-i serverid"
-
vcl
+
backend
{
import
convert
from
"${vmod_topbuild}/src/.libs/libvmod_convert.so"
;
sub
vcl_init
{
new
id
=
convert
.
blob
(
IDENTITY
,
"The quick brown fox jumps over the lazy dog"
);
new
idpieces
=
convert
.
blob
(
IDENTITY
,
""
+
server
.
identity
+
" "
+
server
.
identity
+
""
);
new
idempty
=
convert
.
blob
(
IDENTITY
,
""
);
new
hexuc
=
convert
.
blob
(
HEX
,
"666F6F206261722062617A2071757578"
);
new
hexlc
=
convert
.
blob
(
HEX
,
"666f6f206261722062617a2071757578"
);
new
hexmix
=
convert
.
blob
(
HEX
,
"666F6F206261722062617a2071757578"
);
new
b64
=
convert
.
blob
(
BASE64
,
"L0hlbGxvIHdvcmxkLw=="
);
new
b64nopad
=
convert
.
blob
(
BASE64URLNOPAD
,
"L0hlbGxvIHdvcmxkLw"
);
}
sub
vcl_recv
{
return
(
synth
(
200
));
}
sub
vcl_synth
{
set
resp
.
http
.
id
=
convert
.
encode
(
IDENTITY
,
id
.
get
());
set
resp
.
http
.
idpieces
=
convert
.
encode
(
IDENTITY
,
idpieces
.
get
());
set
resp
.
http
.
idempty
=
convert
.
encode
(
IDENTITY
,
idempty
.
get
());
set
resp
.
http
.
hexuc
=
convert
.
encode
(
IDENTITY
,
hexuc
.
get
());
set
resp
.
http
.
hexlc
=
convert
.
encode
(
IDENTITY
,
hexlc
.
get
());
set
resp
.
http
.
hexmix
=
convert
.
encode
(
IDENTITY
,
hexmix
.
get
());
set
resp
.
http
.
b64
=
convert
.
encode
(
IDENTITY
,
b64
.
get
());
set
resp
.
http
.
b64nopad
=
convert
.
encode
(
IDENTITY
,
b64nopad
.
get
());
}
}
-
start
client
c1
{
txreq
rxresp
expect
resp
.
http
.
id
==
"The quick brown fox jumps over the lazy dog"
expect
resp
.
http
.
idpieces
==
"serverid serverid"
expect
resp
.
http
.
idempty
==
""
expect
resp
.
http
.
hexuc
==
"foo bar baz quux"
expect
resp
.
http
.
hexlc
==
"foo bar baz quux"
expect
resp
.
http
.
hexmix
==
"foo bar baz quux"
expect
resp
.
http
.
b64
==
"/Hello world/"
expect
resp
.
http
.
b64nopad
==
"/Hello world/"
}
client
c1
-
run
src/vmod_convert.c
View file @
76a59341
...
...
@@ -33,6 +33,12 @@
#include "vmod_convert.h"
#include "wb.h"
struct
vmod_convert_blob
{
unsigned
magic
;
#define VMOD_CONVERT_BLOB_MAGIC 0xfade4fa9
struct
vmod_priv
blob
;
};
static
const
struct
vmod_priv
const
null_blob
[
1
]
=
{
{
...
...
@@ -159,6 +165,80 @@ event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e event)
return
(
0
);
}
/* Objects */
VCL_VOID
__match_proto__
(
td_convert_blob__init
)
vmod_blob__init
(
VRT_CTX
,
struct
vmod_convert_blob
**
blobp
,
const
char
*
vcl_name
,
VCL_ENUM
decs
,
const
char
*
p
,
...)
{
struct
vmod_convert_blob
*
b
;
enum
encoding
dec
=
parse_encoding
(
decs
);
va_list
ap
;
ssize_t
len
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
blobp
);
AZ
(
*
blobp
);
AN
(
vcl_name
);
ALLOC_OBJ
(
b
,
VMOD_CONVERT_BLOB_MAGIC
);
AN
(
b
);
*
blobp
=
b
;
b
->
blob
.
free
=
NULL
;
va_start
(
ap
,
p
);
len
=
decode_l_va
(
dec
,
p
,
ap
);
va_end
(
ap
);
if
(
len
==
0
)
{
b
->
blob
.
len
=
0
;
b
->
blob
.
priv
=
NULL
;
return
;
}
assert
(
len
>
0
);
b
->
blob
.
priv
=
malloc
(
len
);
AN
(
b
->
blob
.
priv
);
va_start
(
ap
,
p
);
len
=
decode
(
dec
,
b
->
blob
.
priv
,
len
,
p
,
ap
);
va_end
(
ap
);
if
(
len
==
-
1
)
{
/* XXX: error msg in ctx->msg and fail */
free
(
b
->
blob
.
priv
);
FREE_OBJ
(
b
);
*
blobp
=
NULL
;
return
;
}
if
(
len
==
0
)
{
b
->
blob
.
len
=
0
;
free
(
b
->
blob
.
priv
);
b
->
blob
.
priv
=
NULL
;
return
;
}
b
->
blob
.
len
=
len
;
}
VCL_BLOB
__match_proto__
(
td_convert_blob_get
)
vmod_blob_get
(
VRT_CTX
,
struct
vmod_convert_blob
*
b
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
b
,
VMOD_CONVERT_BLOB_MAGIC
);
return
&
b
->
blob
;
}
VCL_VOID
__match_proto__
(
td_convert_blob__fini
)
vmod_blob__fini
(
struct
vmod_convert_blob
**
blobp
)
{
struct
vmod_convert_blob
*
b
;
AN
(
*
blobp
);
b
=
*
blobp
;
*
blobp
=
NULL
;
CHECK_OBJ_NOTNULL
(
b
,
VMOD_CONVERT_BLOB_MAGIC
);
if
(
b
->
blob
.
priv
!=
NULL
)
free
(
b
->
blob
.
priv
);
FREE_OBJ
(
b
);
}
/* Functions */
VCL_BLOB
__match_proto__
(
td_convert_decode
)
...
...
src/vmod_convert.vcc
View file @
76a59341
...
...
@@ -14,6 +14,10 @@ XXX gen ENUMs
$Event event
$Object blob(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX}, STRING_LIST)
$Method BLOB .get()
$Function BLOB decode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX}, STRING_LIST)
XXX DOC
$Function STRING encode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, HEXLC}, BLOB)
...
...
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