Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
907f220a
Commit
907f220a
authored
Oct 16, 2005
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite base64 encoder
(it was not padding properly the end of encoded stream)
parent
695cb26a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
24 deletions
+38
-24
include/network.h
include/network.h
+38
-24
No files found.
include/network.h
View file @
907f220a
...
...
@@ -306,39 +306,53 @@ static inline int vlc_UrlIsNotEncoded( const char *psz_url )
static
inline
char
*
vlc_b64_encode
(
char
*
src
)
{
static
const
char
b64
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
char
*
dst
=
(
char
*
)
malloc
(
strlen
(
src
)
*
4
/
3
+
12
);
size_t
len
=
strlen
(
src
);
char
*
dst
=
(
char
*
)
malloc
(
(
len
+
4
)
*
4
/
3
);
if
(
dst
==
NULL
)
return
NULL
;
char
*
ret
=
dst
;
unsigned
i_bits
=
0
;
unsigned
i_shift
=
0
;
for
(
;;
)
while
(
len
>
0
)
{
if
(
*
src
)
{
i_bits
=
(
i_bits
<<
8
)
|
(
*
src
++
);
i_shift
+=
8
;
}
else
if
(
i_shift
>
0
)
/* pops (up to) 3 bytes of input */
uint32_t
v
=
*
src
++
<<
24
;
if
(
len
>=
2
)
{
i_bits
<<=
6
-
i_shift
;
i_shift
=
6
;
v
|=
*
src
++
<<
16
;
if
(
len
>=
3
)
v
|=
*
src
++
<<
8
;
}
else
/* pushes (up to) 4 bytes of output */
while
(
v
)
{
*
dst
++
=
'='
;
break
;
*
dst
++
=
b64
[
v
>>
26
]
;
v
=
v
<<
6
;
}
while
(
i_shift
>=
6
)
switch
(
len
)
{
i_shift
-=
6
;
*
dst
++
=
b64
[(
i_bits
>>
i_shift
)
&
0x3f
];
case
1
:
*
dst
++
=
'='
;
*
dst
++
=
'='
;
len
--
;
break
;
case
2
:
*
dst
++
=
'='
;
len
-=
2
;
break
;
default:
len
-=
3
;
}
}
*
dst
++
=
'\0'
;
*
dst
=
'\0'
;
return
ret
;
}
...
...
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