config.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. Copyright (c) 2010, Florian Reuter
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. * Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. * Neither the name of Florian Reuter nor the names of its contributors
  14. may be used to endorse or promote products derived from this
  15. software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  17. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  19. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  20. COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  22. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  25. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  27. OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. /**@file config/opc/config.h
  30. */
  31. #ifndef OPC_CONFIG_H
  32. #define OPC_CONFIG_H
  33. #include <libxml/xmlstring.h>
  34. #include <plib/plib.h>
  35. #include <assert.h>
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /**
  40. Assert expression e is true. Will be removed entirely in release mode.
  41. \hideinitializer
  42. */
  43. #define OPC_ASSERT(e) assert(e)
  44. /**
  45. Assert expression e is true. Expression will be executed in release mode too.
  46. \hideinitializer
  47. */
  48. #ifdef NDEBUG
  49. #define OPC_ENSURE(e) (void)(e)
  50. #else
  51. #define OPC_ENSURE(e) assert(e)
  52. #endif
  53. /**
  54. Constant for boolean true.
  55. \hideinitializer
  56. */
  57. #define OPC_TRUE (0==0)
  58. /**
  59. Constant for boolean false.
  60. \hideinitializer
  61. */
  62. #define OPC_FALSE (0==1)
  63. /**
  64. Boolean type.
  65. \hideinitializer
  66. */
  67. typedef pbool_t opc_bool_t;
  68. /**
  69. Type which represents an offset in e.g. a file.
  70. \hideinitializer
  71. */
  72. typedef pofs_t opc_ofs_t;
  73. /**
  74. 8-bit unsigned integer.
  75. \hideinitializer
  76. */
  77. typedef puint8_t opc_uint8_t;
  78. /**
  79. 16-bit unsigned integer.
  80. \hideinitializer
  81. */
  82. typedef puint16_t opc_uint16_t;
  83. /**
  84. 32-bit unsigned integer.
  85. \hideinitializer
  86. */
  87. typedef puint32_t opc_uint32_t;
  88. /**
  89. 64-bit unsigned integer.
  90. \hideinitializer
  91. */
  92. typedef puint64_t opc_uint64_t;
  93. /**
  94. 8-bit signed integer.
  95. \hideinitializer
  96. */
  97. typedef pint8_t opc_int8_t;
  98. /**
  99. 16-bit signed integer.
  100. \hideinitializer
  101. */
  102. typedef pint16_t opc_int16_t;
  103. /**
  104. 32-bit signed integer.
  105. \hideinitializer
  106. */
  107. typedef pint32_t opc_int32_t;
  108. /**
  109. 64-bit signed integer.
  110. \hideinitializer
  111. */
  112. typedef pint64_t opc_int64_t;
  113. /**
  114. Default size fo the deflate buffer used by zlib.
  115. */
  116. #define OPC_DEFLATE_BUFFER_SIZE 4096
  117. /**
  118. Max system path len.
  119. */
  120. #define OPC_MAX_PATH 512
  121. /**
  122. Error codes for the OPC module.
  123. */
  124. typedef enum OPC_ERROR_ENUM {
  125. OPC_ERROR_NONE,
  126. OPC_ERROR_STREAM,
  127. OPC_ERROR_SEEK, // can't seek
  128. OPC_ERROR_UNSUPPORTED_DATA_DESCRIPTOR,
  129. OPC_ERROR_UNSUPPORTED_COMPRESSION,
  130. OPC_ERROR_DEFLATE,
  131. OPC_ERROR_HEADER,
  132. OPC_ERROR_MEMORY,
  133. OPC_ERROR_XML,
  134. OPC_ERROR_USER // user triggered an abort
  135. } opc_error_t;
  136. /**
  137. Compression options for OPC streams.
  138. */
  139. typedef enum OPC_COMPRESSIONOPTION_ENUM {
  140. OPC_COMPRESSIONOPTION_NONE,
  141. OPC_COMPRESSIONOPTION_NORMAL,
  142. OPC_COMPRESSIONOPTION_MAXIMUM,
  143. OPC_COMPRESSIONOPTION_FAST,
  144. OPC_COMPRESSIONOPTION_SUPERFAST
  145. } opcCompressionOption_t;
  146. /**
  147. Helper for debug logs.
  148. \hideinitializer
  149. */
  150. #define opc_logf printf
  151. /**
  152. Abstraction for memset(m, 0, s).
  153. \hideinitializer
  154. */
  155. #define opc_bzero_mem(m,s) memset(m, 0, s)
  156. #ifdef __cplusplus
  157. } /* extern "C" */
  158. #endif
  159. #endif /* OPC_CONFIG_H */