Пример #1
0
int	get_coord(char *path, t_vertice **v, t_vertice_n **vn, t_face **f)
{
  int	fd;
  char	*buff;
  char	**sep;

  fd = open(path, O_RDONLY);
  if (fd == -1)
    exit(1);
  while ((buff = get_next_line(fd)))
    {
      sep = my_strtok(buff, " ", TOK_DELIM);
      if (sep && size_tab(sep) == 4)
	{
	  if (!my_strcmp("v", sep[0]))
	    add_vertice(v, atof(sep[1]), atof(sep[2]),
			atof(sep[3]));
	  else if (!my_strcmp("f", sep[0]))
	    add_face(f, sep[1], sep[2], sep[3]);
	  else if (!my_strcmp("vn", sep[0]))
	    add_vertice_norme(vn, atof(sep[1]), atof(sep[2]),
			      atof(sep[3]));
	}
    }
  close(fd);
 return (1);
}
Пример #2
0
void		send_file(t_ftp *ftp, int i)
{
  char		**tab;
  char		*line;
  FILE		*fd;
  size_t	len;
  ssize_t	read;

  line = NULL;
  len = 0;
  if ((tab = my_word_tab(ftp->cmd, 0, 0, 0)) == NULL)
    {
      my_err("550 Invalid command.\r\n");
      return ;
    }
  i = size_tab(tab);
  if (i == 2)
    {
      fd = fopen(tab[1], "r");
      while ((read = getline(&line, &len, fd)) != -1)
	write(ftp->data_socket, line, read);
      dprintf(ftp->client_socket, "226 Closing data connection.\r\n");
      dprintf(ftp->client_socket, "Requested file action successful (for exam");
      dprintf(ftp->client_socket, "ple, file transfer or file abort)..\r\n");
      ftp->log = 1;
    }
  my_free(tab);
}