macbin3.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #ifndef __MCBINIII_H__
  2. #define __MCBINIII_H__
  3. /****************************************************************
  4. MacBinaryIII.h
  5. Copyright 1997 Christopher Evans (cevans@poppybank.com)
  6. Basic encoding and decoding of Macintosh files to the
  7. MacBinary III spec.
  8. ****************************************************************/
  9. /*
  10. --------------------------------------------------------------------
  11. This source is copyrighted by Christopher Evans (cevans@poppybank.com)
  12. (available at ftp://ftp.lazerware.com/MacBinaryIII_src_C.sit
  13. homepage of Leonard Rosenthol leonardr@netcom.com)
  14. I made the following changes:
  15. * renamed files MacBinaryIII.h / MacBinaryIII.c to
  16. macbin3.c / macbin3.h
  17. * removed pragmas:
  18. #pragma once
  19. #pragma options align=mac68k
  20. * added 5 macros to make the migration into other projects easier:
  21. DELETE_MACBINARY_SOURCE -> delete the macbinary file after
  22. decoding
  23. INCLUDE_ENCODE_MACBINARY -> include the encode-part of the source
  24. INCLUDE_DECODE_MACBINARY -> include the decode-part of the source
  25. INCLUDE_CRC32CALC -> include the CRC32 calculation
  26. TRACE_MACBINARY -> produce some diagnostic printouts
  27. * changed the source layout to fit into a 80 col window
  28. * removed non-ASCII characters from the sources
  29. * renamed the function CalculateCRC() to crc32() and changed
  30. the order of the arguments. So the crc32() func of the InfoZip
  31. package can be used instead.
  32. * moved module specific macros and protos to the mcbiniii.c
  33. * added comments and enhanced the documention of the MacBinary Spec
  34. * changed definition crc_table[] from short to unsigned long.
  35. * improved the HeaderIsMacBinary() function to be more restrictive
  36. The specification says:
  37. "Offsets 83 and 87, Long Word, (the length of the forks)
  38. should be in the range of 0-$007FFFFF "
  39. However, I do not understand the reason of this range. The data fork
  40. can be much larger than $007FFFFF ( 2 Gigabytes! ) and the size of the
  41. resource fork can be until 16 MByte. ZipIt and Stuffit seems to be
  42. ignore this limit.
  43. I changed this limit (see kResourceForkMaxLen), and I removed the
  44. maximum check of the data fork.
  45. Dirk Haase (d_haase@sitec.de); 05.Dec.1998
  46. --------------------------------------------------------------------
  47. MacBinary III
  48. MacBinary is a standard format for binary transfer of arbitrary Macintosh
  49. documents via a telecommunication link. It is intended for use both between
  50. Macintoshes and for use in uploading arbitrary Macintosh documents to remote
  51. systems (where it is presumed that they will be stored as an exact image of
  52. the data transmitted). It does this by combing both the resource and data
  53. forks (as well as the "Finder Info") of a standard Macintosh file into a
  54. single data fork only file that can be stored on non-Macintosh machines.
  55. The format of the header for MacBinary III is as follows:
  56. Offset Length Contents
  57. 000 Byte old version number, must be kept at zero for
  58. compatibility
  59. 001 Byte Length of filename (must be in the range 1-31)
  60. 002 1 to 63 Bytes filename (only "length" bytes are significant).
  61. 065 Long Word file type (normally expressed as four characters)
  62. 069 Long Word file creator (normally expressed as four
  63. characters)
  64. 073 Byte original Finder flags
  65. Bit 7 - isAlias.
  66. Bit 6 - isInvisible.
  67. Bit 5 - hasBundle.
  68. Bit 4 - nameLocked.
  69. Bit 3 - isStationery.
  70. Bit 2 - hasCustomIcon.
  71. Bit 1 - reserved.
  72. Bit 0 - hasBeenInited.
  73. 074 Byte zero fill, must be zero for compatibility
  74. 075 Word file's vertical position within its window.
  75. 077 Word file's horizontal position within its window.
  76. 079 Word file's window or folder ID.
  77. 081 Byte "Protected" flag (in low order bit).
  78. 082 Byte zero fill, must be zero for compatibility
  79. 083 Long Word Data Fork length (bytes, zero if no Data Fork).
  80. 087 Long Word Resource Fork length (bytes, zero if no R.F.).
  81. 091 Long Word File's creation date
  82. 095 Long Word File's "last modified" date.
  83. 099 Word length of Get Info comment to be sent after the
  84. resource fork (if implemented, see below).
  85. 101 Byte Finder Flags, bits 0-7. (Bits 8-15 are already in
  86. byte 73)
  87. Bit 7 - hasNoInits
  88. Bit 6 - isShared
  89. Bit 5 - requiresSwitchLaunch
  90. Bit 4 - ColorReserved
  91. Bits 1-3 - color
  92. Bit 0 - isOnDesk
  93. *102 Long Word signature for indentification purposes ('mBIN')
  94. *106 Byte script of file name (from the fdScript field of an
  95. fxInfo record)
  96. *107 Byte extended Finder flags (from the fdXFlags field of
  97. an fxInfo record)
  98. 108-115 Unused (must be zeroed by creators, must be
  99. ignored by readers)
  100. 116 Long Word Length of total files when packed files are
  101. unpacked. As of the writing of this document, this
  102. field has never been used.
  103. 120 Word Length of a secondary header. If this is non-zero,
  104. skip this many bytes (rounded up to the next
  105. multiple of 128). This is for future expansion
  106. only, when sending files with MacBinary, this word
  107. should be zero.
  108. *122 Byte Version number of MacBinary III that the uploading
  109. program is written for (the version is 130 for
  110. MacBinary III)
  111. 123 Byte Minimum MacBinary version needed to read this file
  112. (set this value at 129 for backwards compatibility
  113. with MacBinary II)
  114. 124 Word CRC of previous 124 bytes
  115. *These fields have changed for MacBinary III.
  116. All values are stored in normal 68000 order, with Most Significant Byte
  117. appearing first then the file. Any bytes in the header not defined above
  118. should be set to zero.
  119. */
  120. /*
  121. Public functions
  122. */
  123. OSErr EncodeMacbinaryFile(FSSpec *file);
  124. OSErr DecodeMacBinaryFile(FSSpec *source);
  125. Boolean FSpIsMacBinary(FSSpec *file);
  126. #endif