void print_majmin(t_file *file, t_space *spaces) { int min; int maj; min = ft_count_digit(minor(file->st_rdev), 10); maj = ft_count_digit(major(file->st_rdev), 10); ft_putnbr(major(file->st_rdev)); while (maj < spaces->maj--) ft_putchar(' '); ft_putstr(", "); ft_putnbr(minor(file->st_rdev)); while (min < spaces->min--) ft_putchar(' '); ft_putchar(' '); }
static void get_spaces_sys(t_space *space, t_file *file) { int len; len = 0; if (getpwuid(file->st_uid)) len = ft_strlen(getpwuid(file->st_uid)->pw_name); else len = ft_count_digit(file->st_uid, 10); space->user = len > space->user ? len : space->user; if (getgrgid(file->st_gid)) len = ft_strlen(getgrgid(file->st_gid)->gr_name); else len = ft_count_digit(file->st_gid, 10); space->group = len > space->group ? len : space->group; }
static void quick_check(t_space *space, t_file *file) { int tmp; tmp = ft_count_digit(file->st_nlink, 10); space->link = tmp > space->link ? tmp : space->link; tmp = ft_count_digit(major(file->st_rdev), 10); space->maj = tmp > space->maj ? tmp : space->maj; tmp = ft_count_digit(minor(file->st_nlink), 10); space->min = tmp > space->min ? tmp : space->min; tmp = ft_count_digit(file->st_size, 10); space->size = tmp > space->size ? tmp : space->size; space->total += file->st_blocks; }
void print_nbr(int nlink, int space) { int n; n = space - ft_count_digit(nlink, 10); if (nlink == 0) n--; while (n-- > 0) ft_putchar(' '); ft_putnbr(nlink); ft_putchar(' '); }
int ft_put_flag_rd(char **format, va_list arg, int i) { int d; int ret; d = va_arg(arg, int); i = i + ft_count_digit(d); ret = ft_nputnbr(d); while (i < 0) { ret = ret + ft_nputstr(" "); i++; } (*format)++; return (ret); }
int ft_put_flag_d(char **format, va_list arg, int i) { int d; int ret; ret = 0; d = va_arg(arg, int); i = i - ft_count_digit(d); while (i > 0) { ret = ret + ft_nputstr(" "); i--; } *format = *format + 1; ret = ret + ft_nputnbr(d); return (ret); }
char *ft_itoa(int c) { int i; int neg; char *str; neg = 0; if (c < 0) neg = 1; i = ft_count_digit(c); str = (char *)malloc(sizeof(*str) * ((i + neg + 1))); if (str == NULL) return (NULL); if (c == -2147483648) ft_strcpy(str, "-2147483648"); else ft_cpy_itoa(str, c, i, neg); return (str); }
void ft_conv_d(long long k, t_struct *details) { int pad; unsigned long long d; if (details->precision != -1) details->zero = 0; if (k < 0) { details->sign = 1; d = ~k + 1; } else d = (unsigned long long)k; pad = ft_count_int(d, details, 0); if (details->precision != -1) pad = ft_count_digit(pad, details, 1); ft_printf_int(d, details, 1, pad); if (details->minus) ft_printf_pad(details, pad); }
void ft_conv_hex(unsigned long long d, t_struct *details) { int pad; if (details->precision != -1) details->zero = 0; if (details->conv == 'O') details->conv = 'o'; if (details->conv == 'o') details->base = 8; pad = ft_count_hex(d, details, 1); if (details->precision != -1) pad = ft_count_digit(pad, details, 1); if (details->conv == 'p') { details->point = 1; details->conv = 'x'; details->diese = 1; details->digit = details->digit + 2; } ft_printf_hex(d, details, 1, pad); if (details->minus) ft_printf_pad(details, pad); }