From 9b1450d2f4072eee48617170432741c1aa202716 Mon Sep 17 00:00:00 2001 From: Gregory Date: Sat, 23 Mar 2019 20:15:14 +0200 Subject: [PATCH] add -e flag --- inc/ft_des.h | 1 - src/des/ft_des_arg_parsers.c | 16 +++++++++++++++- src/des/ft_des_ecb.c | 4 ++++ src/des/ft_des_init_ctx.c | 1 - 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/inc/ft_des.h b/inc/ft_des.h index 407a9966..4dedd85b 100644 --- a/inc/ft_des.h +++ b/inc/ft_des.h @@ -39,7 +39,6 @@ typedef struct s_des_ctx int output_fd; int decode; int b64; - int output_in_base64; int readed; t_byte1 buffer[FT_DES_BYTE_BLOCK_SIZE]; t_byte1 key[FT_DES_INITIAL_KEY_SIZE]; diff --git a/src/des/ft_des_arg_parsers.c b/src/des/ft_des_arg_parsers.c index ae3ed30a..1d322b6c 100644 --- a/src/des/ft_des_arg_parsers.c +++ b/src/des/ft_des_arg_parsers.c @@ -46,4 +46,18 @@ int ft_des_decode_arg_parser (void)argv; ctx->decode = 1; return (++position); -} \ No newline at end of file +} + +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); +} diff --git a/src/des/ft_des_ecb.c b/src/des/ft_des_ecb.c index 1fd59324..a576e3fe 100644 --- a/src/des/ft_des_ecb.c +++ b/src/des/ft_des_ecb.c @@ -10,6 +10,10 @@ t_des_argument_parser g_arg_parsers[] = { "-d", ft_des_decode_arg_parser, }, + { + "-e", + ft_des_encode_arg_parser, + }, { "-a", ft_des_base64_arg_parser, diff --git a/src/des/ft_des_init_ctx.c b/src/des/ft_des_init_ctx.c index fb75872f..da111af7 100644 --- a/src/des/ft_des_init_ctx.c +++ b/src/des/ft_des_init_ctx.c @@ -20,7 +20,6 @@ void ft_des_init_ctx ctx->readed = 0; ctx->decode = 0; ctx->b64 = 0; - ctx->output_in_base64 = 0; ctx->input_fd = STDIN_FILENO; ctx->output_fd = STDOUT_FILENO; } \ No newline at end of file