Exemplo n.º 1
0
int				options_init(t_anthill *anthill, char *option, int mode)
{
	if (mode == 1)
	{
		if (*option == 'v' && anthill->option_v != 1)
		{
			anthill->option_v = 1;
			return (1);
		}
		else if (*option == 's' && anthill->option_s != 1)
		{
			anthill->option_s = 1;
			return (1);
		}
	}
	else if (mode == 2)
	{
		if (ft_isint(option))
		{
			anthill->option_n = ft_atoi(option);
			return (1);
		}
	}
	return (0);
}
Exemplo n.º 2
0
static int		ft_intleng(int n)
{
	int i;
	int flag;
	int save;

	i = 1;
	flag = 1;
	save = n;
	if (n == 0)
		return (1);
	if (n < 0)
	{
		n = -1 * n;
		flag = -1;
	}
	while (n > 9)
	{
		n = n / 10;
		i++;
	}
	if (i > 11)
		return (0);
	if (i == 11)
		return (ft_isint(save * flag));
	return (i);
}
Exemplo n.º 3
0
static int			ft_check(char **av, int ac, char *opt)
{
	int				i;
	int				a;

	i = -1;
	while (++i < 5)
		opt[i] = '0';
	i = 0;
	while (++i < ac && ((av[i][0] == '-') && ft_isalpha(av[i][1])))
		ft_init_opt(opt, av[i][1]);
	a = i;
	while (av && av[i])
	{
		if (!ft_isint(av[i]))
			return (0);
		if (!ft_isdbl(ft_atoi(av[i]), av, i))
			return (0);
		i++;
	}
	return (a + 1);
}