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
48de3054
Commit
48de3054
authored
Jan 30, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more base64_encode() tweaking
parent
2f09cd05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
base64.c
src/base64.c
+11
-12
No files found.
src/base64.c
View file @
48de3054
...
...
@@ -27,6 +27,7 @@
*/
#include <errno.h>
#include <stdint.h>
#include "base64.h"
...
...
@@ -59,7 +60,7 @@ base64_encode(const enum encoding enc, char *restrict const buf,
{
const
struct
b64_alphabet
*
alpha
=
&
b64_alphabet
[
enc
];
char
*
p
=
buf
;
const
char
*
in
=
inbuf
;
const
uint8_t
*
in
=
(
uint8_t
*
)
inbuf
;
AN
(
buf
);
AN
(
alpha
);
...
...
@@ -69,30 +70,28 @@ base64_encode(const enum encoding enc, char *restrict const buf,
||
maxlen
<
base64nopad_encode_l
(
inlength
))
return
-
1
;
while
(
in
<
inbuf
+
inlength
)
{
u
nsigned
char
*
tmp
,
idx
;
size_t
rest
=
(
inbuf
+
inlength
)
-
in
;
while
(
in
<
(
uint8_t
*
)
inbuf
+
inlength
)
{
u
int8_t
idx
;
size_t
rest
=
(
(
uint8_t
*
)
inbuf
+
inlength
)
-
in
;
tmp
=
(
unsigned
char
*
)
in
;
*
p
++
=
alpha
->
b64
[(
in
[
0
]
>>
2
)
&
0x3f
]
;
*
p
++
=
alpha
->
b64
[(
tmp
[
0
]
>>
2
)
&
0x3f
];
idx
=
(
tmp
[
0
]
<<
4
);
idx
=
(
in
[
0
]
<<
4
);
if
(
rest
>
1
)
idx
+=
(
tmp
[
1
]
>>
4
);
idx
+=
(
in
[
1
]
>>
4
);
*
p
++
=
alpha
->
b64
[
idx
&
0x3f
];
if
(
rest
>
1
)
{
idx
=
(
tmp
[
1
]
<<
2
);
idx
=
(
in
[
1
]
<<
2
);
if
(
rest
>
2
)
idx
+=
tmp
[
2
]
>>
6
;
idx
+=
in
[
2
]
>>
6
;
*
p
++
=
alpha
->
b64
[
idx
&
0x3f
];
}
else
if
(
alpha
->
padding
)
*
p
++
=
alpha
->
padding
;
if
(
rest
>
2
)
*
p
++
=
alpha
->
b64
[
tmp
[
2
]
&
0x3f
];
*
p
++
=
alpha
->
b64
[
in
[
2
]
&
0x3f
];
else
if
(
alpha
->
padding
)
*
p
++
=
alpha
->
padding
;
...
...
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