heroku-tokyotyrant 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (340) hide show
  1. data/COPYING +504 -0
  2. data/README.rdoc +231 -0
  3. data/Rakefile +72 -0
  4. data/benchmarks/balancer.rb +101 -0
  5. data/benchmarks/bulk_db.rb +74 -0
  6. data/benchmarks/bulk_table.rb +87 -0
  7. data/benchmarks/db.rb +114 -0
  8. data/benchmarks/table.rb +161 -0
  9. data/ext/extconf.rb +43 -0
  10. data/ext/tokyo/bin/tcamgr +0 -0
  11. data/ext/tokyo/bin/tcamttest +0 -0
  12. data/ext/tokyo/bin/tcatest +0 -0
  13. data/ext/tokyo/bin/tcbmgr +0 -0
  14. data/ext/tokyo/bin/tcbmttest +0 -0
  15. data/ext/tokyo/bin/tcbtest +0 -0
  16. data/ext/tokyo/bin/tcfmgr +0 -0
  17. data/ext/tokyo/bin/tcfmttest +0 -0
  18. data/ext/tokyo/bin/tcftest +0 -0
  19. data/ext/tokyo/bin/tchmgr +0 -0
  20. data/ext/tokyo/bin/tchmttest +0 -0
  21. data/ext/tokyo/bin/tchtest +0 -0
  22. data/ext/tokyo/bin/tcrmgr +0 -0
  23. data/ext/tokyo/bin/tcrmttest +0 -0
  24. data/ext/tokyo/bin/tcrtest +0 -0
  25. data/ext/tokyo/bin/tctmgr +0 -0
  26. data/ext/tokyo/bin/tctmttest +0 -0
  27. data/ext/tokyo/bin/tcttest +0 -0
  28. data/ext/tokyo/bin/tcucodec +0 -0
  29. data/ext/tokyo/bin/tcumttest +0 -0
  30. data/ext/tokyo/bin/tcutest +0 -0
  31. data/ext/tokyo/bin/ttserver +0 -0
  32. data/ext/tokyo/bin/ttulmgr +0 -0
  33. data/ext/tokyo/bin/ttultest +0 -0
  34. data/ext/tokyo/include/tcadb.h +548 -0
  35. data/ext/tokyo/include/tcbdb.h +1101 -0
  36. data/ext/tokyo/include/tcfdb.h +858 -0
  37. data/ext/tokyo/include/tchdb.h +871 -0
  38. data/ext/tokyo/include/tcrdb.h +801 -0
  39. data/ext/tokyo/include/tctdb.h +1086 -0
  40. data/ext/tokyo/include/tculog.h +392 -0
  41. data/ext/tokyo/include/tcutil.h +4184 -0
  42. data/ext/tokyo/include/ttutil.h +494 -0
  43. data/ext/tokyo/lib/libtokyocabinet.9.4.0.dylib +0 -0
  44. data/ext/tokyo/lib/libtokyocabinet.9.dylib +0 -0
  45. data/ext/tokyo/lib/libtokyocabinet.a +0 -0
  46. data/ext/tokyo/lib/libtokyocabinet.dylib +0 -0
  47. data/ext/tokyo/lib/libtokyotyrant.3.22.0.dylib +0 -0
  48. data/ext/tokyo/lib/libtokyotyrant.3.dylib +0 -0
  49. data/ext/tokyo/lib/libtokyotyrant.a +0 -0
  50. data/ext/tokyo/lib/libtokyotyrant.dylib +0 -0
  51. data/ext/tokyo/lib/pkgconfig/tokyocabinet.pc +14 -0
  52. data/ext/tokyo/lib/pkgconfig/tokyotyrant.pc +14 -0
  53. data/ext/tokyo/lib/ttskeldir.bundle +0 -0
  54. data/ext/tokyo/lib/ttskelmock.bundle +0 -0
  55. data/ext/tokyo/lib/ttskelnull.bundle +0 -0
  56. data/ext/tokyo/lib/ttskelproxy.bundle +0 -0
  57. data/ext/tokyo/libexec/tcawmgr.cgi +0 -0
  58. data/ext/tokyo/sbin/ttservctl +163 -0
  59. data/ext/tokyo/share/man/man1/tcamgr.1 +97 -0
  60. data/ext/tokyo/share/man/man1/tcamttest.1 +35 -0
  61. data/ext/tokyo/share/man/man1/tcatest.1 +55 -0
  62. data/ext/tokyo/share/man/man1/tcbmgr.1 +125 -0
  63. data/ext/tokyo/share/man/man1/tcbmttest.1 +81 -0
  64. data/ext/tokyo/share/man/man1/tcbtest.1 +107 -0
  65. data/ext/tokyo/share/man/man1/tcfmgr.1 +98 -0
  66. data/ext/tokyo/share/man/man1/tcfmttest.1 +62 -0
  67. data/ext/tokyo/share/man/man1/tcftest.1 +73 -0
  68. data/ext/tokyo/share/man/man1/tchmgr.1 +110 -0
  69. data/ext/tokyo/share/man/man1/tchmttest.1 +85 -0
  70. data/ext/tokyo/share/man/man1/tchtest.1 +95 -0
  71. data/ext/tokyo/share/man/man1/tcrmgr.1 +164 -0
  72. data/ext/tokyo/share/man/man1/tcrmttest.1 +55 -0
  73. data/ext/tokyo/share/man/man1/tcrtest.1 +89 -0
  74. data/ext/tokyo/share/man/man1/tctmgr.1 +140 -0
  75. data/ext/tokyo/share/man/man1/tctmttest.1 +92 -0
  76. data/ext/tokyo/share/man/man1/tcttest.1 +105 -0
  77. data/ext/tokyo/share/man/man1/tcucodec.1 +162 -0
  78. data/ext/tokyo/share/man/man1/tcumttest.1 +41 -0
  79. data/ext/tokyo/share/man/man1/tcutest.1 +81 -0
  80. data/ext/tokyo/share/man/man1/ttserver.1 +84 -0
  81. data/ext/tokyo/share/man/man1/ttulmgr.1 +40 -0
  82. data/ext/tokyo/share/man/man1/ttultest.1 +16 -0
  83. data/ext/tokyo/share/man/man3/tcadb.3 +676 -0
  84. data/ext/tokyo/share/man/man3/tcbdb.3 +1355 -0
  85. data/ext/tokyo/share/man/man3/tcfdb.3 +975 -0
  86. data/ext/tokyo/share/man/man3/tchdb.3 +898 -0
  87. data/ext/tokyo/share/man/man3/tclist.3 +1 -0
  88. data/ext/tokyo/share/man/man3/tcmap.3 +1 -0
  89. data/ext/tokyo/share/man/man3/tcmdb.3 +1 -0
  90. data/ext/tokyo/share/man/man3/tcmpool.3 +1 -0
  91. data/ext/tokyo/share/man/man3/tcrdb.3 +1309 -0
  92. data/ext/tokyo/share/man/man3/tctdb.3 +1110 -0
  93. data/ext/tokyo/share/man/man3/tctree.3 +1 -0
  94. data/ext/tokyo/share/man/man3/tculog.3 +15 -0
  95. data/ext/tokyo/share/man/man3/tcutil.3 +4518 -0
  96. data/ext/tokyo/share/man/man3/tcxstr.3 +1 -0
  97. data/ext/tokyo/share/man/man3/tokyocabinet.3 +132 -0
  98. data/ext/tokyo/share/man/man3/ttutil.3 +14 -0
  99. data/ext/tokyo/share/man/man8/ttservctl.8 +37 -0
  100. data/ext/tokyo/share/tokyocabinet/COPYING +504 -0
  101. data/ext/tokyo/share/tokyocabinet/ChangeLog +1252 -0
  102. data/ext/tokyo/share/tokyocabinet/THANKS +12 -0
  103. data/ext/tokyo/share/tokyocabinet/doc/benchmark.pdf +0 -0
  104. data/ext/tokyo/share/tokyocabinet/doc/common.css +211 -0
  105. data/ext/tokyo/share/tokyocabinet/doc/icon16.png +0 -0
  106. data/ext/tokyo/share/tokyocabinet/doc/index.html +156 -0
  107. data/ext/tokyo/share/tokyocabinet/doc/index.ja.html +197 -0
  108. data/ext/tokyo/share/tokyocabinet/doc/logo-ja.png +0 -0
  109. data/ext/tokyo/share/tokyocabinet/doc/logo.png +0 -0
  110. data/ext/tokyo/share/tokyocabinet/doc/spex-en.html +7145 -0
  111. data/ext/tokyo/share/tokyocabinet/doc/spex-ja.html +7476 -0
  112. data/ext/tokyo/share/tokyocabinet/doc/tokyoproducts.pdf +0 -0
  113. data/ext/tokyo/share/tokyocabinet/doc/tokyoproducts.ppt +0 -0
  114. data/ext/tokyo/share/tokyotyrant/COPYING +504 -0
  115. data/ext/tokyo/share/tokyotyrant/ChangeLog +578 -0
  116. data/ext/tokyo/share/tokyotyrant/THANKS +15 -0
  117. data/ext/tokyo/share/tokyotyrant/doc/common.css +211 -0
  118. data/ext/tokyo/share/tokyotyrant/doc/index.html +79 -0
  119. data/ext/tokyo/share/tokyotyrant/doc/spex.html +2264 -0
  120. data/ext/tokyo/share/tokyotyrant/ext/mapreduce.lua +57 -0
  121. data/ext/tokyo/share/tokyotyrant/ext/queue.lua +55 -0
  122. data/ext/tokyo/share/tokyotyrant/ext/senatus.lua +532 -0
  123. data/ext/tokyo/share/tokyotyrant/ext/usherette.lua +438 -0
  124. data/ext/tokyo_tyrant.c +147 -0
  125. data/ext/tokyo_tyrant.h +48 -0
  126. data/ext/tokyo_tyrant_db.c +227 -0
  127. data/ext/tokyo_tyrant_db.h +8 -0
  128. data/ext/tokyo_tyrant_module.c +453 -0
  129. data/ext/tokyo_tyrant_module.h +10 -0
  130. data/ext/tokyo_tyrant_query.c +226 -0
  131. data/ext/tokyo_tyrant_query.h +9 -0
  132. data/ext/tokyo_tyrant_table.c +319 -0
  133. data/ext/tokyo_tyrant_table.h +8 -0
  134. data/ext/tokyocabinet-1.4.41/COPYING +504 -0
  135. data/ext/tokyocabinet-1.4.41/ChangeLog +1252 -0
  136. data/ext/tokyocabinet-1.4.41/Makefile.in +825 -0
  137. data/ext/tokyocabinet-1.4.41/README +38 -0
  138. data/ext/tokyocabinet-1.4.41/THANKS +12 -0
  139. data/ext/tokyocabinet-1.4.41/bros/Makefile +133 -0
  140. data/ext/tokyocabinet-1.4.41/bros/bdbtest.c +438 -0
  141. data/ext/tokyocabinet-1.4.41/bros/cdbtest.c +219 -0
  142. data/ext/tokyocabinet-1.4.41/bros/cmpsqltctest.c +186 -0
  143. data/ext/tokyocabinet-1.4.41/bros/gdbmtest.c +216 -0
  144. data/ext/tokyocabinet-1.4.41/bros/mapreporter +72 -0
  145. data/ext/tokyocabinet-1.4.41/bros/maptest.cc +677 -0
  146. data/ext/tokyocabinet-1.4.41/bros/ndbmtest.c +204 -0
  147. data/ext/tokyocabinet-1.4.41/bros/qdbmtest.c +375 -0
  148. data/ext/tokyocabinet-1.4.41/bros/reporter +141 -0
  149. data/ext/tokyocabinet-1.4.41/bros/result.xls +0 -0
  150. data/ext/tokyocabinet-1.4.41/bros/sdbmtest.c +204 -0
  151. data/ext/tokyocabinet-1.4.41/bros/sqltest.c +404 -0
  152. data/ext/tokyocabinet-1.4.41/bros/tctest.c +748 -0
  153. data/ext/tokyocabinet-1.4.41/bros/tdbtest.c +205 -0
  154. data/ext/tokyocabinet-1.4.41/configure +7402 -0
  155. data/ext/tokyocabinet-1.4.41/configure.in +362 -0
  156. data/ext/tokyocabinet-1.4.41/doc/benchmark.pdf +0 -0
  157. data/ext/tokyocabinet-1.4.41/doc/common.css +211 -0
  158. data/ext/tokyocabinet-1.4.41/doc/icon16.png +0 -0
  159. data/ext/tokyocabinet-1.4.41/doc/index.html +156 -0
  160. data/ext/tokyocabinet-1.4.41/doc/index.ja.html +197 -0
  161. data/ext/tokyocabinet-1.4.41/doc/logo-ja.png +0 -0
  162. data/ext/tokyocabinet-1.4.41/doc/logo.png +0 -0
  163. data/ext/tokyocabinet-1.4.41/doc/spex-en.html +7145 -0
  164. data/ext/tokyocabinet-1.4.41/doc/spex-ja.html +7476 -0
  165. data/ext/tokyocabinet-1.4.41/doc/tokyoproducts.pdf +0 -0
  166. data/ext/tokyocabinet-1.4.41/doc/tokyoproducts.ppt +0 -0
  167. data/ext/tokyocabinet-1.4.41/example/Makefile +113 -0
  168. data/ext/tokyocabinet-1.4.41/example/tcadbex.c +55 -0
  169. data/ext/tokyocabinet-1.4.41/example/tcbdbex.c +64 -0
  170. data/ext/tokyocabinet-1.4.41/example/tcfdbex.c +60 -0
  171. data/ext/tokyocabinet-1.4.41/example/tchdbex.c +60 -0
  172. data/ext/tokyocabinet-1.4.41/example/tctchat.c +97 -0
  173. data/ext/tokyocabinet-1.4.41/example/tctchat.tmpl +141 -0
  174. data/ext/tokyocabinet-1.4.41/example/tctdbex.c +85 -0
  175. data/ext/tokyocabinet-1.4.41/example/tctsearch.c +95 -0
  176. data/ext/tokyocabinet-1.4.41/example/tctsearch.tmpl +122 -0
  177. data/ext/tokyocabinet-1.4.41/example/tcutilex.c +77 -0
  178. data/ext/tokyocabinet-1.4.41/f.tsv +2 -0
  179. data/ext/tokyocabinet-1.4.41/lab/calccomp +118 -0
  180. data/ext/tokyocabinet-1.4.41/lab/datechange +56 -0
  181. data/ext/tokyocabinet-1.4.41/lab/diffcheck +45 -0
  182. data/ext/tokyocabinet-1.4.41/lab/htmltotsv +102 -0
  183. data/ext/tokyocabinet-1.4.41/lab/magic +19 -0
  184. data/ext/tokyocabinet-1.4.41/lab/printenv.cgi +27 -0
  185. data/ext/tokyocabinet-1.4.41/lab/stepcount +26 -0
  186. data/ext/tokyocabinet-1.4.41/lab/stopwatch +61 -0
  187. data/ext/tokyocabinet-1.4.41/lab/tabcheck +43 -0
  188. data/ext/tokyocabinet-1.4.41/lab/wgettsv +239 -0
  189. data/ext/tokyocabinet-1.4.41/lab/widthcheck +57 -0
  190. data/ext/tokyocabinet-1.4.41/man/htmltoman +104 -0
  191. data/ext/tokyocabinet-1.4.41/man/tcadb.3 +676 -0
  192. data/ext/tokyocabinet-1.4.41/man/tcamgr.1 +97 -0
  193. data/ext/tokyocabinet-1.4.41/man/tcamttest.1 +35 -0
  194. data/ext/tokyocabinet-1.4.41/man/tcatest.1 +55 -0
  195. data/ext/tokyocabinet-1.4.41/man/tcbdb.3 +1355 -0
  196. data/ext/tokyocabinet-1.4.41/man/tcbmgr.1 +125 -0
  197. data/ext/tokyocabinet-1.4.41/man/tcbmttest.1 +81 -0
  198. data/ext/tokyocabinet-1.4.41/man/tcbtest.1 +107 -0
  199. data/ext/tokyocabinet-1.4.41/man/tcfdb.3 +975 -0
  200. data/ext/tokyocabinet-1.4.41/man/tcfmgr.1 +98 -0
  201. data/ext/tokyocabinet-1.4.41/man/tcfmttest.1 +62 -0
  202. data/ext/tokyocabinet-1.4.41/man/tcftest.1 +73 -0
  203. data/ext/tokyocabinet-1.4.41/man/tchdb.3 +898 -0
  204. data/ext/tokyocabinet-1.4.41/man/tchmgr.1 +110 -0
  205. data/ext/tokyocabinet-1.4.41/man/tchmttest.1 +85 -0
  206. data/ext/tokyocabinet-1.4.41/man/tchtest.1 +95 -0
  207. data/ext/tokyocabinet-1.4.41/man/tclist.3 +1 -0
  208. data/ext/tokyocabinet-1.4.41/man/tcmap.3 +1 -0
  209. data/ext/tokyocabinet-1.4.41/man/tcmdb.3 +1 -0
  210. data/ext/tokyocabinet-1.4.41/man/tcmpool.3 +1 -0
  211. data/ext/tokyocabinet-1.4.41/man/tctdb.3 +1110 -0
  212. data/ext/tokyocabinet-1.4.41/man/tctmgr.1 +140 -0
  213. data/ext/tokyocabinet-1.4.41/man/tctmttest.1 +92 -0
  214. data/ext/tokyocabinet-1.4.41/man/tctree.3 +1 -0
  215. data/ext/tokyocabinet-1.4.41/man/tcttest.1 +105 -0
  216. data/ext/tokyocabinet-1.4.41/man/tcucodec.1 +162 -0
  217. data/ext/tokyocabinet-1.4.41/man/tcumttest.1 +41 -0
  218. data/ext/tokyocabinet-1.4.41/man/tcutest.1 +81 -0
  219. data/ext/tokyocabinet-1.4.41/man/tcutil.3 +4518 -0
  220. data/ext/tokyocabinet-1.4.41/man/tcxstr.3 +1 -0
  221. data/ext/tokyocabinet-1.4.41/man/tokyocabinet.3 +132 -0
  222. data/ext/tokyocabinet-1.4.41/md5.c +381 -0
  223. data/ext/tokyocabinet-1.4.41/md5.h +101 -0
  224. data/ext/tokyocabinet-1.4.41/myconf.c +493 -0
  225. data/ext/tokyocabinet-1.4.41/myconf.h +549 -0
  226. data/ext/tokyocabinet-1.4.41/tcadb.c +4339 -0
  227. data/ext/tokyocabinet-1.4.41/tcadb.h +548 -0
  228. data/ext/tokyocabinet-1.4.41/tcamgr.c +1019 -0
  229. data/ext/tokyocabinet-1.4.41/tcamttest.c +542 -0
  230. data/ext/tokyocabinet-1.4.41/tcatest.c +1845 -0
  231. data/ext/tokyocabinet-1.4.41/tcawmgr.c +482 -0
  232. data/ext/tokyocabinet-1.4.41/tcbdb.c +4180 -0
  233. data/ext/tokyocabinet-1.4.41/tcbdb.h +1101 -0
  234. data/ext/tokyocabinet-1.4.41/tcbmgr.c +1012 -0
  235. data/ext/tokyocabinet-1.4.41/tcbmttest.c +1810 -0
  236. data/ext/tokyocabinet-1.4.41/tcbtest.c +2586 -0
  237. data/ext/tokyocabinet-1.4.41/tcfdb.c +2746 -0
  238. data/ext/tokyocabinet-1.4.41/tcfdb.h +858 -0
  239. data/ext/tokyocabinet-1.4.41/tcfmgr.c +786 -0
  240. data/ext/tokyocabinet-1.4.41/tcfmttest.c +1220 -0
  241. data/ext/tokyocabinet-1.4.41/tcftest.c +1695 -0
  242. data/ext/tokyocabinet-1.4.41/tchdb.c +5153 -0
  243. data/ext/tokyocabinet-1.4.41/tchdb.h +871 -0
  244. data/ext/tokyocabinet-1.4.41/tchmgr.c +842 -0
  245. data/ext/tokyocabinet-1.4.41/tchmttest.c +1757 -0
  246. data/ext/tokyocabinet-1.4.41/tchtest.c +2129 -0
  247. data/ext/tokyocabinet-1.4.41/tctdb.c +6199 -0
  248. data/ext/tokyocabinet-1.4.41/tctdb.h +1086 -0
  249. data/ext/tokyocabinet-1.4.41/tctmgr.c +1241 -0
  250. data/ext/tokyocabinet-1.4.41/tctmttest.c +1563 -0
  251. data/ext/tokyocabinet-1.4.41/tcttest.c +2062 -0
  252. data/ext/tokyocabinet-1.4.41/tcucodec.c +1357 -0
  253. data/ext/tokyocabinet-1.4.41/tcumttest.c +578 -0
  254. data/ext/tokyocabinet-1.4.41/tcutest.c +1875 -0
  255. data/ext/tokyocabinet-1.4.41/tcutil.c +10528 -0
  256. data/ext/tokyocabinet-1.4.41/tcutil.h +4184 -0
  257. data/ext/tokyocabinet-1.4.41/tokyocabinet.idl +336 -0
  258. data/ext/tokyocabinet-1.4.41/tokyocabinet.pc.in +14 -0
  259. data/ext/tokyotyrant-1.1.39/COPYING +504 -0
  260. data/ext/tokyotyrant-1.1.39/ChangeLog +578 -0
  261. data/ext/tokyotyrant-1.1.39/Makefile.in +365 -0
  262. data/ext/tokyotyrant-1.1.39/README +38 -0
  263. data/ext/tokyotyrant-1.1.39/THANKS +15 -0
  264. data/ext/tokyotyrant-1.1.39/configure +6979 -0
  265. data/ext/tokyotyrant-1.1.39/configure.in +300 -0
  266. data/ext/tokyotyrant-1.1.39/doc/common.css +211 -0
  267. data/ext/tokyotyrant-1.1.39/doc/index.html +79 -0
  268. data/ext/tokyotyrant-1.1.39/doc/spex.html +2264 -0
  269. data/ext/tokyotyrant-1.1.39/example/Makefile +68 -0
  270. data/ext/tokyotyrant-1.1.39/example/httptest.pl +88 -0
  271. data/ext/tokyotyrant-1.1.39/example/mcftest.pl +39 -0
  272. data/ext/tokyotyrant-1.1.39/example/mctest.pl +43 -0
  273. data/ext/tokyotyrant-1.1.39/example/tcrdbex +0 -0
  274. data/ext/tokyotyrant-1.1.39/example/tcrdbex.c +49 -0
  275. data/ext/tokyotyrant-1.1.39/example/tcrdbex.o +0 -0
  276. data/ext/tokyotyrant-1.1.39/example/tcrdbtblex +0 -0
  277. data/ext/tokyotyrant-1.1.39/example/tcrdbtblex.c +79 -0
  278. data/ext/tokyotyrant-1.1.39/example/tcrdbtblex.o +0 -0
  279. data/ext/tokyotyrant-1.1.39/ext/mapreduce.lua +57 -0
  280. data/ext/tokyotyrant-1.1.39/ext/queue.lua +55 -0
  281. data/ext/tokyotyrant-1.1.39/ext/senatus.lua +532 -0
  282. data/ext/tokyotyrant-1.1.39/ext/usherette.lua +438 -0
  283. data/ext/tokyotyrant-1.1.39/lab/datechange +56 -0
  284. data/ext/tokyotyrant-1.1.39/lab/diffcheck +45 -0
  285. data/ext/tokyotyrant-1.1.39/lab/fibonacci.lua +20 -0
  286. data/ext/tokyotyrant-1.1.39/lab/footprint.lua +67 -0
  287. data/ext/tokyotyrant-1.1.39/lab/highlow.lua +88 -0
  288. data/ext/tokyotyrant-1.1.39/lab/killdualmaster +12 -0
  289. data/ext/tokyotyrant-1.1.39/lab/rundualmaster +38 -0
  290. data/ext/tokyotyrant-1.1.39/lab/stepcount +26 -0
  291. data/ext/tokyotyrant-1.1.39/lab/tabcheck +43 -0
  292. data/ext/tokyotyrant-1.1.39/lab/ushrtregister.pl +55 -0
  293. data/ext/tokyotyrant-1.1.39/lab/widthcheck +57 -0
  294. data/ext/tokyotyrant-1.1.39/man/htmltoman +100 -0
  295. data/ext/tokyotyrant-1.1.39/man/tcrdb.3 +1309 -0
  296. data/ext/tokyotyrant-1.1.39/man/tcrmgr.1 +164 -0
  297. data/ext/tokyotyrant-1.1.39/man/tcrmttest.1 +55 -0
  298. data/ext/tokyotyrant-1.1.39/man/tcrtest.1 +89 -0
  299. data/ext/tokyotyrant-1.1.39/man/tculog.3 +15 -0
  300. data/ext/tokyotyrant-1.1.39/man/ttservctl.8 +37 -0
  301. data/ext/tokyotyrant-1.1.39/man/ttserver.1 +84 -0
  302. data/ext/tokyotyrant-1.1.39/man/ttulmgr.1 +40 -0
  303. data/ext/tokyotyrant-1.1.39/man/ttultest.1 +16 -0
  304. data/ext/tokyotyrant-1.1.39/man/ttutil.3 +14 -0
  305. data/ext/tokyotyrant-1.1.39/myconf.c +169 -0
  306. data/ext/tokyotyrant-1.1.39/myconf.h +408 -0
  307. data/ext/tokyotyrant-1.1.39/scrext.c +2394 -0
  308. data/ext/tokyotyrant-1.1.39/scrext.h +96 -0
  309. data/ext/tokyotyrant-1.1.39/tcrdb.c +2637 -0
  310. data/ext/tokyotyrant-1.1.39/tcrdb.h +801 -0
  311. data/ext/tokyotyrant-1.1.39/tcrmgr.c +1559 -0
  312. data/ext/tokyotyrant-1.1.39/tcrmttest.c +915 -0
  313. data/ext/tokyotyrant-1.1.39/tcrtest.c +1542 -0
  314. data/ext/tokyotyrant-1.1.39/tculog.c +1211 -0
  315. data/ext/tokyotyrant-1.1.39/tculog.h +392 -0
  316. data/ext/tokyotyrant-1.1.39/tokyotyrant.idl +143 -0
  317. data/ext/tokyotyrant-1.1.39/tokyotyrant.pc.in +14 -0
  318. data/ext/tokyotyrant-1.1.39/ttservctl +163 -0
  319. data/ext/tokyotyrant-1.1.39/ttserver.c +3583 -0
  320. data/ext/tokyotyrant-1.1.39/ttskeldir.c +141 -0
  321. data/ext/tokyotyrant-1.1.39/ttskelmock.c +64 -0
  322. data/ext/tokyotyrant-1.1.39/ttskelnull.c +79 -0
  323. data/ext/tokyotyrant-1.1.39/ttskelproxy.c +74 -0
  324. data/ext/tokyotyrant-1.1.39/ttulmgr.c +266 -0
  325. data/ext/tokyotyrant-1.1.39/ttultest.c +371 -0
  326. data/ext/tokyotyrant-1.1.39/ttutil.c +1510 -0
  327. data/ext/tokyotyrant-1.1.39/ttutil.h +494 -0
  328. data/lib/tokyo_tyrant/balancer.rb +189 -0
  329. data/spec/ext.lua +4 -0
  330. data/spec/plu_db.rb +538 -0
  331. data/spec/spec.rb +1 -0
  332. data/spec/spec_base.rb +17 -0
  333. data/spec/start_tyrants.sh +36 -0
  334. data/spec/stop_tyrants.sh +9 -0
  335. data/spec/tokyo_tyrant_balancer_db_spec.rb +160 -0
  336. data/spec/tokyo_tyrant_balancer_table_spec.rb +177 -0
  337. data/spec/tokyo_tyrant_query_spec.rb +159 -0
  338. data/spec/tokyo_tyrant_spec.rb +254 -0
  339. data/spec/tokyo_tyrant_table_spec.rb +301 -0
  340. metadata +402 -0
