redis-server 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. data/LICENSE +38 -0
  2. data/README.md +33 -0
  3. data/bin/redis +114 -0
  4. data/redis/Makefile +5 -0
  5. data/redis/extconf.rb +3 -0
  6. data/redis/redis-2.2.11/00-RELEASENOTES +199 -0
  7. data/redis/redis-2.2.11/BUGS +1 -0
  8. data/redis/redis-2.2.11/CONTRIBUTING +13 -0
  9. data/redis/redis-2.2.11/COPYING +10 -0
  10. data/redis/redis-2.2.11/Changelog +1032 -0
  11. data/redis/redis-2.2.11/INSTALL +30 -0
  12. data/redis/redis-2.2.11/Makefile +22 -0
  13. data/redis/redis-2.2.11/README +83 -0
  14. data/redis/redis-2.2.11/TODO +4 -0
  15. data/redis/redis-2.2.11/client-libraries/README +11 -0
  16. data/redis/redis-2.2.11/deps/hiredis/COPYING +10 -0
  17. data/redis/redis-2.2.11/deps/hiredis/Makefile +115 -0
  18. data/redis/redis-2.2.11/deps/hiredis/README.md +311 -0
  19. data/redis/redis-2.2.11/deps/hiredis/TODO +2 -0
  20. data/redis/redis-2.2.11/deps/hiredis/adapters/ae.h +95 -0
  21. data/redis/redis-2.2.11/deps/hiredis/adapters/libev.h +113 -0
  22. data/redis/redis-2.2.11/deps/hiredis/adapters/libevent.h +76 -0
  23. data/redis/redis-2.2.11/deps/hiredis/async.c +321 -0
  24. data/redis/redis-2.2.11/deps/hiredis/async.h +112 -0
  25. data/redis/redis-2.2.11/deps/hiredis/example-ae.c +53 -0
  26. data/redis/redis-2.2.11/deps/hiredis/example-libev.c +47 -0
  27. data/redis/redis-2.2.11/deps/hiredis/example-libevent.c +48 -0
  28. data/redis/redis-2.2.11/deps/hiredis/example.c +67 -0
  29. data/redis/redis-2.2.11/deps/hiredis/fmacros.h +15 -0
  30. data/redis/redis-2.2.11/deps/hiredis/hiredis.c +1058 -0
  31. data/redis/redis-2.2.11/deps/hiredis/hiredis.h +170 -0
  32. data/redis/redis-2.2.11/deps/hiredis/net.c +170 -0
  33. data/redis/redis-2.2.11/deps/hiredis/net.h +43 -0
  34. data/redis/redis-2.2.11/deps/hiredis/sds.c +479 -0
  35. data/redis/redis-2.2.11/deps/hiredis/sds.h +77 -0
  36. data/redis/redis-2.2.11/deps/hiredis/test.c +479 -0
  37. data/redis/redis-2.2.11/deps/hiredis/util.h +40 -0
  38. data/redis/redis-2.2.11/deps/linenoise/Makefile +10 -0
  39. data/redis/redis-2.2.11/deps/linenoise/README.markdown +45 -0
  40. data/redis/redis-2.2.11/deps/linenoise/example.c +27 -0
  41. data/redis/redis-2.2.11/deps/linenoise/linenoise.c +609 -0
  42. data/redis/redis-2.2.11/deps/linenoise/linenoise.h +55 -0
  43. data/redis/redis-2.2.11/design-documents/REDIS-CLUSTER +214 -0
  44. data/redis/redis-2.2.11/design-documents/REDIS-CLUSTER-2 +343 -0
  45. data/redis/redis-2.2.11/doc/AppendCommand.html +48 -0
  46. data/redis/redis-2.2.11/doc/AppendOnlyFileHowto.html +41 -0
  47. data/redis/redis-2.2.11/doc/AuthCommand.html +39 -0
  48. data/redis/redis-2.2.11/doc/Benchmarks.html +129 -0
  49. data/redis/redis-2.2.11/doc/BgrewriteaofCommand.html +41 -0
  50. data/redis/redis-2.2.11/doc/BgsaveCommand.html +39 -0
  51. data/redis/redis-2.2.11/doc/BlpopCommand.html +51 -0
  52. data/redis/redis-2.2.11/doc/BrpoplpushCommand.html +39 -0
  53. data/redis/redis-2.2.11/doc/CommandReference.html +47 -0
  54. data/redis/redis-2.2.11/doc/Comparisons.html +42 -0
  55. data/redis/redis-2.2.11/doc/ConfigCommand.html +76 -0
  56. data/redis/redis-2.2.11/doc/Configuration.html +38 -0
  57. data/redis/redis-2.2.11/doc/ConnectionHandlingSidebar.html +36 -0
  58. data/redis/redis-2.2.11/doc/ControlCommandsSidebar.html +36 -0
  59. data/redis/redis-2.2.11/doc/Credits.html +38 -0
  60. data/redis/redis-2.2.11/doc/DbsizeCommand.html +38 -0
  61. data/redis/redis-2.2.11/doc/DelCommand.html +41 -0
  62. data/redis/redis-2.2.11/doc/DesignPatterns.html +37 -0
  63. data/redis/redis-2.2.11/doc/EventLibray.html +44 -0
  64. data/redis/redis-2.2.11/doc/ExistsCommand.html +42 -0
  65. data/redis/redis-2.2.11/doc/ExpireCommand.html +96 -0
  66. data/redis/redis-2.2.11/doc/FAQ.html +70 -0
  67. data/redis/redis-2.2.11/doc/Features.html +38 -0
  68. data/redis/redis-2.2.11/doc/FlushallCommand.html +39 -0
  69. data/redis/redis-2.2.11/doc/FlushdbCommand.html +39 -0
  70. data/redis/redis-2.2.11/doc/FromSqlToDataStructures.html +37 -0
  71. data/redis/redis-2.2.11/doc/GenericCommandsSidebar.html +36 -0
  72. data/redis/redis-2.2.11/doc/GetCommand.html +39 -0
  73. data/redis/redis-2.2.11/doc/GetbitCommand.html +39 -0
  74. data/redis/redis-2.2.11/doc/GetsetCommand.html +38 -0
  75. data/redis/redis-2.2.11/doc/HackingStrings.html +83 -0
  76. data/redis/redis-2.2.11/doc/HashCommandsSidebar.html +36 -0
  77. data/redis/redis-2.2.11/doc/Hashes.html +37 -0
  78. data/redis/redis-2.2.11/doc/HdelCommand.html +39 -0
  79. data/redis/redis-2.2.11/doc/HexistsCommand.html +39 -0
  80. data/redis/redis-2.2.11/doc/HgetCommand.html +39 -0
  81. data/redis/redis-2.2.11/doc/HgetallCommand.html +40 -0
  82. data/redis/redis-2.2.11/doc/HincrbyCommand.html +45 -0
  83. data/redis/redis-2.2.11/doc/HlenCommand.html +38 -0
  84. data/redis/redis-2.2.11/doc/HmgetCommand.html +40 -0
  85. data/redis/redis-2.2.11/doc/HmsetCommand.html +40 -0
  86. data/redis/redis-2.2.11/doc/HsetCommand.html +40 -0
  87. data/redis/redis-2.2.11/doc/HsetnxCommand.html +41 -0
  88. data/redis/redis-2.2.11/doc/IncrCommand.html +43 -0
  89. data/redis/redis-2.2.11/doc/InfoCommand.html +48 -0
  90. data/redis/redis-2.2.11/doc/IntroductionToRedisDataTypes.html +152 -0
  91. data/redis/redis-2.2.11/doc/KeysCommand.html +43 -0
  92. data/redis/redis-2.2.11/doc/LastsaveCommand.html +39 -0
  93. data/redis/redis-2.2.11/doc/LindexCommand.html +40 -0
  94. data/redis/redis-2.2.11/doc/ListCommandsSidebar.html +36 -0
  95. data/redis/redis-2.2.11/doc/Lists.html +42 -0
  96. data/redis/redis-2.2.11/doc/LlenCommand.html +41 -0
  97. data/redis/redis-2.2.11/doc/LpopCommand.html +41 -0
  98. data/redis/redis-2.2.11/doc/LrangeCommand.html +47 -0
  99. data/redis/redis-2.2.11/doc/LremCommand.html +41 -0
  100. data/redis/redis-2.2.11/doc/LsetCommand.html +38 -0
  101. data/redis/redis-2.2.11/doc/LtrimCommand.html +47 -0
  102. data/redis/redis-2.2.11/doc/MgetCommand.html +52 -0
  103. data/redis/redis-2.2.11/doc/MonitorCommand.html +63 -0
  104. data/redis/redis-2.2.11/doc/MoveCommand.html +42 -0
  105. data/redis/redis-2.2.11/doc/MsetCommand.html +44 -0
  106. data/redis/redis-2.2.11/doc/MultiExecCommand.html +166 -0
  107. data/redis/redis-2.2.11/doc/NonexistentCommands.html +51 -0
  108. data/redis/redis-2.2.11/doc/ObjectHashMappers.html +39 -0
  109. data/redis/redis-2.2.11/doc/Pipelining.html +36 -0
  110. data/redis/redis-2.2.11/doc/ProgrammingExamples.html +38 -0
  111. data/redis/redis-2.2.11/doc/ProtocolSpecification.html +137 -0
  112. data/redis/redis-2.2.11/doc/PublishSubscribe.html +115 -0
  113. data/redis/redis-2.2.11/doc/QuickStart.html +68 -0
  114. data/redis/redis-2.2.11/doc/QuitCommand.html +38 -0
  115. data/redis/redis-2.2.11/doc/README.html +119 -0
  116. data/redis/redis-2.2.11/doc/RandomkeyCommand.html +39 -0
  117. data/redis/redis-2.2.11/doc/Redis0100ChangeLog.html +67 -0
  118. data/redis/redis-2.2.11/doc/Redis0900ChangeLog.html +56 -0
  119. data/redis/redis-2.2.11/doc/RedisBigData.html +61 -0
  120. data/redis/redis-2.2.11/doc/RedisCLI.html +37 -0
  121. data/redis/redis-2.2.11/doc/RedisEventLibrary.html +70 -0
  122. data/redis/redis-2.2.11/doc/RedisGuides.html +37 -0
  123. data/redis/redis-2.2.11/doc/RedisInternals.html +38 -0
  124. data/redis/redis-2.2.11/doc/RedisPipelining.html +93 -0
  125. data/redis/redis-2.2.11/doc/RedisStatus.html +56 -0
  126. data/redis/redis-2.2.11/doc/Redis_1_2_0_Changelog.html +40 -0
  127. data/redis/redis-2.2.11/doc/Redis_2_0_0_Changelog.html +62 -0
  128. data/redis/redis-2.2.11/doc/Redis_2_0_Whats_new.html +59 -0
  129. data/redis/redis-2.2.11/doc/RenameCommand.html +39 -0
  130. data/redis/redis-2.2.11/doc/RenamenxCommand.html +42 -0
  131. data/redis/redis-2.2.11/doc/ReplicationHowto.html +43 -0
  132. data/redis/redis-2.2.11/doc/ReplyTypes.html +42 -0
  133. data/redis/redis-2.2.11/doc/RoadMap.html +38 -0
  134. data/redis/redis-2.2.11/doc/RpoplpushCommand.html +44 -0
  135. data/redis/redis-2.2.11/doc/RpushCommand.html +40 -0
  136. data/redis/redis-2.2.11/doc/SaddCommand.html +41 -0
  137. data/redis/redis-2.2.11/doc/SaveCommand.html +39 -0
  138. data/redis/redis-2.2.11/doc/ScardCommand.html +41 -0
  139. data/redis/redis-2.2.11/doc/SdiffCommand.html +45 -0
  140. data/redis/redis-2.2.11/doc/SdiffstoreCommand.html +38 -0
  141. data/redis/redis-2.2.11/doc/SelectCommand.html +39 -0
  142. data/redis/redis-2.2.11/doc/SetCommand.html +39 -0
  143. data/redis/redis-2.2.11/doc/SetCommandsSidebar.html +36 -0
  144. data/redis/redis-2.2.11/doc/SetbitCommand.html +45 -0
  145. data/redis/redis-2.2.11/doc/SetexCommand.html +42 -0
  146. data/redis/redis-2.2.11/doc/SetnxCommand.html +51 -0
  147. data/redis/redis-2.2.11/doc/SetrangeCommand.html +58 -0
  148. data/redis/redis-2.2.11/doc/Sets.html +36 -0
  149. data/redis/redis-2.2.11/doc/ShutdownCommand.html +39 -0
  150. data/redis/redis-2.2.11/doc/SideBar.html +36 -0
  151. data/redis/redis-2.2.11/doc/SinterCommand.html +40 -0
  152. data/redis/redis-2.2.11/doc/SinterstoreCommand.html +39 -0
  153. data/redis/redis-2.2.11/doc/SismemberCommand.html +42 -0
  154. data/redis/redis-2.2.11/doc/SlaveofCommand.html +41 -0
  155. data/redis/redis-2.2.11/doc/SmembersCommand.html +38 -0
  156. data/redis/redis-2.2.11/doc/SmoveCommand.html +44 -0
  157. data/redis/redis-2.2.11/doc/SortCommand.html +75 -0
  158. data/redis/redis-2.2.11/doc/SortedSetCommandsSidebar.html +36 -0
  159. data/redis/redis-2.2.11/doc/SortedSets.html +36 -0
  160. data/redis/redis-2.2.11/doc/Speed.html +38 -0
  161. data/redis/redis-2.2.11/doc/SponsorshipHistory.html +38 -0
  162. data/redis/redis-2.2.11/doc/SpopCommand.html +40 -0
  163. data/redis/redis-2.2.11/doc/SrandmemberCommand.html +40 -0
  164. data/redis/redis-2.2.11/doc/SremCommand.html +42 -0
  165. data/redis/redis-2.2.11/doc/StringCommandsSidebar.html +36 -0
  166. data/redis/redis-2.2.11/doc/Strings.html +37 -0
  167. data/redis/redis-2.2.11/doc/StrlenCommand.html +39 -0
  168. data/redis/redis-2.2.11/doc/SubstrCommand.html +52 -0
  169. data/redis/redis-2.2.11/doc/SunionCommand.html +40 -0
  170. data/redis/redis-2.2.11/doc/SunionstoreCommand.html +38 -0
  171. data/redis/redis-2.2.11/doc/SupportedLanguages.html +60 -0
  172. data/redis/redis-2.2.11/doc/SupportedPlatforms.html +37 -0
  173. data/redis/redis-2.2.11/doc/TemplateCommand.html +38 -0
  174. data/redis/redis-2.2.11/doc/TtlCommand.html +38 -0
  175. data/redis/redis-2.2.11/doc/TwitterAlikeExample.html +250 -0
  176. data/redis/redis-2.2.11/doc/TypeCommand.html +46 -0
  177. data/redis/redis-2.2.11/doc/UnstableSource.html +39 -0
  178. data/redis/redis-2.2.11/doc/VirtualMemorySpecification.html +156 -0
  179. data/redis/redis-2.2.11/doc/VirtualMemoryUserGuide.html +66 -0
  180. data/redis/redis-2.2.11/doc/ZaddCommand.html +43 -0
  181. data/redis/redis-2.2.11/doc/ZcardCommand.html +41 -0
  182. data/redis/redis-2.2.11/doc/ZincrbyCommand.html +42 -0
  183. data/redis/redis-2.2.11/doc/ZrangeCommand.html +42 -0
  184. data/redis/redis-2.2.11/doc/ZrangebyscoreCommand.html +77 -0
  185. data/redis/redis-2.2.11/doc/ZrankCommand.html +43 -0
  186. data/redis/redis-2.2.11/doc/ZremCommand.html +42 -0
  187. data/redis/redis-2.2.11/doc/ZremrangebyrankCommand.html +39 -0
  188. data/redis/redis-2.2.11/doc/ZremrangebyscoreCommand.html +39 -0
  189. data/redis/redis-2.2.11/doc/ZscoreCommand.html +41 -0
  190. data/redis/redis-2.2.11/doc/ZunionCommand.html +42 -0
  191. data/redis/redis-2.2.11/doc/ZunionstoreCommand.html +43 -0
  192. data/redis/redis-2.2.11/doc/index.html +43 -0
  193. data/redis/redis-2.2.11/doc/redis.png +0 -0
  194. data/redis/redis-2.2.11/doc/style.css +25 -0
  195. data/redis/redis-2.2.11/redis.conf +417 -0
  196. data/redis/redis-2.2.11/src/Makefile +177 -0
  197. data/redis/redis-2.2.11/src/adlist.c +325 -0
  198. data/redis/redis-2.2.11/src/adlist.h +92 -0
  199. data/redis/redis-2.2.11/src/ae.c +390 -0
  200. data/redis/redis-2.2.11/src/ae.h +117 -0
  201. data/redis/redis-2.2.11/src/ae_epoll.c +91 -0
  202. data/redis/redis-2.2.11/src/ae_kqueue.c +93 -0
  203. data/redis/redis-2.2.11/src/ae_select.c +72 -0
  204. data/redis/redis-2.2.11/src/anet.c +347 -0
  205. data/redis/redis-2.2.11/src/anet.h +57 -0
  206. data/redis/redis-2.2.11/src/aof.c +675 -0
  207. data/redis/redis-2.2.11/src/config.c +627 -0
  208. data/redis/redis-2.2.11/src/config.h +64 -0
  209. data/redis/redis-2.2.11/src/db.c +543 -0
  210. data/redis/redis-2.2.11/src/debug.c +314 -0
  211. data/redis/redis-2.2.11/src/dict.c +721 -0
  212. data/redis/redis-2.2.11/src/dict.h +156 -0
  213. data/redis/redis-2.2.11/src/fmacros.h +15 -0
  214. data/redis/redis-2.2.11/src/help.h +638 -0
  215. data/redis/redis-2.2.11/src/intset.c +422 -0
  216. data/redis/redis-2.2.11/src/intset.h +19 -0
  217. data/redis/redis-2.2.11/src/lzf.h +100 -0
  218. data/redis/redis-2.2.11/src/lzfP.h +159 -0
  219. data/redis/redis-2.2.11/src/lzf_c.c +295 -0
  220. data/redis/redis-2.2.11/src/lzf_d.c +150 -0
  221. data/redis/redis-2.2.11/src/mkreleasehdr.sh +9 -0
  222. data/redis/redis-2.2.11/src/multi.c +268 -0
  223. data/redis/redis-2.2.11/src/networking.c +899 -0
  224. data/redis/redis-2.2.11/src/object.c +484 -0
  225. data/redis/redis-2.2.11/src/pqsort.c +197 -0
  226. data/redis/redis-2.2.11/src/pqsort.h +15 -0
  227. data/redis/redis-2.2.11/src/pubsub.c +267 -0
  228. data/redis/redis-2.2.11/src/rdb.c +1020 -0
  229. data/redis/redis-2.2.11/src/redis-benchmark.c +530 -0
  230. data/redis/redis-2.2.11/src/redis-check-aof.c +185 -0
  231. data/redis/redis-2.2.11/src/redis-check-dump.c +681 -0
  232. data/redis/redis-2.2.11/src/redis-cli.c +773 -0
  233. data/redis/redis-2.2.11/src/redis.c +1677 -0
  234. data/redis/redis-2.2.11/src/redis.h +1022 -0
  235. data/redis/redis-2.2.11/src/release.c +13 -0
  236. data/redis/redis-2.2.11/src/replication.c +557 -0
  237. data/redis/redis-2.2.11/src/sds.c +639 -0
  238. data/redis/redis-2.2.11/src/sds.h +78 -0
  239. data/redis/redis-2.2.11/src/sha1.c +276 -0
  240. data/redis/redis-2.2.11/src/sha1.h +17 -0
  241. data/redis/redis-2.2.11/src/solarisfixes.h +22 -0
  242. data/redis/redis-2.2.11/src/sort.c +389 -0
  243. data/redis/redis-2.2.11/src/syncio.c +154 -0
  244. data/redis/redis-2.2.11/src/t_hash.c +476 -0
  245. data/redis/redis-2.2.11/src/t_list.c +986 -0
  246. data/redis/redis-2.2.11/src/t_set.c +610 -0
  247. data/redis/redis-2.2.11/src/t_string.c +438 -0
  248. data/redis/redis-2.2.11/src/t_zset.c +1084 -0
  249. data/redis/redis-2.2.11/src/testhelp.h +54 -0
  250. data/redis/redis-2.2.11/src/util.c +243 -0
  251. data/redis/redis-2.2.11/src/valgrind.sup +5 -0
  252. data/redis/redis-2.2.11/src/version.h +1 -0
  253. data/redis/redis-2.2.11/src/vm.c +1149 -0
  254. data/redis/redis-2.2.11/src/ziplist.c +1323 -0
  255. data/redis/redis-2.2.11/src/ziplist.h +15 -0
  256. data/redis/redis-2.2.11/src/zipmap.c +455 -0
  257. data/redis/redis-2.2.11/src/zipmap.h +48 -0
  258. data/redis/redis-2.2.11/src/zmalloc.c +278 -0
  259. data/redis/redis-2.2.11/src/zmalloc.h +47 -0
  260. data/redis/redis-2.2.11/tests/assets/default.conf +308 -0
  261. data/redis/redis-2.2.11/tests/integration/aof.tcl +104 -0
  262. data/redis/redis-2.2.11/tests/integration/redis-cli.tcl +208 -0
  263. data/redis/redis-2.2.11/tests/integration/replication.tcl +98 -0
  264. data/redis/redis-2.2.11/tests/support/redis.tcl +241 -0
  265. data/redis/redis-2.2.11/tests/support/server.tcl +294 -0
  266. data/redis/redis-2.2.11/tests/support/test.tcl +190 -0
  267. data/redis/redis-2.2.11/tests/support/tmpfile.tcl +15 -0
  268. data/redis/redis-2.2.11/tests/support/util.tcl +296 -0
  269. data/redis/redis-2.2.11/tests/test_helper.tcl +221 -0
  270. data/redis/redis-2.2.11/tests/unit/auth.tcl +15 -0
  271. data/redis/redis-2.2.11/tests/unit/basic.tcl +616 -0
  272. data/redis/redis-2.2.11/tests/unit/cas.tcl +135 -0
  273. data/redis/redis-2.2.11/tests/unit/expire.tcl +74 -0
  274. data/redis/redis-2.2.11/tests/unit/other.tcl +240 -0
  275. data/redis/redis-2.2.11/tests/unit/printver.tcl +6 -0
  276. data/redis/redis-2.2.11/tests/unit/protocol.tcl +62 -0
  277. data/redis/redis-2.2.11/tests/unit/pubsub.tcl +195 -0
  278. data/redis/redis-2.2.11/tests/unit/quit.tcl +40 -0
  279. data/redis/redis-2.2.11/tests/unit/sort.tcl +189 -0
  280. data/redis/redis-2.2.11/tests/unit/type/hash.tcl +300 -0
  281. data/redis/redis-2.2.11/tests/unit/type/list.tcl +819 -0
  282. data/redis/redis-2.2.11/tests/unit/type/set.tcl +334 -0
  283. data/redis/redis-2.2.11/tests/unit/type/zset.tcl +587 -0
  284. data/redis/redis-2.2.11/utils/build-static-symbols.tcl +22 -0
  285. data/redis/redis-2.2.11/utils/generate-command-help.rb +112 -0
  286. data/redis/redis-2.2.11/utils/mktarball.sh +13 -0
  287. data/redis/redis-2.2.11/utils/redis-copy.rb +78 -0
  288. data/redis/redis-2.2.11/utils/redis-sha1.rb +52 -0
  289. data/redis/redis-2.2.11/utils/redis_init_script +42 -0
  290. metadata +362 -0
