diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-21 15:26:32 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-21 15:26:32 +0200 |
| commit | 23ad79e8b41c25bb4992d103d29a17612a52e351 (patch) | |
| tree | 9de3cde07cc38e59f08885171e9f99eeab8ab71b /rush02/ex00/error.c | |
| parent | 8b6e91bdb56bc01a588718472546f2a88e750b48 (diff) | |
| download | piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.tar.gz piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.tar.bz2 piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.zip | |
c10 done, c11 on going, rush02 probably finished, bsq start
Diffstat (limited to 'rush02/ex00/error.c')
| -rw-r--r-- | rush02/ex00/error.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/rush02/ex00/error.c b/rush02/ex00/error.c new file mode 100644 index 0000000..27dba41 --- /dev/null +++ b/rush02/ex00/error.c @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* error.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: yiacono <yiacono@student.s19.be> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/20 10:55:27 by agassin #+# #+# */ +/* Updated: 2019/07/21 14:17:53 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "include.h" + +/* +** similar to atoi but doesn't allow anything before or after ('-' included) +** return the number or -1 in case of error +*/ + +t_max_nbr strict_atoi(char *str) +{ + t_max_nbr nb; + int i; + + nb = 0; + i = 0; + while (str[i]) + { + if (str[i] < '0' || str[i] > '9') + return (-1); + i++; + } + if (i == 0) + return (-1); + i = 0; + while (str[i]) + { + nb *= 10; + nb += str[i++] - '0'; + } + return (nb); +} + +int print_error_if(int status, t_dict dict) +{ + if (status) + { + ft_putstr("Error\n"); + destroy_dict(dict, -1); + } + return (status); +} + +int print_dict_error_if(int status, t_dict dict) +{ + if (status) + { + ft_putstr("Dict Error\n"); + destroy_dict(dict, -1); + } + return (status); +} |
