Initial public busybox upstream commit
[busybox4maemo] / archival / libunarchive / header_verbose_list.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
4  */
5
6 #include "libbb.h"
7 #include "unarchive.h"
8
9 void header_verbose_list(const file_header_t *file_header)
10 {
11         struct tm *mtime = localtime(&(file_header->mtime));
12
13 #if ENABLE_FEATURE_TAR_UNAME_GNAME
14         char uid[8];
15         char gid[8];
16         char *user = file_header->uname;
17         char *group = file_header->gname;
18
19         if (user == NULL) {
20                 snprintf(uid, sizeof(uid), "%u", (unsigned)file_header->uid);
21                 user = uid;
22         }
23         if (group == NULL) {
24                 snprintf(gid, sizeof(gid), "%u", (unsigned)file_header->gid);
25                 group = gid;
26         }
27         printf("%s %s/%s %9u %4u-%02u-%02u %02u:%02u:%02u %s",
28                 bb_mode_string(file_header->mode),
29                 user,
30                 group,
31                 (unsigned int) file_header->size,
32                 1900 + mtime->tm_year,
33                 1 + mtime->tm_mon,
34                 mtime->tm_mday,
35                 mtime->tm_hour,
36                 mtime->tm_min,
37                 mtime->tm_sec,
38                 file_header->name);
39 #else /* !FEATURE_TAR_UNAME_GNAME */
40         printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
41                 bb_mode_string(file_header->mode),
42                 file_header->uid,
43                 file_header->gid,
44                 file_header->size,
45                 1900 + mtime->tm_year,
46                 1 + mtime->tm_mon,
47                 mtime->tm_mday,
48                 mtime->tm_hour,
49                 mtime->tm_min,
50                 mtime->tm_sec,
51                 file_header->name);
52 #endif /* FEATURE_TAR_UNAME_GNAME */
53
54         if (file_header->link_target) {
55                 printf(" -> %s", file_header->link_target);
56         }
57         bb_putchar('\n');
58 }