packhead.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /******************************************************************************
  2. *
  3. * project name: TIGCC Tools Suite
  4. * file name: packhead.h
  5. * initial date: 14/08/2000
  6. * author: thomas.nussbaumer@gmx.net
  7. * description: header definition of compressed data
  8. *
  9. ******************************************************************************/
  10. /*
  11. This file is part of the TIGCC Tools Suite.
  12. This file is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU Lesser General Public
  14. License as published by the Free Software Foundation; either
  15. version 2.1 of the License, or (at your option) any later version.
  16. As a special exception, UNMODIFIED copies of some TIGCC Tools Suite utilities
  17. may also be redistributed or sold without source code, for any purpose. (The
  18. Lesser General Public License restrictions do apply in other respects; for
  19. example, they cover modification of the program.) Please refer to the main
  20. source file for the individual utility as to whether this is the case for a
  21. particular tool. This exception notice must be removed on modified copies of
  22. this file.
  23. This program is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with this library; if not, write to the Free Software
  29. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  30. */
  31. #ifndef __PACKHEAD_H__
  32. #define __PACKHEAD_H__
  33. #define MAGIC_CHAR1 'T'
  34. #define MAGIC_CHAR2 'P'
  35. #define MAX_RLE_ENTRIES 31
  36. // size = 16 bytes
  37. typedef struct {
  38. unsigned char origsize_lo; // original size lowbyte
  39. unsigned char origsize_hi; // original size highbyte
  40. unsigned char magic1; // must be equal to MAGIC_CHAR1
  41. unsigned char magic2; // must be equal to MAGIC_CHAR2
  42. unsigned char compsize_lo; // compressed size lowbyte
  43. unsigned char compsize_hi; // compressed size lowbyte
  44. unsigned char esc1; // escape >> (8-escBits)
  45. unsigned char notused3;
  46. unsigned char notused4;
  47. unsigned char esc2; // escBits
  48. unsigned char gamma1; // maxGamma + 1
  49. unsigned char gamma2; // (1<<maxGamma)
  50. unsigned char extralz; // extraLZPosBits
  51. unsigned char notused1;
  52. unsigned char notused2;
  53. unsigned char rleentries; // rleUsed
  54. } PackedHeader;
  55. #define GetUnPackedSize(p) (unsigned int)((p)->origsize_lo | ((p)->origsize_hi << 8))
  56. #define IsPacked(p) ((p)->magic1 == MAGIC_CHAR1 && (p)->magic2 == MAGIC_CHAR2)
  57. typedef struct {
  58. unsigned char value[MAX_RLE_ENTRIES];
  59. } RLEEntries;
  60. #endif
  61. //#############################################################################
  62. //###################### NO MORE FAKES BEYOND THIS LINE #######################
  63. //#############################################################################
  64. //
  65. //=============================================================================
  66. // Revision History
  67. //=============================================================================
  68. //
  69. // Revision 1.3 2000/08/20 15:24:28 Thomas Nussbaumer
  70. // macros to get unpacked size and to check if packed added
  71. //
  72. // Revision 1.2 2000/08/16 23:08:55 Thomas Nussbaumer
  73. // magic characters changed to TP ... t(igcc tools) p(acked file)
  74. //
  75. // Revision 1.1 2000/08/14 22:49:57 Thomas Nussbaumer
  76. // initial version
  77. //
  78. //