licenses.list.txt 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. ====================BSL-1.0====================
  2. * Distributed under the Boost Software License, Version 1.0.(See accompanying
  3. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  4. ====================BSL-1.0====================
  5. * Distributed under the Boost Software License, Version 1.0.(See accompanying
  6. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  7. ====================BSL-1.0====================
  8. ### License
  9. Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
  10. ====================BSL-1.0====================
  11. * Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
  12. ====================BSL-1.0====================
  13. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  14. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  15. ====================BSL-1.0====================
  16. Boost Software License - Version 1.0 - August 17th, 2003
  17. Permission is hereby granted, free of charge, to any person or organization
  18. obtaining a copy of the software and accompanying documentation covered by
  19. this license (the "Software") to use, reproduce, display, distribute,
  20. execute, and transmit the Software, and to prepare derivative works of the
  21. Software, and to permit third-parties to whom the Software is furnished to
  22. do so, all subject to the following:
  23. The copyright notices in the Software and this entire statement, including
  24. the above license grant, this restriction and the following disclaimer,
  25. must be included in all copies of the Software, in whole or in part, and
  26. all derivative works of the Software, unless such copies or derivative
  27. works are solely in the form of machine-executable object code generated by
  28. a source language processor.
  29. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  30. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  31. FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  32. SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  33. FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  34. ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  35. DEALINGS IN THE SOFTWARE.
  36. ====================COPYRIGHT====================
  37. * Date: Sun Jan 06 12:57:30 MST 2008
  38. * Copyright: 2008 CodeRage, LLC
  39. 2004-2007 Jonathan Turkanis
  40. * Author: Jonathan Turkanis
  41. * Contact: turkanis at coderage dot com
  42. ====================COPYRIGHT====================
  43. * Date: Sun Jun 22 14:23:12 MDT 2008
  44. * Copyright: 2008 CodeRage, LLC
  45. * Author: Jonathan Turkanis
  46. * Contact: turkanis at coderage dot com
  47. ====================COPYRIGHT====================
  48. * Date: Thu Dec 06 13:21:54 MST 2007
  49. * Copyright: 2007-2008 CodeRage, LLC
  50. * Author: Jonathan Turkanis
  51. * Contact: turkanis at coderage dot com
  52. ====================COPYRIGHT====================
  53. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  54. // (C) Copyright 2003-2007 Jonathan Turkanis
  55. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  56. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  57. ====================COPYRIGHT====================
  58. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  59. // (C) Copyright 2004-2007 Jonathan Turkanis
  60. // (C) Copyright 2002, 2003 Beman Dawes Boost.Filesystem
  61. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  62. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  63. ====================COPYRIGHT====================
  64. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  65. // (C) Copyright 2004-2007 Jonathan Turkanis
  66. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  67. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  68. ====================COPYRIGHT====================
  69. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  70. // (C) Copyright 2005-2007 Jonathan Turkanis
  71. // (C) Copyright David Abrahams 2004.
  72. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  73. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  74. ====================COPYRIGHT====================
  75. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  76. // (C) Copyright 2005-2007 Jonathan Turkanis
  77. // (C) Copyright Jonathan Graehl 2004.
  78. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  79. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  80. ====================COPYRIGHT====================
  81. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  82. // (C) Copyright 2005-2007 Jonathan Turkanis
  83. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  84. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  85. ====================COPYRIGHT====================
  86. // (C) Copyright 2010 Daniel James
  87. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  88. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  89. ====================COPYRIGHT====================
  90. // (C) Copyright Craig Henderson 2002 'boost/memmap.hpp' from sandbox
  91. // (C) Copyright Jonathan Turkanis 2004.
  92. // (C) Copyright Jonathan Graehl 2004.
  93. // (C) Copyright Jorge Lodos 2008.
  94. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  95. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  96. ====================COPYRIGHT====================
  97. // (C) Copyright Jorge Lodos 2008.
  98. // (C) Copyright Jonathan Turkanis 2003.
  99. // (C) Copyright Craig Henderson 2002. 'boost/memmap.hpp' from sandbox
  100. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  101. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  102. ====================COPYRIGHT====================
  103. // (C) Copyright Milan Svoboda 2008.
  104. // Originally developed under the fusecompress project.
  105. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  106. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  107. ====================COPYRIGHT====================
  108. // (C) Copyright Reimar Döffinger 2018.
  109. // Based on zstd.hpp by:
  110. // (C) Copyright Milan Svoboda 2008.
  111. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  112. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  113. ====================COPYRIGHT====================
  114. // Inspired by fdstream.hpp, (C) Copyright Nicolai M. Josuttis 2001,
  115. // available at http://www.josuttis.com/cppcode/fdstream.html.
  116. ====================File: include/boost/iostreams/filter/zstd.hpp====================
  117. // (C) Copyright Reimar Döffinger 2018.
  118. // Based on zstd.hpp by:
  119. // (C) Copyright Milan Svoboda 2008.
  120. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  121. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  122. // See http://www.boost.org/libs/iostreams for documentation.
  123. #ifndef BOOST_IOSTREAMS_ZSTD_HPP_INCLUDED
  124. #define BOOST_IOSTREAMS_ZSTD_HPP_INCLUDED
  125. #if defined(_MSC_VER)
  126. # pragma once
  127. #endif
  128. #include <cassert>
  129. #include <iosfwd> // streamsize.
  130. #include <memory> // allocator, bad_alloc.
  131. #include <new>
  132. #include <boost/config.hpp> // MSVC, STATIC_CONSTANT, DEDUCED_TYPENAME, DINKUM.
  133. #include <boost/detail/workaround.hpp>
  134. #include <boost/iostreams/constants.hpp> // buffer size.
  135. #include <boost/iostreams/detail/config/auto_link.hpp>
  136. #include <boost/iostreams/detail/config/dyn_link.hpp>
  137. #include <boost/iostreams/detail/config/wide_streams.hpp>
  138. #include <boost/iostreams/detail/ios.hpp> // failure, streamsize.
  139. #include <boost/iostreams/filter/symmetric.hpp>
  140. #include <boost/iostreams/pipeline.hpp>
  141. #include <boost/type_traits/is_same.hpp>
  142. // Must come last.
  143. #ifdef BOOST_MSVC
  144. # pragma warning(push)
  145. # pragma warning(disable:4251 4231 4660) // Dependencies not exported.
  146. #endif
  147. #include <boost/config/abi_prefix.hpp>
  148. namespace boost { namespace iostreams {
  149. namespace zstd {
  150. typedef void* (*alloc_func)(void*, size_t, size_t);
  151. typedef void (*free_func)(void*, void*);
  152. // Compression levels
  153. BOOST_IOSTREAMS_DECL extern const uint32_t best_speed;
  154. BOOST_IOSTREAMS_DECL extern const uint32_t best_compression;
  155. BOOST_IOSTREAMS_DECL extern const uint32_t default_compression;
  156. // Status codes
  157. BOOST_IOSTREAMS_DECL extern const int okay;
  158. BOOST_IOSTREAMS_DECL extern const int stream_end;
  159. // Flush codes
  160. BOOST_IOSTREAMS_DECL extern const int finish;
  161. BOOST_IOSTREAMS_DECL extern const int flush;
  162. BOOST_IOSTREAMS_DECL extern const int run;
  163. // Code for current OS
  164. // Null pointer constant.
  165. const int null = 0;
  166. // Default values
  167. } // End namespace zstd.
  168. //
  169. // Class name: zstd_params.
  170. // Description: Encapsulates the parameters passed to zstddec_init
  171. // to customize compression and decompression.
  172. //
  173. struct zstd_params {
  174. // Non-explicit constructor.
  175. zstd_params( uint32_t level = zstd::default_compression )
  176. : level(level)
  177. { }
  178. uint32_t level;
  179. };
  180. //
  181. // Class name: zstd_error.
  182. // Description: Subclass of std::ios::failure thrown to indicate
  183. // zstd errors other than out-of-memory conditions.
  184. //
  185. class BOOST_IOSTREAMS_DECL zstd_error : public BOOST_IOSTREAMS_FAILURE {
  186. public:
  187. explicit zstd_error(size_t error);
  188. int error() const { return error_; }
  189. static void check BOOST_PREVENT_MACRO_SUBSTITUTION(size_t error);
  190. private:
  191. size_t error_;
  192. };
  193. namespace detail {
  194. template<typename Alloc>
  195. struct zstd_allocator_traits {
  196. #ifndef BOOST_NO_STD_ALLOCATOR
  197. #if defined(BOOST_NO_CXX11_ALLOCATOR)
  198. typedef typename Alloc::template rebind<char>::other type;
  199. #else
  200. typedef typename std::allocator_traits<Alloc>::template rebind_alloc<char> type;
  201. #endif
  202. #else
  203. typedef std::allocator<char> type;
  204. #endif
  205. };
  206. template< typename Alloc,
  207. typename Base = // VC6 workaround (C2516)
  208. BOOST_DEDUCED_TYPENAME zstd_allocator_traits<Alloc>::type >
  209. struct zstd_allocator : private Base {
  210. private:
  211. #if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_STD_ALLOCATOR)
  212. typedef typename Base::size_type size_type;
  213. #else
  214. typedef typename std::allocator_traits<Base>::size_type size_type;
  215. #endif
  216. public:
  217. BOOST_STATIC_CONSTANT(bool, custom =
  218. (!is_same<std::allocator<char>, Base>::value));
  219. typedef typename zstd_allocator_traits<Alloc>::type allocator_type;
  220. static void* allocate(void* self, size_t items, size_t size);
  221. static void deallocate(void* self, void* address);
  222. };
  223. class BOOST_IOSTREAMS_DECL zstd_base {
  224. public:
  225. typedef char char_type;
  226. protected:
  227. zstd_base();
  228. ~zstd_base();
  229. template<typename Alloc>
  230. void init( const zstd_params& p,
  231. bool compress,
  232. zstd_allocator<Alloc>& zalloc )
  233. {
  234. bool custom = zstd_allocator<Alloc>::custom;
  235. do_init( p, compress,
  236. custom ? zstd_allocator<Alloc>::allocate : 0,
  237. custom ? zstd_allocator<Alloc>::deallocate : 0,
  238. &zalloc );
  239. }
  240. void before( const char*& src_begin, const char* src_end,
  241. char*& dest_begin, char* dest_end );
  242. void after( const char*& src_begin, char*& dest_begin,
  243. bool compress );
  244. int deflate(int action);
  245. int inflate(int action);
  246. void reset(bool compress, bool realloc);
  247. private:
  248. void do_init( const zstd_params& p, bool compress,
  249. zstd::alloc_func,
  250. zstd::free_func,
  251. void* derived );
  252. void* cstream_; // Actual type: ZSTD_CStream *
  253. void* dstream_; // Actual type: ZSTD_DStream *
  254. void* in_; // Actual type: ZSTD_inBuffer *
  255. void* out_; // Actual type: ZSTD_outBuffer *
  256. int eof_;
  257. uint32_t level;
  258. };
  259. //
  260. // Template name: zstd_compressor_impl
  261. // Description: Model of C-Style Filter implementing compression by
  262. // delegating to the zstd function deflate.
  263. //
  264. template<typename Alloc = std::allocator<char> >
  265. class zstd_compressor_impl : public zstd_base, public zstd_allocator<Alloc> {
  266. public:
  267. zstd_compressor_impl(const zstd_params& = zstd::default_compression);
  268. ~zstd_compressor_impl();
  269. bool filter( const char*& src_begin, const char* src_end,
  270. char*& dest_begin, char* dest_end, bool flush );
  271. void close();
  272. };
  273. //
  274. // Template name: zstd_decompressor_impl
  275. // Description: Model of C-Style Filter implementing decompression by
  276. // delegating to the zstd function inflate.
  277. //
  278. template<typename Alloc = std::allocator<char> >
  279. class zstd_decompressor_impl : public zstd_base, public zstd_allocator<Alloc> {
  280. public:
  281. zstd_decompressor_impl(const zstd_params&);
  282. zstd_decompressor_impl();
  283. ~zstd_decompressor_impl();
  284. bool filter( const char*& begin_in, const char* end_in,
  285. char*& begin_out, char* end_out, bool flush );
  286. void close();
  287. };
  288. } // End namespace detail.
  289. //
  290. // Template name: zstd_compressor
  291. // Description: Model of InputFilter and OutputFilter implementing
  292. // compression using zstd.
  293. //
  294. template<typename Alloc = std::allocator<char> >
  295. struct basic_zstd_compressor
  296. : symmetric_filter<detail::zstd_compressor_impl<Alloc>, Alloc>
  297. {
  298. private:
  299. typedef detail::zstd_compressor_impl<Alloc> impl_type;
  300. typedef symmetric_filter<impl_type, Alloc> base_type;
  301. public:
  302. typedef typename base_type::char_type char_type;
  303. typedef typename base_type::category category;
  304. basic_zstd_compressor( const zstd_params& = zstd::default_compression,
  305. std::streamsize buffer_size = default_device_buffer_size );
  306. };
  307. BOOST_IOSTREAMS_PIPABLE(basic_zstd_compressor, 1)
  308. typedef basic_zstd_compressor<> zstd_compressor;
  309. //
  310. // Template name: zstd_decompressor
  311. // Description: Model of InputFilter and OutputFilter implementing
  312. // decompression using zstd.
  313. //
  314. template<typename Alloc = std::allocator<char> >
  315. struct basic_zstd_decompressor
  316. : symmetric_filter<detail::zstd_decompressor_impl<Alloc>, Alloc>
  317. {
  318. private:
  319. typedef detail::zstd_decompressor_impl<Alloc> impl_type;
  320. typedef symmetric_filter<impl_type, Alloc> base_type;
  321. public:
  322. typedef typename base_type::char_type char_type;
  323. typedef typename base_type::category category;
  324. basic_zstd_decompressor( std::streamsize buffer_size = default_device_buffer_size );
  325. basic_zstd_decompressor( const zstd_params& p,
  326. std::streamsize buffer_size = default_device_buffer_size );
  327. };
  328. BOOST_IOSTREAMS_PIPABLE(basic_zstd_decompressor, 1)
  329. typedef basic_zstd_decompressor<> zstd_decompressor;
  330. //----------------------------------------------------------------------------//
  331. //------------------Implementation of zstd_allocator--------------------------//
  332. namespace detail {
  333. template<typename Alloc, typename Base>
  334. void* zstd_allocator<Alloc, Base>::allocate
  335. (void* self, size_t items, size_t size)
  336. {
  337. size_type len = items * size;
  338. char* ptr =
  339. static_cast<allocator_type*>(self)->allocate
  340. (len + sizeof(size_type)
  341. #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
  342. , (char*)0
  343. #endif
  344. );
  345. *reinterpret_cast<size_type*>(ptr) = len;
  346. return ptr + sizeof(size_type);
  347. }
  348. template<typename Alloc, typename Base>
  349. void zstd_allocator<Alloc, Base>::deallocate(void* self, void* address)
  350. {
  351. char* ptr = reinterpret_cast<char*>(address) - sizeof(size_type);
  352. size_type len = *reinterpret_cast<size_type*>(ptr) + sizeof(size_type);
  353. static_cast<allocator_type*>(self)->deallocate(ptr, len);
  354. }
  355. //------------------Implementation of zstd_compressor_impl--------------------//
  356. template<typename Alloc>
  357. zstd_compressor_impl<Alloc>::zstd_compressor_impl(const zstd_params& p)
  358. { init(p, true, static_cast<zstd_allocator<Alloc>&>(*this)); }
  359. template<typename Alloc>
  360. zstd_compressor_impl<Alloc>::~zstd_compressor_impl()
  361. { reset(true, false); }
  362. template<typename Alloc>
  363. bool zstd_compressor_impl<Alloc>::filter
  364. ( const char*& src_begin, const char* src_end,
  365. char*& dest_begin, char* dest_end, bool flush )
  366. {
  367. before(src_begin, src_end, dest_begin, dest_end);
  368. int result = deflate(flush ? zstd::finish : zstd::run);
  369. after(src_begin, dest_begin, true);
  370. return result != zstd::stream_end;
  371. }
  372. template<typename Alloc>
  373. void zstd_compressor_impl<Alloc>::close() { reset(true, true); }
  374. //------------------Implementation of zstd_decompressor_impl------------------//
  375. template<typename Alloc>
  376. zstd_decompressor_impl<Alloc>::zstd_decompressor_impl(const zstd_params& p)
  377. { init(p, false, static_cast<zstd_allocator<Alloc>&>(*this)); }
  378. template<typename Alloc>
  379. zstd_decompressor_impl<Alloc>::~zstd_decompressor_impl()
  380. { reset(false, false); }
  381. template<typename Alloc>
  382. zstd_decompressor_impl<Alloc>::zstd_decompressor_impl()
  383. {
  384. zstd_params p;
  385. init(p, false, static_cast<zstd_allocator<Alloc>&>(*this));
  386. }
  387. template<typename Alloc>
  388. bool zstd_decompressor_impl<Alloc>::filter
  389. ( const char*& src_begin, const char* src_end,
  390. char*& dest_begin, char* dest_end, bool flush )
  391. {
  392. before(src_begin, src_end, dest_begin, dest_end);
  393. int result = inflate(flush ? zstd::finish : zstd::run);
  394. after(src_begin, dest_begin, false);
  395. return result != zstd::stream_end;
  396. }
  397. template<typename Alloc>
  398. void zstd_decompressor_impl<Alloc>::close() { reset(false, true); }
  399. } // End namespace detail.
  400. //------------------Implementation of zstd_compressor-----------------------//
  401. template<typename Alloc>
  402. basic_zstd_compressor<Alloc>::basic_zstd_compressor
  403. (const zstd_params& p, std::streamsize buffer_size)
  404. : base_type(buffer_size, p) { }
  405. //------------------Implementation of zstd_decompressor-----------------------//
  406. template<typename Alloc>
  407. basic_zstd_decompressor<Alloc>::basic_zstd_decompressor
  408. (std::streamsize buffer_size)
  409. : base_type(buffer_size) { }
  410. template<typename Alloc>
  411. basic_zstd_decompressor<Alloc>::basic_zstd_decompressor
  412. (const zstd_params& p, std::streamsize buffer_size)
  413. : base_type(buffer_size, p) { }
  414. //----------------------------------------------------------------------------//
  415. } } // End namespaces iostreams, boost.
  416. #include <boost/config/abi_suffix.hpp> // Pops abi_suffix.hpp pragmas.
  417. #ifdef BOOST_MSVC
  418. # pragma warning(pop)
  419. #endif
  420. #endif // #ifndef BOOST_IOSTREAMS_ZSTD_HPP_INCLUDED