summaryrefslogtreecommitdiffstats
path: root/src/b_sqb_nbr.c
blob: 3ee48670d2ab67156d015a9d5c400893c554288f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   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 "d_define.h"

static t_bool	b_sqb_nbr_tests(unsigned char id, int n1, int n2)
{
	if (id == B_ID_SQB_EQ && n1 == n2)
		return (TRUE);
	else if (id == B_ID_SQB_NE && n1 != n2)
		return (TRUE);
	else if (id == B_ID_SQB_GT && n1 > n2)
		return (TRUE);
	else if (id == B_ID_SQB_GE && n1 >= n2)
		return (TRUE);
	else if (id == B_ID_SQB_LT && n1 < n2)
		return (TRUE);
	else if (id == B_ID_SQB_LE && n1 <= n2)
		return (TRUE);
	return (FALSE);
}

unsigned char	b_sqb_nbr(unsigned char id, char *argv[])
{
	if (b_sqb_nbr_tests(id, ft_atoi(argv[0]), ft_atoi(argv[2])) == TRUE)
		return (0);
	return (1);
}