tarfn.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * tarfn.h - tar archive extraction functions
  4. *
  5. * Copyright © 1995 Bruce Perens
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef LIBDPKG_TARFN_H
  21. #define LIBDPKG_TARFN_H
  22. #include <sys/types.h>
  23. #include <unistd.h>
  24. #include <stdlib.h>
  25. enum tar_format {
  26. tar_format_old,
  27. tar_format_gnu,
  28. tar_format_ustar,
  29. tar_format_pax,
  30. };
  31. enum TarFileType {
  32. NormalFile0 = '\0', /* For compatibility with decades-old bug */
  33. NormalFile1 = '0',
  34. HardLink = '1',
  35. SymbolicLink = '2',
  36. CharacterDevice = '3',
  37. BlockDevice = '4',
  38. Directory = '5',
  39. FIFO = '6',
  40. GNU_LONGLINK = 'K',
  41. GNU_LONGNAME = 'L'
  42. };
  43. typedef enum TarFileType TarFileType;
  44. struct TarInfo {
  45. enum tar_format format; /* Tar archive format. */
  46. void * UserData; /* User passed this in as argument */
  47. char * Name; /* File name */
  48. mode_t Mode; /* Unix mode, including device bits. */
  49. size_t Size; /* Size of file */
  50. time_t ModTime; /* Last-modified time */
  51. TarFileType Type; /* Regular, Directory, Special, Link */
  52. char * LinkName; /* Name for symbolic and hard links */
  53. dev_t Device; /* Special device for mknod() */
  54. uid_t UserID; /* Numeric UID */
  55. gid_t GroupID; /* Numeric GID */
  56. };
  57. typedef struct TarInfo TarInfo;
  58. typedef int (*TarReadFunction)(void * userData, char * buffer, int length);
  59. typedef int (*TarFunction)(TarInfo * h);
  60. struct TarFunctions {
  61. TarReadFunction Read;
  62. TarFunction ExtractFile;
  63. TarFunction MakeDirectory;
  64. TarFunction MakeHardLink;
  65. TarFunction MakeSymbolicLink;
  66. TarFunction MakeSpecialFile;
  67. };
  68. typedef struct TarFunctions TarFunctions;
  69. int TarExtractor(void *userData, const TarFunctions *functions);
  70. #endif