Ejemplo n.º 1
0
static int			readfile(int const fd, t_list *list)
{
	int				ret;
	char			*line;
	char			*tmp;

	ret = BUFF_SIZE;
	line = NULL;
	if (!list)
		return (EXIT_FAIL);
	while (ret)
	{
		line = ft_strnew(BUFF_SIZE + 2);
		if ( line == NULL || (ret = read(fd, line, BUFF_SIZE)) == -1 )
			return (EXIT_FAIL);
		line[ret] = '\0';
		while ((int)ft_strlen(line) != ret)
			line[ft_strlen(line)] = '\a';
		tmp = ft_ctos('\a');
		ft_strreplace(&line, tmp, "", -1);
		ft_strdel(&tmp);
		list = ft_listadd(list, line);
	}
	return (EXIT_NULL);
}
Ejemplo n.º 2
0
char			*ft_build(va_list args, t_format *opt)
{
	va_list			ptr;
	char			*content;
	int				i;

	if (opt->type & 0xff)
	{
		if (opt->arg > 0)
		{
			va_copy(ptr, args);
			i = -1;
			while (++i < opt->arg)
				va_arg(ptr, void *);
			content = ft_get(ptr, opt);
			va_end(ptr);
		}
		else
			content = ft_get(args, opt);
	}
	else
		content = ft_alter(ft_ctos(opt->spec), opt, 0, 1);
	return (content);
}