/dep/libmpq/libmpq/mpq.h

https://github.com/kizura/server · C Header · 98 lines · 51 code · 13 blank · 34 comment · 1 complexity · 64ab484f8a7f6fe87d5cc7fa15bc7fcb MD5 · raw file

  1. /*
  2. * mpq.h -- some default types and defines.
  3. *
  4. * Copyright (c) 2003-2008 Maik Broemme <mbroemme@plusserver.de>
  5. *
  6. * Some parts (the encryption and decryption stuff) were adapted from
  7. * the C++ version of StormLib.h and StormPort.h included in stormlib.
  8. * The C++ version belongs to the following authors:
  9. *
  10. * Ladislav Zezula <ladik@zezula.net>
  11. * Marko Friedemann <marko.friedemann@bmx-chemnitz.de>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  26. */
  27. #ifndef _MPQ_H
  28. #define _MPQ_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /* generic includes. */
  33. #include <stdint.h>
  34. #include <sys/types.h>
  35. #if defined(__GNUC__) && (__GNUC__ >= 4)
  36. # define LIBMPQ_API __attribute__((visibility("default")))
  37. #else
  38. # define LIBMPQ_API
  39. #endif
  40. /* define errors. */
  41. #define LIBMPQ_ERROR_OPEN -1 /* open error on file. */
  42. #define LIBMPQ_ERROR_CLOSE -2 /* close error on file. */
  43. #define LIBMPQ_ERROR_SEEK -3 /* lseek error on file. */
  44. #define LIBMPQ_ERROR_READ -4 /* read error on file. */
  45. #define LIBMPQ_ERROR_WRITE -5 /* write error on file. */
  46. #define LIBMPQ_ERROR_MALLOC -6 /* memory allocation error. */
  47. #define LIBMPQ_ERROR_FORMAT -7 /* format errror. */
  48. #define LIBMPQ_ERROR_NOT_INITIALIZED -8 /* libmpq__init() wasn't called. */
  49. #define LIBMPQ_ERROR_SIZE -9 /* buffer size is to small. */
  50. #define LIBMPQ_ERROR_EXIST -10 /* file or block does not exist in archive. */
  51. #define LIBMPQ_ERROR_DECRYPT -11 /* we don't know the decryption seed. */
  52. #define LIBMPQ_ERROR_UNPACK -12 /* error on unpacking file. */
  53. /* internal data structure. */
  54. typedef struct mpq_archive mpq_archive_s;
  55. /* file offset data type for API*/
  56. typedef int64_t libmpq__off_t;
  57. /* generic information about library. */
  58. extern LIBMPQ_API const char *libmpq__version(void);
  59. /* generic mpq archive information. */
  60. extern LIBMPQ_API int32_t libmpq__archive_open(mpq_archive_s **mpq_archive, const char *mpq_filename, libmpq__off_t archive_offset);
  61. extern LIBMPQ_API int32_t libmpq__archive_close(mpq_archive_s *mpq_archive);
  62. extern LIBMPQ_API int32_t libmpq__archive_packed_size(mpq_archive_s *mpq_archive, libmpq__off_t *packed_size);
  63. extern LIBMPQ_API int32_t libmpq__archive_unpacked_size(mpq_archive_s *mpq_archive, libmpq__off_t *unpacked_size);
  64. extern LIBMPQ_API int32_t libmpq__archive_offset(mpq_archive_s *mpq_archive, libmpq__off_t *offset);
  65. extern LIBMPQ_API int32_t libmpq__archive_version(mpq_archive_s *mpq_archive, uint32_t *version);
  66. extern LIBMPQ_API int32_t libmpq__archive_files(mpq_archive_s *mpq_archive, uint32_t *files);
  67. /* generic file processing functions. */
  68. extern LIBMPQ_API int32_t libmpq__file_packed_size(mpq_archive_s *mpq_archive, uint32_t file_number, libmpq__off_t *packed_size);
  69. extern LIBMPQ_API int32_t libmpq__file_unpacked_size(mpq_archive_s *mpq_archive, uint32_t file_number, libmpq__off_t *unpacked_size);
  70. extern LIBMPQ_API int32_t libmpq__file_offset(mpq_archive_s *mpq_archive, uint32_t file_number, libmpq__off_t *offset);
  71. extern LIBMPQ_API int32_t libmpq__file_blocks(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t *blocks);
  72. extern LIBMPQ_API int32_t libmpq__file_encrypted(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t *encrypted);
  73. extern LIBMPQ_API int32_t libmpq__file_compressed(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t *compressed);
  74. extern LIBMPQ_API int32_t libmpq__file_imploded(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t *imploded);
  75. extern LIBMPQ_API int32_t libmpq__file_number(mpq_archive_s *mpq_archive, const char *filename, uint32_t *number);
  76. extern LIBMPQ_API int32_t libmpq__file_read(mpq_archive_s *mpq_archive, uint32_t file_number, uint8_t *out_buf, libmpq__off_t out_size, libmpq__off_t *transferred);
  77. /* generic block processing functions. */
  78. extern LIBMPQ_API int32_t libmpq__block_open_offset(mpq_archive_s *mpq_archive, uint32_t file_number);
  79. extern LIBMPQ_API int32_t libmpq__block_close_offset(mpq_archive_s *mpq_archive, uint32_t file_number);
  80. extern LIBMPQ_API int32_t libmpq__block_unpacked_size(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t block_number, libmpq__off_t *unpacked_size);
  81. extern LIBMPQ_API int32_t libmpq__block_read(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t block_number, uint8_t *out_buf, libmpq__off_t out_size, libmpq__off_t *transferred);
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif /* _MPQ_H */