Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-tus
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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-tus
Commits
3d30f996
Unverified
Commit
3d30f996
authored
Sep 08, 2020
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move hex decode to own source file
parent
4d4aa2c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
66 deletions
+100
-66
Makefile.am
src/Makefile.am
+1
-0
tus_blob.c
src/tus_blob.c
+0
-66
tus_hex.c
src/tus_hex.c
+99
-0
No files found.
src/Makefile.am
View file @
3d30f996
...
...
@@ -42,6 +42,7 @@ libvmod_tus_la_SOURCES = \
tus_file_exp.h
\
tus_hdr.c
\
tus_hdr.h
\
tus_hex.c
\
tus_hex.h
\
tus_request.c
\
tus_request.h
\
...
...
src/tus_blob.c
View file @
3d30f996
...
...
@@ -290,69 +290,3 @@ tus_chksum_equal(VRT_CTX, struct tus_chksum *c)
(
void
)
tus_chksum_final
(
ctx
,
c
);
return
(
vmod_blob
->
equal
(
ctx
,
c
->
expect
,
c
->
final
));
}
// ------------------------------------------------------------
// not using vmod_blob because upload filenames should work without it
static
inline
char
hexnibble
(
unsigned
char
n
)
{
return
(
n
<
0xa
?
'0'
+
n
:
'a'
+
n
-
0xa
);
}
VCL_STRING
tus_hex_buf
(
char
*
buf
,
size_t
bufl
,
VCL_BLOB
b
)
{
VCL_STRING
r
=
buf
;
const
unsigned
char
*
p
;
unsigned
char
n
;
size_t
l
;
if
(
b
==
NULL
||
b
->
len
==
0
)
return
(
""
);
p
=
b
->
blob
;
l
=
b
->
len
;
while
(
l
>
0
)
{
if
(
bufl
<
3
)
return
(
NULL
);
n
=
*
p
;
buf
[
1
]
=
hexnibble
(
n
&
0xf
);
n
>>=
4
;
buf
[
0
]
=
hexnibble
(
n
&
0xf
);
buf
+=
2
;
bufl
-=
2
;
p
++
;
l
--
;
}
AN
(
bufl
);
buf
[
0
]
=
'\0'
;
return
(
r
);
}
VCL_STRING
tus_hex
(
VRT_CTX
,
VCL_BLOB
b
)
{
char
*
buf
;
size_t
bufl
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
b
==
NULL
||
b
->
len
==
0
)
return
(
""
);
bufl
=
b
->
len
*
2
+
1
;
buf
=
WS_Alloc
(
ctx
->
ws
,
bufl
);
if
(
buf
==
NULL
)
return
(
NULL
);
return
(
tus_hex_buf
(
buf
,
bufl
,
b
));
}
void
tus_vsbhex
(
struct
vsb
*
vsb
,
VCL_BLOB
b
)
{
size_t
l
=
b
->
len
*
2
+
1
;
char
buf
[
l
];
VSB_cat
(
vsb
,
tus_hex_buf
(
buf
,
l
,
b
));
}
src/tus_hex.c
0 → 100644
View file @
3d30f996
/*-
* Copyright 2020 UPLEX Nils Goroll Systemoptimierung
* All rights reserved.
*
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include "cache/cache.h"
#include "vsb.h"
#include "tus_hex.h"
// ------------------------------------------------------------
// not using vmod_blob because upload filenames should work without it
static
inline
char
hexnibble
(
unsigned
char
n
)
{
return
(
n
<
0xa
?
'0'
+
n
:
'a'
+
n
-
0xa
);
}
VCL_STRING
tus_hex_buf
(
char
*
buf
,
size_t
bufl
,
VCL_BLOB
b
)
{
VCL_STRING
r
=
buf
;
const
unsigned
char
*
p
;
unsigned
char
n
;
size_t
l
;
if
(
b
==
NULL
||
b
->
len
==
0
)
return
(
""
);
p
=
b
->
blob
;
l
=
b
->
len
;
while
(
l
>
0
)
{
if
(
bufl
<
3
)
return
(
NULL
);
n
=
*
p
;
buf
[
1
]
=
hexnibble
(
n
&
0xf
);
n
>>=
4
;
buf
[
0
]
=
hexnibble
(
n
&
0xf
);
buf
+=
2
;
bufl
-=
2
;
p
++
;
l
--
;
}
AN
(
bufl
);
buf
[
0
]
=
'\0'
;
return
(
r
);
}
VCL_STRING
tus_hex
(
VRT_CTX
,
VCL_BLOB
b
)
{
char
*
buf
;
size_t
bufl
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
b
==
NULL
||
b
->
len
==
0
)
return
(
""
);
bufl
=
b
->
len
*
2
+
1
;
buf
=
WS_Alloc
(
ctx
->
ws
,
bufl
);
if
(
buf
==
NULL
)
return
(
NULL
);
return
(
tus_hex_buf
(
buf
,
bufl
,
b
));
}
void
tus_vsbhex
(
struct
vsb
*
vsb
,
VCL_BLOB
b
)
{
size_t
l
=
b
->
len
*
2
+
1
;
char
buf
[
l
];
VSB_cat
(
vsb
,
tus_hex_buf
(
buf
,
l
,
b
));
}
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