@@ -0,0 +1,159 @@
1
+ /*
2
+ * Copyright (c) 2000-2007 Marc Alexander Lehmann <schmorp@schmorp.de>
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without modifica-
5
+ * tion, are permitted provided that the following conditions are met:
6
+ *
7
+ * 1. Redistributions of source code must retain the above copyright notice,
8
+ * this list of conditions and the following disclaimer.
9
+ *
10
+ * 2. Redistributions in binary form must reproduce the above copyright
11
+ * notice, this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
16
+ * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
18
+ * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
22
+ * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
23
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * Alternatively, the contents of this file may be used under the terms of
26
+ * the GNU General Public License ("GPL") version 2 or any later version,
27
+ * in which case the provisions of the GPL are applicable instead of
28
+ * the above. If you wish to allow the use of your version of this file
29
+ * only under the terms of the GPL and not to allow others to use your
30
+ * version of this file under the BSD license, indicate your decision
31
+ * by deleting the provisions above and replace them with the notice
32
+ * and other provisions required by the GPL. If you do not delete the
33
+ * provisions above, a recipient may use your version of this file under
34
+ * either the BSD or the GPL.
35
+ */
36
+
37
+ #ifndef LZFP_h
38
+ #define LZFP_h
39
+
40
+ #define STANDALONE 1 /* at the moment, this is ok. */
41
+
42
+ #ifndef STANDALONE
43
+ # include "lzf.h"
44
+ #endif
45
+
46
+ /*
47
+ * Size of hashtable is (1 << HLOG) * sizeof (char *)
48
+ * decompression is independent of the hash table size
49
+ * the difference between 15 and 14 is very small
50
+ * for small blocks (and 14 is usually a bit faster).
51
+ * For a low-memory/faster configuration, use HLOG == 13;
52
+ * For best compression, use 15 or 16 (or more, up to 23).
53
+ */
54
+ #ifndef HLOG
55
+ # define HLOG 16
56
+ #endif
57
+
58
+ /*
59
+ * Sacrifice very little compression quality in favour of compression speed.
60
+ * This gives almost the same compression as the default code, and is
61
+ * (very roughly) 15% faster. This is the preferred mode of operation.
62
+ */
63
+ #ifndef VERY_FAST
64
+ # define VERY_FAST 1
65
+ #endif
66
+
67
+ /*
68
+ * Sacrifice some more compression quality in favour of compression speed.
69
+ * (roughly 1-2% worse compression for large blocks and
70
+ * 9-10% for small, redundant, blocks and >>20% better speed in both cases)
71
+ * In short: when in need for speed, enable this for binary data,
72
+ * possibly disable this for text data.
73
+ */
74
+ #ifndef ULTRA_FAST
75
+ # define ULTRA_FAST 0
76
+ #endif
77
+
78
+ /*
79
+ * Unconditionally aligning does not cost very much, so do it if unsure
80
+ */
81
+ #ifndef STRICT_ALIGN
82
+ # define STRICT_ALIGN !(defined(__i386) || defined (__amd64))
83
+ #endif
84
+
85
+ /*
86
+ * You may choose to pre-set the hash table (might be faster on some
87
+ * modern cpus and large (>>64k) blocks, and also makes compression
88
+ * deterministic/repeatable when the configuration otherwise is the same).
89
+ */
90
+ #ifndef INIT_HTAB
91
+ # define INIT_HTAB 0
92
+ #endif
93
+
94
+ /*
95
+ * Avoid assigning values to errno variable? for some embedding purposes
96
+ * (linux kernel for example), this is neccessary. NOTE: this breaks
97
+ * the documentation in lzf.h.
98
+ */
99
+ #ifndef AVOID_ERRNO
100
+ # define AVOID_ERRNO 0
101
+ #endif
102
+
103
+ /*
104
+ * Wether to pass the LZF_STATE variable as argument, or allocate it
105
+ * on the stack. For small-stack environments, define this to 1.
106
+ * NOTE: this breaks the prototype in lzf.h.
107
+ */
108
+ #ifndef LZF_STATE_ARG
109
+ # define LZF_STATE_ARG 0
110
+ #endif
111
+
112
+ /*
113
+ * Wether to add extra checks for input validity in lzf_decompress
114
+ * and return EINVAL if the input stream has been corrupted. This
115
+ * only shields against overflowing the input buffer and will not
116
+ * detect most corrupted streams.
117
+ * This check is not normally noticable on modern hardware
118
+ * (<1% slowdown), but might slow down older cpus considerably.
119
+ */
120
+ #ifndef CHECK_INPUT
121
+ # define CHECK_INPUT 1
122
+ #endif
123
+
124
+ /*****************************************************************************/
125
+ /* nothing should be changed below */
126
+
127
+ typedef unsigned char u8;
128
+
129
+ typedef const u8 *LZF_STATE[1 << (HLOG)];
130
+
131
+ #if !STRICT_ALIGN
132
+ /* for unaligned accesses we need a 16 bit datatype. */
133
+ # include <limits.h>
134
+ # if USHRT_MAX == 65535
135
+ typedef unsigned short u16;
136
+ # elif UINT_MAX == 65535
137
+ typedef unsigned int u16;
138
+ # else
139
+ # undef STRICT_ALIGN
140
+ # define STRICT_ALIGN 1
141
+ # endif
142
+ #endif
143
+
144
+ #if ULTRA_FAST
145
+ # if defined(VERY_FAST)
146
+ # undef VERY_FAST
147
+ # endif
148
+ #endif
149
+
150
+ #if INIT_HTAB
151
+ # ifdef __cplusplus
152
+ # include <cstring>
153
+ # else
154
+ # include <string.h>
155
+ # endif
156
+ #endif
157
+
158
+ #endif
159
+
@@ -0,0 +1,295 @@
1
+ /*
2
+ * Copyright (c) 2000-2008 Marc Alexander Lehmann <schmorp@schmorp.de>
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without modifica-
5
+ * tion, are permitted provided that the following conditions are met:
6
+ *
7
+ * 1. Redistributions of source code must retain the above copyright notice,
8
+ * this list of conditions and the following disclaimer.
9
+ *
10
+ * 2. Redistributions in binary form must reproduce the above copyright
11
+ * notice, this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
16
+ * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
18
+ * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
22
+ * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
23
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * Alternatively, the contents of this file may be used under the terms of
26
+ * the GNU General Public License ("GPL") version 2 or any later version,
27
+ * in which case the provisions of the GPL are applicable instead of
28
+ * the above. If you wish to allow the use of your version of this file
29
+ * only under the terms of the GPL and not to allow others to use your
30
+ * version of this file under the BSD license, indicate your decision
31
+ * by deleting the provisions above and replace them with the notice
32
+ * and other provisions required by the GPL. If you do not delete the
33
+ * provisions above, a recipient may use your version of this file under
34
+ * either the BSD or the GPL.
35
+ */
36
+
37
+ #include "lzfP.h"
38
+
39
+ #define HSIZE (1 << (HLOG))
40
+
41
+ /*
42
+ * don't play with this unless you benchmark!
43
+ * decompression is not dependent on the hash function
44
+ * the hashing function might seem strange, just believe me
45
+ * it works ;)
46
+ */
47
+ #ifndef FRST
48
+ # define FRST(p) (((p[0]) << 8) | p[1])
49
+ # define NEXT(v,p) (((v) << 8) | p[2])
50
+ # if ULTRA_FAST
51
+ # define IDX(h) ((( h >> (3*8 - HLOG)) - h ) & (HSIZE - 1))
52
+ # elif VERY_FAST
53
+ # define IDX(h) ((( h >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
54
+ # else
55
+ # define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
56
+ # endif
57
+ #endif
58
+ /*
59
+ * IDX works because it is very similar to a multiplicative hash, e.g.
60
+ * ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1))
61
+ * the latter is also quite fast on newer CPUs, and compresses similarly.
62
+ *
63
+ * the next one is also quite good, albeit slow ;)
64
+ * (int)(cos(h & 0xffffff) * 1e6)
65
+ */
66
+
67
+ #if 0
68
+ /* original lzv-like hash function, much worse and thus slower */
69
+ # define FRST(p) (p[0] << 5) ^ p[1]
70
+ # define NEXT(v,p) ((v) << 5) ^ p[2]
71
+ # define IDX(h) ((h) & (HSIZE - 1))
72
+ #endif
73
+
74
+ #define MAX_LIT (1 << 5)
75
+ #define MAX_OFF (1 << 13)
76
+ #define MAX_REF ((1 << 8) + (1 << 3))
77
+
78
+ #if __GNUC__ >= 3
79
+ # define expect(expr,value) __builtin_expect ((expr),(value))
80
+ # define inline inline
81
+ #else
82
+ # define expect(expr,value) (expr)
83
+ # define inline static
84
+ #endif
85
+
86
+ #define expect_false(expr) expect ((expr) != 0, 0)
87
+ #define expect_true(expr) expect ((expr) != 0, 1)
88
+
89
+ /*
90
+ * compressed format
91
+ *
92
+ * 000LLLLL <L+1> ; literal
93
+ * LLLooooo oooooooo ; backref L
94
+ * 111ooooo LLLLLLLL oooooooo ; backref L+7
95
+ *
96
+ */
97
+
98
+ unsigned int
99
+ lzf_compress (const void *const in_data, unsigned int in_len,
100
+ void *out_data, unsigned int out_len
101
+ #if LZF_STATE_ARG
102
+ , LZF_STATE htab
103
+ #endif
104
+ )
105
+ {
106
+ #if !LZF_STATE_ARG
107
+ LZF_STATE htab;
108
+ #endif
109
+ const u8 **hslot;
110
+ const u8 *ip = (const u8 *)in_data;
111
+ u8 *op = (u8 *)out_data;
112
+ const u8 *in_end = ip + in_len;
113
+ u8 *out_end = op + out_len;
114
+ const u8 *ref;
115
+
116
+ /* off requires a type wide enough to hold a general pointer difference.
117
+ * ISO C doesn't have that (size_t might not be enough and ptrdiff_t only
118
+ * works for differences within a single object). We also assume that no
119
+ * no bit pattern traps. Since the only platform that is both non-POSIX
120
+ * and fails to support both assumptions is windows 64 bit, we make a
121
+ * special workaround for it.
122
+ */
123
+ #if defined (WIN32) && defined (_M_X64)
124
+ unsigned _int64 off; /* workaround for missing POSIX compliance */
125
+ #else
126
+ unsigned long off;
127
+ #endif
128
+ unsigned int hval;
129
+ int lit;
130
+
131
+ if (!in_len || !out_len)
132
+ return 0;
133
+
134
+ #if INIT_HTAB
135
+ memset (htab, 0, sizeof (htab));
136
+ # if 0
137
+ for (hslot = htab; hslot < htab + HSIZE; hslot++)
138
+ *hslot++ = ip;
139
+ # endif
140
+ #endif
141
+
142
+ lit = 0; op++; /* start run */
143
+
144
+ hval = FRST (ip);
145
+ while (ip < in_end - 2)
146
+ {
147
+ hval = NEXT (hval, ip);
148
+ hslot = htab + IDX (hval);
149
+ ref = *hslot; *hslot = ip;
150
+
151
+ if (1
152
+ #if INIT_HTAB
153
+ && ref < ip /* the next test will actually take care of this, but this is faster */
154
+ #endif
155
+ && (off = ip - ref - 1) < MAX_OFF
156
+ && ip + 4 < in_end
157
+ && ref > (u8 *)in_data
158
+ #if STRICT_ALIGN
159
+ && ref[0] == ip[0]
160
+ && ref[1] == ip[1]
161
+ && ref[2] == ip[2]
162
+ #else
163
+ && *(u16 *)ref == *(u16 *)ip
164
+ && ref[2] == ip[2]
165
+ #endif
166
+ )
167
+ {
168
+ /* match found at *ref++ */
169
+ unsigned int len = 2;
170
+ unsigned int maxlen = in_end - ip - len;
171
+ maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;
172
+
173
+ op [- lit - 1] = lit - 1; /* stop run */
174
+ op -= !lit; /* undo run if length is zero */
175
+
176
+ if (expect_false (op + 3 + 1 >= out_end))
177
+ return 0;
178
+
179
+ for (;;)
180
+ {
181
+ if (expect_true (maxlen > 16))
182
+ {
183
+ len++; if (ref [len] != ip [len]) break;
184
+ len++; if (ref [len] != ip [len]) break;
185
+ len++; if (ref [len] != ip [len]) break;
186
+ len++; if (ref [len] != ip [len]) break;
187
+
188
+ len++; if (ref [len] != ip [len]) break;
189
+ len++; if (ref [len] != ip [len]) break;
190
+ len++; if (ref [len] != ip [len]) break;
191
+ len++; if (ref [len] != ip [len]) break;
192
+
193
+ len++; if (ref [len] != ip [len]) break;
194
+ len++; if (ref [len] != ip [len]) break;
195
+ len++; if (ref [len] != ip [len]) break;
196
+ len++; if (ref [len] != ip [len]) break;
197
+
198
+ len++; if (ref [len] != ip [len]) break;
199
+ len++; if (ref [len] != ip [len]) break;
200
+ len++; if (ref [len] != ip [len]) break;
201
+ len++; if (ref [len] != ip [len]) break;
202
+ }
203
+
204
+ do
205
+ len++;
206
+ while (len < maxlen && ref[len] == ip[len]);
207
+
208
+ break;
209
+ }
210
+
211
+ len -= 2; /* len is now #octets - 1 */
212
+ ip++;
213
+
214
+ if (len < 7)
215
+ {
216
+ *op++ = (off >> 8) + (len << 5);
217
+ }
218
+ else
219
+ {
220
+ *op++ = (off >> 8) + ( 7 << 5);
221
+ *op++ = len - 7;
222
+ }
223
+
224
+ *op++ = off;
225
+ lit = 0; op++; /* start run */
226
+
227
+ ip += len + 1;
228
+
229
+ if (expect_false (ip >= in_end - 2))
230
+ break;
231
+
232
+ #if ULTRA_FAST || VERY_FAST
233
+ --ip;
234
+ # if VERY_FAST && !ULTRA_FAST
235
+ --ip;
236
+ # endif
237
+ hval = FRST (ip);
238
+
239
+ hval = NEXT (hval, ip);
240
+ htab[IDX (hval)] = ip;
241
+ ip++;
242
+
243
+ # if VERY_FAST && !ULTRA_FAST
244
+ hval = NEXT (hval, ip);
245
+ htab[IDX (hval)] = ip;
246
+ ip++;
247
+ # endif
248
+ #else
249
+ ip -= len + 1;
250
+
251
+ do
252
+ {
253
+ hval = NEXT (hval, ip);
254
+ htab[IDX (hval)] = ip;
255
+ ip++;
256
+ }
257
+ while (len--);
258
+ #endif
259
+ }
260
+ else
261
+ {
262
+ /* one more literal byte we must copy */
263
+ if (expect_false (op >= out_end))
264
+ return 0;
265
+
266
+ lit++; *op++ = *ip++;
267
+
268
+ if (expect_false (lit == MAX_LIT))
269
+ {
270
+ op [- lit - 1] = lit - 1; /* stop run */
271
+ lit = 0; op++; /* start run */
272
+ }
273
+ }
274
+ }
275
+
276
+ if (op + 3 > out_end) /* at most 3 bytes can be missing here */
277
+ return 0;
278
+
279
+ while (ip < in_end)
280
+ {
281
+ lit++; *op++ = *ip++;
282
+
283
+ if (expect_false (lit == MAX_LIT))
284
+ {
285
+ op [- lit - 1] = lit - 1; /* stop run */
286
+ lit = 0; op++; /* start run */
287
+ }
288
+ }
289
+
290
+ op [- lit - 1] = lit - 1; /* end run */
291
+ op -= !lit; /* undo run if length is zero */
292
+
293
+ return op - (u8 *)out_data;
294
+ }
295
+