Esempio n. 1
0
int		error_boss(char *map)
{
  char		*file;
  char		**tab;
  int		width;
  int		height;

  if (check_existence(map) == -1
      || (file = get_file_content(map)) == NULL
      || check_integer(file, "ibwsm.lg\n") == -1
      || (file = put_return(file)) == NULL
      || (tab = my_str_to_wordtab(file, '\n')) == NULL
      || check_largest(tab) == -1
      || is_present("i", file) != 1
      || is_present("b", file) != 1
      || check_tab(tab) == -1)
    return (puterror("One of Boss map isn't correct.\n"));
  width = my_strlen(tab[0]) * 29;
  height = tablen(tab) * 26;
  if (width > 1300 || height > 750)
    return (puterror("Error: Dimension are too big in Boss Map.\n"));
  free(file);
  free_tab(tab);
  return (0);
}
Esempio n. 2
0
void	get_tab(int fd, t_env *e)
{
	char	**line;
	int		ret;
	int		i;
	int		j;

	ret = 1;
	i = 0;
	line = malloc(sizeof(char*) * 1024);
	while (ret > 0)
	{
		ret = get_next_line(fd, &line[i]);
		if (ret > 0)
			i++;
		if (ret == -1)
			exit(0);
	}
	j = 0;
	e->tab = malloc(sizeof(char **) * (i + 1));
	while (i)
	{
		e->tab[j] = ft_strsplit(line[j], ' ');
		i--;
		j++;
	}
	e->tab[j] = NULL;
	check_tab(e);
}
Esempio n. 3
0
File: main.c Progetto: barug/Epitech
int		main(int argc, char **argv, char **envp)
{
  t_tabnfo	*tabnfo;
  t_maxsquare	*maxsquare;

  argc = argc;
  if (load_termcaps(envp) == -1)
    return (-1);
  if ((tabnfo = malloc(sizeof(t_tabnfo))) == NULL)
    return (-1);
  if ((maxsquare = malloc(sizeof(t_maxsquare))) == NULL)
    return (-1);
  if (make_tab(argv[1], tabnfo) == -1)
    return (-1);
  if (check_tab(tabnfo) == -1)
    return (-1);
  if (find_maxsquare(tabnfo, maxsquare) == -1)
    {
      my_printf("no possible square");
      return (-1);
    }
  my_printf("FOUND:\n");
  make_maxsquare(tabnfo, maxsquare);
  display_tab(tabnfo);
  free_tabnfo(tabnfo);
  return (0);
}
Esempio n. 4
0
File: main.c Progetto: koloux/Fillit
int	main(int ac, char **av)
{
	unsigned int	*tab;
	unsigned int	bottom;
	unsigned int	right;

	if (ac > 2)
		print_usage();
	else
	{
		if (!(tab = (unsigned int *)ft_memalloc(sizeof(int) * 27)))
			return ((int)NULL);
		ft_bzero(tab, 27);
		if (read_file(av[1], tab) == -1)
			return (-1);
		move_resetall(tab);
		if (check_tab(tab) == -1)
			ft_putstr("error\n");
		else
		{
			right = pos_getborder(tab[1], "right");
			bottom = pos_getborder(tab[1], "bottom");
			tab[0] = right > bottom ? right : bottom;
			(void)solve(tab, 1, 0);
			print_result(tab);
		}
	}
	return (0);
}
Esempio n. 5
0
int     first_check(t_allum *allum, t_ia ia)
{
  if (check_allum(allum, ia) == 2)
    return (0);
  if (check_tab(allum) == 2)
    return (0);
  return (1);
}
Esempio n. 6
0
int main()
{
    int connfd,listenfd;
    int port;
    char *send_ip;
    char data[LEN];
    port = init_route();
    listenfd = rec_connect(port);
    connfd = accept(listenfd,(struct sockaddr*)NULL,NULL);
    if (connfd >= 0)
        printf("Route connect OK!\n");
    while (read(connfd,data,LEN) > 0)
    {
        char s_ip[IP_LEN + 1],d_ip[IP_LEN + 1];
        memcpy(s_ip,data,IP_LEN);
        memcpy(d_ip,data + IP_LEN,IP_LEN);
        for (int i = 0; i < IP_LEN; i++)
            if (s_ip[i] == '$')
            {
                s_ip[i] = '\0';
                break;
            }
        s_ip[IP_LEN] = '\0';
        for (int i = 0; i < IP_LEN; i++)
            if (d_ip[i] == '$')
            {
                d_ip[i] = '\0';
                break;
            }
        d_ip[IP_LEN] = '\0';
        printf("**********source IP               destination IP***************\n");
        printf("          %s               %s                            \n",s_ip,d_ip);

        send_ip = check_tab(d_ip);//check the routing table.
        if (strcmp(send_ip,"127.0.0.1") == 0)
            send_data(data,send_ip,H_PORT);
        else
            send_data(data,send_ip,R_PORT);
        close(connfd);
        data[0] = '\0';

        connfd = accept(listenfd,(struct sockaddr*)NULL,NULL);
    }
}
Esempio n. 7
0
static int		cache_fd(const int fd, char **buf, char **tab, char **line)
{
	int		ret;
	int		i;
	char	*temp;
	char	*temp2;

	i = 0;
	ret = 1;
	temp = line[0];
	temp2 = NULL;
	if ((ret = check_tab(&tab[fd], line, buf)) != 3)
		return (ret);
	else
	{
		if ((ret = read(fd, buf[0], BUFF_SIZE)) != 0)
		{
			if (ret < 0)
				return (ret);
			return (parse_read(&tab[fd], buf, line, NULL));
		}
	}
	return (ft_strlen(*line) == 0 ? 0 : 1);
}
Esempio n. 8
0
void		parse_args(int ac, char **av)
{
  int		*val;
  int		i;
  char		**name_team;
  int		ret;

  val = xmalloc(sizeof(int) * OPT_INT);
  bzero(val, OPT_INT * sizeof(int));
  name_team = (i = 1) ? NULL : NULL;
  while (i < ac)
    {
      if ((ret = check_tab(i, ac, av)) != -1)
	val[ret] = atoi(av[i + 1]);
      else if (strcmp(av[i], "-n") == 0)
	name_team = manage_team(name_team, av, &i);
      else
	printf("unknow parameter :%s\n", av[i]);
      i += 2;
    }
  if (print_code_error(check_name_team(name_team)) == -1)
    exit(EXIT_FAILURE);
  run_server(check(val, name_team));
}