Exemplo n.º 1
0
int		fcheck(int fd, va_list p, t_form formats[], char f)
{
  int		j;
  int		i;
  int		ok;

  ok = 0;
  i = 0;
  j = 0;
  while (formats[i].c != 0)
    {
      if (formats[i].c == f)
	{
	  j += formats[i].f(fd, p);
	  ok = 1;
	}
      i++;
    }
  if (ok == 0)
    {
      my_fputchar(fd, '%');
      my_fputchar(fd, f);
      j += 2;
    }
  return (j);
}
Exemplo n.º 2
0
void		my_fprintf(int fd, const char *format, ...)
{
  va_list	ap;
  int		i;

  i = 0;
  va_start(ap, format);
  while (format[i])
    {
      while (format[i] && format[i] != '%')
	my_fputchar(fd, format[i++]);
      if (format[i] == '%')
	{
	  check_option(fd, format[++i], ap);
	  i++;
	}
    }
  va_end(ap);
}
Exemplo n.º 3
0
int		my_fprintf(int fd, const char *format, ...)
{
  va_list	ap;
  int		i;

  i = 0;
  va_start(ap, format);
  while (*format)
    {
      if (*format == '%')
	{
	  i += fcorr(fd, ap, *(format + 1));
	  format++;
	}
      else
	{
	  my_fputchar(fd, *format);
	  i++;
	}
      format++;
    }
  return (i);
}
Exemplo n.º 4
0
void		my_fputnbr(int fd, int nb)
{
  if (nb / 10 > 0)
    my_fputnbr(fd, nb / 10);
  my_fputchar(fd, nb % 10 + 48);
}