home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_02 / cujhuff.h < prev    next >
Text File  |  1991-12-09  |  4KB  |  122 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. #define CLEAR_BIT_SEVEN  254
  61.  
  62.  
  63.  
  64.      /************************************************
  65.      *
  66.      *   This is the item_struct which defines the
  67.      *   item_array used throughout the Huffman 
  68.      *   program.
  69.      *
  70.      *      indicator - shows whether or not to process
  71.      *         an element of the item array.  The values
  72.      *         can be D=disable or E=enalble.
  73.      *
  74.      *      character - the original character in the big
  75.      *         file.  This can be any character from
  76.      *         decimal 0 to 255.
  77.      *
  78.      *      count - counts the number of times a character
  79.      *         appears in the original big file.
  80.      *
  81.      *      coded[CODE_LENGTH] - this holds the code for a
  82.      *         character.  It is of the form 101101222222.
  83.      *         The '2' is the OTHER character which means
  84.      *         it is not used. e.g. if code=10122222, then
  85.      *         the code is 101 and the 22222 are dummy
  86.      *         characters.
  87.      *
  88.      *      includes - this is a number that links the item
  89.      *         to any other item with which it has been 
  90.      *         combined.
  91.      *
  92.      *************************************************/
  93.  
  94. struct item_struct{
  95.    char   indicator;
  96.    char   character;
  97.    long   count;
  98.    char   coded[CODE_LENGTH];
  99.    short  includes[LLENGTH];
  100. };
  101.  
  102.  
  103.      /************************************************
  104.      *
  105.      *   This is the header_struct.  We'll save this
  106.      *   at the beginning of the compressed file.  It
  107.      *   is smaller than the item_struct and will save
  108.      *   some space in the compressed file.
  109.      *
  110.      *************************************************/
  111.  
  112. struct short_item{
  113.    char   character;
  114.    char   coded[CODE_LENGTH];
  115. };
  116.  
  117.  
  118. struct header_struct{
  119.    struct short_item items[LENGTH];
  120.    long   in_file_length;
  121. };
  122.