almost...

This commit is contained in:
Fulton Browne 2021-05-16 19:21:23 +00:00
parent 712a87ab85
commit a97878bf45
3 changed files with 5 additions and 5 deletions

View File

@ -86,7 +86,7 @@ b64_encode(char* in, unsigned int in_len, char* out){
return k;
}
unsigned int
int
b64_decode(char* in, unsigned int in_len, char* out){
unsigned int i=0, j=0, k=0, s[4];

View File

@ -30,4 +30,4 @@ unsigned int b64_encode(char* in, unsigned int in_len, char* out);
// in_len : number of bytes to be decoded.
// out : pointer to buffer with enough memory, user is responsible for memory allocation, receives "raw" binary
// returns size of output excluding null byte
unsigned int b64_decode(char* in, unsigned int in_len, char* out);
int b64_decode(char* in, unsigned int in_len, char* out);

View File

@ -12,7 +12,7 @@ usage(void)
static void
decode(int fd, char *name)
{
int n;
int n, nb;
long tot;
char *buf, *outbuf;
outbuf = nil;
@ -29,9 +29,9 @@ decode(int fd, char *name)
tot += n;
}
buf[tot] = 0;
print("DEBUG: %d \n", strlen(outbuf));
outbuf = malloc(b64d_size(strlen(buf)));
b64_decode(buf, strlen(buf), outbuf);
nb = b64_decode(buf, strlen(buf), outbuf);
outbuf[nb] = 0;
if((n=write(1, outbuf, strlen(outbuf))) != strlen(outbuf))
sysfatal("writing bytes failed");
}