summaryrefslogtreecommitdiffstats
path: root/src/b_sqb_nbr.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-26 17:54:40 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-26 17:54:40 +0200
commit63d4df1fbb5ac13cd388a1a0069ab82a13f81069 (patch)
tree12c4ef5371b2f2e5d7435bf51fa406a5d4d45060 /src/b_sqb_nbr.c
parentNew comparison strings stuff (diff)
download42-minishell-63d4df1fbb5ac13cd388a1a0069ab82a13f81069.tar.gz
42-minishell-63d4df1fbb5ac13cd388a1a0069ab82a13f81069.tar.bz2
42-minishell-63d4df1fbb5ac13cd388a1a0069ab82a13f81069.tar.xz
42-minishell-63d4df1fbb5ac13cd388a1a0069ab82a13f81069.tar.zst
42-minishell-63d4df1fbb5ac13cd388a1a0069ab82a13f81069.zip
Numbers are goodio, now errcheck
Diffstat (limited to 'src/b_sqb_nbr.c')
-rw-r--r--src/b_sqb_nbr.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/b_sqb_nbr.c b/src/b_sqb_nbr.c
new file mode 100644
index 0000000..6ea2456
--- /dev/null
+++ b/src/b_sqb_nbr.c
@@ -0,0 +1,45 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* b_sqb_nbr.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <stdint.h>
+
+#include "d_define.h"
+
+static t_bool
+ b_sqb_nbr_tests(uint8_t id,
+ int32_t n1,
+ int32_t n2)
+{
+ if (id == FT_ID_SQB_EQ && n1 == n2)
+ return (TRUE);
+ else if (id == FT_ID_SQB_NE && n1 != n2)
+ return (TRUE);
+ else if (id == FT_ID_SQB_GT && n1 > n2)
+ return (TRUE);
+ else if (id == FT_ID_SQB_GE && n1 >= n2)
+ return (TRUE);
+ else if (id == FT_ID_SQB_LT && n1 < n2)
+ return (TRUE);
+ else if (id == FT_ID_SQB_LE && n1 <= n2)
+ return (TRUE);
+ return (FALSE);
+}
+
+uint8_t
+ b_sqb_nbr(uint8_t id,
+ char *argv[])
+{
+ if (b_sqb_nbr_tests(id, ft_atoi(argv[0]), ft_atoi(argv[2])) == TRUE)
+ return (0);
+ return (1);
+}