pgtar.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pgtar.h
  4. * Functions for manipulating tarfile datastructures (src/port/tar.c)
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/include/pgtar.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef PG_TAR_H
  15. #define PG_TAR_H
  16. #define TAR_BLOCK_SIZE 512
  17. enum tarError
  18. {
  19. TAR_OK = 0,
  20. TAR_NAME_TOO_LONG,
  21. TAR_SYMLINK_TOO_LONG
  22. };
  23. extern enum tarError tarCreateHeader(char *h, const char *filename,
  24. const char *linktarget, pgoff_t size,
  25. mode_t mode, uid_t uid, gid_t gid,
  26. time_t mtime);
  27. extern uint64 read_tar_number(const char *s, int len);
  28. extern void print_tar_number(char *s, int len, uint64 val);
  29. extern int tarChecksum(char *header);
  30. /*
  31. * Compute the number of padding bytes required for an entry in a tar
  32. * archive. We must pad out to a multiple of TAR_BLOCK_SIZE. Since that's
  33. * a power of 2, we can use TYPEALIGN().
  34. */
  35. static inline size_t
  36. tarPaddingBytesRequired(size_t len)
  37. {
  38. return TYPEALIGN(TAR_BLOCK_SIZE, len) - len;
  39. }
  40. #endif