#include "philo.h"

int parse_arguments(int argc,char *argv[], t_rules *rules)
{
	rules->n_must_eat = -1;
	printf("argc: %d\n", argc);
    if (argc != 5 && argc != 6)
        return (FAILURE);
    if (!ph_atoi(argv[1], &rules->n_philos))
        return (FAILURE);
    if (!ph_atoi(argv[2], &rules->time_to_die))
		return (FAILURE);
    if (!ph_atoi(argv[3], &rules->time_to_eat))
		return (FAILURE);
	if (!ph_atoi(argv[4], &rules->time_to_sleep))
        return (FAILURE);
    if (argc == 6 && !ph_atoi(argv[5], &rules->n_must_eat))
		return (FAILURE);
    rules->print_lock = malloc(sizeof(pthread_mutex_t));
	rules->death_lock = malloc(sizeof(pthread_mutex_t));
	if (!rules->print_lock || !rules->death_lock)
		return (FAILURE);
	rules->forks = malloc(rules->n_philos * sizeof(pthread_mutex_t));
	if (!rules->forks)
		return (FAILURE);
	print_rules(rules);
	return (SUCCESS);
}