zip.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. typedef struct ZipHead ZipHead;
  10. enum
  11. {
  12. /*
  13. * magic numbers
  14. */
  15. ZHeader = 0x04034b50,
  16. ZCHeader = 0x02014b50,
  17. ZECHeader = 0x06054b50,
  18. /*
  19. * "general purpose flag" bits
  20. */
  21. ZEncrypted = 1 << 0,
  22. ZTrailInfo = 1 << 3, /* uncsize, csize, and crc are in trailer */
  23. ZCompPatch = 1 << 5, /* compression patched data */
  24. ZCrcPoly = 0xedb88320,
  25. /*
  26. * compression method
  27. */
  28. ZDeflate = 8,
  29. /*
  30. * internal file attributes
  31. */
  32. ZIsText = 1 << 0,
  33. /*
  34. * file attribute interpretation, from high byte of version
  35. */
  36. ZDos = 0,
  37. ZAmiga = 1,
  38. ZVMS = 2,
  39. ZUnix = 3,
  40. ZVMCMS = 4,
  41. ZAtariST = 5,
  42. ZOS2HPFS = 6,
  43. ZMac = 7,
  44. ZZsys = 8,
  45. ZCPM = 9,
  46. ZNtfs = 10,
  47. /*
  48. * external attribute flags for ZDos
  49. */
  50. ZDROnly = 0x01,
  51. ZDHidden = 0x02,
  52. ZDSystem = 0x04,
  53. ZDVLable = 0x08,
  54. ZDDir = 0x10,
  55. ZDArch = 0x20,
  56. ZHeadSize = 4 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 2,
  57. ZHeadCrc = 4 + 2 + 2 + 2 + 2 + 2,
  58. ZTrailSize = 4 + 4 + 4,
  59. ZCHeadSize = 4 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 2 + 2 + 2 + 2 + 4 + 4,
  60. ZECHeadSize = 4 + 2 + 2 + 2 + 2 + 4 + 4 + 2,
  61. };
  62. /*
  63. * interesting info from a zip header
  64. */
  65. struct ZipHead
  66. {
  67. int madeos; /* version made by */
  68. int madevers;
  69. int extos; /* version needed to extract */
  70. int extvers;
  71. int flags; /* general purpose bit flag */
  72. int meth;
  73. int modtime;
  74. int moddate;
  75. uint32_t crc;
  76. uint32_t csize;
  77. uint32_t uncsize;
  78. int iattr;
  79. uint32_t eattr;
  80. uint32_t off;
  81. char *file;
  82. };