home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / oslib / h / squash < prev    next >
Encoding:
Text File  |  1994-09-14  |  7.3 KB  |  239 lines

  1. #ifndef squash_H
  2. #define squash_H
  3.  
  4. /* C header file for Squash
  5.  * written by DefMod (Sep  7 1994) on Wed Sep 14 13:17:59 1994
  6.  * Copyright © Acorn Computers Ltd, 1994
  7.  */
  8.  
  9. /*************************************************************************
  10.  * This source file was written by Acorn Computers Limited. It is part   *
  11.  * of the OSLib library for writing applications for RISC OS. It may be  *
  12.  * used freely in the creation of programs for RISC OS.                  *
  13.  *************************************************************************/
  14.  
  15. #ifndef types_H
  16.    #include "types.h"
  17. #endif
  18.  
  19. #ifndef os_H
  20.    #include "os.h"
  21. #endif
  22.  
  23. /**********************************
  24.  * SWI names and SWI reason codes *
  25.  **********************************/
  26. #undef  Squash_CompressReturnSizes
  27. #define Squash_CompressReturnSizes              0x42700
  28. #undef  XSquash_CompressReturnSizes
  29. #define XSquash_CompressReturnSizes             0x62700
  30. #undef  Squash_Compress
  31. #define Squash_Compress                         0x42700
  32. #undef  XSquash_Compress
  33. #define XSquash_Compress                        0x62700
  34. #undef  Squash_DecompressReturnSizes
  35. #define Squash_DecompressReturnSizes            0x42701
  36. #undef  XSquash_DecompressReturnSizes
  37. #define XSquash_DecompressReturnSizes           0x62701
  38. #undef  Squash_Decompress
  39. #define Squash_Decompress                       0x42701
  40. #undef  XSquash_Decompress
  41. #define XSquash_Decompress                      0x62701
  42.  
  43. /************************************
  44.  * Structure and union declarations *
  45.  ************************************/
  46. typedef struct squash_file                      squash_file;
  47.  
  48. /********************
  49.  * Type definitions *
  50.  ********************/
  51. struct squash_file
  52.    {  bits id;
  53.       int size;
  54.       bits load_addr;
  55.       bits exec_addr;
  56.       int reserved;
  57.       byte data [UNKNOWN];
  58.    };
  59.  
  60. #define squash_FILE(N) \
  61.    struct \
  62.       {  bits id; \
  63.          int size; \
  64.          bits load_addr; \
  65.          bits exec_addr; \
  66.          int reserved; \
  67.          byte data [N]; \
  68.       }
  69.  
  70. #define squash_SIZEOF_FILE(N) \
  71.    (offsetof (squash_file, data) + \
  72.          (N)*sizeof ((squash_file *) NULL)->data)
  73.  
  74. /************************
  75.  * Constant definitions *
  76.  ************************/
  77. #define error_SQUASH_BAD_ADDRESS                0x921u
  78. #define error_SQUASH_BAD_INPUT                  0x922u
  79. #define error_SQUASH_BAD_WORKSPACE              0x923u
  80. #define error_SQUASH_BAD_PARAMETERS             0x924u
  81. #define squash_FILE_TYPE                        0xFCAu
  82. #define squash_INPUT_NOT_START                  0x1u
  83. #define squash_INPUT_NOT_END                    0x2u
  84. #define squash_INPUT_ALL_PRESENT                0x4u
  85. #define squash_OUTPUT_END                       0x1u
  86. #define squash_OUTPUT_MORE                      0x2u
  87. #define squash_OUTPUT_NO_MEM                    0x4u
  88.  
  89. /*************************
  90.  * Function declarations *
  91.  *************************/
  92.  
  93. #ifdef __cplusplus
  94.    extern "C" {
  95. #endif
  96.  
  97. /*************************************************************
  98.  * NOTE: The following functions provide direct access to    *
  99.  *       the SWI's noted in the function description.        *
  100.  *       Please read the relevant PRM section for more       *
  101.  *       information on their input/output parameters.       *
  102.  *************************************************************/
  103.  
  104. /* ------------------------------------------------------------------------
  105.  * Function:      squash_compress_return_sizes()
  106.  *
  107.  * Description:   Returns the workspace and maximum output sizes for
  108.  *                Squash_Compress
  109.  *
  110.  * Input:         input_size - value of R1 on entry
  111.  *
  112.  * Output:        workspace_size - value of R0 on exit
  113.  *                output_size - value of R1 on exit
  114.  *
  115.  * Other notes:   Calls SWI 0x42700 with R0 = 0x8.
  116.  */
  117.  
  118. extern os_error *xsquash_compress_return_sizes (int input_size,
  119.       int *workspace_size,
  120.       int *output_size);
  121. extern void squash_compress_return_sizes (int input_size,
  122.       int *workspace_size,
  123.       int *output_size);
  124.  
  125. /* ------------------------------------------------------------------------
  126.  * Function:      squash_compress()
  127.  *
  128.  * Description:   Provides general compression of a lossless nature
  129.  *
  130.  * Input:         input_status - value of R0 on entry
  131.  *                workspace - value of R1 on entry
  132.  *                input - value of R2 on entry
  133.  *                input_size - value of R3 on entry
  134.  *                output - value of R4 on entry
  135.  *                output_size - value of R5 on entry
  136.  *
  137.  * Output:        output_status - value of R0 on exit
  138.  *                input_out - value of R2 on exit
  139.  *                input_spare - value of R3 on exit
  140.  *                output_out - value of R4 on exit
  141.  *                output_spare - value of R5 on exit
  142.  *
  143.  * Other notes:   Calls SWI 0x42700.
  144.  */
  145.  
  146. extern os_error *xsquash_compress (bits input_status,
  147.       void *workspace,
  148.       byte *input,
  149.       int input_size,
  150.       byte *output,
  151.       int output_size,
  152.       bits *output_status,
  153.       byte **input_out,
  154.       int *input_spare,
  155.       byte **output_out,
  156.       int *output_spare);
  157. extern void squash_compress (bits input_status,
  158.       void *workspace,
  159.       byte *input,
  160.       int input_size,
  161.       byte *output,
  162.       int output_size,
  163.       bits *output_status,
  164.       byte **input_out,
  165.       int *input_spare,
  166.       byte **output_out,
  167.       int *output_spare);
  168.  
  169. /* ------------------------------------------------------------------------
  170.  * Function:      squash_decompress_return_sizes()
  171.  *
  172.  * Description:   Returns the workspace and maximum output sizes for
  173.  *                Squash_Decompress
  174.  *
  175.  * Input:         input_size - value of R1 on entry
  176.  *
  177.  * Output:        workspace_size - value of R0 on exit
  178.  *                output_size - value of R1 on exit
  179.  *
  180.  * Other notes:   Calls SWI 0x42701 with R0 = 0x8.
  181.  */
  182.  
  183. extern os_error *xsquash_decompress_return_sizes (int input_size,
  184.       int *workspace_size,
  185.       int *output_size);
  186. extern void squash_decompress_return_sizes (int input_size,
  187.       int *workspace_size,
  188.       int *output_size);
  189.  
  190. /* ------------------------------------------------------------------------
  191.  * Function:      squash_decompress()
  192.  *
  193.  * Description:   Decompresses data produced by Squash_Compress
  194.  *
  195.  * Input:         input_status - value of R0 on entry
  196.  *                workspace - value of R1 on entry
  197.  *                input - value of R2 on entry
  198.  *                input_size - value of R3 on entry
  199.  *                output - value of R4 on entry
  200.  *                output_size - value of R5 on entry
  201.  *
  202.  * Output:        output_status - value of R0 on exit
  203.  *                input_out - value of R2 on exit
  204.  *                input_spare - value of R3 on exit
  205.  *                output_out - value of R4 on exit
  206.  *                output_spare - value of R5 on exit
  207.  *
  208.  * Other notes:   Calls SWI 0x42701.
  209.  */
  210.  
  211. extern os_error *xsquash_decompress (bits input_status,
  212.       void *workspace,
  213.       byte *input,
  214.       int input_size,
  215.       byte *output,
  216.       int output_size,
  217.       bits *output_status,
  218.       byte **input_out,
  219.       int *input_spare,
  220.       byte **output_out,
  221.       int *output_spare);
  222. extern void squash_decompress (bits input_status,
  223.       void *workspace,
  224.       byte *input,
  225.       int input_size,
  226.       byte *output,
  227.       int output_size,
  228.       bits *output_status,
  229.       byte **input_out,
  230.       int *input_spare,
  231.       byte **output_out,
  232.       int *output_spare);
  233.  
  234. #ifdef __cplusplus
  235.    }
  236. #endif
  237.  
  238. #endif
  239.