wrap.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /* wrap.h -- wrapper functions
  2. This file is part of the LZO real-time data compression library.
  3. Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer
  4. All Rights Reserved.
  5. The LZO library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of
  8. the License, or (at your option) any later version.
  9. The LZO library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with the LZO library; see the file COPYING.
  15. If not, write to the Free Software Foundation, Inc.,
  16. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. Markus F.X.J. Oberhumer
  18. <markus@oberhumer.com>
  19. http://www.oberhumer.com/opensource/lzo/
  20. */
  21. /*************************************************************************
  22. // compression levels of LZO1X-999 and LZO1Y-999
  23. **************************************************************************/
  24. #if defined(HAVE_LZO1X_H)
  25. LZO_PRIVATE(int)
  26. lzo1x_999_1_compress ( const lzo_bytep src, lzo_uint src_len,
  27. lzo_bytep dst, lzo_uintp dst_len,
  28. lzo_voidp wrkmem )
  29. {
  30. return lzo1x_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  31. dict.ptr, dict.len, 0, 1);
  32. }
  33. LZO_PRIVATE(int)
  34. lzo1x_999_2_compress ( const lzo_bytep src, lzo_uint src_len,
  35. lzo_bytep dst, lzo_uintp dst_len,
  36. lzo_voidp wrkmem )
  37. {
  38. return lzo1x_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  39. dict.ptr, dict.len, 0, 2);
  40. }
  41. LZO_PRIVATE(int)
  42. lzo1x_999_3_compress ( const lzo_bytep src, lzo_uint src_len,
  43. lzo_bytep dst, lzo_uintp dst_len,
  44. lzo_voidp wrkmem )
  45. {
  46. return lzo1x_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  47. dict.ptr, dict.len, 0, 3);
  48. }
  49. LZO_PRIVATE(int)
  50. lzo1x_999_4_compress ( const lzo_bytep src, lzo_uint src_len,
  51. lzo_bytep dst, lzo_uintp dst_len,
  52. lzo_voidp wrkmem )
  53. {
  54. return lzo1x_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  55. dict.ptr, dict.len, 0, 4);
  56. }
  57. LZO_PRIVATE(int)
  58. lzo1x_999_5_compress ( const lzo_bytep src, lzo_uint src_len,
  59. lzo_bytep dst, lzo_uintp dst_len,
  60. lzo_voidp wrkmem )
  61. {
  62. return lzo1x_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  63. dict.ptr, dict.len, 0, 5);
  64. }
  65. LZO_PRIVATE(int)
  66. lzo1x_999_6_compress ( const lzo_bytep src, lzo_uint src_len,
  67. lzo_bytep dst, lzo_uintp dst_len,
  68. lzo_voidp wrkmem )
  69. {
  70. return lzo1x_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  71. dict.ptr, dict.len, 0, 6);
  72. }
  73. LZO_PRIVATE(int)
  74. lzo1x_999_7_compress ( const lzo_bytep src, lzo_uint src_len,
  75. lzo_bytep dst, lzo_uintp dst_len,
  76. lzo_voidp wrkmem )
  77. {
  78. return lzo1x_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  79. dict.ptr, dict.len, 0, 7);
  80. }
  81. LZO_PRIVATE(int)
  82. lzo1x_999_8_compress ( const lzo_bytep src, lzo_uint src_len,
  83. lzo_bytep dst, lzo_uintp dst_len,
  84. lzo_voidp wrkmem )
  85. {
  86. return lzo1x_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  87. dict.ptr, dict.len, 0, 8);
  88. }
  89. LZO_PRIVATE(int)
  90. lzo1x_999_9_compress ( const lzo_bytep src, lzo_uint src_len,
  91. lzo_bytep dst, lzo_uintp dst_len,
  92. lzo_voidp wrkmem )
  93. {
  94. return lzo1x_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  95. dict.ptr, dict.len, 0, 9);
  96. }
  97. #endif
  98. #if defined(HAVE_LZO1Y_H)
  99. LZO_PRIVATE(int)
  100. lzo1y_999_1_compress ( const lzo_bytep src, lzo_uint src_len,
  101. lzo_bytep dst, lzo_uintp dst_len,
  102. lzo_voidp wrkmem )
  103. {
  104. return lzo1y_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  105. dict.ptr, dict.len, 0, 1);
  106. }
  107. LZO_PRIVATE(int)
  108. lzo1y_999_2_compress ( const lzo_bytep src, lzo_uint src_len,
  109. lzo_bytep dst, lzo_uintp dst_len,
  110. lzo_voidp wrkmem )
  111. {
  112. return lzo1y_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  113. dict.ptr, dict.len, 0, 2);
  114. }
  115. LZO_PRIVATE(int)
  116. lzo1y_999_3_compress ( const lzo_bytep src, lzo_uint src_len,
  117. lzo_bytep dst, lzo_uintp dst_len,
  118. lzo_voidp wrkmem )
  119. {
  120. return lzo1y_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  121. dict.ptr, dict.len, 0, 3);
  122. }
  123. LZO_PRIVATE(int)
  124. lzo1y_999_4_compress ( const lzo_bytep src, lzo_uint src_len,
  125. lzo_bytep dst, lzo_uintp dst_len,
  126. lzo_voidp wrkmem )
  127. {
  128. return lzo1y_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  129. dict.ptr, dict.len, 0, 4);
  130. }
  131. LZO_PRIVATE(int)
  132. lzo1y_999_5_compress ( const lzo_bytep src, lzo_uint src_len,
  133. lzo_bytep dst, lzo_uintp dst_len,
  134. lzo_voidp wrkmem )
  135. {
  136. return lzo1y_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  137. dict.ptr, dict.len, 0, 5);
  138. }
  139. LZO_PRIVATE(int)
  140. lzo1y_999_6_compress ( const lzo_bytep src, lzo_uint src_len,
  141. lzo_bytep dst, lzo_uintp dst_len,
  142. lzo_voidp wrkmem )
  143. {
  144. return lzo1y_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  145. dict.ptr, dict.len, 0, 6);
  146. }
  147. LZO_PRIVATE(int)
  148. lzo1y_999_7_compress ( const lzo_bytep src, lzo_uint src_len,
  149. lzo_bytep dst, lzo_uintp dst_len,
  150. lzo_voidp wrkmem )
  151. {
  152. return lzo1y_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  153. dict.ptr, dict.len, 0, 7);
  154. }
  155. LZO_PRIVATE(int)
  156. lzo1y_999_8_compress ( const lzo_bytep src, lzo_uint src_len,
  157. lzo_bytep dst, lzo_uintp dst_len,
  158. lzo_voidp wrkmem )
  159. {
  160. return lzo1y_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  161. dict.ptr, dict.len, 0, 8);
  162. }
  163. LZO_PRIVATE(int)
  164. lzo1y_999_9_compress ( const lzo_bytep src, lzo_uint src_len,
  165. lzo_bytep dst, lzo_uintp dst_len,
  166. lzo_voidp wrkmem )
  167. {
  168. return lzo1y_999_compress_level(src, src_len, dst, dst_len, wrkmem,
  169. dict.ptr, dict.len, 0, 9);
  170. }
  171. #endif
  172. /*************************************************************************
  173. // other wrappers (pseudo compressors)
  174. **************************************************************************/
  175. LZO_PRIVATE(int)
  176. memcpy_x_compress ( const lzo_bytep src, lzo_uint src_len,
  177. lzo_bytep dst, lzo_uintp dst_len,
  178. lzo_voidp wrkmem )
  179. {
  180. lzo_memcpy(dst, src, src_len);
  181. *dst_len = src_len;
  182. LZO_UNUSED(wrkmem);
  183. return 0;
  184. }
  185. LZO_PRIVATE(int)
  186. memset_x_compress ( const lzo_bytep src, lzo_uint src_len,
  187. lzo_bytep dst, lzo_uintp dst_len,
  188. lzo_voidp wrkmem )
  189. {
  190. lzo_memset(dst, 0, src_len);
  191. *dst_len = src_len;
  192. LZO_UNUSED(src); LZO_UNUSED(wrkmem);
  193. return 0;
  194. }
  195. LZO_PRIVATE(int)
  196. adler32_x_compress ( const lzo_bytep src, lzo_uint src_len,
  197. lzo_bytep dst, lzo_uintp dst_len,
  198. lzo_voidp wrkmem )
  199. {
  200. lzo_uint32_t adler;
  201. adler = lzo_adler32(0, NULL, 0);
  202. adler = lzo_adler32(adler, dst, src_len);
  203. *dst_len = src_len;
  204. LZO_UNUSED(src); LZO_UNUSED(wrkmem);
  205. return 0;
  206. }
  207. LZO_PRIVATE(int)
  208. crc32_x_compress ( const lzo_bytep src, lzo_uint src_len,
  209. lzo_bytep dst, lzo_uintp dst_len,
  210. lzo_voidp wrkmem )
  211. {
  212. lzo_uint32_t crc;
  213. crc = lzo_crc32(0, NULL, 0);
  214. crc = lzo_crc32(crc, dst, src_len);
  215. *dst_len = src_len;
  216. LZO_UNUSED(src); LZO_UNUSED(wrkmem);
  217. return 0;
  218. }
  219. /* vim:set ts=4 sw=4 et: */