static void crashlog_printf(const char *fmt, ...) { va_list args; int len = get_maxlen(); if (!len) return; va_start(args, fmt); crashlog_buf->len += vsnprintf( &crashlog_buf->data[crashlog_buf->len], len, fmt, args); va_end(args); }
void print_ls(t_list *list, t_arg *arg_list) { t_maxlen maxlen; ft_bzero(&maxlen, sizeof(t_maxlen)); get_maxlen(arg_list->arg[10], list, &maxlen); if (list != NULL && arg_list->arg[9] == 1 && S_ISDIR(((t_file *)list->content)->mode) == 1) print_total(list); while (list != NULL) { if (arg_list->arg[8] == 1) print_ino(((t_file *)list->content)->ino, maxlen.ino); if (list != NULL && arg_list->arg[9] == 1) print_ls_ext((t_file *)list->content, arg_list, &maxlen); print_name((t_file *)list->content, arg_list->arg[9]); list = list->next; } }
crashlog_printf("Time: %lu.%lu\n", (long)tv.tv_sec, (long)tv.tv_usec); if (first) { crashlog_printf("Modules:"); list_for_each_entry(m, crashlog_modules, list) { crashlog_printf("\t%s@%p+%x", m->name, m->module_core, m->core_size, m->module_init, m->init_size); } crashlog_printf("\n"); first = false; } buf = (char *)&crashlog_buf->data[crashlog_buf->len]; len = get_maxlen(); l2_cpy = min(l2, (unsigned long)len); l1_cpy = min(l1, (unsigned long)len - l2_cpy); s2_start = l2 - l2_cpy; s1_start = l1 - l1_cpy; memcpy(buf, s1 + s1_start, l1_cpy); memcpy(buf + l1_cpy, s2 + s2_start, l2_cpy); crashlog_buf->len += l1_cpy + l2_cpy; } int __init crashlog_init_fs(void) {
/* * Routine to print a table * Modified from 'ls.c' mods (BJB/83) * Arguments: * base - address of first entry * num - number of entries * d_cols - number of columns to use if > 0, "best" size if == 0 * width - max line width if not zero * prentry - address of the routine to call to print the string * length - address of the routine to call to determine the length * of string to be printed * * prtable and length are called with the address of the base and * an index */ void prtable(char **base, int num, int d_cols, int width, void (*prentry)(char **, int), int (*length)(char **, int)) { int c, j; int a, b, cols, loc, maxlen, nrows, z; int col, row; if (num == 0) return; maxlen = get_maxlen(base, num, length) + 1; if (d_cols > 0) cols = d_cols; else cols = width / maxlen; if (cols == 0) cols = NCOLS; nrows = (num - 1) / cols + 1; for (a = 1; a <= nrows; a++) { b = c = z = loc = 0; for (j = 0; j < num; j++) { c++; if (c >= a + b) break; } while (j < num) { (*prentry)(base, j); loc += (*length)(base, j); z++; b += nrows; for (j++; j < num; j++) { c++; if (c >= a + b) break; } if (j < num) { while (loc < z * maxlen) { addch(' '); loc++; } } } getyx(stdscr, row, col); move(row + 1, 0); if (row + 1 == lastline && a != nrows) { attron(A_REVERSE); printw("--More--"); attroff(A_REVERSE); do { j = inputch(); } while (j != ' ' && j != 'q' && j != 'Q'); if (j == 'q' || j == 'Q') { move(row + 1, 0); wclrtoeol(stdscr); break; } move(LIST_LINE, LIST_COL); wclrtobot(stdscr); } } refresh(); }