add -e flag

This commit is contained in:
Gregory 2019-03-23 20:15:14 +02:00
parent b6460d9b6b
commit 9b1450d2f4
4 changed files with 19 additions and 3 deletions

View file

@ -39,7 +39,6 @@ typedef struct s_des_ctx
int output_fd; int output_fd;
int decode; int decode;
int b64; int b64;
int output_in_base64;
int readed; int readed;
t_byte1 buffer[FT_DES_BYTE_BLOCK_SIZE]; t_byte1 buffer[FT_DES_BYTE_BLOCK_SIZE];
t_byte1 key[FT_DES_INITIAL_KEY_SIZE]; t_byte1 key[FT_DES_INITIAL_KEY_SIZE];

View file

@ -46,4 +46,18 @@ int ft_des_decode_arg_parser
(void)argv; (void)argv;
ctx->decode = 1; ctx->decode = 1;
return (++position); return (++position);
} }
int ft_des_encode_arg_parser
(
int argc,
char **argv,
int position,
t_des_ctx *ctx
)
{
(void)argc;
(void)argv;
ctx->encode = 1;
return (++position);
}

View file

@ -10,6 +10,10 @@ t_des_argument_parser g_arg_parsers[] = {
"-d", "-d",
ft_des_decode_arg_parser, ft_des_decode_arg_parser,
}, },
{
"-e",
ft_des_encode_arg_parser,
},
{ {
"-a", "-a",
ft_des_base64_arg_parser, ft_des_base64_arg_parser,

View file

@ -20,7 +20,6 @@ void ft_des_init_ctx
ctx->readed = 0; ctx->readed = 0;
ctx->decode = 0; ctx->decode = 0;
ctx->b64 = 0; ctx->b64 = 0;
ctx->output_in_base64 = 0;
ctx->input_fd = STDIN_FILENO; ctx->input_fd = STDIN_FILENO;
ctx->output_fd = STDOUT_FILENO; ctx->output_fd = STDOUT_FILENO;
} }