pf_putstr.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* pf_putstr.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2016/02/27 00:48:09 by bchanot #+# #+# */
  9. /* Updated: 2018/10/14 03:36:14 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libftprintf.h"
  13. #include <unistd.h>
  14. int pf_xlong2(int len, t_inf *inf, unsigned long long nb)
  15. {
  16. len += pf_putuhex(nb, inf->fd);
  17. if (inf->width > 0 && inf->min == 1)
  18. while (len < inf->width && len++ >= 0)
  19. ft_putchar_fd(' ', inf->fd);
  20. return (len);
  21. }
  22. int pf_x_uplong2(int len, t_inf *inf, unsigned long long nb)
  23. {
  24. len += pf_putuhexm(nb, inf->fd);
  25. if (inf->width > 0 && inf->min == 1)
  26. while (len < inf->width && len++ >= 0)
  27. ft_putchar_fd(' ', inf->fd);
  28. return (len);
  29. }
  30. int pf_putstr(const char *s, int fd)
  31. {
  32. int len;
  33. len = -1;
  34. while (s[++len])
  35. ft_putchar_fd(s[len], fd);
  36. return (len);
  37. }
  38. int pf_putnstr(const char *s, int n, int fd)
  39. {
  40. write(fd, s, n);
  41. return (n);
  42. }