Let base64_encode() take a char *
Throughout the whole code base only char * is passed, but a unsigned char * is expected. This leads to several warnings. Fix the interface and cast to unsigned char * internally to avoid any changes to the behaviour.
This commit is contained in:
14
etc.c
14
etc.c
@@ -2021,13 +2021,15 @@ static char Base64Table[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
Str
|
||||
base64_encode(const unsigned char *src, size_t len)
|
||||
base64_encode(const char *src, size_t len)
|
||||
{
|
||||
Str dest;
|
||||
const unsigned char *in, *endw;
|
||||
const unsigned char *in, *endw, *s;
|
||||
unsigned long j;
|
||||
size_t k;
|
||||
|
||||
s = (unsigned char*)src;
|
||||
|
||||
k = len;
|
||||
if (k % 3)
|
||||
k += 3 - (k % 3);
|
||||
@@ -2043,9 +2045,9 @@ base64_encode(const unsigned char *src, size_t len)
|
||||
return Strnew();
|
||||
}
|
||||
|
||||
in = src;
|
||||
in = s;
|
||||
|
||||
endw = src + len - 2;
|
||||
endw = s + len - 2;
|
||||
|
||||
while (in < endw) {
|
||||
j = *in++;
|
||||
@@ -2058,9 +2060,9 @@ base64_encode(const unsigned char *src, size_t len)
|
||||
Strcatc(dest, Base64Table[j & 0x3f]);
|
||||
}
|
||||
|
||||
if (src + len - in) {
|
||||
if (s + len - in) {
|
||||
j = *in++;
|
||||
if (src + len - in) {
|
||||
if (s + len - in) {
|
||||
j = j << 8 | *in++;
|
||||
j = j << 8;
|
||||
Strcatc(dest, Base64Table[(j >> 18) & 0x3f]);
|
||||
|
Reference in New Issue
Block a user