header_verbose_list.c 1.4 KB

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