codex.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. */
  19. /*------------------------------------------------------------------*/
  20. /* */
  21. /* Compression Decompression Exchange(CODEX) v2.00 */
  22. /* */
  23. /* by FrANK G. Barchard, EAC */
  24. /* */
  25. /* Header Module - Oct 15, 2001 */
  26. /* */
  27. /*------------------------------------------------------------------*/
  28. /* */
  29. /* Version Date SE History */
  30. /* ------- ------ -- ------- */
  31. /* 1.00 990824 FB codex API seperated from huff tool */
  32. /* 1.01 010427 FB fb6 32 bit size header */
  33. /* 1.02 011011 FB c++ defaults */
  34. /* 2.00 011015 FB bool, dest/source, new about struct,no QPUBLIC */
  35. /* */
  36. /*------------------------------------------------------------------*/
  37. #ifndef __CODEX_H
  38. #define __CODEX_H 1
  39. #if defined(_MSC_VER)
  40. #pragma once
  41. #endif
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. #define CODEX_VERSION 200
  46. /****************************************************************/
  47. /* Data Types */
  48. /****************************************************************/
  49. /* Info structure describing bitmaps */
  50. typedef struct
  51. {
  52. int signature; /* signature of codex ie 'tga ' (optional) */
  53. int size; /* size of CODEXABOUT structure */
  54. int version; /* version number of CODEXABOUT structure (200) */
  55. unsigned int decode :1; /* supports decoding */
  56. unsigned int encode :1; /* supports encoding */
  57. unsigned int size32 :1; /* support 32 bit size field */
  58. unsigned int pad :29;
  59. char versionstr[8]; /* version number of codex module ie 1.00 */
  60. char shorttypestr[8]; /* 3 or 4 character type string ie ref */
  61. char longtypestr[16]; /* full name of data format ie Refpack */
  62. } CODEXABOUT;
  63. #define QMAKEID(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
  64. #if !defined(GCALL)
  65. #if defined(_MSC_VER) && !defined(_XBOX)
  66. #define GCALL __stdcall
  67. #else
  68. #define GCALL
  69. #endif
  70. #endif
  71. typedef struct QFUNCTIONS
  72. {
  73. CODEXABOUT * (GCALL * CODEX_about)(void);
  74. bool (GCALL * CODEX_is)(const void *compressed);
  75. int (GCALL * CODEX_size)(const void *compressed);
  76. int (GCALL * CODEX_decode)(void *dest, const void *source, int *sourcesizeptr);
  77. int (GCALL * CODEX_encode)(void *dest, const void *source, int sourcesize, int *opts);
  78. } QFUNCTIONS;
  79. extern struct QFUNCTIONS qfunctions[];
  80. /****************************************************************/
  81. /* Codex Module Example Prototypes */
  82. /****************************************************************/
  83. #include "gimex.h" /* for memory IO */
  84. /* Information Functions */
  85. CODEXABOUT *GCALL CODEX_about(void);
  86. bool GCALL CODEX_is(const void *source);
  87. int GCALL CODEX_size(const void *source);
  88. /* Decode/Encode Functions */
  89. #ifdef __cplusplus
  90. int GCALL CODEX_decode(void *dest, const void *source, int *sourcesizeptr=0);
  91. int GCALL CODEX_encode(void *dest, const void *source, int sourcesize, int *opts=0);
  92. #else
  93. int GCALL CODEX_decode(void *dest, const void *source, int *sourcesizeptr);
  94. int GCALL CODEX_encode(void *dest, const void *source, int sourcesize, int *opts);
  95. #endif
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif