Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
aa7dd949
Commit
aa7dd949
authored
Nov 01, 2005
by
lars@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/users/lthalmann/bkroot/mysql-5.0
into mysql.com:/users/lthalmann/bk/mysql-5.0-base64
parents
72343cef
13686ee3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
mysys/base64.c
mysys/base64.c
+14
-4
No files found.
mysys/base64.c
View file @
aa7dd949
...
...
@@ -27,9 +27,13 @@ static char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
int
base64_needed_encoded_length
(
int
length_of_data
)
{
return
ceil
(
length_of_data
*
4
/
3
)
/* base64 chars */
+
ceil
(
length_of_data
/
(
76
*
3
/
4
))
/* Newlines */
+
3
/* Padding */
;
int
nb_base64_chars
;
nb_base64_chars
=
(
length_of_data
+
2
)
/
3
*
4
;
return
nb_base64_chars
+
/* base64 char incl padding */
(
nb_base64_chars
-
1
)
/
76
+
/* newlines */
1
;
/* NUL termination of string */
}
...
...
@@ -89,6 +93,7 @@ base64_encode(const void *src, size_t src_len, char *dst)
else
*
dst
++=
base64_table
[(
c
>>
0
)
&
0x3f
];
}
*
dst
=
'\0'
;
return
0
;
}
...
...
@@ -209,6 +214,7 @@ main(void)
size_t
j
;
size_t
k
,
l
;
size_t
dst_len
;
size_t
needed_length
;
for
(
i
=
0
;
i
<
500
;
i
++
)
{
...
...
@@ -227,8 +233,12 @@ main(void)
}
/* Encode */
str
=
(
char
*
)
malloc
(
base64_needed_encoded_length
(
src_len
));
needed_length
=
base64_needed_encoded_length
(
src_len
);
str
=
(
char
*
)
malloc
(
needed_length
);
for
(
k
=
0
;
k
<
needed_length
;
k
++
)
str
[
k
]
=
0xff
;
/* Fill memory to check correct NUL termination */
require
(
base64_encode
(
src
,
src_len
,
str
)
==
0
);
require
(
needed_length
==
strlen
(
str
)
+
1
);
/* Decode */
dst
=
(
char
*
)
malloc
(
base64_needed_decoded_length
(
strlen
(
str
)));
...
...
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