base64 decode done

This commit is contained in:
Gregory 2019-03-01 00:10:16 +02:00
parent 413e7fabd3
commit 924c10f5da
6 changed files with 9 additions and 16 deletions

View file

@ -130,7 +130,6 @@ void ft_base64_decode_transform
void ft_base64_decode_finish
(
t_base64_ctx *ctx,
t_base64_decode_buffer *buff
);

View file

@ -13,5 +13,5 @@ void ft_base64_decode(t_base64_ctx *ctx)
readed = ft_base64_decode_filter(readed, read_buff);
ft_base64_decode_chunk(ctx, readed, read_buff, &decode_buff);
}
ft_base64_decode_finish(ctx, &decode_buff);
ft_base64_decode_finish(&decode_buff);
}

View file

@ -3,27 +3,18 @@
void ft_base64_decode_finish
(
t_base64_ctx *ctx,
t_base64_decode_buffer *buff
)
{
t_byte8 buffer_index;
t_byte8 padding_size;
// t_byte1 chars[FT_BASE64_ENCODE_BLOCK_SIZE];
buffer_index = buff->readed % FT_BASE64_DECODE_BLOCK_SIZE;
padding_size = FT_BASE64_DECODE_BLOCK_SIZE - buffer_index;
if (!buff->readed)
return ;
if (!buffer_index)
if (buffer_index != 0)
{
write(ctx->output_fd, "\n", 1);
return ;
ft_putstr("\nbase64: invalid input: readed \
bytes count isn't multiple of 4\n");
exit(1);
}
// ft_bzero(&buff->block[buffer_index], padding_size);
// ft_base64_encode_transform(ctx, buff->block, chars);
// ft_memset(chars + FT_BASE64_DECODE_BLOCK_SIZE - padding_size, '=',
// padding_size);
// write(ctx->output_fd, chars, FT_BASE64_DECODE_BLOCK_SIZE);
// write(ctx->output_fd, "\n", 1);
}

View file

@ -12,7 +12,9 @@ static t_byte1 get_alphabet_index
alphabet_addr = ft_strchr((const char*)alphabet, ch);
if (!alphabet_addr)
{
ft_putstr("base64: invalid input\n");
ft_putstr("base64: invalid input: \"");
ft_putchar(ch);
ft_putstr("\" char not in base64 alphabet\n");
exit(1);
}
return (alphabet_addr - (char *)alphabet);

View file

@ -0,0 +1 @@
TWFFu