almost...
This commit is contained in:
parent
712a87ab85
commit
a97878bf45
2
base64.c
2
base64.c
|
@ -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];
|
||||
|
|
2
base64.h
2
base64.h
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue