mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 08:41:58 +00:00
60 lines
1.7 KiB
C
60 lines
1.7 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* verif_flag.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2026/01/09 09:51:11 by mteriier #+# #+# */
|
|
/* Updated: 2026/01/09 09:51:12 by mteriier ### ########lyon.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "parsing.h"
|
|
|
|
static int is_exist_flag(char **tab, int pos)
|
|
{
|
|
int verif;
|
|
|
|
verif = 0;
|
|
if (ft_strncmp(tab[pos], "--bench", 7)
|
|
|| ft_strncmp(tab[pos], "--simple", 8)
|
|
|| ft_strncmp(tab[pos], "--medium", 8)
|
|
|| ft_strncmp(tab[pos], "--complex", 9))
|
|
verif = 1;
|
|
return (verif);
|
|
}
|
|
|
|
static int verif_exist_flag(char **tab, int mod)
|
|
{
|
|
int verif;
|
|
|
|
verif = 0;
|
|
if (mod == 1)
|
|
verif = (is_exist_flag(tab, 1));
|
|
else if (mod == 2)
|
|
{
|
|
if (is_exist_flag(tab, 1) && is_exist_flag(tab, 2))
|
|
verif = 1;
|
|
}
|
|
return (verif);
|
|
}
|
|
|
|
static int verif_double_flag(char **tab, int mod)
|
|
{
|
|
int verif;
|
|
|
|
verif = 1;
|
|
if (mod == 2 && ft_strncmp(tab[1], tab[2], 9))
|
|
verif = 0;
|
|
return (verif);
|
|
}
|
|
|
|
int verif_flag(char **tab, int mod)
|
|
{
|
|
if (mod == 0)
|
|
return (1);
|
|
if (verif_double_flag(tab, mod) && verif_exist_flag(tab, mod))
|
|
return (1);
|
|
return (0);
|
|
} |