3
0

header_verbose_list.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  4. */
  5. #include "libbb.h"
  6. #include "bb_archive.h"
  7. void FAST_FUNC header_verbose_list(const file_header_t *file_header)
  8. {
  9. struct tm tm_time;
  10. struct tm *ptm = &tm_time; //localtime(&file_header->mtime);
  11. #if ENABLE_FEATURE_TAR_UNAME_GNAME
  12. char uid[sizeof(int)*3 + 2];
  13. /*char gid[sizeof(int)*3 + 2];*/
  14. char *user;
  15. char *group;
  16. localtime_r(&file_header->mtime, ptm);
  17. user = file_header->tar__uname;
  18. if (user == NULL) {
  19. sprintf(uid, "%u", (unsigned)file_header->uid);
  20. user = uid;
  21. }
  22. group = file_header->tar__gname;
  23. if (group == NULL) {
  24. /*sprintf(gid, "%u", (unsigned)file_header->gid);*/
  25. group = utoa(file_header->gid);
  26. }
  27. printf("%s %s/%s %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
  28. bb_mode_string(file_header->mode),
  29. user,
  30. group,
  31. file_header->size,
  32. 1900 + ptm->tm_year,
  33. 1 + ptm->tm_mon,
  34. ptm->tm_mday,
  35. ptm->tm_hour,
  36. ptm->tm_min,
  37. ptm->tm_sec,
  38. file_header->name);
  39. #else /* !FEATURE_TAR_UNAME_GNAME */
  40. localtime_r(&file_header->mtime, ptm);
  41. printf("%s %u/%u %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
  42. bb_mode_string(file_header->mode),
  43. (unsigned)file_header->uid,
  44. (unsigned)file_header->gid,
  45. file_header->size,
  46. 1900 + ptm->tm_year,
  47. 1 + ptm->tm_mon,
  48. ptm->tm_mday,
  49. ptm->tm_hour,
  50. ptm->tm_min,
  51. ptm->tm_sec,
  52. file_header->name);
  53. #endif /* FEATURE_TAR_UNAME_GNAME */
  54. /* NB: GNU tar shows "->" for symlinks and "link to" for hardlinks */
  55. if (file_header->link_target) {
  56. printf(" -> %s", file_header->link_target);
  57. }
  58. bb_putchar('\n');
  59. }