Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

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