lha_basic_reader.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. Copyright (c) 2011, 2012, Simon Howard
  3. Permission to use, copy, modify, and/or distribute this software
  4. for any purpose with or without fee is hereby granted, provided
  5. that the above copyright notice and this permission notice appear
  6. in all copies.
  7. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  8. WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  9. WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  10. AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  11. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  12. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef LHASA_LHA_BASIC_READER_H
  17. #define LHASA_LHA_BASIC_READER_H
  18. #include "lha_input_stream.h"
  19. #include "lha_file_header.h"
  20. #include "lha_decoder.h"
  21. /**
  22. * Basic LHA stream reader.
  23. *
  24. * The basic reader structure just reads @ref LHAFileHeader structures
  25. * from an input stream and decompresses files. The more elaborate
  26. * @ref LHAReader builds upon this to offer more complicated functionality.
  27. */
  28. typedef struct _LHABasicReader LHABasicReader;
  29. /**
  30. * Create a new LHA reader to read data from an input stream.
  31. *
  32. * @param stream The input stream to read from.
  33. * @return Pointer to an LHABasicReader structure, or NULL for error.
  34. */
  35. LHABasicReader *lha_basic_reader_new(LHAInputStream *stream);
  36. /**
  37. * Free an LHA reader.
  38. *
  39. * @param reader The LHABasicReader structure.
  40. */
  41. void lha_basic_reader_free(LHABasicReader *reader);
  42. /**
  43. * Return the last file read by @ref lha_basic_reader_next_file.
  44. *
  45. * @param reader The LHABasicReader structure.
  46. * @return Last file returned by @ref lha_basic_reader_next_file,
  47. * or NULL if no file has been read yet.
  48. */
  49. LHAFileHeader *lha_basic_reader_curr_file(LHABasicReader *reader);
  50. /**
  51. * Read the header of the next archived file from the input stream.
  52. *
  53. * @param reader The LHABasicReader structure.
  54. * @return Pointer to an LHAFileHeader structure, or NULL if
  55. * an error occurred. This pointer is only valid until
  56. * the next time that lha_basic_reader_next_file is called.
  57. */
  58. LHAFileHeader *lha_basic_reader_next_file(LHABasicReader *reader);
  59. /**
  60. * Read some of the compressed data for the current archived file.
  61. *
  62. * @param reader The LHABasicReader structure.
  63. * @param buf Pointer to the buffer in which to store the data.
  64. * @param buf_len Size of the buffer, in bytes.
  65. */
  66. size_t lha_basic_reader_read_compressed(LHABasicReader *reader, void *buf,
  67. size_t buf_len);
  68. /**
  69. * Create a decoder object to decompress the compressed data in the
  70. * current file.
  71. *
  72. * @param reader The LHABasicReader structure.
  73. * @return Pointer to a @ref LHADecoder structure to decompress
  74. * the current file, or NULL for failure.
  75. */
  76. LHADecoder *lha_basic_reader_decode(LHABasicReader *reader);
  77. #endif /* #ifndef LHASA_LHA_BASIC_READER_H */