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:
Rene Kita
2021-09-12 11:47:38 +02:00
parent 561f27f833
commit cf7058b56c
2 changed files with 9 additions and 7 deletions

14
etc.c
View File

@@ -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]);

View File

@@ -831,4 +831,4 @@ void srand48(long);
long lrand48(void);
#endif
extern Str base64_encode(const unsigned char *src, size_t len);
extern Str base64_encode(const char *src, size_t len);