diff options
| author | Thorsten Töpper <atsutane@freethoughts.de> | 2025-07-26 02:09:04 +0200 |
|---|---|---|
| committer | Thorsten Töpper <atsutane@freethoughts.de> | 2025-07-26 02:09:04 +0200 |
| commit | c59f8e70b3240ff9117176b8dce6115e6b8c80e5 (patch) | |
| tree | f05d1ad07077c918984d44918454cc24fe1ab0d1 /src/output.c | |
| parent | ec46d19f2ac8c44a807a94edde75497822b3f4f9 (diff) | |
| download | dir_monitor-c59f8e70b3240ff9117176b8dce6115e6b8c80e5.tar.gz dir_monitor-c59f8e70b3240ff9117176b8dce6115e6b8c80e5.tar.bz2 | |
output: replace print_list() code with print_list_formatted('stn') call
Diffstat (limited to 'src/output.c')
| -rw-r--r-- | src/output.c | 64 |
1 files changed, 7 insertions, 57 deletions
diff --git a/src/output.c b/src/output.c index 4c660d6..1c3678d 100644 --- a/src/output.c +++ b/src/output.c @@ -487,61 +487,9 @@ inline void out_print_format_string_header(const char *format, size_t longest_fn -/* The most simple default output, formatted output is planned */ +/* The most simple default output. */ void print_list(struct list_head *list) { - struct list_head *lh = list; - struct list_node *ptr; - size_t total_size = 0; - size_t longest_fname = 0, i = 0; - - if (list == NULL) return; - if (option_sort_reverse_order) { - lh = create_list_sort_reversed(list); - /* be tolerant */ - if (lh == NULL) { - lh = list; - } - } - - longest_fname = get_longest_filename(list); - - if (option_print_header) { - out_print_format_string_header("stn", longest_fname); - } - - ptr = lh->first; - while (ptr != NULL) { - if (option_print_boxed_table) out_vsep(); - out_print_size(ptr); - if (option_print_boxed_table) out_vsep(); - out_print_time_by_option(ptr); - if (option_print_boxed_table) out_vsep(); - out_print_fname(ptr); - if (option_print_boxed_table) { - for (i=0; i<(longest_fname-strlen(ptr->fname)); i++) fputc(' ', stdout); - out_vsep(); - } - out_print_newline(); - - /* Linux: Neither man stat(2) nor stat(3type) declare why struct stat field st_size - * would get a negative value assigned. The type off_t masks __off_t or __off64_t - * which themselves mask bits/types.h __SLONGWORD_TYPE on x86_64 that's long int. - * Haven't checked libc/kernel code but regardless why, I assume that a negative - * value would imply a corrupt filesystem. - */ - total_size += (ptr->ln_stat.st_size>0) ? (unsigned long int)ptr->ln_stat.st_size : 0; - ptr = ptr->next; - } - if (option_print_boxed_table && global_sep_line != NULL) { - fputs(global_sep_line, stdout); - } else { - fputc_all_cols('=', stdout); - } - out_print_newline(); - printf("\nTotal size: %lu %s\n", ((total_size>1024) ? total_size/1024 : total_size), - ((total_size >= 1024) ? "kB" : "")); - - if (lh != list) destroy_list(lh); + print_list_formatted("stn", list); } @@ -604,10 +552,12 @@ void print_list_formatted(const char *format, struct list_head *list) { switch (format[i]) { case 'n': out_print_fname(ptr); - for (j=0; j<(longest_fname - strlen(ptr->fname)); j++) { - fputc(' ', stdout); + if (option_print_boxed_table) { + for (j=0; j<(longest_fname - strlen(ptr->fname)); j++) { + fputc(' ', stdout); + } + out_vsep(); } - if (option_print_boxed_table) { out_vsep(); } break; case 's': out_print_size(ptr); |
