mz_strm.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* mz_strm.h -- Stream interface
  2. part of the minizip-ng project
  3. Copyright (C) 2010-2021 Nathan Moinvaziri
  4. https://github.com/zlib-ng/minizip-ng
  5. This program is distributed under the terms of the same license as zlib.
  6. See the accompanying LICENSE file for the full text of the license.
  7. */
  8. #ifndef MZ_STREAM_H
  9. #define MZ_STREAM_H
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /***************************************************************************/
  14. #define MZ_STREAM_PROP_TOTAL_IN (1)
  15. #define MZ_STREAM_PROP_TOTAL_IN_MAX (2)
  16. #define MZ_STREAM_PROP_TOTAL_OUT (3)
  17. #define MZ_STREAM_PROP_TOTAL_OUT_MAX (4)
  18. #define MZ_STREAM_PROP_HEADER_SIZE (5)
  19. #define MZ_STREAM_PROP_FOOTER_SIZE (6)
  20. #define MZ_STREAM_PROP_DISK_SIZE (7)
  21. #define MZ_STREAM_PROP_DISK_NUMBER (8)
  22. #define MZ_STREAM_PROP_COMPRESS_LEVEL (9)
  23. #define MZ_STREAM_PROP_COMPRESS_METHOD (10)
  24. #define MZ_STREAM_PROP_COMPRESS_WINDOW (11)
  25. /***************************************************************************/
  26. typedef int32_t (*mz_stream_open_cb) (void *stream, const char *path, int32_t mode);
  27. typedef int32_t (*mz_stream_is_open_cb) (void *stream);
  28. typedef int32_t (*mz_stream_read_cb) (void *stream, void *buf, int32_t size);
  29. typedef int32_t (*mz_stream_write_cb) (void *stream, const void *buf, int32_t size);
  30. typedef int64_t (*mz_stream_tell_cb) (void *stream);
  31. typedef int32_t (*mz_stream_seek_cb) (void *stream, int64_t offset, int32_t origin);
  32. typedef int32_t (*mz_stream_close_cb) (void *stream);
  33. typedef int32_t (*mz_stream_error_cb) (void *stream);
  34. typedef void* (*mz_stream_create_cb) (void **stream);
  35. typedef void (*mz_stream_destroy_cb) (void **stream);
  36. typedef int32_t (*mz_stream_get_prop_int64_cb) (void *stream, int32_t prop, int64_t *value);
  37. typedef int32_t (*mz_stream_set_prop_int64_cb) (void *stream, int32_t prop, int64_t value);
  38. typedef int32_t (*mz_stream_find_cb) (void *stream, const void *find, int32_t find_size,
  39. int64_t max_seek, int64_t *position);
  40. /***************************************************************************/
  41. typedef struct mz_stream_vtbl_s {
  42. mz_stream_open_cb open;
  43. mz_stream_is_open_cb is_open;
  44. mz_stream_read_cb read;
  45. mz_stream_write_cb write;
  46. mz_stream_tell_cb tell;
  47. mz_stream_seek_cb seek;
  48. mz_stream_close_cb close;
  49. mz_stream_error_cb error;
  50. mz_stream_create_cb create;
  51. mz_stream_destroy_cb destroy;
  52. mz_stream_get_prop_int64_cb get_prop_int64;
  53. mz_stream_set_prop_int64_cb set_prop_int64;
  54. } mz_stream_vtbl;
  55. typedef struct mz_stream_s {
  56. mz_stream_vtbl *vtbl;
  57. struct mz_stream_s *base;
  58. } mz_stream;
  59. /***************************************************************************/
  60. int32_t mz_stream_open(void *stream, const char *path, int32_t mode);
  61. int32_t mz_stream_is_open(void *stream);
  62. int32_t mz_stream_read(void *stream, void *buf, int32_t size);
  63. int32_t mz_stream_read_uint8(void *stream, uint8_t *value);
  64. int32_t mz_stream_read_uint16(void *stream, uint16_t *value);
  65. int32_t mz_stream_read_uint32(void *stream, uint32_t *value);
  66. int32_t mz_stream_read_int64(void *stream, int64_t *value);
  67. int32_t mz_stream_read_uint64(void *stream, uint64_t *value);
  68. int32_t mz_stream_write(void *stream, const void *buf, int32_t size);
  69. int32_t mz_stream_write_uint8(void *stream, uint8_t value);
  70. int32_t mz_stream_write_uint16(void *stream, uint16_t value);
  71. int32_t mz_stream_write_uint32(void *stream, uint32_t value);
  72. int32_t mz_stream_write_int64(void *stream, int64_t value);
  73. int32_t mz_stream_write_uint64(void *stream, uint64_t value);
  74. int32_t mz_stream_copy(void *target, void *source, int32_t len);
  75. int32_t mz_stream_copy_to_end(void *target, void *source);
  76. int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *source, mz_stream_read_cb read_cb, int32_t len);
  77. int32_t mz_stream_copy_stream_to_end(void *target, mz_stream_write_cb write_cb, void *source, mz_stream_read_cb read_cb);
  78. int64_t mz_stream_tell(void *stream);
  79. int32_t mz_stream_seek(void *stream, int64_t offset, int32_t origin);
  80. int32_t mz_stream_find(void *stream, const void *find, int32_t find_size, int64_t max_seek, int64_t *position);
  81. int32_t mz_stream_find_reverse(void *stream, const void *find, int32_t find_size, int64_t max_seek, int64_t *position);
  82. int32_t mz_stream_close(void *stream);
  83. int32_t mz_stream_error(void *stream);
  84. int32_t mz_stream_set_base(void *stream, void *base);
  85. void* mz_stream_get_interface(void *stream);
  86. int32_t mz_stream_get_prop_int64(void *stream, int32_t prop, int64_t *value);
  87. int32_t mz_stream_set_prop_int64(void *stream, int32_t prop, int64_t value);
  88. void* mz_stream_create(void **stream, mz_stream_vtbl *vtbl);
  89. void mz_stream_delete(void **stream);
  90. /***************************************************************************/
  91. int32_t mz_stream_raw_open(void *stream, const char *filename, int32_t mode);
  92. int32_t mz_stream_raw_is_open(void *stream);
  93. int32_t mz_stream_raw_read(void *stream, void *buf, int32_t size);
  94. int32_t mz_stream_raw_write(void *stream, const void *buf, int32_t size);
  95. int64_t mz_stream_raw_tell(void *stream);
  96. int32_t mz_stream_raw_seek(void *stream, int64_t offset, int32_t origin);
  97. int32_t mz_stream_raw_close(void *stream);
  98. int32_t mz_stream_raw_error(void *stream);
  99. int32_t mz_stream_raw_get_prop_int64(void *stream, int32_t prop, int64_t *value);
  100. int32_t mz_stream_raw_set_prop_int64(void *stream, int32_t prop, int64_t value);
  101. void* mz_stream_raw_create(void **stream);
  102. void mz_stream_raw_delete(void **stream);
  103. /***************************************************************************/
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. #endif