summaryrefslogtreecommitdiffstats
path: root/src/b_sqb_str.c
blob: cc7e4ed4959a7969c67fe0eb2679a0c27fea36c9 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   b_sqb_str.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_str_comp(uint8_t id,
				const char s_one[],
				const char s_two[])
{
	if (id == FT_ID_SQB_EQUA &&
		ft_strncmp(s_one, s_two, ft_strlen(s_one) + 1) == 0)
		return (TRUE);
	else if (id == FT_ID_SQB_EQUA &&
		ft_strncmp(s_one, s_two, ft_strlen(s_one) + 1) != 0)
		return (TRUE);
	return (FALSE);
}

uint8_t
	b_sqb_str(uint8_t id,
			char *argv[])
{
	if (id == FT_ID_SQB_N)
	{
		if (argv[1][0] != '\0')
			return (0);
		else
			return (1);
	}
	else if (id == FT_ID_SQB_Z)
	{
		if (argv[1][0] == '\0')
			return (0);
		else
			return (1);
	}
	if (b_sqb_str_comp(id, argv[0], argv[2]) == TRUE)
		return (0);
	return (1);
}