int major_max_len(t_llist *root, int ret, t_param *param) { char *tmp; t_list *list; t_stat s; char *str; list = root->start; while (list != NULL) { tmp = ft_strjoin(root->path, "/"); str = ft_strjoin(tmp, list->str); if (lstat(str, &s) == 0 && file_ok(list, param) == 1) { if (S_ISCHR(s.st_mode) || S_ISBLK(s.st_mode)) { if (ft_nbrlen(major(s.st_rdev)) > ret) ret = ft_nbrlen(major(s.st_rdev)); } } list = list->next; ft_strdel(&str); ft_strdel(&tmp); } return (ret); }
int ft_check_nbr(t_env *env) { /* 4 ok ft_putstr("FORMAT=="); ft_putchar(FORMAT[IFOR]); ft_putstr("<<<\n"); */ if (FORMAT[IFOR] >= '1' && FORMAT[IFOR] <= '9' ) { if (FNDFLAGS[9] == 1) IFOR = IFOR + ft_nbrlen((NBRPREC = ft_atoi(&FORMAT[IFOR]))); else IFOR = IFOR + ft_nbrlen((NBR = ft_atoi(&FORMAT[IFOR]))); /*nbr 4 ok ft_putstr("NBR=="); ft_putnbr(NBR); ft_putstr("<<<"); */ /* 1 ok ft_putstr("NBRLEN=="); ft_putnbr(ft_nbrlen(NBR)); ft_putstr("<<<"); */ //ft_putstr(">>>>FIN<<<<"); return (1); } return (0); }
void conv_i(t_spec *spec, t_print *print) { int i; int j; intmax_t p; p = get_param(spec->hljz, print->ap); if (p >= -9223372036854775807) { i = (p < 0) || (spec->flags & 3); j = !(spec->prec || p) ? 0 : (ft_max(spec->prec + i, ft_nbrlen(ft_abs(p)) + i)); ++spec->mfw; (spec->flags & E_ZERO) ? apply_plusspace(print, spec, p >= 0) : --spec->mfw; (spec->flags & E_ZERO && p > 0) ? --spec->prec : 0; (!(spec->flags & E_DASH)) ? apply_mfw(print, spec, spec->mfw - j) : 0; !(spec->flags & E_ZERO) ? apply_plusspace(print, spec, p >= 0) : 0; apply_numprec(print, spec, ft_nbrlen(ft_abs(p))); (!spec->prec && !p) ? 0 : ft_sitoa(p, print, ft_nbrlen(ft_abs(p))); j = (spec->flags & 3) && (p > 0); (spec->flags & E_DASH) ? apply_mfw(print, spec, spec->mfw + (p >= 0) - j) : 0; } }
static void before_nbr(t_env *env) { if (FNDFLAGS[1] == -1 && NBR != -1 && NBR > ft_nbrlen((int)ARG)) { if (FNDFLAGS[3] == 1 && (int)ARG > 0) NBR = NBR - 1; NBR = NBR - ft_nbrlen((int)ARG); RET = RET + ft_putspace(NBR); } else if (FNDFLAGS[4] == 1 && FNDFLAGS[3] == -1 && ((int)ARG >= 0)) { RET = RET + ft_putchar(' '); NBR = NBR - 1; } if ((FNDFLAGS[3] == 1) && ((int)ARG >= 0)) { if (env->putneg != 1) { RET = RET + ft_putchar('+'); NBR = NBR - 1; } } if (NBR != -1 && NBR > ft_nbrlen((int)ARG)) { if (FNDFLAGS[1] == 1 && FNDFLAGS[2] != 1) ft_putzero(env); } }
void ft_print_grid_small(int g_size, int *grid) { int i; int j; int k; i = 1; k = ft_nbrlen(ft_nbrlargest(grid, g_size * g_size)); while ((i - 1) < (g_size * g_size)) { j = 0; if (grid[i - 1] != 0) { printw(" %d ", grid[i - 1]); while (j++ < k - ft_nbrlen(grid[i - 1])) printw(" "); } else { while (j++ < k + 2) printw(" "); } (i % g_size == 0 && i != 0) ? printw("\n") : printw("|"); i++; } }
void storage_maj_min(t_max_l *len, t_stat *st) { size_t maj; size_t min; maj = ft_nbrlen(major(st->st_rdev)); min = ft_nbrlen(minor(st->st_rdev)); len->major = ((maj > len->major) ? maj : len->major); len->minor = ((min > len->minor) ? min : len->minor); }
static t_size max_link_len(t_list *files) { t_list *tmp; t_size padding; tmp = files; padding = 0; while (tmp) { if (padding < ft_nbrlen(LINK(tmp))) padding = ft_nbrlen(LINK(tmp)); tmp = tmp->next; } return (padding); }
void print_flag_min(t_flags *flags, int *tab, int c, va_list list) { int size; size = (c >= 0) ? ft_nbrlen(c) : ft_nbrlen(c) + 1; if (flags->width && flags->width > size && ((!flags->precision || flags->precision <= ft_nbrlen(c)) || (flags->precision > ft_nbrlen(c) && flags->precision < flags->width))) print_width_prec_rev(flags, tab, c); else { flags->o_min = 0; arg_is_int_flags(flags, list, tab, c); } }
int flag_number(t_pfflags *flags, const char *format, va_list ap) { flags->nformat = atoi(format); return (ft_nbrlen((int64_t)flags->nformat, 10)); (void)ap; }
char *ft_itoa(int n) { int len; int neg; int divide; char *str; len = 0; if (n != -2147483648) { neg = 0; divide = 1; if (n < 0) { n *= -1; neg = 1; len++; } len = ft_nbrlen(n, ÷); str = ft_transcription(n, divide, len, neg); } else { str = ft_strnew(11); str = ft_strcpy(str, "-2147483648"); } return (str); }
char *ft_itoa(int n) { int i; unsigned int x; char *buff; int neg; if (!(buff = ft_strnew(ft_nbrlen(n)))) return (NULL); x = n; if ((neg = n) < 0) x = -n; i = 0; if (x == 0) buff[i++] = '0'; while (x > 0) { buff[i++] = x % 10 + '0'; x /= 10; } if (neg < 0) buff[i++] = '-'; buff[i] = '\0'; ft_strrev(buff); return (buff); }
char *ft_itoa(int n) { char *nb; int i; int j; int len; int sign; i = 0; len = ft_nbrlen(n); sign = n < 0 ? -1 : 1; n < 0 ? n = -n : 0; n < 0 ? len++ : 0; j = (sign < 0) ? len + 1 : len; nb = ft_strnew(len + 2); if (n < -2147483647 || n == 0) return (except(n, nb)); nb[j--] = '\0'; while (i < len) { nb[j--] = n % 10 + '0'; n /= 10; i++; } (sign == -1) ? nb[j] = '-' : 0; return (nb); }
char *ft_itoa(int n) { int nlen; int sign; char *str; nlen = ft_nbrlen(n); sign = ft_nbrsign(n); if (!(str = (char *)malloc(sizeof(char) * (nlen + sign + 1)))) return (NULL); if (str) { str = str + nlen + sign; *str = '\0'; if (n < 0) n = -n; if (n == 0) *--str = '0'; while (n != 0) { *--str = ft_abs(n % 10) + '0'; n = n / 10; } if (sign) *--str = '-'; } return (str); }
int flag_number(t_pfflags *flags, const char *format, va_list ap) { flags->nformat = ft_atoi(format); (void)ap; return ((signed)ft_nbrlen((intmax_t)flags->nformat, 10)); }
void update_ld(int *indent, int stat_obj, int calculate_int_len) { if (calculate_int_len == 1) stat_obj = ft_nbrlen(stat_obj); if (stat_obj > *indent) *indent = stat_obj; }
int *ft_stritab(char *str) { int i; int i_max; int *itab; char flag; flag = 0; itab = NULL; while (i = 0, flag < 2) { i_max = 0; while (str[i]) if (ft_isnbr(&(str[i]))) { i_max++; if (flag) itab[i_max] = ft_atoi(&(str[i])); i += ft_nbrlen(&(str[i])); } else i++; if (!flag++ && i_max) itab = init_itab(i_max); } return (itab); }
char *ft_printf_i(void *n) { int sign; char *buff; long int len; long int i; long int nb; nb = (long int)(int)(long int)n; sign = (nb < 0 ? 'n' : 'p'); nb = (nb < 0 ? -nb : nb); len = ft_nbrlen(nb); buff = (sign == 'n' ? ft_strnew(len + 1) : ft_strnew(len)); if (buff == NULL) return (NULL); i = 0; while (i < len) { buff[i] = nb % 10 + '0'; nb = nb / 10; i++; } buff[i] = (sign == 'n' ? '-' : 0); ft_strrev(buff); return (buff); }
char *ft_itoa(int n) { size_t l[2]; int i; char *str; i = 1; l[1] = 0; l[0] = ft_nbrlen(n); str = (char *)malloc(sizeof(char) * (l[0] + 1)); if (!str) return (NULL); str[l[0]] = '\0'; if (n < 0) { str[0] = '-'; l[1]++; i = -1; } while (l[0] > l[1]) { str[l[0] - 1] = ((n % 10) * i) + 48; n = n / 10; l[0]--; } return (str); }
char *ft_itoa(int n) { char *s; size_t len; if (n == -2147483648) return (ft_strdup("-2147483648")); if (n == 0) return (ft_strdup("0")); len = ft_nbrlen(n); if (!(s = ft_strnew(len + 1))) return (NULL); if (n < 0) { s[0] = '-'; n *= -1; } s[len] = '\0'; while (n >= 10) { s[len - 1] = n % 10 + '0'; n = n / 10; len--; } s[len - 1] = n + '0'; return (s); }
char *ft_itoa(int n) { int i; int j; int len; char *str; char *itoa; len = ft_nbrlen(n, 10); i = 0; j = 0; str = ft_strnew(len); if (!str) return (NULL); if (n < 0) str[i++] = '-'; itoa = ft_itoa_base_ll(n, 10); while (itoa[j] != '\0') { str[i + j] = itoa[j]; j++; } str[i + j] = '\0'; ft_memdel((void **)&itoa); return (str); }
int uid_max_len(t_llist *root, int ret, int temp, t_param *param) { char *tmp; t_list *list; t_stat s; char *str; list = root->start; param->list_total = 0; while (list != NULL) { tmp = ft_strjoin(root->path, "/"); str = ft_strjoin(tmp, list->str); if (lstat(str, &s) == 0 && file_ok(list, param) == 1) { temp = ft_nbrlen(s.st_uid); param->list_total += s.st_blocks / 2; if (temp > ret) ret = temp; } list = list->next; ft_strdel(&str); ft_strdel(&tmp); } return (ret); }
float ft_atof(const char *str) { float res; float dot_part; size_t len; if (!str) return (0); while (*str == ' ' || *str == '\f' || *str == '\n') str++; res = ft_atoi(str); if (*str == '+' || *str == '-') str++; while (*str <= '9' && *str >= '0') str++; if (*str == '.' && str[1] <= '9' && str[1] >= '0') { dot_part = ft_atoi(str + 1); len = ft_nbrlen(str + 1); while (len--) dot_part /= 10.0; res += dot_part; } return (res); }
static char *ft_putnbr_char(long f) { char *tmp; int i; int negative; negative = 0; i = ft_nbrlen(f); tmp = (char *)malloc(sizeof(tmp) * i + 1); if (tmp == NULL) return (NULL); tmp[i] = '\0'; if (f < 0) { negative = 1; f = f * (-1); } while (i > 0) { tmp[i - 1] = (f % 10) + '0'; f = f / 10; i--; } if (negative == 1) tmp[i] = '-'; return (tmp); }
int fonct_d(t_env *env) { ARGLEN = ft_nbrlen((int)ARG); if (FNDFLAGS[2] == 1) FNDFLAGS[1] = -1; if (FNDFLAGS[9] == 1) ft_flag_prec(env); else { if (FNDFLAGS[2] != 1) before_nbr(env); if ((int)ARG >= 0 && FNDFLAGS[3] == 1 && FNDFLAGS[2] == 1) { ARGLEN = ARGLEN + 1; RET = RET + ft_putchar('+'); } if (env->putneg == 1) ft_which_putnbrnegd(env); else ft_which_putnbrd(env); if (FNDFLAGS[2] == 1) after_nbr(env); } return (1); }
static void storage_max_len(t_max_l *len, t_stat *st, t_flag *flg) { size_t m_ino; size_t m_nlnk; size_t m_fsize; m_ino = ft_nbrlen(st->st_ino); m_nlnk = ft_nbrlen(st->st_nlink); m_fsize = ft_nbrlen(st->st_size); if (flg->i == TRUE) len->ino = ((m_ino > len->ino) ? m_ino : len->ino); len->n_lnk = ((m_nlnk > len->n_lnk) ? m_nlnk : len->n_lnk); storage_m_len_id(len, st, flg->g); if (((S_ISBLK(st->st_mode)) == TRUE || (S_ISCHR(st->st_mode)) == TRUE)) storage_maj_min(len, st); else len->f_size = ((m_fsize > len->f_size) ? m_fsize : len->f_size); }
int count_spaces(long long info, size_t maxlength) { size_t length; length = ft_nbrlen(info); if (length > maxlength) maxlength = length; return (maxlength); }
static void print_ino(int ino, int ino_maxlen) { int i; i = ino_maxlen - ft_nbrlen(ino); while (i-- > 0) ft_putchar(' '); ft_putnbr(ino); ft_putchar(' '); }
void ft_cut_init_o_short(t_cut *t_v, t_var **var, char **str, int count[3]) { (*t_v).k = 0; (*t_v).c = 't'; (*t_v).nbr = ft_nbrlen(var[count[2]]->u_short); (*t_v).flag = check_flag(str, count, &(*t_v).nbr, &(*t_v).c); (*t_v).l = ft_atoi_spec_o(str[count[0]]); str[count[0]] = ft_ntoa_base_un(var[count[2]]->u_short, "01234567"); (*t_v).nbr = ft_strlen(str[count[0]]); }
char *ft_itoa(int n) { char *str; int x; x = 0; str = ft_memalloc((n >= 0 ? ft_nbrlen(n) + 1 : ft_nbrlen(n) + 2)); if (!str) return (NULL); while (n / 10) { str[x] = abs(n % 10) + '0'; n /= 10; x++; } str[x] = abs(n % 10) + '0'; if (n < 0) str[x + 1] = '-'; return (ft_strrev(str)); }
void ft_cut_flag_d6_1(t_cut *t_v, t_var **var, char **str, int count[3]) { if (var[count[2]]->entier < 0) str[count[0]] = ft_strsub(str[count[0]], 1, ft_nbrlen(var[count[2]]->entier) + 1); while ((*t_v).k < (*t_v).flag - (*t_v).nbr - (*t_v).neg) { str[count[0]] = ft_strjoin("0", str[count[0]]); (*t_v).k++; } if (var[count[2]]->entier < 0) str[count[0]] = ft_strjoin("-", str[count[0]]); }