home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_02 / 1002056a < prev    next >
Text File  |  1991-12-12  |  4KB  |  125 lines

  1.  
  2.  
  3.         /******************************************************
  4.         *      
  5.         *       file d:\lsu\huffman.h
  6.         *
  7.         *       Functions: This file contains no functions. It
  8.         *           contains declarations of the data 
  9.         *           structures used by the hoffman coding 
  10.         *           program.
  11.         *
  12.         *       Purpose: To declare data structures.
  13.         *
  14.         *       Modifications:
  15.         *
  16.         *******************************************************/
  17.  
  18. #include "d:\c600\include\stdio.h"
  19. #include "d:\c600\include\graph.h"
  20. #include "d:\c600\include\io.h"
  21. #include "d:\c600\include\fcntl.h"
  22. #include "d:\c600\include\dos.h"
  23. #include "d:\c600\include\math.h"
  24. #include "d:\c600\include\sys\types.h"
  25. #include "d:\c600\include\sys\stat.h"
  26. #include "d:\lsu\iptype.h"
  27.  
  28.  
  29.  
  30.  
  31. #define LENGTH      256  /* length of item array */
  32. #define LLENGTH      25  /* length of includes array */
  33. #define ONE         '1'
  34. #define ZERO        '0'
  35. #define OTHER       '2'
  36. #define CODE_LENGTH  16  /* max # of bits for a character */
  37. #define IB_LENGTH   150
  38. #define OB_LENGTH  1000
  39. #define END_FILE    254
  40.  
  41.    /* The following constants are for setting, clearing, and
  42.       testing bits in a char buffer */
  43.  
  44. #define SET_BIT_SEVEN   1
  45. #define SET_BIT_SIX     2
  46. #define SET_BIT_FIVE    4
  47. #define SET_BIT_FOUR    8
  48. #define SET_BIT_THREE  16
  49. #define SET_BIT_TWO    32
  50. #define SET_BIT_ONE    64
  51. #define SET_BIT_ZERO  128
  52.  
  53. #define CLEAR_BIT_ZERO   127
  54. #define CLEAR_BIT_ONE    191
  55. #define CLEAR_BIT_TWO    223
  56. #define CLEAR_BIT_THREE  239
  57. #define CLEAR_BIT_FOUR   247
  58. #define CLEAR_BIT_FIVE   251
  59. #define CLEAR_BIT_SIX    253
  60.  
  61. #define CLEAR_BIT_SEVEN  254
  62.  
  63.  
  64.  
  65.      /************************************************
  66.      *
  67.      *   This is the item_struct which defines the
  68.      *   item_array used throughout the Huffman 
  69.      *   program.
  70.      *
  71.      *      indicator - shows whether or not to process
  72.      *         an element of the item array.  The values
  73.      *         can be D=disable or E=enalble.
  74.      *
  75.      *      character - the original character in the big
  76.      *         file.  This can be any character from
  77.      *         decimal 0 to 255.
  78.      *
  79.      *      count - counts the number of times a character
  80.      *         appears in the original big file.
  81.      *
  82.      *      coded[CODE_LENGTH] - this holds the code for a
  83.      *         character.  It is of the form 101101222222.
  84.      *         The '2' is the OTHER character which means
  85.      *         it is not used. e.g. if code=10122222, then
  86.      *         the code is 101 and the 22222 are dummy
  87.      *         characters.
  88.      *
  89.      *      includes - this is a number that links the item
  90.      *         to any other item with which it has been 
  91.      *         combined.
  92.      *
  93.      *************************************************/
  94.  
  95. struct item_struct{
  96.    char   indicator;
  97.    char   character;
  98.    long   count;
  99.    char   coded[CODE_LENGTH];
  100.    short  includes[LLENGTH];
  101. };
  102.  
  103.  
  104.      /************************************************
  105.      *
  106.      *   This is the header_struct.  We'll save this
  107.      *   at the beginning of the compressed file.  It
  108.      *   is smaller than the item_struct and will save
  109.      *   some space in the compressed file.
  110.      *
  111.      *************************************************/
  112.  
  113. struct short_item{
  114.    char   character;
  115.    char   coded[CODE_LENGTH];
  116. };
  117.  
  118.  
  119. struct header_struct{
  120.    struct short_item items[LENGTH];
  121.  
  122.    long   in_file_length;
  123. };
  124. /* End of File */
  125.