59 lines
1.5 KiB
C
59 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_parser.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: lvincent <lvincent@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/07/30 17:19:40 by lvincent #+# #+# */
|
|
/* Updated: 2022/07/31 16:20:45 by lvincent ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "rush02.h"
|
|
|
|
#define UI_MAX 4294967295
|
|
|
|
int ft_parse(char *str)
|
|
{
|
|
int i;
|
|
int len;
|
|
|
|
i = 0;
|
|
while (ft_is_whitespace(str[i]) && str[i])
|
|
i++;
|
|
if (i >= ft_strlen(str))
|
|
return (0);
|
|
while (str[i])
|
|
{
|
|
if (ft_is_whitespace(str[i]))
|
|
break ;
|
|
else if ((str[i] < '0' || str[i] > '9') && !ft_is_whitespace(str[i]))
|
|
return (0);
|
|
i++;
|
|
}
|
|
while (str[i])
|
|
{
|
|
if (!ft_is_whitespace(str[i]))
|
|
return (0);
|
|
i++;
|
|
}
|
|
return (1);
|
|
}
|
|
|
|
char *ft_trim(char *str)
|
|
{
|
|
int i;
|
|
int j;
|
|
|
|
i = 0;
|
|
while (str[i] && ft_is_whitespace(str[i]))
|
|
i++;
|
|
j = i;
|
|
while (str[i] && !ft_is_whitespace(str[i]))
|
|
i++;
|
|
if (i < ft_strlen(str))
|
|
str[i] = '\0';
|
|
return (str + j);
|
|
}
|