@@ -0,0 +1,1875 @@
1
+ /*************************************************************************************************
2
+ * The test cases of the utility API
3
+ * Copyright (C) 2006-2009 Mikio Hirabayashi
4
+ * This file is part of Tokyo Cabinet.
5
+ * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of
6
+ * the GNU Lesser General Public License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License or any later version. Tokyo Cabinet is distributed in the hope
8
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10
+ * License for more details.
11
+ * You should have received a copy of the GNU Lesser General Public License along with Tokyo
12
+ * Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
13
+ * Boston, MA 02111-1307 USA.
14
+ *************************************************************************************************/
15
+
16
+
17
+ #include <tcutil.h>
18
+ #include "myconf.h"
19
+
20
+ #define RECBUFSIZ 48 // buffer for records
21
+
22
+
23
+ /* global variables */
24
+ const char *g_progname; // program name
25
+ unsigned int g_randseed; // random seed
26
+
27
+
28
+ /* function prototypes */
29
+ int main(int argc, char **argv);
30
+ static void usage(void);
31
+ static void iprintf(const char *format, ...);
32
+ static void iputchar(int c);
33
+ static void sysprint(void);
34
+ static int myrand(int range);
35
+ static void *pdprocfunc(const void *vbuf, int vsiz, int *sp, void *op);
36
+ static bool iterfunc(const void *kbuf, int ksiz, const void *vbuf, int vsiz, void *op);
37
+ static int intcompar(const void *ap, const void *bp);
38
+ static int runxstr(int argc, char **argv);
39
+ static int runlist(int argc, char **argv);
40
+ static int runmap(int argc, char **argv);
41
+ static int runtree(int argc, char **argv);
42
+ static int runmdb(int argc, char **argv);
43
+ static int runndb(int argc, char **argv);
44
+ static int runmisc(int argc, char **argv);
45
+ static int runwicked(int argc, char **argv);
46
+ static int procxstr(int rnum);
47
+ static int proclist(int rnum, int anum, bool rd);
48
+ static int procmap(int rnum, int bnum, bool rd, bool tr, bool rnd, int dmode);
49
+ static int proctree(int rnum, bool rd, bool tr, bool rnd, int dmode);
50
+ static int procmdb(int rnum, int bnum, bool rd, bool tr, bool rnd, int dmode);
51
+ static int procndb(int rnum, bool rd, bool tr, bool rnd, int dmode);
52
+ static int procmisc(int rnum);
53
+ static int procwicked(int rnum);
54
+
55
+
56
+ /* main routine */
57
+ int main(int argc, char **argv){
58
+ g_progname = argv[0];
59
+ const char *ebuf = getenv("TCRNDSEED");
60
+ g_randseed = ebuf ? tcatoix(ebuf) : tctime() * 1000;
61
+ srand(g_randseed);
62
+ if(argc < 2) usage();
63
+ int rv = 0;
64
+ if(!strcmp(argv[1], "xstr")){
65
+ rv = runxstr(argc, argv);
66
+ } else if(!strcmp(argv[1], "list")){
67
+ rv = runlist(argc, argv);
68
+ } else if(!strcmp(argv[1], "map")){
69
+ rv = runmap(argc, argv);
70
+ } else if(!strcmp(argv[1], "tree")){
71
+ rv = runtree(argc, argv);
72
+ } else if(!strcmp(argv[1], "mdb")){
73
+ rv = runmdb(argc, argv);
74
+ } else if(!strcmp(argv[1], "ndb")){
75
+ rv = runndb(argc, argv);
76
+ } else if(!strcmp(argv[1], "misc")){
77
+ rv = runmisc(argc, argv);
78
+ } else if(!strcmp(argv[1], "wicked")){
79
+ rv = runwicked(argc, argv);
80
+ } else {
81
+ usage();
82
+ }
83
+ if(rv != 0){
84
+ printf("FAILED: TCRNDSEED=%u PID=%d", g_randseed, (int)getpid());
85
+ for(int i = 0; i < argc; i++){
86
+ printf(" %s", argv[i]);
87
+ }
88
+ printf("\n\n");
89
+ }
90
+ return rv;
91
+ }
92
+
93
+
94
+ /* print the usage and exit */
95
+ static void usage(void){
96
+ fprintf(stderr, "%s: test cases of the utility API of Tokyo Cabinet\n", g_progname);
97
+ fprintf(stderr, "\n");
98
+ fprintf(stderr, "usage:\n");
99
+ fprintf(stderr, " %s xstr rnum\n", g_progname);
100
+ fprintf(stderr, " %s list [-rd] rnum [anum]\n", g_progname);
101
+ fprintf(stderr, " %s map [-rd] [-tr] [-rnd] [-dk|-dc|-dai|-dad|-dpr] rnum [bnum]\n",
102
+ g_progname);
103
+ fprintf(stderr, " %s tree [-rd] [-tr] [-rnd] [-dk|-dc|-dai|-dad|-dpr] rnum\n",
104
+ g_progname);
105
+ fprintf(stderr, " %s mdb [-rd] [-tr] [-rnd] [-dk|-dc|-dai|-dad|-dpr] rnum [bnum]\n",
106
+ g_progname);
107
+ fprintf(stderr, " %s ndb [-rd] [-tr] [-rnd] [-dk|-dc|-dai|-dad|-dpr] rnum\n",
108
+ g_progname);
109
+ fprintf(stderr, " %s misc rnum\n", g_progname);
110
+ fprintf(stderr, " %s wicked rnum\n", g_progname);
111
+ fprintf(stderr, "\n");
112
+ exit(1);
113
+ }
114
+
115
+
116
+ /* print formatted information string and flush the buffer */
117
+ static void iprintf(const char *format, ...){
118
+ va_list ap;
119
+ va_start(ap, format);
120
+ vprintf(format, ap);
121
+ fflush(stdout);
122
+ va_end(ap);
123
+ }
124
+
125
+
126
+ /* print a character and flush the buffer */
127
+ static void iputchar(int c){
128
+ putchar(c);
129
+ fflush(stdout);
130
+ }
131
+
132
+
133
+ /* print system information */
134
+ static void sysprint(void){
135
+ TCMAP *info = tcsysinfo();
136
+ if(info){
137
+ tcmapiterinit(info);
138
+ const char *kbuf;
139
+ while((kbuf = tcmapiternext2(info)) != NULL){
140
+ iprintf("sys_%s: %s\n", kbuf, tcmapiterval2(kbuf));
141
+ }
142
+ tcmapdel(info);
143
+ }
144
+ }
145
+
146
+
147
+ /* get a random number */
148
+ static int myrand(int range){
149
+ if(range < 2) return 0;
150
+ int high = (unsigned int)rand() >> 4;
151
+ int low = range * (rand() / (RAND_MAX + 1.0));
152
+ low &= (unsigned int)INT_MAX >> 4;
153
+ return (high + low) % range;
154
+ }
155
+
156
+
157
+ /* duplication callback function */
158
+ static void *pdprocfunc(const void *vbuf, int vsiz, int *sp, void *op){
159
+ if(myrand(4) == 0) return (void *)-1;
160
+ if(myrand(2) == 0) return NULL;
161
+ int len = myrand(RECBUFSIZ);
162
+ char buf[RECBUFSIZ];
163
+ memset(buf, '*', len);
164
+ *sp = len;
165
+ return tcmemdup(buf, len);
166
+ }
167
+
168
+
169
+ /* iterator function */
170
+ static bool iterfunc(const void *kbuf, int ksiz, const void *vbuf, int vsiz, void *op){
171
+ unsigned int sum = 0;
172
+ while(--ksiz >= 0){
173
+ sum += ((char *)kbuf)[ksiz];
174
+ }
175
+ while(--vsiz >= 0){
176
+ sum += ((char *)vbuf)[vsiz];
177
+ }
178
+ return myrand(100 + (sum & 0xff)) > 0;
179
+ }
180
+
181
+
182
+ /* compare two integers */
183
+ static int intcompar(const void *ap, const void *bp){
184
+ return *(int *)ap - *(int *)bp;
185
+ }
186
+
187
+
188
+ /* parse arguments of xstr command */
189
+ static int runxstr(int argc, char **argv){
190
+ char *rstr = NULL;
191
+ for(int i = 2; i < argc; i++){
192
+ if(!rstr && argv[i][0] == '-'){
193
+ usage();
194
+ } else if(!rstr){
195
+ rstr = argv[i];
196
+ } else {
197
+ usage();
198
+ }
199
+ }
200
+ if(!rstr) usage();
201
+ int rnum = tcatoix(rstr);
202
+ if(rnum < 1) usage();
203
+ int rv = procxstr(rnum);
204
+ return rv;
205
+ }
206
+
207
+
208
+ /* parse arguments of list command */
209
+ static int runlist(int argc, char **argv){
210
+ char *rstr = NULL;
211
+ char *astr = NULL;
212
+ bool rd = false;
213
+ for(int i = 2; i < argc; i++){
214
+ if(!rstr && argv[i][0] == '-'){
215
+ if(!strcmp(argv[i], "-rd")){
216
+ rd = true;
217
+ } else {
218
+ usage();
219
+ }
220
+ } else if(!rstr){
221
+ rstr = argv[i];
222
+ } else if(!astr){
223
+ astr = argv[i];
224
+ } else {
225
+ usage();
226
+ }
227
+ }
228
+ if(!rstr) usage();
229
+ int rnum = tcatoix(rstr);
230
+ if(rnum < 1) usage();
231
+ int anum = astr ? tcatoix(astr) : -1;
232
+ int rv = proclist(rnum, anum, rd);
233
+ return rv;
234
+ }
235
+
236
+
237
+ /* parse arguments of map command */
238
+ static int runmap(int argc, char **argv){
239
+ char *rstr = NULL;
240
+ char *bstr = NULL;
241
+ bool rd = false;
242
+ bool tr = false;
243
+ bool rnd = false;
244
+ int dmode = 0;
245
+ for(int i = 2; i < argc; i++){
246
+ if(!rstr && argv[i][0] == '-'){
247
+ if(!strcmp(argv[i], "-rd")){
248
+ rd = true;
249
+ } else if(!strcmp(argv[i], "-tr")){
250
+ tr = true;
251
+ } else if(!strcmp(argv[i], "-rnd")){
252
+ rnd = true;
253
+ } else if(!strcmp(argv[i], "-dk")){
254
+ dmode = -1;
255
+ } else if(!strcmp(argv[i], "-dc")){
256
+ dmode = 1;
257
+ } else if(!strcmp(argv[i], "-dai")){
258
+ dmode = 10;
259
+ } else if(!strcmp(argv[i], "-dad")){
260
+ dmode = 11;
261
+ } else if(!strcmp(argv[i], "-dpr")){
262
+ dmode = 12;
263
+ } else {
264
+ usage();
265
+ }
266
+ } else if(!rstr){
267
+ rstr = argv[i];
268
+ } else if(!bstr){
269
+ bstr = argv[i];
270
+ } else {
271
+ usage();
272
+ }
273
+ }
274
+ if(!rstr) usage();
275
+ int rnum = tcatoix(rstr);
276
+ if(rnum < 1) usage();
277
+ int bnum = bstr ? tcatoix(bstr) : -1;
278
+ int rv = procmap(rnum, bnum, rd, tr, rnd, dmode);
279
+ return rv;
280
+ }
281
+
282
+
283
+ /* parse arguments of tree command */
284
+ static int runtree(int argc, char **argv){
285
+ char *rstr = NULL;
286
+ bool rd = false;
287
+ bool tr = false;
288
+ bool rnd = false;
289
+ int dmode = 0;
290
+ for(int i = 2; i < argc; i++){
291
+ if(!rstr && argv[i][0] == '-'){
292
+ if(!strcmp(argv[i], "-rd")){
293
+ rd = true;
294
+ } else if(!strcmp(argv[i], "-tr")){
295
+ tr = true;
296
+ } else if(!strcmp(argv[i], "-rnd")){
297
+ rnd = true;
298
+ } else if(!strcmp(argv[i], "-dk")){
299
+ dmode = -1;
300
+ } else if(!strcmp(argv[i], "-dc")){
301
+ dmode = 1;
302
+ } else if(!strcmp(argv[i], "-dai")){
303
+ dmode = 10;
304
+ } else if(!strcmp(argv[i], "-dad")){
305
+ dmode = 11;
306
+ } else if(!strcmp(argv[i], "-dpr")){
307
+ dmode = 12;
308
+ } else {
309
+ usage();
310
+ }
311
+ } else if(!rstr){
312
+ rstr = argv[i];
313
+ } else {
314
+ usage();
315
+ }
316
+ }
317
+ if(!rstr) usage();
318
+ int rnum = tcatoix(rstr);
319
+ if(rnum < 1) usage();
320
+ int rv = proctree(rnum, rd, tr, rnd, dmode);
321
+ return rv;
322
+ }
323
+
324
+
325
+ /* parse arguments of mdb command */
326
+ static int runmdb(int argc, char **argv){
327
+ char *rstr = NULL;
328
+ char *bstr = NULL;
329
+ bool rd = false;
330
+ bool tr = false;
331
+ bool rnd = false;
332
+ int dmode = 0;
333
+ for(int i = 2; i < argc; i++){
334
+ if(!rstr && argv[i][0] == '-'){
335
+ if(!strcmp(argv[i], "-rd")){
336
+ rd = true;
337
+ } else if(!strcmp(argv[i], "-tr")){
338
+ tr = true;
339
+ } else if(!strcmp(argv[i], "-rnd")){
340
+ rnd = true;
341
+ } else if(!strcmp(argv[i], "-dk")){
342
+ dmode = -1;
343
+ } else if(!strcmp(argv[i], "-dc")){
344
+ dmode = 1;
345
+ } else if(!strcmp(argv[i], "-dai")){
346
+ dmode = 10;
347
+ } else if(!strcmp(argv[i], "-dad")){
348
+ dmode = 11;
349
+ } else if(!strcmp(argv[i], "-dpr")){
350
+ dmode = 12;
351
+ } else {
352
+ usage();
353
+ }
354
+ } else if(!rstr){
355
+ rstr = argv[i];
356
+ } else if(!bstr){
357
+ bstr = argv[i];
358
+ } else {
359
+ usage();
360
+ }
361
+ }
362
+ if(!rstr) usage();
363
+ int rnum = tcatoix(rstr);
364
+ if(rnum < 1) usage();
365
+ int bnum = bstr ? tcatoix(bstr) : -1;
366
+ int rv = procmdb(rnum, bnum, rd, tr, rnd, dmode);
367
+ return rv;
368
+ }
369
+
370
+
371
+ /* parse arguments of ndb command */
372
+ static int runndb(int argc, char **argv){
373
+ char *rstr = NULL;
374
+ bool rd = false;
375
+ bool tr = false;
376
+ bool rnd = false;
377
+ int dmode = 0;
378
+ for(int i = 2; i < argc; i++){
379
+ if(!rstr && argv[i][0] == '-'){
380
+ if(!strcmp(argv[i], "-rd")){
381
+ rd = true;
382
+ } else if(!strcmp(argv[i], "-tr")){
383
+ tr = true;
384
+ } else if(!strcmp(argv[i], "-rnd")){
385
+ rnd = true;
386
+ } else if(!strcmp(argv[i], "-dk")){
387
+ dmode = -1;
388
+ } else if(!strcmp(argv[i], "-dc")){
389
+ dmode = 1;
390
+ } else if(!strcmp(argv[i], "-dai")){
391
+ dmode = 10;
392
+ } else if(!strcmp(argv[i], "-dad")){
393
+ dmode = 11;
394
+ } else if(!strcmp(argv[i], "-dpr")){
395
+ dmode = 12;
396
+ } else {
397
+ usage();
398
+ }
399
+ } else if(!rstr){
400
+ rstr = argv[i];
401
+ } else {
402
+ usage();
403
+ }
404
+ }
405
+ if(!rstr) usage();
406
+ int rnum = tcatoix(rstr);
407
+ if(rnum < 1) usage();
408
+ int rv = procndb(rnum, rd, tr, rnd, dmode);
409
+ return rv;
410
+ }
411
+
412
+
413
+ /* parse arguments of misc command */
414
+ static int runmisc(int argc, char **argv){
415
+ char *rstr = NULL;
416
+ for(int i = 2; i < argc; i++){
417
+ if(!rstr && argv[i][0] == '-'){
418
+ usage();
419
+ } else if(!rstr){
420
+ rstr = argv[i];
421
+ } else {
422
+ usage();
423
+ }
424
+ }
425
+ if(!rstr) usage();
426
+ int rnum = tcatoix(rstr);
427
+ if(rnum < 1) usage();
428
+ int rv = procmisc(rnum);
429
+ return rv;
430
+ }
431
+
432
+
433
+ /* parse arguments of wicked command */
434
+ static int runwicked(int argc, char **argv){
435
+ char *rstr = NULL;
436
+ for(int i = 2; i < argc; i++){
437
+ if(!rstr && argv[i][0] == '-'){
438
+ usage();
439
+ } else if(!rstr){
440
+ rstr = argv[i];
441
+ } else {
442
+ usage();
443
+ }
444
+ }
445
+ if(!rstr) usage();
446
+ int rnum = tcatoix(rstr);
447
+ if(rnum < 1) usage();
448
+ int rv = procwicked(rnum);
449
+ return rv;
450
+ }
451
+
452
+
453
+ /* perform xstr command */
454
+ static int procxstr(int rnum){
455
+ iprintf("<Extensible String Writing Test>\n seed=%u rnum=%d\n\n", g_randseed, rnum);
456
+ double stime = tctime();
457
+ TCXSTR *xstr = tcxstrnew();
458
+ for(int i = 1; i <= rnum; i++){
459
+ char buf[RECBUFSIZ];
460
+ int len = sprintf(buf, "%08d", i);
461
+ tcxstrcat(xstr, buf, len);
462
+ if(rnum > 250 && i % (rnum / 250) == 0){
463
+ iputchar('.');
464
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
465
+ }
466
+ }
467
+ iprintf("size: %u\n", tcxstrsize(xstr));
468
+ sysprint();
469
+ tcxstrdel(xstr);
470
+ iprintf("time: %.3f\n", tctime() - stime);
471
+ iprintf("ok\n\n");
472
+ return 0;
473
+ }
474
+
475
+
476
+ /* perform list command */
477
+ static int proclist(int rnum, int anum, bool rd){
478
+ iprintf("<List Writing Test>\n seed=%u rnum=%d anum=%d rd=%d\n\n",
479
+ g_randseed, rnum, anum, rd);
480
+ double stime = tctime();
481
+ TCLIST *list = (anum > 0) ? tclistnew2(anum) : tclistnew();
482
+ for(int i = 1; i <= rnum; i++){
483
+ char buf[RECBUFSIZ];
484
+ int len = sprintf(buf, "%08d", i);
485
+ tclistpush(list, buf, len);
486
+ if(rnum > 250 && i % (rnum / 250) == 0){
487
+ iputchar('.');
488
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
489
+ }
490
+ }
491
+ if(rd){
492
+ double itime = tctime();
493
+ iprintf("time: %.3f\n", itime - stime);
494
+ stime = itime;
495
+ for(int i = 1; i <= rnum; i++){
496
+ int len;
497
+ tclistval(list, i, &len);
498
+ if(rnum > 250 && i % (rnum / 250) == 0){
499
+ iputchar('.');
500
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
501
+ }
502
+ }
503
+ }
504
+ iprintf("record number: %u\n", tclistnum(list));
505
+ sysprint();
506
+ tclistdel(list);
507
+ iprintf("time: %.3f\n", tctime() - stime);
508
+ iprintf("ok\n\n");
509
+ return 0;
510
+ }
511
+
512
+
513
+ /* perform map command */
514
+ static int procmap(int rnum, int bnum, bool rd, bool tr, bool rnd, int dmode){
515
+ iprintf("<Map Writing Test>\n seed=%u rnum=%d bnum=%d rd=%d tr=%d rnd=%d dmode=%d\n\n",
516
+ g_randseed, rnum, bnum, rd, tr, rnd, dmode);
517
+ double stime = tctime();
518
+ TCMAP *map = (bnum > 0) ? tcmapnew2(bnum) : tcmapnew();
519
+ for(int i = 1; i <= rnum; i++){
520
+ char buf[RECBUFSIZ];
521
+ int len = sprintf(buf, "%08d", rnd ? myrand(rnum) + 1 : i);
522
+ switch(dmode){
523
+ case -1:
524
+ tcmapputkeep(map, buf, len, buf, len);
525
+ break;
526
+ case 1:
527
+ tcmapputcat(map, buf, len, buf, len);
528
+ break;
529
+ case 10:
530
+ tcmapaddint(map, buf, len, myrand(3));
531
+ break;
532
+ case 11:
533
+ tcmapadddouble(map, buf, len, myrand(3));
534
+ break;
535
+ case 12:
536
+ tcmapputproc(map, buf, len, buf, len, pdprocfunc, NULL);
537
+ break;
538
+ default:
539
+ tcmapput(map, buf, len, buf, len);
540
+ break;
541
+ }
542
+ if(rnum > 250 && i % (rnum / 250) == 0){
543
+ iputchar('.');
544
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
545
+ }
546
+ }
547
+ if(rd){
548
+ double itime = tctime();
549
+ iprintf("time: %.3f\n", itime - stime);
550
+ stime = itime;
551
+ for(int i = 1; i <= rnum; i++){
552
+ char buf[RECBUFSIZ];
553
+ int len = sprintf(buf, "%08d", rnd ? myrand(rnum) + 1 : i);
554
+ tcmapget(map, buf, len, &len);
555
+ if(rnum > 250 && i % (rnum / 250) == 0){
556
+ iputchar('.');
557
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
558
+ }
559
+ }
560
+ }
561
+ if(tr){
562
+ double itime = tctime();
563
+ iprintf("time: %.3f\n", itime - stime);
564
+ stime = itime;
565
+ tcmapiterinit(map);
566
+ int ksiz;
567
+ const char *kbuf;
568
+ int inum = 1;
569
+ while((kbuf = tcmapiternext(map, &ksiz)) != NULL){
570
+ tcmapiterval2(kbuf);
571
+ if(rnum > 250 && inum % (rnum / 250) == 0){
572
+ iputchar('.');
573
+ if(inum == rnum || inum % (rnum / 10) == 0) iprintf(" (%08d)\n", inum);
574
+ }
575
+ inum++;
576
+ }
577
+ if(rnd && rnum > 250) iprintf(" (%08d)\n", inum);
578
+ }
579
+ iprintf("record number: %llu\n", (unsigned long long)tcmaprnum(map));
580
+ iprintf("size: %llu\n", (unsigned long long)tcmapmsiz(map));
581
+ sysprint();
582
+ tcmapdel(map);
583
+ iprintf("time: %.3f\n", tctime() - stime);
584
+ iprintf("ok\n\n");
585
+ return 0;
586
+ }
587
+
588
+
589
+ /* perform tree command */
590
+ static int proctree(int rnum, bool rd, bool tr, bool rnd, int dmode){
591
+ iprintf("<Tree Writing Test>\n seed=%u rnum=%d rd=%d tr=%d rnd=%d dmode=%d\n\n",
592
+ g_randseed, rnum, rd, tr, rnd, dmode);
593
+ double stime = tctime();
594
+ TCTREE *tree = tctreenew();
595
+ for(int i = 1; i <= rnum; i++){
596
+ char buf[RECBUFSIZ];
597
+ int len = sprintf(buf, "%08d", rnd ? myrand(rnum) + 1 : i);
598
+ switch(dmode){
599
+ case -1:
600
+ tctreeputkeep(tree, buf, len, buf, len);
601
+ break;
602
+ case 1:
603
+ tctreeputcat(tree, buf, len, buf, len);
604
+ break;
605
+ case 10:
606
+ tctreeaddint(tree, buf, len, myrand(3));
607
+ break;
608
+ case 11:
609
+ tctreeadddouble(tree, buf, len, myrand(3));
610
+ break;
611
+ case 12:
612
+ tctreeputproc(tree, buf, len, buf, len, pdprocfunc, NULL);
613
+ break;
614
+ default:
615
+ tctreeput(tree, buf, len, buf, len);
616
+ break;
617
+ }
618
+ if(rnum > 250 && i % (rnum / 250) == 0){
619
+ iputchar('.');
620
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
621
+ }
622
+ }
623
+ if(rd){
624
+ double itime = tctime();
625
+ iprintf("time: %.3f\n", itime - stime);
626
+ stime = itime;
627
+ for(int i = 1; i <= rnum; i++){
628
+ char buf[RECBUFSIZ];
629
+ int len = sprintf(buf, "%08d", rnd ? myrand(rnum) + 1 : i);
630
+ tctreeget(tree, buf, len, &len);
631
+ if(rnum > 250 && i % (rnum / 250) == 0){
632
+ iputchar('.');
633
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
634
+ }
635
+ }
636
+ }
637
+ if(tr){
638
+ double itime = tctime();
639
+ iprintf("time: %.3f\n", itime - stime);
640
+ stime = itime;
641
+ tctreeiterinit(tree);
642
+ int ksiz;
643
+ const char *kbuf;
644
+ int inum = 1;
645
+ while((kbuf = tctreeiternext(tree, &ksiz)) != NULL){
646
+ tctreeiterval2(kbuf);
647
+ if(rnum > 250 && inum % (rnum / 250) == 0){
648
+ iputchar('.');
649
+ if(inum == rnum || inum % (rnum / 10) == 0) iprintf(" (%08d)\n", inum);
650
+ }
651
+ inum++;
652
+ }
653
+ if(rnd && rnum > 250) iprintf(" (%08d)\n", inum);
654
+ }
655
+ iprintf("record number: %llu\n", (unsigned long long)tctreernum(tree));
656
+ iprintf("size: %llu\n", (unsigned long long)tctreemsiz(tree));
657
+ sysprint();
658
+ tctreedel(tree);
659
+ iprintf("time: %.3f\n", tctime() - stime);
660
+ iprintf("ok\n\n");
661
+ return 0;
662
+ }
663
+
664
+
665
+ /* perform mdb command */
666
+ static int procmdb(int rnum, int bnum, bool rd, bool tr, bool rnd, int dmode){
667
+ iprintf("<On-memory Hash Database Writing Test>\n seed=%u rnum=%d bnum=%d rd=%d tr=%d"
668
+ " rnd=%d dmode=%d\n\n", g_randseed, rnum, bnum, rd, tr, rnd, dmode);
669
+ double stime = tctime();
670
+ TCMDB *mdb = (bnum > 0) ? tcmdbnew2(bnum) : tcmdbnew();
671
+ for(int i = 1; i <= rnum; i++){
672
+ char buf[RECBUFSIZ];
673
+ int len = sprintf(buf, "%08d", rnd ? myrand(rnum) + 1 : i);
674
+ switch(dmode){
675
+ case -1:
676
+ tcmdbputkeep(mdb, buf, len, buf, len);
677
+ break;
678
+ case 1:
679
+ tcmdbputcat(mdb, buf, len, buf, len);
680
+ break;
681
+ case 10:
682
+ tcmdbaddint(mdb, buf, len, myrand(3));
683
+ break;
684
+ case 11:
685
+ tcmdbadddouble(mdb, buf, len, myrand(3));
686
+ break;
687
+ case 12:
688
+ tcmdbputproc(mdb, buf, len, buf, len, pdprocfunc, NULL);
689
+ break;
690
+ default:
691
+ tcmdbput(mdb, buf, len, buf, len);
692
+ break;
693
+ }
694
+ if(rnum > 250 && i % (rnum / 250) == 0){
695
+ iputchar('.');
696
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
697
+ }
698
+ }
699
+ if(rd){
700
+ double itime = tctime();
701
+ iprintf("time: %.3f\n", itime - stime);
702
+ stime = itime;
703
+ for(int i = 1; i <= rnum; i++){
704
+ char buf[RECBUFSIZ];
705
+ int len = sprintf(buf, "%08d", rnd ? myrand(rnum) + 1 : i);
706
+ tcfree(tcmdbget(mdb, buf, len, &len));
707
+ if(rnum > 250 && i % (rnum / 250) == 0){
708
+ iputchar('.');
709
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
710
+ }
711
+ }
712
+ }
713
+ if(tr){
714
+ double itime = tctime();
715
+ iprintf("time: %.3f\n", itime - stime);
716
+ stime = itime;
717
+ tcmdbiterinit(mdb);
718
+ int ksiz;
719
+ char *kbuf;
720
+ int inum = 1;
721
+ while((kbuf = tcmdbiternext(mdb, &ksiz)) != NULL){
722
+ tcfree(kbuf);
723
+ if(rnum > 250 && inum % (rnum / 250) == 0){
724
+ iputchar('.');
725
+ if(inum == rnum || inum % (rnum / 10) == 0) iprintf(" (%08d)\n", inum);
726
+ }
727
+ inum++;
728
+ }
729
+ if(rnd && rnum > 250) iprintf(" (%08d)\n", inum);
730
+ }
731
+ iprintf("record number: %llu\n", (unsigned long long)tcmdbrnum(mdb));
732
+ iprintf("size: %llu\n", (unsigned long long)tcmdbmsiz(mdb));
733
+ sysprint();
734
+ tcmdbdel(mdb);
735
+ iprintf("time: %.3f\n", tctime() - stime);
736
+ iprintf("ok\n\n");
737
+ return 0;
738
+ }
739
+
740
+
741
+ /* perform ndb command */
742
+ static int procndb(int rnum, bool rd, bool tr, bool rnd, int dmode){
743
+ iprintf("<On-memory Tree Database Writing Test>\n seed=%u rnum=%d rd=%d tr=%d"
744
+ " rnd=%d dmode=%d\n\n", g_randseed, rnum, rd, tr, rnd, dmode);
745
+ double stime = tctime();
746
+ TCNDB *ndb = tcndbnew();
747
+ for(int i = 1; i <= rnum; i++){
748
+ char buf[RECBUFSIZ];
749
+ int len = sprintf(buf, "%08d", rnd ? myrand(rnum) + 1 : i);
750
+ switch(dmode){
751
+ case -1:
752
+ tcndbputkeep(ndb, buf, len, buf, len);
753
+ break;
754
+ case 1:
755
+ tcndbputcat(ndb, buf, len, buf, len);
756
+ break;
757
+ case 10:
758
+ tcndbaddint(ndb, buf, len, myrand(3));
759
+ break;
760
+ case 11:
761
+ tcndbadddouble(ndb, buf, len, myrand(3));
762
+ break;
763
+ case 12:
764
+ tcndbputproc(ndb, buf, len, buf, len, pdprocfunc, NULL);
765
+ break;
766
+ default:
767
+ tcndbput(ndb, buf, len, buf, len);
768
+ break;
769
+ }
770
+ if(rnum > 250 && i % (rnum / 250) == 0){
771
+ iputchar('.');
772
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
773
+ }
774
+ }
775
+ if(rd){
776
+ double itime = tctime();
777
+ iprintf("time: %.3f\n", itime - stime);
778
+ stime = itime;
779
+ for(int i = 1; i <= rnum; i++){
780
+ char buf[RECBUFSIZ];
781
+ int len = sprintf(buf, "%08d", rnd ? myrand(rnum) + 1 : i);
782
+ tcfree(tcndbget(ndb, buf, len, &len));
783
+ if(rnum > 250 && i % (rnum / 250) == 0){
784
+ iputchar('.');
785
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
786
+ }
787
+ }
788
+ }
789
+ if(tr){
790
+ double itime = tctime();
791
+ iprintf("time: %.3f\n", itime - stime);
792
+ stime = itime;
793
+ tcndbiterinit(ndb);
794
+ int ksiz;
795
+ char *kbuf;
796
+ int inum = 1;
797
+ while((kbuf = tcndbiternext(ndb, &ksiz)) != NULL){
798
+ tcfree(kbuf);
799
+ if(rnum > 250 && inum % (rnum / 250) == 0){
800
+ iputchar('.');
801
+ if(inum == rnum || inum % (rnum / 10) == 0) iprintf(" (%08d)\n", inum);
802
+ }
803
+ inum++;
804
+ }
805
+ if(rnd && rnum > 250) iprintf(" (%08d)\n", inum);
806
+ }
807
+ iprintf("record number: %llu\n", (unsigned long long)tcndbrnum(ndb));
808
+ iprintf("size: %llu\n", (unsigned long long)tcndbmsiz(ndb));
809
+ sysprint();
810
+ tcndbdel(ndb);
811
+ iprintf("time: %.3f\n", tctime() - stime);
812
+ iprintf("ok\n\n");
813
+ return 0;
814
+ }
815
+
816
+
817
+ /* perform misc command */
818
+ static int procmisc(int rnum){
819
+ iprintf("<Miscellaneous Test>\n seed=%u rnum=%d\n\n", g_randseed, rnum);
820
+ double stime = tctime();
821
+ bool err = false;
822
+ for(int i = 1; i <= rnum && !err; i++){
823
+ const char *str = "5%2+3-1=4 \"Yes/No\" <a&b>";
824
+ int slen = strlen(str);
825
+ char *buf, *dec;
826
+ int bsiz, dsiz, jl;
827
+ time_t date, ddate;
828
+ TCXSTR *xstr;
829
+ TCLIST *list;
830
+ TCMAP *map;
831
+ TCTREE *tree;
832
+ TCPTRLIST *ptrlist;
833
+ buf = tcmemdup(str, slen);
834
+ xstr = tcxstrfrommalloc(buf, slen);
835
+ buf = tcxstrtomalloc(xstr);
836
+ if(strcmp(buf, str)) err = true;
837
+ tcfree(buf);
838
+ if(tclmax(1, 2) != 2) err = true;
839
+ if(tclmin(1, 2) != 1) err = true;
840
+ tclrand();
841
+ if(tcdrand() >= 1.0) err = true;
842
+ tcdrandnd(50, 10);
843
+ if(tcstricmp("abc", "ABC") != 0) err = true;
844
+ if(!tcstrfwm("abc", "ab") || !tcstrifwm("abc", "AB")) err = true;
845
+ if(!tcstrbwm("abc", "bc") || !tcstribwm("abc", "BC")) err = true;
846
+ if(tcstrdist("abcde", "abdfgh") != 4 || tcstrdist("abdfgh", "abcde") != 4) err = true;
847
+ if(tcstrdistutf("abcde", "abdfgh") != 4 || tcstrdistutf("abdfgh", "abcde") != 4) err = true;
848
+ buf = tcmemdup("abcde", 5);
849
+ tcstrtoupper(buf);
850
+ if(strcmp(buf, "ABCDE")) err = true;
851
+ tcstrtolower(buf);
852
+ if(strcmp(buf, "abcde")) err = true;
853
+ tcfree(buf);
854
+ buf = tcmemdup(" ab cd ", 10);
855
+ tcstrtrim(buf);
856
+ if(strcmp(buf, "ab cd")) err = true;
857
+ tcstrsqzspc(buf);
858
+ if(strcmp(buf, "ab cd")) err = true;
859
+ tcstrsubchr(buf, "cd", "C");
860
+ if(strcmp(buf, "ab C")) err = true;
861
+ if(tcstrcntutf(buf) != 4) err = true;
862
+ tcstrcututf(buf, 2);
863
+ if(strcmp(buf, "ab")) err = true;
864
+ tcfree(buf);
865
+ if(i % 10 == 1){
866
+ int anum = myrand(30);
867
+ uint16_t ary[anum+1];
868
+ for(int j = 0; j < anum; j++){
869
+ ary[j] = myrand(65535) + 1;
870
+ }
871
+ char ustr[anum*3+1];
872
+ tcstrucstoutf(ary, anum, ustr);
873
+ uint16_t dary[anum+1];
874
+ int danum;
875
+ tcstrutftoucs(ustr, dary, &danum);
876
+ if(danum != anum){
877
+ err = true;
878
+ } else {
879
+ for(int j = 0; j < danum; j++){
880
+ if(dary[j] != dary[j]) err = true;
881
+ }
882
+ }
883
+ tcstrutfnorm(ustr, TCUNSPACE | TCUNLOWER | TCUNNOACC | TCUNWIDTH);
884
+ if(tcstrucsnorm(dary, danum, TCUNSPACE | TCUNLOWER | TCUNNOACC | TCUNWIDTH) > danum)
885
+ err = true;
886
+ list = tcstrtokenize("a ab abc b bc bcd abcde \"I'm nancy\" x \"xx");
887
+ if(tclistnum(list) != 10) err = true;
888
+ int opts = myrand(TCKWMUBRCT + 1);
889
+ if(myrand(2) == 0) opts |= TCKWNOOVER;
890
+ if(myrand(2) == 0) opts |= TCKWPULEAD;
891
+ TCLIST *texts = tcstrkwic(ustr, list, myrand(10), opts);
892
+ tclistdel(texts);
893
+ tclistdel(list);
894
+ list = tclistnew3("hop", "step", "jump", "touchdown", NULL);
895
+ if(tclistnum(list) != 4) err = true;
896
+ tclistprintf(list, "%s:%010d:%7.3f", "game set", 123456789, 12345.6789);
897
+ tclistdel(list);
898
+ map = tcmapnew3("hop", "step", "jump", "touchdown", NULL);
899
+ if(tcmaprnum(map) != 2) err = true;
900
+ tcmapprintf(map, "joker", "%s:%010d:%7.3f", "game set", 123456789, 12345.6789);
901
+ tcmapdel(map);
902
+ list = tcstrsplit(",a,b..c,d,", ",.");
903
+ if(tclistnum(list) != 7) err = true;
904
+ buf = tcstrjoin(list, ':');
905
+ if(strcmp(buf, ":a:b::c:d:")) err = true;
906
+ tcfree(buf);
907
+ tclistdel(list);
908
+ char zbuf[RECBUFSIZ];
909
+ memcpy(zbuf, "abc\0def\0ghij\0kl\0m", 17);
910
+ list = tcstrsplit2(zbuf, 17);
911
+ if(tclistnum(list) != 5) err = true;
912
+ buf = tcstrjoin2(list, &bsiz);
913
+ if(bsiz != 17 || memcmp(buf, "abc\0def\0ghij\0kl\0m", 17)) err = true;
914
+ tcfree(buf);
915
+ tclistdel(list);
916
+ map = tcstrsplit3("abc.def,ghij.kl,", ",.");
917
+ if(tcmaprnum(map) != 2) err = true;
918
+ buf = tcstrjoin3(map, ':');
919
+ if(strcmp(buf, "abc:def:ghij:kl")) err = true;
920
+ tcfree(buf);
921
+ tcmapdel(map);
922
+ memcpy(zbuf, "abc\0def\0ghij\0kl\0m", 17);
923
+ map = tcstrsplit4(zbuf, 17);
924
+ if(tcmaprnum(map) != 2) err = true;
925
+ buf = tcstrjoin4(map, &bsiz);
926
+ if(bsiz != 15 || memcmp(buf, "abc\0def\0ghij\0kl", 15)) err = true;
927
+ tcfree(buf);
928
+ tcmapdel(map);
929
+ if(!tcregexmatch("ABCDEFGHI", "*(b)c[d-f]*g(h)")) err = true;
930
+ buf = tcregexreplace("ABCDEFGHI", "*(b)c[d-f]*g(h)", "[\\1][\\2][&]");
931
+ if(strcmp(buf, "A[B][H][BCDEFGH]I")) err = true;
932
+ tcfree(buf);
933
+ buf = tcmalloc(48);
934
+ for(int i = 0; i < 10; i++){
935
+ char kbuf[RECBUFSIZ];
936
+ int ksiz = sprintf(kbuf, "%d", myrand(1000000));
937
+ tcmd5hash(kbuf, ksiz, buf);
938
+ }
939
+ tcfree(buf);
940
+ anum = myrand(30) + 1;
941
+ int tary[anum], qary[anum];
942
+ for(int j = 0; j < anum; j++){
943
+ int val = myrand(anum * 2 + 1);
944
+ tary[j] = val;
945
+ qary[j] = val;
946
+ }
947
+ int tnum = myrand(anum);
948
+ tctopsort(tary, anum, sizeof(*tary), tnum, intcompar);
949
+ qsort(qary, anum, sizeof(*qary), intcompar);
950
+ for(int j = 0; j < tnum; j++){
951
+ if(tary[j] != qary[j]) err = true;
952
+ }
953
+ qsort(tary, anum, sizeof(*tary), intcompar);
954
+ for(int j = 0; j < anum; j++){
955
+ if(tary[j] != qary[j]) err = true;
956
+ }
957
+ TCCHIDX *chidx = tcchidxnew(5);
958
+ for(int i = 0; i < 10; i++){
959
+ char kbuf[RECBUFSIZ];
960
+ int ksiz = sprintf(kbuf, "%d", myrand(1000000));
961
+ tcchidxhash(chidx, kbuf, ksiz);
962
+ }
963
+ tcchidxdel(chidx);
964
+ char kbuf[TCNUMBUFSIZ];
965
+ int ksiz = sprintf(kbuf, "%d", myrand(200));
966
+ char *enc = tcmalloc(slen + 1);
967
+ tcarccipher(str, slen, kbuf, ksiz, enc);
968
+ tcarccipher(enc, slen, kbuf, ksiz, enc);
969
+ if(memcmp(enc, str, slen)) err = true;
970
+ tcfree(enc);
971
+ buf = tczeromap(myrand(1024*256) + 1);
972
+ tczerounmap(buf);
973
+ }
974
+ buf = tcmalloc(48);
975
+ date = myrand(INT_MAX - 1000000);
976
+ jl = 3600 * (myrand(23) - 11);
977
+ tcdatestrwww(date, jl, buf);
978
+ ddate = tcstrmktime(buf);
979
+ if(ddate != date) err = true;
980
+ tcdatestrhttp(date, jl, buf);
981
+ ddate = tcstrmktime(buf);
982
+ if(ddate != date) err = true;
983
+ tcfree(buf);
984
+ if(i % 100 == 1){
985
+ map = myrand(2) == 0 ? tcmapnew() : tcmapnew2(myrand(10));
986
+ tree = tctreenew();
987
+ for(int j = 0; j < 10; j++){
988
+ char kbuf[RECBUFSIZ];
989
+ int ksiz = sprintf(kbuf, "%d", myrand(10));
990
+ tcmapaddint(map, kbuf, ksiz, 1);
991
+ const char *vbuf = tcmapget2(map, kbuf);
992
+ if(*(int *)vbuf < 1) err = true;
993
+ tctreeaddint(tree, kbuf, ksiz, 1);
994
+ vbuf = tctreeget2(tree, kbuf);
995
+ if(*(int *)vbuf < 1) err = true;
996
+ }
997
+ tcmapclear(map);
998
+ tctreeclear(tree);
999
+ for(int j = 0; j < 10; j++){
1000
+ char kbuf[RECBUFSIZ];
1001
+ int ksiz = sprintf(kbuf, "%d", myrand(10));
1002
+ tcmapadddouble(map, kbuf, ksiz, 1.0);
1003
+ const char *vbuf = tcmapget2(map, kbuf);
1004
+ if(*(double *)vbuf < 1.0) err = true;
1005
+ tctreeadddouble(tree, kbuf, ksiz, 1.0);
1006
+ vbuf = tctreeget2(tree, kbuf);
1007
+ if(*(double *)vbuf < 1.0) err = true;
1008
+ }
1009
+ for(int j = 0; j < 10; j++){
1010
+ char kbuf[RECBUFSIZ];
1011
+ sprintf(kbuf, "%d", myrand(10));
1012
+ tcmapprintf(map, kbuf, "%s:%f", kbuf, (double)i * j);
1013
+ tctreeprintf(tree, kbuf, "%s:%f", kbuf, (double)i * j);
1014
+ }
1015
+ if(!tcmapget4(map, "ace", "dummy")) err = true;
1016
+ if(!tctreeget4(tree, "ace", "dummy")) err = true;
1017
+ tctreedel(tree);
1018
+ tcmapdel(map);
1019
+ }
1020
+ if(i % 100 == 1){
1021
+ ptrlist = myrand(2) == 0 ? tcptrlistnew() : tcptrlistnew2(myrand(10));
1022
+ for(int j = 0; j < 10; j++){
1023
+ tcptrlistpush(ptrlist, tcsprintf("%d", j));
1024
+ tcptrlistunshift(ptrlist, tcsprintf("::%d", j));
1025
+ }
1026
+ for(int j = 0; j < 5; j++){
1027
+ tcfree(tcptrlistpop(ptrlist));
1028
+ tcfree(tcptrlistshift(ptrlist));
1029
+ }
1030
+ for(int j = 0; j < tcptrlistnum(ptrlist); j++){
1031
+ tcfree(tcptrlistval(ptrlist, j));
1032
+ }
1033
+ tcptrlistdel(ptrlist);
1034
+ }
1035
+ buf = tcurlencode(str, slen);
1036
+ if(strcmp(buf, "5%252%2B3-1%3D4%20%22Yes%2FNo%22%20%3Ca%26b%3E")) err = true;
1037
+ dec = tcurldecode(buf, &dsiz);
1038
+ if(dsiz != slen || strcmp(dec, str)) err = true;
1039
+ tcfree(dec);
1040
+ tcfree(buf);
1041
+ if(i % 10 == 1){
1042
+ map = tcurlbreak("http://mikio:oikim@estraier.net:1978/foo/bar/baz.cgi?ab=cd&ef=jkl#quux");
1043
+ const char *elem;
1044
+ if(!(elem = tcmapget2(map, "self")) ||
1045
+ strcmp(elem, "http://mikio:oikim@estraier.net:1978/foo/bar/baz.cgi?ab=cd&ef=jkl#quux"))
1046
+ err = true;
1047
+ if(!(elem = tcmapget2(map, "scheme")) || strcmp(elem, "http")) err = true;
1048
+ if(!(elem = tcmapget2(map, "host")) || strcmp(elem, "estraier.net")) err = true;
1049
+ if(!(elem = tcmapget2(map, "port")) || strcmp(elem, "1978")) err = true;
1050
+ if(!(elem = tcmapget2(map, "authority")) || strcmp(elem, "mikio:oikim")) err = true;
1051
+ if(!(elem = tcmapget2(map, "path")) || strcmp(elem, "/foo/bar/baz.cgi")) err = true;
1052
+ if(!(elem = tcmapget2(map, "file")) || strcmp(elem, "baz.cgi")) err = true;
1053
+ if(!(elem = tcmapget2(map, "query")) || strcmp(elem, "ab=cd&ef=jkl")) err = true;
1054
+ if(!(elem = tcmapget2(map, "fragment")) || strcmp(elem, "quux")) err = true;
1055
+ tcmapdel(map);
1056
+ buf = tcurlresolve("http://a:b@c.d:1/e/f/g.h?i=j#k", "http://A:B@C.D:1/E/F/G.H?I=J#K");
1057
+ if(strcmp(buf, "http://A:B@c.d:1/E/F/G.H?I=J#K")) err = true;
1058
+ tcfree(buf);
1059
+ buf = tcurlresolve("http://a:b@c.d:1/e/f/g.h?i=j#k", "/E/F/G.H?I=J#K");
1060
+ if(strcmp(buf, "http://a:b@c.d:1/E/F/G.H?I=J#K")) err = true;
1061
+ tcfree(buf);
1062
+ buf = tcurlresolve("http://a:b@c.d:1/e/f/g.h?i=j#k", "G.H?I=J#K");
1063
+ if(strcmp(buf, "http://a:b@c.d:1/e/f/G.H?I=J#K")) err = true;
1064
+ tcfree(buf);
1065
+ buf = tcurlresolve("http://a:b@c.d:1/e/f/g.h?i=j#k", "?I=J#K");
1066
+ if(strcmp(buf, "http://a:b@c.d:1/e/f/g.h?I=J#K")) err = true;
1067
+ tcfree(buf);
1068
+ buf = tcurlresolve("http://a:b@c.d:1/e/f/g.h?i=j#k", "#K");
1069
+ if(strcmp(buf, "http://a:b@c.d:1/e/f/g.h?i=j#K")) err = true;
1070
+ tcfree(buf);
1071
+ }
1072
+ buf = tcbaseencode(str, slen);
1073
+ if(strcmp(buf, "NSUyKzMtMT00ICJZZXMvTm8iIDxhJmI+")) err = true;
1074
+ dec = tcbasedecode(buf, &dsiz);
1075
+ if(dsiz != slen || strcmp(dec, str)) err = true;
1076
+ tcfree(dec);
1077
+ tcfree(buf);
1078
+ buf = tcquoteencode(str, slen);
1079
+ if(strcmp(buf, "5%2+3-1=3D4 \"Yes/No\" <a&b>")) err = true;
1080
+ dec = tcquotedecode(buf, &dsiz);
1081
+ if(dsiz != slen || strcmp(dec, str)) err = true;
1082
+ tcfree(dec);
1083
+ tcfree(buf);
1084
+ buf = tcmimeencode(str, "UTF-8", true);
1085
+ if(strcmp(buf, "=?UTF-8?B?NSUyKzMtMT00ICJZZXMvTm8iIDxhJmI+?=")) err = true;
1086
+ char encname[32];
1087
+ dec = tcmimedecode(buf, encname);
1088
+ if(strcmp(dec, str) || strcmp(encname, "UTF-8")) err = true;
1089
+ tcfree(dec);
1090
+ tcfree(buf);
1091
+ if(i % 10 == 1){
1092
+ const char *mstr = "Subject: Hello\r\nContent-Type: multipart/mixed; boundary=____\r\n\r\n"
1093
+ "\r\n--____\r\nThis is a pen.\r\n--____\r\nIs this your bag?\r\n--____--\r\n";
1094
+ map = tcmapnew2(10);
1095
+ char *buf = tcmimebreak(mstr, strlen(mstr), map, &bsiz);
1096
+ const char *boundary = tcmapget2(map, "BOUNDARY");
1097
+ if(boundary){
1098
+ list = tcmimeparts(buf, bsiz, boundary);
1099
+ if(tclistnum(list) == 2){
1100
+ if(strcmp(tclistval2(list, 0), "This is a pen.")) err = true;
1101
+ if(strcmp(tclistval2(list, 1), "Is this your bag?")) err = true;
1102
+ } else {
1103
+ err = true;
1104
+ }
1105
+ tclistdel(list);
1106
+ } else {
1107
+ err = true;
1108
+ }
1109
+ tcfree(buf);
1110
+ tcmapdel(map);
1111
+ }
1112
+ buf = tcpackencode(str, slen, &bsiz);
1113
+ dec = tcpackdecode(buf, bsiz, &dsiz);
1114
+ if(dsiz != slen || strcmp(dec, str)) err = true;
1115
+ tcfree(dec);
1116
+ tcfree(buf);
1117
+ buf = tcbsencode(str, slen, &bsiz);
1118
+ dec = tcbsdecode(buf, bsiz, &dsiz);
1119
+ if(dsiz != slen || strcmp(dec, str)) err = true;
1120
+ tcfree(dec);
1121
+ tcfree(buf);
1122
+ int idx;
1123
+ buf = tcbwtencode(str, slen, &idx);
1124
+ if(memcmp(buf, "4\"o 5a23s-%+=> 1b/\"<&YNe", slen) || idx != 13) err = true;
1125
+ dec = tcbwtdecode(buf, slen, idx);
1126
+ if(memcmp(dec, str, slen)) err = true;
1127
+ tcfree(dec);
1128
+ tcfree(buf);
1129
+ if(_tc_deflate){
1130
+ if((buf = tcdeflate(str, slen, &bsiz)) != NULL){
1131
+ if((dec = tcinflate(buf, bsiz, &dsiz)) != NULL){
1132
+ if(slen != dsiz || memcmp(str, dec, dsiz)) err = true;
1133
+ tcfree(dec);
1134
+ } else {
1135
+ err = true;
1136
+ }
1137
+ tcfree(buf);
1138
+ } else {
1139
+ err = true;
1140
+ }
1141
+ if((buf = tcgzipencode(str, slen, &bsiz)) != NULL){
1142
+ if((dec = tcgzipdecode(buf, bsiz, &dsiz)) != NULL){
1143
+ if(slen != dsiz || memcmp(str, dec, dsiz)) err = true;
1144
+ tcfree(dec);
1145
+ } else {
1146
+ err = true;
1147
+ }
1148
+ tcfree(buf);
1149
+ } else {
1150
+ err = true;
1151
+ }
1152
+ if(tcgetcrc("hoge", 4) % 10000 != 7034) err = true;
1153
+ }
1154
+ if(_tc_bzcompress){
1155
+ if((buf = tcbzipencode(str, slen, &bsiz)) != NULL){
1156
+ if((dec = tcbzipdecode(buf, bsiz, &dsiz)) != NULL){
1157
+ if(slen != dsiz || memcmp(str, dec, dsiz)) err = true;
1158
+ tcfree(dec);
1159
+ } else {
1160
+ err = true;
1161
+ }
1162
+ tcfree(buf);
1163
+ } else {
1164
+ err = true;
1165
+ }
1166
+ }
1167
+ int anum = myrand(50)+1;
1168
+ unsigned int ary[anum];
1169
+ for(int j = 0; j < anum; j++){
1170
+ ary[j] = myrand(INT_MAX);
1171
+ }
1172
+ buf = tcberencode(ary, anum, &bsiz);
1173
+ int dnum;
1174
+ unsigned int *dary = tcberdecode(buf, bsiz, &dnum);
1175
+ if(anum != dnum || memcmp(ary, dary, sizeof(*dary) * dnum)) err = true;
1176
+ tcfree(dary);
1177
+ tcfree(buf);
1178
+ buf = tcxmlescape(str);
1179
+ if(strcmp(buf, "5%2+3-1=4 &quot;Yes/No&quot; &lt;a&amp;b&gt;")) err = true;
1180
+ dec = tcxmlunescape(buf);
1181
+ if(strcmp(dec, str)) err = true;
1182
+ tcfree(dec);
1183
+ tcfree(buf);
1184
+ buf = tccstrescape(str);
1185
+ if(strcmp(buf, "5%2+3-1=4 \\x22Yes/No\\x22 <a&b>")) err = true;
1186
+ dec = tccstrunescape(buf);
1187
+ if(strcmp(dec, str)) err = true;
1188
+ tcfree(dec);
1189
+ tcfree(buf);
1190
+ buf = tcjsonescape(str);
1191
+ if(strcmp(buf, "5%2+3-1=4 \\u0022Yes/No\\u0022 <a&b>")) err = true;
1192
+ dec = tcjsonunescape(buf);
1193
+ if(strcmp(dec, str)) err = true;
1194
+ tcfree(dec);
1195
+ tcfree(buf);
1196
+ if(i % 10 == 1){
1197
+ TCMAP *params = tcmapnew3("one", "=first=", "two", "&second&", "three", "#third#", NULL);
1198
+ char *estr = tcwwwformencode(params);
1199
+ TCMAP *nparams = tcmapnew2(1);
1200
+ tcwwwformdecode(estr, nparams);
1201
+ if(strcmp(estr, "one=%3Dfirst%3D&two=%26second%26&three=%23third%23") ||
1202
+ tcmaprnum(nparams) != tcmaprnum(params) || !tcmapget2(nparams, "two")) err = true;
1203
+ tcmapdel(nparams);
1204
+ tcfree(estr);
1205
+ tcmapdel(params);
1206
+ list = tcxmlbreak("<abc de=\"foo&amp;\" gh='&lt;bar&gt;'>xyz<br>\na<!--<mikio>--></abc>");
1207
+ for(int j = 0; j < tclistnum(list); j++){
1208
+ const char *elem = tclistval2(list, j);
1209
+ TCMAP *attrs = tcxmlattrs(elem);
1210
+ tcmapdel(attrs);
1211
+ }
1212
+ tclistdel(list);
1213
+ }
1214
+ if(i % 100 == 1){
1215
+ TCTMPL *tmpl = tctmplnew();
1216
+ const char *str =
1217
+ "{{ title XML }}{{UNKNOWN COMMAND}}{{CONF author 'Mikio Hirabayashi'}}\n"
1218
+ "{{ FOREACH docs \\}}\n"
1219
+ "{{ IF void }}===={{void}}{{ ELSE }}----{{void.void}}{{ END }}\n"
1220
+ "{{ IF .id }}ID:{{ .id }}{{ END }}\n"
1221
+ "{{ IF .title }}Title:{{ .title }}{{ END }}\n"
1222
+ "{{ IF author }}Author:{{ author }}{{ END }}\n"
1223
+ "{{ IF .coms }}{{ SET addr 'Setagaya, Tokyo' }}--\n"
1224
+ "{{ FOREACH .coms com }}{{ com.author MD5 }}: {{ com.body }}\n"
1225
+ "{{ END \\}}\n"
1226
+ "{{ END \\}}\n"
1227
+ "{{ END \\}}\n";
1228
+ tctmplsetsep(tmpl, "{{", "}}");
1229
+ tctmplload(tmpl, str);
1230
+ const char *cval = tctmplconf(tmpl, "author");
1231
+ if(!cval || strcmp(cval, "Mikio Hirabayashi")) err = true;
1232
+ TCMPOOL *mpool = tcmpoolnew();
1233
+ TCMAP *vars = tcmpoolmapnew(mpool);
1234
+ tcmapput2(vars, "title", "I LOVE YOU");
1235
+ TCLIST *docs = tcmpoollistnew(mpool);
1236
+ for(int j = 0; j < 3; j++){
1237
+ TCMAP *doc = tcmpoolmapnew(mpool);
1238
+ char vbuf[TCNUMBUFSIZ];
1239
+ sprintf(vbuf, "%d", i + j);
1240
+ tcmapput2(doc, "id", vbuf);
1241
+ sprintf(vbuf, "[%08d]", i + j);
1242
+ tcmapput2(doc, "title", vbuf);
1243
+ TCLIST *coms = tcmpoollistnew(mpool);
1244
+ for(int k = 0; k < 3; k++){
1245
+ TCMAP *com = tcmpoolmapnew(mpool);
1246
+ sprintf(vbuf, "u%d", k);
1247
+ tcmapput2(com, "author", vbuf);
1248
+ sprintf(vbuf, "this is the %dth pen.", (j + 1) * (k + 1) + i);
1249
+ tcmapput2(com, "body", vbuf);
1250
+ tclistpushmap(coms, com);
1251
+ }
1252
+ tcmapputlist(doc, "coms", coms);
1253
+ tclistpushmap(docs, doc);
1254
+ }
1255
+ tcmapputlist(vars, "docs", docs);
1256
+ char *res = tctmpldump(tmpl, vars);
1257
+ tcfree(res);
1258
+ tcmpoolclear(mpool, true);
1259
+ tcmpoolmalloc(mpool, 1);
1260
+ tcmpoollistnew(mpool);
1261
+ tcmpooldel(mpool);
1262
+ tctmpldel(tmpl);
1263
+ }
1264
+ if(i % 10 == 1){
1265
+ for(int16_t j = 1; j <= 0x2000; j *= 2){
1266
+ for(int16_t num = j - 1; num <= j + 1; num++){
1267
+ int16_t nnum = TCHTOIS(num);
1268
+ if(num != TCITOHS(nnum)) err = true;
1269
+ }
1270
+ }
1271
+ for(int32_t j = 1; j <= 0x20000000; j *= 2){
1272
+ for(int32_t num = j - 1; num <= j + 1; num++){
1273
+ int32_t nnum = TCHTOIL(num);
1274
+ if(num != TCITOHL(nnum)) err = true;
1275
+ char buf[TCNUMBUFSIZ];
1276
+ int step, nstep;
1277
+ TCSETVNUMBUF(step, buf, num);
1278
+ TCREADVNUMBUF(buf, nnum, nstep);
1279
+ if(num != nnum || step != nstep) err = true;
1280
+ }
1281
+ }
1282
+ for(int64_t j = 1; j <= 0x2000000000000000; j *= 2){
1283
+ for(int64_t num = j - 1; num <= j + 1; num++){
1284
+ int64_t nnum = TCHTOILL(num);
1285
+ if(num != TCITOHLL(nnum)) err = true;
1286
+ char buf[TCNUMBUFSIZ];
1287
+ int step, nstep;
1288
+ TCSETVNUMBUF64(step, buf, num);
1289
+ TCREADVNUMBUF64(buf, nnum, nstep);
1290
+ if(num != nnum || step != nstep) err = true;
1291
+ }
1292
+ }
1293
+ TCBITMAP *bitmap = TCBITMAPNEW(100);
1294
+ for(int j = 0; j < 100; j++){
1295
+ if(j % 3 == 0) TCBITMAPON(bitmap, j);
1296
+ if(j % 5 == 0) TCBITMAPOFF(bitmap, j);
1297
+ }
1298
+ for(int j = 0; j < 100; j++){
1299
+ if(j % 5 == 0){
1300
+ if(TCBITMAPCHECK(bitmap, j)) err = true;
1301
+ } else if(j % 3 == 0){
1302
+ if(!TCBITMAPCHECK(bitmap, j)) err = true;
1303
+ }
1304
+ }
1305
+ TCBITMAPDEL(bitmap);
1306
+ buf = tcmalloc(i / 8 + 2);
1307
+ TCBITSTRM strm;
1308
+ TCBITSTRMINITW(strm, buf);
1309
+ for(int j = 0; j < i; j++){
1310
+ int sign = j % 3 == 0 || j % 7 == 0;
1311
+ TCBITSTRMCAT(strm, sign);
1312
+ }
1313
+ TCBITSTRMSETEND(strm);
1314
+ int bnum = TCBITSTRMNUM(strm);
1315
+ if(bnum != i) err = true;
1316
+ TCBITSTRMINITR(strm, buf, bsiz);
1317
+ for(int j = 0; j < i; j++){
1318
+ int sign;
1319
+ TCBITSTRMREAD(strm, sign);
1320
+ if(sign != (j % 3 == 0 || j % 7 == 0)) err = true;
1321
+ }
1322
+ tcfree(buf);
1323
+ }
1324
+ if(i % 100 == 1){
1325
+ char path[RECBUFSIZ];
1326
+ sprintf(path, "%d", myrand(10));
1327
+ if(tcpathlock(path)){
1328
+ if(!tcpathunlock(path)) err = true;
1329
+ } else {
1330
+ err = true;
1331
+ }
1332
+ }
1333
+ if(rnum > 250 && i % (rnum / 250) == 0){
1334
+ iputchar('.');
1335
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1336
+ }
1337
+ }
1338
+ iprintf("time: %.3f\n", tctime() - stime);
1339
+ if(err){
1340
+ iprintf("error\n\n");
1341
+ return 1;
1342
+ }
1343
+ iprintf("ok\n\n");
1344
+ return 0;
1345
+ }
1346
+
1347
+
1348
+ /* perform wicked command */
1349
+ static int procwicked(int rnum){
1350
+ iprintf("<Wicked Writing Test>\n seed=%u rnum=%d\n\n", g_randseed, rnum);
1351
+ double stime = tctime();
1352
+ TCMPOOL *mpool = tcmpoolglobal();
1353
+ TCXSTR *xstr = myrand(2) > 0 ? tcxstrnew() : tcxstrnew2("hello world");
1354
+ tcmpoolpushxstr(mpool, xstr);
1355
+ TCLIST *list = myrand(2) > 0 ? tclistnew() : tclistnew2(myrand(rnum) + rnum / 2);
1356
+ tcmpoolpushlist(mpool, list);
1357
+ TCPTRLIST *ptrlist = myrand(2) > 0 ? tcptrlistnew() : tcptrlistnew2(myrand(rnum) + rnum / 2);
1358
+ tcmpoolpush(mpool, ptrlist, (void (*)(void*))tcptrlistdel);
1359
+ TCMAP *map = myrand(2) > 0 ? tcmapnew() : tcmapnew2(myrand(rnum) + rnum / 2);
1360
+ tcmpoolpushmap(mpool, map);
1361
+ TCTREE *tree = myrand(2) > 0 ? tctreenew() : tctreenew2(tccmpdecimal, NULL);
1362
+ tcmpoolpushtree(mpool, tree);
1363
+ TCMDB *mdb = myrand(2) > 0 ? tcmdbnew() : tcmdbnew2(myrand(rnum) + rnum / 2);
1364
+ tcmpoolpush(mpool, mdb, (void (*)(void*))tcmdbdel);
1365
+ TCNDB *ndb = myrand(2) > 0 ? tcndbnew() : tcndbnew2(tccmpdecimal, NULL);
1366
+ tcmpoolpush(mpool, ndb, (void (*)(void*))tcndbdel);
1367
+ for(int i = 1; i <= rnum; i++){
1368
+ char kbuf[RECBUFSIZ];
1369
+ int ksiz = sprintf(kbuf, "%d", myrand(i));
1370
+ char vbuf[RECBUFSIZ];
1371
+ int vsiz = sprintf(vbuf, "%d", myrand(i));
1372
+ char *tmp;
1373
+ switch(myrand(70)){
1374
+ case 0:
1375
+ iputchar('0');
1376
+ tcxstrcat(xstr, kbuf, ksiz);
1377
+ break;
1378
+ case 1:
1379
+ iputchar('1');
1380
+ tcxstrcat2(xstr, kbuf);
1381
+ break;
1382
+ case 2:
1383
+ iputchar('2');
1384
+ if(myrand(rnum / 100 + 1) == 0) tcxstrclear(xstr);
1385
+ break;
1386
+ case 3:
1387
+ iputchar('3');
1388
+ tcxstrprintf(xstr, "[%s:%d:%llu:%b:%llb]\n",
1389
+ kbuf, i, (long long)i * 65521, i, (unsigned long long)i * 65521);
1390
+ break;
1391
+ case 4:
1392
+ iputchar('4');
1393
+ tclistpush(list, kbuf, ksiz);
1394
+ tcptrlistpush(ptrlist, tcmemdup(kbuf, ksiz));
1395
+ break;
1396
+ case 5:
1397
+ iputchar('5');
1398
+ tclistpush2(list, kbuf);
1399
+ break;
1400
+ case 6:
1401
+ iputchar('6');
1402
+ tmp = tcmemdup(kbuf, ksiz);
1403
+ tclistpushmalloc(list, tmp, strlen(tmp));
1404
+ break;
1405
+ case 7:
1406
+ iputchar('7');
1407
+ if(myrand(10) == 0){
1408
+ tcfree(tclistpop(list, &ksiz));
1409
+ tcfree(tcptrlistpop(ptrlist));
1410
+ }
1411
+ break;
1412
+ case 8:
1413
+ iputchar('8');
1414
+ if(myrand(10) == 0) tcfree(tclistpop2(list));
1415
+ break;
1416
+ case 9:
1417
+ iputchar('9');
1418
+ tclistunshift(list, kbuf, ksiz);
1419
+ tcptrlistunshift(ptrlist, tcmemdup(kbuf, ksiz));
1420
+ break;
1421
+ case 10:
1422
+ iputchar('A');
1423
+ tclistunshift2(list, kbuf);
1424
+ break;
1425
+ case 11:
1426
+ iputchar('B');
1427
+ if(myrand(10) == 0){
1428
+ tcfree(tclistshift(list, &ksiz));
1429
+ tcfree(tcptrlistshift(ptrlist));
1430
+ }
1431
+ break;
1432
+ case 12:
1433
+ iputchar('C');
1434
+ if(myrand(10) == 0) tcfree(tclistshift2(list));
1435
+ break;
1436
+ case 13:
1437
+ iputchar('D');
1438
+ tclistinsert(list, i / 10, kbuf, ksiz);
1439
+ if(tcptrlistnum(ptrlist) > i / 10)
1440
+ tcptrlistinsert(ptrlist, i / 10, tcmemdup(kbuf, ksiz));
1441
+ break;
1442
+ case 14:
1443
+ iputchar('E');
1444
+ tclistinsert2(list, i / 10, kbuf);
1445
+ break;
1446
+ case 15:
1447
+ iputchar('F');
1448
+ if(myrand(10) == 0){
1449
+ tcfree(tclistremove(list, i / 10, &ksiz));
1450
+ tcfree(tcptrlistremove(ptrlist, i / 10));
1451
+ }
1452
+ break;
1453
+ case 16:
1454
+ iputchar('G');
1455
+ if(myrand(10) == 0) tcfree(tclistremove2(list, i / 10));
1456
+ break;
1457
+ case 17:
1458
+ iputchar('H');
1459
+ tclistover(list, i / 10, kbuf, ksiz);
1460
+ if(tcptrlistnum(ptrlist) > i / 10){
1461
+ tcfree(tcptrlistval(ptrlist, i / 10));
1462
+ tcptrlistover(ptrlist, i / 10, tcmemdup(kbuf, ksiz));
1463
+ }
1464
+ break;
1465
+ case 18:
1466
+ iputchar('I');
1467
+ tclistover2(list, i / 10, kbuf);
1468
+ break;
1469
+ case 19:
1470
+ iputchar('J');
1471
+ if(myrand(rnum / 1000 + 1) == 0) tclistsort(list);
1472
+ break;
1473
+ case 20:
1474
+ iputchar('K');
1475
+ if(myrand(rnum / 1000 + 1) == 0) tclistsortci(list);
1476
+ break;
1477
+ case 21:
1478
+ iputchar('L');
1479
+ if(myrand(rnum / 1000 + 1) == 0) tclistlsearch(list, kbuf, ksiz);
1480
+ break;
1481
+ case 22:
1482
+ iputchar('M');
1483
+ if(myrand(rnum / 1000 + 1) == 0) tclistbsearch(list, kbuf, ksiz);
1484
+ break;
1485
+ case 23:
1486
+ iputchar('N');
1487
+ if(myrand(rnum / 100 + 1) == 0){
1488
+ tclistclear(list);
1489
+ for(int j = 0; j < tcptrlistnum(ptrlist); j++){
1490
+ tcfree(tcptrlistval(ptrlist, j));
1491
+ }
1492
+ tcptrlistclear(ptrlist);
1493
+ }
1494
+ break;
1495
+ case 24:
1496
+ iputchar('O');
1497
+ if(myrand(rnum / 100 + 1) == 0){
1498
+ int dsiz;
1499
+ char *dbuf = tclistdump(list, &dsiz);
1500
+ tclistdel(tclistload(dbuf, dsiz));
1501
+ tcfree(dbuf);
1502
+ }
1503
+ break;
1504
+ case 25:
1505
+ iputchar('P');
1506
+ if(myrand(100) == 0){
1507
+ if(myrand(2) == 0){
1508
+ for(int j = 0; j < tclistnum(list); j++){
1509
+ int rsiz;
1510
+ tclistval(list, j, &rsiz);
1511
+ tcptrlistval(ptrlist, j);
1512
+ }
1513
+ } else {
1514
+ for(int j = 0; j < tclistnum(list); j++){
1515
+ tclistval2(list, j);
1516
+ }
1517
+ }
1518
+ }
1519
+ break;
1520
+ case 26:
1521
+ iputchar('Q');
1522
+ tcmapput(map, kbuf, ksiz, vbuf, vsiz);
1523
+ tctreeput(tree, kbuf, ksiz, vbuf, vsiz);
1524
+ break;
1525
+ case 27:
1526
+ iputchar('R');
1527
+ tcmapput2(map, kbuf, vbuf);
1528
+ tctreeput2(tree, kbuf, vbuf);
1529
+ break;
1530
+ case 28:
1531
+ iputchar('S');
1532
+ tcmapputkeep(map, kbuf, ksiz, vbuf, vsiz);
1533
+ tctreeputkeep(tree, kbuf, ksiz, vbuf, vsiz);
1534
+ break;
1535
+ case 29:
1536
+ iputchar('T');
1537
+ tcmapputkeep2(map, kbuf, vbuf);
1538
+ tctreeputkeep2(tree, kbuf, vbuf);
1539
+ break;
1540
+ case 30:
1541
+ iputchar('U');
1542
+ tcmapputcat(map, kbuf, ksiz, vbuf, vsiz);
1543
+ tctreeputcat(tree, kbuf, ksiz, vbuf, vsiz);
1544
+ break;
1545
+ case 31:
1546
+ iputchar('V');
1547
+ tcmapputcat2(map, kbuf, vbuf);
1548
+ tctreeputcat2(tree, kbuf, vbuf);
1549
+ break;
1550
+ case 32:
1551
+ iputchar('W');
1552
+ if(myrand(2) == 0){
1553
+ tcmapput3(map, kbuf, ksiz, vbuf, vsiz);
1554
+ tctreeput3(tree, kbuf, ksiz, vbuf, vsiz);
1555
+ }
1556
+ if(myrand(2) == 0){
1557
+ tcmapput4(map, kbuf, ksiz, vbuf, vsiz, vbuf, vsiz);
1558
+ tctreeputkeep3(tree, kbuf, ksiz, vbuf, vsiz);
1559
+ }
1560
+ if(myrand(2) == 0){
1561
+ tcmapputcat3(map, kbuf, ksiz, vbuf, vsiz);
1562
+ tctreeputcat3(tree, kbuf, ksiz, vbuf, vsiz);
1563
+ }
1564
+ break;
1565
+ case 33:
1566
+ iputchar('X');
1567
+ if(myrand(10) == 0){
1568
+ tcmapout(map, kbuf, ksiz);
1569
+ tctreeout(tree, kbuf, ksiz);
1570
+ }
1571
+ break;
1572
+ case 34:
1573
+ iputchar('Y');
1574
+ if(myrand(10) == 0){
1575
+ tcmapout2(map, kbuf);
1576
+ tctreeout2(tree, kbuf);
1577
+ }
1578
+ break;
1579
+ case 35:
1580
+ iputchar('Z');
1581
+ tcmapget3(map, kbuf, ksiz, &vsiz);
1582
+ tctreeget3(tree, kbuf, ksiz, &vsiz);
1583
+ break;
1584
+ case 36:
1585
+ iputchar('a');
1586
+ tcmapmove(map, kbuf, ksiz, true);
1587
+ break;
1588
+ case 37:
1589
+ iputchar('b');
1590
+ tcmapmove(map, kbuf, ksiz, false);
1591
+ break;
1592
+ case 38:
1593
+ iputchar('c');
1594
+ tcmapmove2(map, kbuf, true);
1595
+ break;
1596
+ case 39:
1597
+ iputchar('d');
1598
+ if(myrand(100) == 0){
1599
+ if(myrand(2) == 0){
1600
+ tcmapiterinit(map);
1601
+ tctreeiterinit(tree);
1602
+ } else {
1603
+ tcmapiterinit2(map, kbuf, ksiz);
1604
+ tctreeiterinit2(tree, kbuf, ksiz);
1605
+ }
1606
+ }
1607
+ break;
1608
+ case 40:
1609
+ iputchar('e');
1610
+ tcmapiternext(map, &vsiz);
1611
+ tctreeiternext(tree, &vsiz);
1612
+ break;
1613
+ case 41:
1614
+ iputchar('f');
1615
+ tcmapiternext2(map);
1616
+ tctreeiternext2(tree);
1617
+ break;
1618
+ case 42:
1619
+ iputchar('g');
1620
+ if(myrand(100) == 0){
1621
+ int anum;
1622
+ switch(myrand(4)){
1623
+ case 0:
1624
+ tclistdel(tcmapkeys(map));
1625
+ tclistdel(tctreekeys(tree));
1626
+ break;
1627
+ case 1:
1628
+ tcfree(tcmapkeys2(map, &anum));
1629
+ tcfree(tctreekeys2(tree, &anum));
1630
+ break;
1631
+ case 2:
1632
+ tclistdel(tcmapvals(map));
1633
+ tclistdel(tctreevals(tree));
1634
+ break;
1635
+ default:
1636
+ tcfree(tcmapvals2(map, &anum));
1637
+ tcfree(tctreevals2(tree, &anum));
1638
+ break;
1639
+ }
1640
+ }
1641
+ break;
1642
+ case 43:
1643
+ iputchar('h');
1644
+ if(myrand(rnum / 100 + 1) == 0){
1645
+ tcmapclear(map);
1646
+ tctreeclear(tree);
1647
+ }
1648
+ break;
1649
+ case 44:
1650
+ iputchar('i');
1651
+ if(myrand(20) == 0){
1652
+ tcmapcutfront(map, myrand(10));
1653
+ tctreecutfringe(tree, myrand(10));
1654
+ }
1655
+ break;
1656
+ case 45:
1657
+ iputchar('j');
1658
+ if(myrand(rnum / 100 + 1) == 0){
1659
+ int dsiz;
1660
+ char *dbuf = tcmapdump(map, &dsiz);
1661
+ tcfree(tcmaploadone(dbuf, dsiz, kbuf, ksiz, &vsiz));
1662
+ tcmapdel(tcmapload(dbuf, dsiz));
1663
+ tcfree(dbuf);
1664
+ dbuf = tctreedump(tree, &dsiz);
1665
+ tcfree(tctreeloadone(dbuf, dsiz, kbuf, ksiz, &vsiz));
1666
+ tctreedel(tctreeload(dbuf, dsiz, tccmplexical, NULL));
1667
+ tcfree(dbuf);
1668
+ }
1669
+ break;
1670
+ case 46:
1671
+ iputchar('k');
1672
+ tcmdbput(mdb, kbuf, ksiz, vbuf, vsiz);
1673
+ tcndbput(ndb, kbuf, ksiz, vbuf, vsiz);
1674
+ break;
1675
+ case 47:
1676
+ iputchar('l');
1677
+ tcmdbput2(mdb, kbuf, vbuf);
1678
+ tcndbput2(ndb, kbuf, vbuf);
1679
+ break;
1680
+ case 48:
1681
+ iputchar('m');
1682
+ tcmdbputkeep(mdb, kbuf, ksiz, vbuf, vsiz);
1683
+ tcndbputkeep(ndb, kbuf, ksiz, vbuf, vsiz);
1684
+ break;
1685
+ case 49:
1686
+ iputchar('n');
1687
+ tcmdbputkeep2(mdb, kbuf, vbuf);
1688
+ tcndbputkeep2(ndb, kbuf, vbuf);
1689
+ break;
1690
+ case 50:
1691
+ iputchar('o');
1692
+ tcmdbputcat(mdb, kbuf, ksiz, vbuf, vsiz);
1693
+ tcndbputcat(ndb, kbuf, ksiz, vbuf, vsiz);
1694
+ break;
1695
+ case 51:
1696
+ iputchar('p');
1697
+ tcmdbputcat2(mdb, kbuf, vbuf);
1698
+ tcndbputcat2(ndb, kbuf, vbuf);
1699
+ break;
1700
+ case 52:
1701
+ iputchar('q');
1702
+ if(myrand(2) == 0){
1703
+ tcmdbput3(mdb, kbuf, ksiz, vbuf, vsiz);
1704
+ tcndbput3(ndb, kbuf, ksiz, vbuf, vsiz);
1705
+ }
1706
+ if(myrand(2) == 0){
1707
+ tcmdbput4(mdb, kbuf, ksiz, vbuf, vsiz, vbuf, vsiz);
1708
+ tcndbputkeep3(ndb, kbuf, ksiz, vbuf, vsiz);
1709
+ }
1710
+ if(myrand(2) == 0){
1711
+ tcmdbputcat3(mdb, kbuf, ksiz, vbuf, vsiz);
1712
+ tcndbputcat3(ndb, kbuf, ksiz, vbuf, vsiz);
1713
+ }
1714
+ break;
1715
+ case 53:
1716
+ iputchar('r');
1717
+ if(myrand(10) == 0){
1718
+ tcmdbout(mdb, kbuf, ksiz);
1719
+ tcndbout(ndb, kbuf, ksiz);
1720
+ }
1721
+ break;
1722
+ case 54:
1723
+ iputchar('s');
1724
+ if(myrand(10) == 0){
1725
+ tcmdbout2(mdb, kbuf);
1726
+ tcndbout2(ndb, kbuf);
1727
+ }
1728
+ break;
1729
+ case 55:
1730
+ iputchar('t');
1731
+ tcfree(tcmdbget(mdb, kbuf, ksiz, &vsiz));
1732
+ tcfree(tcndbget(ndb, kbuf, ksiz, &vsiz));
1733
+ break;
1734
+ case 56:
1735
+ iputchar('u');
1736
+ tcfree(tcmdbget3(mdb, kbuf, ksiz, &vsiz));
1737
+ tcfree(tcndbget3(ndb, kbuf, ksiz, &vsiz));
1738
+ break;
1739
+ case 57:
1740
+ iputchar('v');
1741
+ if(myrand(100) == 0){
1742
+ if(myrand(2) == 0){
1743
+ tcmdbiterinit(mdb);
1744
+ tcndbiterinit(ndb);
1745
+ } else {
1746
+ tcmdbiterinit2(mdb, kbuf, ksiz);
1747
+ tcndbiterinit2(ndb, kbuf, ksiz);
1748
+ }
1749
+ }
1750
+ break;
1751
+ case 58:
1752
+ iputchar('w');
1753
+ tcfree(tcmdbiternext(mdb, &vsiz));
1754
+ tcfree(tcndbiternext(ndb, &vsiz));
1755
+ break;
1756
+ case 59:
1757
+ iputchar('x');
1758
+ tcfree(tcmdbiternext2(mdb));
1759
+ tcfree(tcndbiternext2(ndb));
1760
+ break;
1761
+ case 60:
1762
+ iputchar('y');
1763
+ if(myrand(rnum / 100 + 1) == 0){
1764
+ tcmdbvanish(mdb);
1765
+ tcndbvanish(ndb);
1766
+ }
1767
+ break;
1768
+ case 61:
1769
+ iputchar('z');
1770
+ if(myrand(200) == 0){
1771
+ tcmdbcutfront(mdb, myrand(100));
1772
+ tcndbcutfringe(ndb, myrand(100));
1773
+ }
1774
+ break;
1775
+ case 62:
1776
+ iputchar('+');
1777
+ if(myrand(200) == 0){
1778
+ tcmdbforeach(mdb, iterfunc, NULL);
1779
+ tcndbforeach(ndb, iterfunc, NULL);
1780
+ }
1781
+ break;
1782
+ case 63:
1783
+ iputchar('+');
1784
+ if(myrand(100) == 0){
1785
+ char *tptr = tcmpoolmalloc(mpool, 1);
1786
+ switch(myrand(5)){
1787
+ case 0:
1788
+ tcfree(tptr);
1789
+ tcmpoolpop(mpool, false);
1790
+ break;
1791
+ case 1:
1792
+ tcmpoolpop(mpool, true);
1793
+ break;
1794
+ }
1795
+ }
1796
+ break;
1797
+ case 64:
1798
+ iputchar('+');
1799
+ if(myrand(100) == 0){
1800
+ TCXSTR *txstr = tcmpoolxstrnew(mpool);
1801
+ switch(myrand(5)){
1802
+ case 0:
1803
+ tcxstrdel(txstr);
1804
+ tcmpoolpop(mpool, false);
1805
+ break;
1806
+ case 1:
1807
+ tcmpoolpop(mpool, true);
1808
+ break;
1809
+ }
1810
+ }
1811
+ break;
1812
+ case 65:
1813
+ iputchar('+');
1814
+ if(myrand(100) == 0){
1815
+ TCLIST *tlist = tcmpoollistnew(mpool);
1816
+ switch(myrand(5)){
1817
+ case 0:
1818
+ tclistdel(tlist);
1819
+ tcmpoolpop(mpool, false);
1820
+ break;
1821
+ case 1:
1822
+ tcmpoolpop(mpool, true);
1823
+ break;
1824
+ }
1825
+ }
1826
+ break;
1827
+ case 66:
1828
+ iputchar('+');
1829
+ if(myrand(100) == 0){
1830
+ TCMAP *tmap = tcmpoolmapnew(mpool);
1831
+ switch(myrand(5)){
1832
+ case 0:
1833
+ tcmapdel(tmap);
1834
+ tcmpoolpop(mpool, false);
1835
+ break;
1836
+ case 1:
1837
+ tcmpoolpop(mpool, true);
1838
+ break;
1839
+ }
1840
+ }
1841
+ break;
1842
+ case 67:
1843
+ iputchar('+');
1844
+ if(myrand(100) == 0){
1845
+ TCTREE *ttree = tcmpooltreenew(mpool);
1846
+ switch(myrand(5)){
1847
+ case 0:
1848
+ tctreedel(ttree);
1849
+ tcmpoolpop(mpool, false);
1850
+ break;
1851
+ case 1:
1852
+ tcmpoolpop(mpool, true);
1853
+ break;
1854
+ }
1855
+ }
1856
+ break;
1857
+ default:
1858
+ iputchar('@');
1859
+ if(myrand(10000) == 0) srand((unsigned int)(tctime() * 1000) % UINT_MAX);
1860
+ break;
1861
+ }
1862
+ if(i % 50 == 0) iprintf(" (%08d)\n", i);
1863
+ }
1864
+ if(rnum % 50 > 0) iprintf(" (%08d)\n", rnum);
1865
+ for(int i = 0; i < tcptrlistnum(ptrlist); i++){
1866
+ tcfree(tcptrlistval(ptrlist, i));
1867
+ }
1868
+ iprintf("time: %.3f\n", tctime() - stime);
1869
+ iprintf("ok\n\n");
1870
+ return 0;
1871
+ }
1872
+
1873
+
1874
+
1875
+ // END OF FILE