@based/db 0.0.1 → 0.0.2

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 (354) hide show
  1. package/dist/lib/darwin_aarch64/include/jemalloc.h +468 -0
  2. package/dist/lib/darwin_aarch64/include/selva/selva_string.h +2 -0
  3. package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
  4. package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
  5. package/dist/lib/darwin_aarch64/libnode-v20.11.1.node +0 -0
  6. package/dist/lib/darwin_aarch64/libnode-v22.13.1.node +0 -0
  7. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  8. package/dist/src/client/bitWise.d.ts +7 -0
  9. package/dist/src/client/bitWise.js +62 -0
  10. package/dist/src/client/bitWise.js.map +1 -0
  11. package/dist/src/client/crc32.js.map +1 -0
  12. package/dist/src/client/index.js.map +1 -0
  13. package/dist/src/client/modify/ModifyRes.js.map +1 -0
  14. package/dist/src/client/modify/alias.js.map +1 -0
  15. package/dist/src/client/modify/binary.js.map +1 -0
  16. package/dist/src/client/modify/create.js.map +1 -0
  17. package/dist/src/client/modify/fixed.js.map +1 -0
  18. package/dist/src/client/modify/hll.js.map +1 -0
  19. package/dist/src/client/modify/index.js.map +1 -0
  20. package/dist/src/client/modify/modify.js +5 -1
  21. package/dist/src/client/modify/modify.js.map +1 -0
  22. package/dist/src/client/modify/references/edge.js.map +1 -0
  23. package/dist/src/client/modify/references/reference.js.map +1 -0
  24. package/dist/src/client/modify/references/references.js.map +1 -0
  25. package/dist/src/client/modify/remove.js.map +1 -0
  26. package/dist/src/client/modify/setCursor.js.map +1 -0
  27. package/dist/src/client/modify/string.js.map +1 -0
  28. package/dist/src/client/modify/text.d.ts +4 -2
  29. package/dist/src/client/modify/text.js +1 -2
  30. package/dist/src/client/modify/text.js.map +1 -0
  31. package/dist/src/client/modify/types.js.map +1 -0
  32. package/dist/src/client/modify/update.js.map +1 -0
  33. package/dist/src/client/modify/upsert.js.map +1 -0
  34. package/dist/src/client/modify/vector.d.ts +4 -0
  35. package/dist/src/client/modify/vector.js +44 -0
  36. package/dist/src/client/modify/vector.js.map +1 -0
  37. package/dist/src/client/operations.js.map +1 -0
  38. package/dist/src/client/query/BasedDbQuery.d.ts +3 -1
  39. package/dist/src/client/query/BasedDbQuery.js +9 -7
  40. package/dist/src/client/query/BasedDbQuery.js.map +1 -0
  41. package/dist/src/client/query/BasedIterable.d.ts +2 -2
  42. package/dist/src/client/query/BasedIterable.js +10 -5
  43. package/dist/src/client/query/BasedIterable.js.map +1 -0
  44. package/dist/src/client/query/debug.js +4 -3
  45. package/dist/src/client/query/debug.js.map +1 -0
  46. package/dist/src/client/query/display.js +19 -4
  47. package/dist/src/client/query/display.js.map +1 -0
  48. package/dist/src/client/query/filter/FilterBranch.js.map +1 -0
  49. package/dist/src/client/query/filter/createFixedFilterBuffer.js.map +1 -0
  50. package/dist/src/client/query/filter/createReferenceFilter.js.map +1 -0
  51. package/dist/src/client/query/filter/createVariableFilterBuffer.d.ts +2 -1
  52. package/dist/src/client/query/filter/createVariableFilterBuffer.js +16 -7
  53. package/dist/src/client/query/filter/createVariableFilterBuffer.js.map +1 -0
  54. package/dist/src/client/query/filter/filter.js +17 -4
  55. package/dist/src/client/query/filter/filter.js.map +1 -0
  56. package/dist/src/client/query/filter/operators.js.map +1 -0
  57. package/dist/src/client/query/filter/parseFilterValue.js.map +1 -0
  58. package/dist/src/client/query/filter/primitiveFilter.d.ts +2 -1
  59. package/dist/src/client/query/filter/primitiveFilter.js +2 -2
  60. package/dist/src/client/query/filter/primitiveFilter.js.map +1 -0
  61. package/dist/src/client/query/filter/toBuffer.js.map +1 -0
  62. package/dist/src/client/query/filter/types.js.map +1 -0
  63. package/dist/src/client/query/include/props.js.map +1 -0
  64. package/dist/src/client/query/include/toBuffer.js.map +1 -0
  65. package/dist/src/client/query/include/utils.js +1 -0
  66. package/dist/src/client/query/include/utils.js.map +1 -0
  67. package/dist/src/client/query/include/walk.js +1 -0
  68. package/dist/src/client/query/include/walk.js.map +1 -0
  69. package/dist/src/client/query/query.js.map +1 -0
  70. package/dist/src/client/query/queryDef.js +2 -0
  71. package/dist/src/client/query/queryDef.js.map +1 -0
  72. package/dist/src/client/query/read/read.d.ts +2 -2
  73. package/dist/src/client/query/read/read.js +64 -38
  74. package/dist/src/client/query/read/read.js.map +1 -0
  75. package/dist/src/client/query/registerQuery.js.map +1 -0
  76. package/dist/src/client/query/search/index.js.map +1 -0
  77. package/dist/src/client/query/sort.js.map +1 -0
  78. package/dist/src/client/query/subscription/index.js +3 -3
  79. package/dist/src/client/query/subscription/index.js.map +1 -0
  80. package/dist/src/client/query/subscription/markers.js.map +1 -0
  81. package/dist/src/client/query/subscription/run.d.ts +1 -1
  82. package/dist/src/client/query/subscription/run.js +12 -2
  83. package/dist/src/client/query/subscription/run.js.map +1 -0
  84. package/dist/src/client/query/subscription/types.js.map +1 -0
  85. package/dist/src/client/query/thresholds.js.map +1 -0
  86. package/dist/src/client/query/toBuffer.js +3 -0
  87. package/dist/src/client/query/toBuffer.js.map +1 -0
  88. package/dist/src/client/query/types.d.ts +2 -0
  89. package/dist/src/client/query/types.js.map +1 -0
  90. package/dist/src/client/query/validation.js.map +1 -0
  91. package/dist/src/client/string.d.ts +3 -2
  92. package/dist/src/client/string.js +13 -7
  93. package/dist/src/client/string.js.map +1 -0
  94. package/dist/src/client/tree.js.map +1 -0
  95. package/dist/src/index.js.map +1 -0
  96. package/dist/src/native.d.ts +1 -1
  97. package/dist/src/native.js +2 -1
  98. package/dist/src/native.js.map +1 -0
  99. package/dist/src/server/csmt/draw-dot.js.map +1 -0
  100. package/dist/src/server/csmt/index.js.map +1 -0
  101. package/dist/src/server/csmt/match.js.map +1 -0
  102. package/dist/src/server/csmt/memebership-proof.js.map +1 -0
  103. package/dist/src/server/csmt/tree-utils.js.map +1 -0
  104. package/dist/src/server/csmt/tree.js.map +1 -0
  105. package/dist/src/server/csmt/types.js.map +1 -0
  106. package/dist/src/server/index.d.ts +1 -1
  107. package/dist/src/server/index.js +2 -1
  108. package/dist/src/server/index.js.map +1 -0
  109. package/dist/src/server/migrate/index.js.map +1 -0
  110. package/dist/src/server/migrate/worker.js.map +1 -0
  111. package/dist/src/server/save.js.map +1 -0
  112. package/dist/src/server/schema/schema.js.map +1 -0
  113. package/dist/src/server/schema/selvaBuffer.js +4 -3
  114. package/dist/src/server/schema/selvaBuffer.js.map +1 -0
  115. package/dist/src/server/schema/typeDef.js +4 -1
  116. package/dist/src/server/schema/typeDef.js.map +1 -0
  117. package/dist/src/server/schema/types.d.ts +3 -0
  118. package/dist/src/server/schema/types.js +5 -0
  119. package/dist/src/server/schema/types.js.map +1 -0
  120. package/dist/src/server/schema/utils.js.map +1 -0
  121. package/dist/src/server/start.js.map +1 -0
  122. package/dist/src/server/tree.js.map +1 -0
  123. package/dist/src/server/worker.js +1 -1
  124. package/dist/src/server/worker.js.map +1 -0
  125. package/dist/test/alias.d.ts +1 -0
  126. package/dist/test/alias.js +232 -0
  127. package/dist/test/alias.js.map +1 -0
  128. package/dist/test/binary.d.ts +1 -0
  129. package/dist/test/binary.js +45 -0
  130. package/dist/test/binary.js.map +1 -0
  131. package/dist/test/boolean.d.ts +1 -0
  132. package/dist/test/boolean.js +43 -0
  133. package/dist/test/boolean.js.map +1 -0
  134. package/dist/test/clientServer.d.ts +1 -0
  135. package/dist/test/clientServer.js +64 -0
  136. package/dist/test/clientServer.js.map +1 -0
  137. package/dist/test/concurrency.d.ts +1 -0
  138. package/dist/test/concurrency.js +61 -0
  139. package/dist/test/concurrency.js.map +1 -0
  140. package/dist/test/csmt.d.ts +1 -0
  141. package/dist/test/csmt.js +365 -0
  142. package/dist/test/csmt.js.map +1 -0
  143. package/dist/test/edges.d.ts +1 -0
  144. package/dist/test/edges.js +295 -0
  145. package/dist/test/edges.js.map +1 -0
  146. package/dist/test/edgesReference.d.ts +1 -0
  147. package/dist/test/edgesReference.js +179 -0
  148. package/dist/test/edgesReference.js.map +1 -0
  149. package/dist/test/edgesReferences.d.ts +1 -0
  150. package/dist/test/edgesReferences.js +472 -0
  151. package/dist/test/edgesReferences.js.map +1 -0
  152. package/dist/test/enum.d.ts +1 -0
  153. package/dist/test/enum.js +44 -0
  154. package/dist/test/enum.js.map +1 -0
  155. package/dist/test/filter.d.ts +1 -0
  156. package/dist/test/filter.js +512 -0
  157. package/dist/test/filter.js.map +1 -0
  158. package/dist/test/filterString.d.ts +1 -0
  159. package/dist/test/filterString.js +482 -0
  160. package/dist/test/filterString.js.map +1 -0
  161. package/dist/test/flush.d.ts +1 -0
  162. package/dist/test/flush.js +44 -0
  163. package/dist/test/flush.js.map +1 -0
  164. package/dist/test/hll.d.ts +1 -0
  165. package/dist/test/hll.js +32 -0
  166. package/dist/test/hll.js.map +1 -0
  167. package/dist/test/migration.d.ts +1 -0
  168. package/dist/test/migration.js +112 -0
  169. package/dist/test/migration.js.map +1 -0
  170. package/dist/test/number.d.ts +1 -0
  171. package/dist/test/number.js +172 -0
  172. package/dist/test/number.js.map +1 -0
  173. package/dist/test/range.d.ts +1 -0
  174. package/dist/test/range.js +70 -0
  175. package/dist/test/range.js.map +1 -0
  176. package/dist/test/references.d.ts +1 -0
  177. package/dist/test/references.js +350 -0
  178. package/dist/test/references.js.map +1 -0
  179. package/dist/test/referencesIndex.d.ts +1 -0
  180. package/dist/test/referencesIndex.js +151 -0
  181. package/dist/test/referencesIndex.js.map +1 -0
  182. package/dist/test/referencesModify.d.ts +1 -0
  183. package/dist/test/referencesModify.js +79 -0
  184. package/dist/test/referencesModify.js.map +1 -0
  185. package/dist/test/remove.d.ts +1 -0
  186. package/dist/test/remove.js +61 -0
  187. package/dist/test/remove.js.map +1 -0
  188. package/dist/test/rootProps.d.ts +1 -0
  189. package/dist/test/rootProps.js +53 -0
  190. package/dist/test/rootProps.js.map +1 -0
  191. package/dist/test/save.d.ts +1 -0
  192. package/dist/test/save.js +43 -0
  193. package/dist/test/save.js.map +1 -0
  194. package/dist/test/saveRange.d.ts +1 -0
  195. package/dist/test/saveRange.js +230 -0
  196. package/dist/test/saveRange.js.map +1 -0
  197. package/dist/test/search.d.ts +1 -0
  198. package/dist/test/search.js +322 -0
  199. package/dist/test/search.js.map +1 -0
  200. package/dist/test/shared/assert.d.ts +5 -0
  201. package/dist/test/shared/assert.js +75 -0
  202. package/dist/test/shared/assert.js.map +1 -0
  203. package/dist/test/shared/examples.d.ts +6 -0
  204. package/dist/test/shared/examples.js +1323 -0
  205. package/dist/test/shared/examples.js.map +1 -0
  206. package/dist/test/shared/playground.d.ts +1 -0
  207. package/dist/test/shared/playground.js +250 -0
  208. package/dist/test/shared/playground.js.map +1 -0
  209. package/dist/test/shared/test.d.ts +11 -0
  210. package/dist/test/shared/test.js +112 -0
  211. package/dist/test/shared/test.js.map +1 -0
  212. package/dist/test/shared/worker.d.ts +1 -0
  213. package/dist/test/shared/worker.js +127 -0
  214. package/dist/test/shared/worker.js.map +1 -0
  215. package/dist/test/simpleQuery.d.ts +1 -0
  216. package/dist/test/simpleQuery.js +43 -0
  217. package/dist/test/simpleQuery.js.map +1 -0
  218. package/dist/test/singleRef.d.ts +1 -0
  219. package/dist/test/singleRef.js +572 -0
  220. package/dist/test/singleRef.js.map +1 -0
  221. package/dist/test/singleRefQuery.d.ts +1 -0
  222. package/dist/test/singleRefQuery.js +136 -0
  223. package/dist/test/singleRefQuery.js.map +1 -0
  224. package/dist/test/sort.d.ts +1 -0
  225. package/dist/test/sort.js +401 -0
  226. package/dist/test/sort.js.map +1 -0
  227. package/dist/test/sortIds.d.ts +1 -0
  228. package/dist/test/sortIds.js +104 -0
  229. package/dist/test/sortIds.js.map +1 -0
  230. package/dist/test/sortNumber.d.ts +1 -0
  231. package/dist/test/sortNumber.js +76 -0
  232. package/dist/test/sortNumber.js.map +1 -0
  233. package/dist/test/sortString.d.ts +1 -0
  234. package/dist/test/sortString.js +118 -0
  235. package/dist/test/sortString.js.map +1 -0
  236. package/dist/test/string.d.ts +1 -0
  237. package/dist/test/string.js +310 -0
  238. package/dist/test/string.js.map +1 -0
  239. package/dist/test/subscription.d.ts +1 -0
  240. package/dist/test/subscription.js +336 -0
  241. package/dist/test/subscription.js.map +1 -0
  242. package/dist/test/text.d.ts +1 -0
  243. package/dist/test/text.js +87 -0
  244. package/dist/test/text.js.map +1 -0
  245. package/dist/test/timestamp.d.ts +1 -0
  246. package/dist/test/timestamp.js +50 -0
  247. package/dist/test/timestamp.js.map +1 -0
  248. package/dist/test/update.d.ts +1 -0
  249. package/dist/test/update.js +223 -0
  250. package/dist/test/update.js.map +1 -0
  251. package/dist/test/validation.d.ts +1 -0
  252. package/dist/test/validation.js +90 -0
  253. package/dist/test/validation.js.map +1 -0
  254. package/dist/test/vector.d.ts +1 -0
  255. package/dist/test/vector.js +47 -0
  256. package/dist/test/vector.js.map +1 -0
  257. package/package.json +4 -4
  258. package/dist/lib/darwin_aarch64/libnode-v20.18.1.node +0 -0
  259. package/dist/lib/darwin_aarch64/libnode-v22.13.0.node +0 -0
  260. package/dist/lib/darwin_aarch64/libnode-v22.8.0.node +0 -0
  261. package/dist/lib/linux_aarch64/include/cdefs.h +0 -317
  262. package/dist/lib/linux_aarch64/include/libdeflate.h +0 -322
  263. package/dist/lib/linux_aarch64/include/libdeflate_strings.h +0 -35
  264. package/dist/lib/linux_aarch64/include/linker_set.h +0 -109
  265. package/dist/lib/linux_aarch64/include/queue.h +0 -627
  266. package/dist/lib/linux_aarch64/include/selva/_export.h +0 -7
  267. package/dist/lib/linux_aarch64/include/selva/align.h +0 -9
  268. package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +0 -29
  269. package/dist/lib/linux_aarch64/include/selva/base64.h +0 -59
  270. package/dist/lib/linux_aarch64/include/selva/base64url.h +0 -59
  271. package/dist/lib/linux_aarch64/include/selva/bitmap.h +0 -95
  272. package/dist/lib/linux_aarch64/include/selva/crc32c.h +0 -17
  273. package/dist/lib/linux_aarch64/include/selva/ctime.h +0 -135
  274. package/dist/lib/linux_aarch64/include/selva/db.h +0 -284
  275. package/dist/lib/linux_aarch64/include/selva/endian.h +0 -301
  276. package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +0 -23
  277. package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +0 -11
  278. package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +0 -36
  279. package/dist/lib/linux_aarch64/include/selva/fields.h +0 -338
  280. package/dist/lib/linux_aarch64/include/selva/find.h +0 -47
  281. package/dist/lib/linux_aarch64/include/selva/lpf.h +0 -28
  282. package/dist/lib/linux_aarch64/include/selva/node_id_set.h +0 -43
  283. package/dist/lib/linux_aarch64/include/selva/poptop.h +0 -114
  284. package/dist/lib/linux_aarch64/include/selva/queue_r.h +0 -190
  285. package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +0 -39
  286. package/dist/lib/linux_aarch64/include/selva/selva_lang.h +0 -105
  287. package/dist/lib/linux_aarch64/include/selva/selva_math.h +0 -37
  288. package/dist/lib/linux_aarch64/include/selva/selva_string.h +0 -672
  289. package/dist/lib/linux_aarch64/include/selva/sort.h +0 -119
  290. package/dist/lib/linux_aarch64/include/selva/strsearch.h +0 -43
  291. package/dist/lib/linux_aarch64/include/selva/timestamp.h +0 -25
  292. package/dist/lib/linux_aarch64/include/selva/traverse.h +0 -65
  293. package/dist/lib/linux_aarch64/include/selva/types.h +0 -110
  294. package/dist/lib/linux_aarch64/include/selva/vector.h +0 -14
  295. package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +0 -13
  296. package/dist/lib/linux_aarch64/include/selva_error.h +0 -137
  297. package/dist/lib/linux_aarch64/include/selva_lang_code.h +0 -157
  298. package/dist/lib/linux_aarch64/include/tree.h +0 -852
  299. package/dist/lib/linux_aarch64/libdeflate.so +0 -0
  300. package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
  301. package/dist/lib/linux_aarch64/libnode-v20.11.1.node +0 -0
  302. package/dist/lib/linux_aarch64/libnode-v20.18.1.node +0 -0
  303. package/dist/lib/linux_aarch64/libnode-v22.13.0.node +0 -0
  304. package/dist/lib/linux_aarch64/libselva.so +0 -0
  305. package/dist/lib/linux_aarch64/libxxhash.so +0 -0
  306. package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
  307. package/dist/lib/linux_aarch64/libxxhash.so.0.8.2 +0 -0
  308. package/dist/lib/linux_x86_64/include/cdefs.h +0 -317
  309. package/dist/lib/linux_x86_64/include/libdeflate.h +0 -322
  310. package/dist/lib/linux_x86_64/include/libdeflate_strings.h +0 -35
  311. package/dist/lib/linux_x86_64/include/linker_set.h +0 -109
  312. package/dist/lib/linux_x86_64/include/queue.h +0 -627
  313. package/dist/lib/linux_x86_64/include/selva/_export.h +0 -7
  314. package/dist/lib/linux_x86_64/include/selva/align.h +0 -9
  315. package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +0 -29
  316. package/dist/lib/linux_x86_64/include/selva/base64.h +0 -59
  317. package/dist/lib/linux_x86_64/include/selva/base64url.h +0 -59
  318. package/dist/lib/linux_x86_64/include/selva/bitmap.h +0 -95
  319. package/dist/lib/linux_x86_64/include/selva/crc32c.h +0 -17
  320. package/dist/lib/linux_x86_64/include/selva/ctime.h +0 -135
  321. package/dist/lib/linux_x86_64/include/selva/db.h +0 -284
  322. package/dist/lib/linux_x86_64/include/selva/endian.h +0 -301
  323. package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +0 -23
  324. package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +0 -11
  325. package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +0 -36
  326. package/dist/lib/linux_x86_64/include/selva/fields.h +0 -338
  327. package/dist/lib/linux_x86_64/include/selva/find.h +0 -47
  328. package/dist/lib/linux_x86_64/include/selva/lpf.h +0 -28
  329. package/dist/lib/linux_x86_64/include/selva/node_id_set.h +0 -43
  330. package/dist/lib/linux_x86_64/include/selva/poptop.h +0 -114
  331. package/dist/lib/linux_x86_64/include/selva/queue_r.h +0 -190
  332. package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +0 -39
  333. package/dist/lib/linux_x86_64/include/selva/selva_lang.h +0 -105
  334. package/dist/lib/linux_x86_64/include/selva/selva_math.h +0 -37
  335. package/dist/lib/linux_x86_64/include/selva/selva_string.h +0 -672
  336. package/dist/lib/linux_x86_64/include/selva/sort.h +0 -119
  337. package/dist/lib/linux_x86_64/include/selva/strsearch.h +0 -43
  338. package/dist/lib/linux_x86_64/include/selva/timestamp.h +0 -25
  339. package/dist/lib/linux_x86_64/include/selva/traverse.h +0 -65
  340. package/dist/lib/linux_x86_64/include/selva/types.h +0 -110
  341. package/dist/lib/linux_x86_64/include/selva/vector.h +0 -14
  342. package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +0 -13
  343. package/dist/lib/linux_x86_64/include/selva_error.h +0 -137
  344. package/dist/lib/linux_x86_64/include/selva_lang_code.h +0 -157
  345. package/dist/lib/linux_x86_64/include/tree.h +0 -852
  346. package/dist/lib/linux_x86_64/libdeflate.so +0 -0
  347. package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
  348. package/dist/lib/linux_x86_64/libnode-v20.11.1.node +0 -0
  349. package/dist/lib/linux_x86_64/libnode-v20.18.1.node +0 -0
  350. package/dist/lib/linux_x86_64/libnode-v22.13.0.node +0 -0
  351. package/dist/lib/linux_x86_64/libselva.so +0 -0
  352. package/dist/lib/linux_x86_64/libxxhash.so +0 -0
  353. package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
  354. package/dist/lib/linux_x86_64/libxxhash.so.0.8.2 +0 -0
@@ -1,317 +0,0 @@
1
- /*
2
- * Copyright (c) 2020-2024 SAULX
3
- * SPDX-License-Identifier: BSD-2-Clause
4
- */
5
-
6
- #pragma once
7
- #ifndef _UTIL_CDEFS_H_
8
- #define _UTIL_CDEFS_H_
9
-
10
- #if __STDC_VERSION__ < 202311L
11
- #define static_assert _Static_assert
12
- #if defined(__clang__) && !defined(unreachable)
13
- #define unreachable __builtin_unreachable
14
- #endif
15
- #endif
16
-
17
- #if defined(__linux__)
18
- /**
19
- * Force linking against a specific version of a GLIBC symbol.
20
- * Use this at the top-level of a source file.
21
- */
22
- #define GLIBC_COMPAT_SYMBOL(SYM, VER) \
23
- __asm__(".symver " #SYM "," #SYM "@GLIBC_" #VER);
24
- #else
25
- #define GLIBC_COMPAT_SYMBOL(SYM, VER)
26
- #endif
27
-
28
- #if defined(__GNUC__) && !defined(__clang__)
29
- /**
30
- * The char array isn't a NUL terminated C-string.
31
- * Using this attribute will help to get better warnings at compilation time.
32
- */
33
- #define __nonstring __attribute__((nonstring))
34
- /**
35
- * Annotate a pure function.
36
- * The function has no side effects and the value returned depends on the
37
- * arguments and the state of global variables. Therefore it is safe for
38
- * the optimizer to eliminate repeated calls with unchanged arguments.
39
- */
40
- #define __purefn __attribute__((pure))
41
- /**
42
- * Annotate a const function.
43
- * The return value of the function is solely a function of its arguments,
44
- * and if any of the arguments are pointers, then the pointers are not be
45
- * dereferenced.
46
- */
47
- #define __constfn __attribute__((const))
48
- #else
49
- #define __nonstring
50
- #define __purefn
51
- #define __constfn
52
- #endif
53
-
54
- #define __sentinel __attribute__((sentinel))
55
-
56
- #if __has_c_attribute(noreturn)
57
- #define __noreturn [[noreturn]]
58
- #else
59
- #define __noreturn __attribute__((noreturn))
60
- #endif
61
-
62
- #define __transparent_union __attribute__((__transparent_union__))
63
-
64
- #define CONCATENATE(arg1, arg2) CONCATENATE1(arg1, arg2)
65
- #define CONCATENATE1(arg1, arg2) CONCATENATE2(arg1, arg2)
66
- #define CONCATENATE2(arg1, arg2) arg1##arg2
67
-
68
- #define UTIL_NARG(...) \
69
- UTIL_NARG_(__VA_ARGS__, UTIL_RSEQ_N())
70
- #define UTIL_NARG_(...) UTIL_ARG_N(__VA_ARGS__)
71
- #define UTIL_ARG_N( \
72
- _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
73
- _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, \
74
- _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, \
75
- _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, \
76
- _57, _58, _59, _60, _61, _62, _63, N, ...) N
77
- # define UTIL_RSEQ_N() \
78
- 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, \
79
- 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
80
- 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
81
- 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
82
-
83
- #define _S__LINE__S(x) #x
84
- #define _S__LINE__S2(x) _S__LINE__S(x)
85
- /**
86
- * Current line number as a string.
87
- */
88
- #define S__LINE__ _S__LINE__S2(__LINE__)
89
-
90
- #ifndef __GLOBL1
91
- #define __GLOBL1(sym) __asm__(".globl " #sym)
92
- /**
93
- * Make the symbol `sym` visible to the linker.
94
- */
95
- #define __GLOBL(sym) __GLOBL1(sym)
96
- #endif
97
-
98
- #ifndef __weak_sym
99
- /**
100
- * Emit the declaration as a weak symbol.
101
- * A weak symbol can be overridden at linking. This is particularly useful for
102
- * functions.
103
- *
104
- */
105
- #define __weak_sym __attribute__((weak))
106
- #endif
107
-
108
- #ifndef __used
109
- /**
110
- * The function or variable is used.
111
- * Inform the compiler that the fuction is used and the code must be emitted
112
- * even if the function name is not referenced.
113
- */
114
- #define __used __attribute__((__used__))
115
- #endif
116
-
117
- #ifndef __unused
118
- /**
119
- * The function or variable is unused on purpose.
120
- */
121
- #define __unused __attribute__((__unused__))
122
- #endif
123
-
124
- #ifndef __section
125
- /**
126
- * Store the variable or function in a named section.
127
- */
128
- #define __section(x) __attribute__((__section__(x)))
129
- #endif
130
-
131
- #if defined(__APPLE__)
132
- #define __lazy_alloc_glob
133
- #else
134
- /**
135
- * Lazy alloc global variable.
136
- * On many system (especially Linux) user defined sections are not zeroed on
137
- * startup and thus implicitly neither allocated until accessed. This allows
138
- * us to create global variables that are allocated lazily.
139
- */
140
- #define __lazy_alloc_glob __attribute__((__section__("lazy")))
141
- #endif
142
-
143
- /**
144
- * A function that must be called before `main()`.
145
- * The function is called automatically before executing `main()`.
146
- */
147
- #define __constructor __attribute__((constructor))
148
-
149
- /**
150
- * A function that must be called after `main()` exits.
151
- * The function is called automatically after `main()` exits.
152
- */
153
- #define __destructor __attribute__((destructor))
154
-
155
- #ifndef __hot
156
- /**
157
- * Inform the compiler that the function is a hotspot.
158
- * Hot functions might be placed closely together in memory to improve locality.
159
- */
160
- #define __hot __attribute__((hot))
161
- #endif
162
-
163
- #ifndef __cold
164
- /**
165
- * Inform the compiler that the function is unlikely to be executed.
166
- */
167
- #define __cold __attribute__((cold))
168
- #endif
169
-
170
- #ifndef __packed
171
- /**
172
- * Use the minimum required memory to represent the type.
173
- * The enum, union, structure, or a structure member should have the smallest
174
- * possible alignment.
175
- */
176
- #define __packed __attribute__((packed))
177
- #endif
178
-
179
- #ifndef __counted_by
180
- #if __has_attribute(__counted_by__)
181
- /**
182
- * struct foo {
183
- * unsigned int len;
184
- * char buf[] __counted_by(len);
185
- * };
186
- * __builtin_dynamic_object_size(p->buf) == p->len * sizeof(*p->buf)
187
- */
188
- #define __counted_by(member) __attribute__((__counted_by__(member)))
189
- #else
190
- #define __counted_by(member)
191
- #endif
192
- #endif
193
-
194
- #ifndef __pcounted_by
195
- #if __has_attribute(__counted_by__) && !defined(__clang__)
196
- /**
197
- * struct foo {
198
- * unsigned int len;
199
- * char *buf __pcounted_by(len);
200
- * };
201
- * __builtin_dynamic_object_size(p->buf) == p->len * sizeof(*p->buf)
202
- */
203
- #define __pcounted_by(member) __attribute__((__counted_by__(member)))
204
- #else
205
- #define __pcounted_by(member)
206
- #endif
207
- #endif
208
-
209
- #ifndef __designated_init
210
- #if __has_attribute(__designated_init__)
211
- /**
212
- * Must use a designated initializer with a struct.
213
- */
214
- #define __designated_init __attribute__((__designated_init__))
215
- #else
216
- #define __designated_init
217
- #endif
218
- #endif
219
-
220
- /* This should come with C23 */
221
- #ifndef alignas
222
- #define alignas(x) _Alignas(x)
223
- #endif
224
-
225
- /* This should come with C23 */
226
- #ifndef alignof
227
- #define alignof(x) _Alignof(x)
228
- #endif
229
-
230
- /**
231
- * It's likely that `x` is always truthy in runtime.
232
- */
233
- #define likely(x) __builtin_expect(!!(x), 1)
234
- #define unlikely(x) __builtin_expect(!!(x), 0)
235
-
236
- #if __has_builtin(__builtin_speculation_safe_value)
237
- #define speculation_safe_value(x) __builtin_speculation_safe_value(x)
238
- #else
239
- #define speculation_safe_value(x) x
240
- #endif
241
-
242
- #define same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
243
-
244
- /**
245
- * Statically assert that VAR is compatible with the type TYPE.
246
- */
247
- #define ASSERT_TYPE(TYPE, VAR) \
248
- static_assert(__builtin_types_compatible_p(TYPE, typeof(VAR)))
249
-
250
- /**
251
- * Returns the smaller of the given values.
252
- */
253
- #define min(a, b) \
254
- ({ __typeof__ (a) _a = (a); \
255
- __typeof__ (b) _b = (b); \
256
- _a < _b ? _a : _b; })
257
-
258
- /**
259
- * Returns the greater of the given values.
260
- */
261
- #define max(a, b) \
262
- ({ __typeof__ (a) _a = (a); \
263
- __typeof__ (b) _b = (b); \
264
- _a > _b ? _a : _b; })
265
-
266
- /**
267
- * Get the struct that contains `m`.
268
- * This macro can be only used if we know for certain that `x` is a pointer to
269
- * the member `m` in type `s`.
270
- * @param x is a pointer to the member `m` in a struct of type `s`.
271
- * @param s is a struct type.
272
- * @param m is the name of the member in `s`.
273
- */
274
- #define containerof(x, s, m) ({ \
275
- const __typeof(((s *)0)->m) *__x = (x); \
276
- ((s *)((uint8_t *)(__x) - offsetof(s, m))); \
277
- })
278
-
279
- /**
280
- * Get the number of elements in an array.
281
- */
282
- #define num_elem(x) (sizeof(x) / sizeof(*(x)))
283
-
284
- /**
285
- * Size of struct field.
286
- */
287
- #define typeof_field(t, f) typeof(((t*)0)->f)
288
-
289
- /**
290
- * Size of struct field.
291
- */
292
- #define sizeof_field(t, f) (sizeof(((t*)0)->f))
293
-
294
- /**
295
- * Size of a struct with its flexible array member.
296
- */
297
- #define sizeof_wflex(t, f, count) \
298
- max(sizeof(t), offsetof(t, f[0]) + count * sizeof(((t*)0)->f[0]))
299
-
300
- /**
301
- * Check if pointer has a const qualifier.
302
- */
303
- #define IS_POINTER_CONST(P) \
304
- _Generic(1 ? (P) : (void *)(P), \
305
- void const *: 1, \
306
- default : 0)
307
-
308
- /**
309
- * Static ternary if.
310
- * Selects either T or E depending on P.
311
- */
312
- #define STATIC_IF(P, T, E) \
313
- _Generic (&(char [!!(P) + 1]) {0}, \
314
- char (*) [2] : T, \
315
- char (*) [1] : E)
316
-
317
- #endif /* _UTIL_CDEFS_H_ */
@@ -1,322 +0,0 @@
1
- /*
2
- * libdeflate.h - public header for libdeflate
3
- * Copyright (c) 2024 SAULX
4
- * Copyright 2023 housisong
5
- * Copyright 2016 Eric Biggers
6
- *
7
- * SPDX-License-Identifier: MIT
8
- */
9
-
10
- #ifndef LIBDEFLATE_H
11
- #define LIBDEFLATE_H
12
-
13
- #define LIBDEFLATE_VERSION_MAJOR 2
14
- #define LIBDEFLATE_VERSION_MINOR 0
15
- #define LIBDEFLATE_VERSION_STRING "2.0"
16
-
17
- #include <stddef.h>
18
- #include <stdint.h>
19
-
20
- #ifndef LIBDEFLATEEXPORT
21
- #ifdef BUILDING_LIBDEFLATE
22
- #define LIBDEFLATEEXPORT __attribute__((visibility("default")))
23
- #else
24
- #define LIBDEFLATEEXPORT
25
- #endif
26
- #endif
27
-
28
- /* ========================================================================== */
29
- /* Compression */
30
- /* ========================================================================== */
31
-
32
- struct libdeflate_compressor;
33
-
34
- /**
35
- * libdeflate_alloc_compressor() allocates a new compressor.
36
- * 'compression_level' is the compression level on a zlib-like scale but with a
37
- * higher maximum value (1 = fastest, 6 = medium/default, 9 = slow, 12 = slowest).
38
- * Level 0 is also supported and means "no compression", specifically "create a
39
- * valid stream, but only emit uncompressed blocks" (this will expand the data
40
- * slightly).
41
- *
42
- * The return value is a pointer to the new compressor, or NULL if out of memory
43
- * or if the compression level is invalid (i.e. outside the range [0, 12]).
44
- *
45
- * Note: for compression, the sliding window size is defined at compilation time
46
- * to 32768, the largest size permissible in the DEFLATE format. It cannot be
47
- * changed at runtime.
48
- *
49
- * A single compressor is not safe to use by multiple threads concurrently.
50
- * However, different threads may use different compressors concurrently.
51
- */
52
- LIBDEFLATEEXPORT struct libdeflate_compressor *
53
- libdeflate_alloc_compressor(int compression_level);
54
-
55
- LIBDEFLATEEXPORT struct libdeflate_compressor *
56
- libdeflate_alloc_compressor2(int compression_level, const void *shared_dict);
57
-
58
- /**
59
- * libdeflate_compress() performs raw DEFLATE compression on a buffer of
60
- * data. The function attempts to compress 'in_nbytes' bytes of data located at
61
- * 'in' and write the results to 'out', which has space for 'out_nbytes_avail'
62
- * bytes. The return value is the compressed size in bytes, or 0 if the data
63
- * could not be compressed to 'out_nbytes_avail' bytes or fewer.
64
- */
65
- LIBDEFLATEEXPORT size_t
66
- libdeflate_compress(struct libdeflate_compressor *compressor,
67
- const void *in, size_t in_nbytes,
68
- void *out, size_t out_nbytes_avail);
69
-
70
- /**
71
- * libdeflate_compress_bound() returns a worst-case upper bound on the
72
- * number of bytes of compressed data that may be produced by compressing any
73
- * buffer of length less than or equal to 'in_nbytes' using
74
- * libdeflate_compress() with the specified compressor. Mathematically,
75
- * this bound will necessarily be a number greater than or equal to 'in_nbytes'.
76
- * It may be an overestimate of the true upper bound. The return value is
77
- * guaranteed to be the same for all invocations with the same compressor and
78
- * same 'in_nbytes'.
79
- *
80
- * Note that this function is not necessary in many applications. With
81
- * block-based compression, it is usually preferable to separately store the
82
- * uncompressed size of each block and to store any blocks that did not compress
83
- * to less than their original size uncompressed. In that scenario, there is no
84
- * need to know the worst-case compressed size, since the maximum number of
85
- * bytes of compressed data that may be used would always be one less than the
86
- * input length. You can just pass a buffer of that size to
87
- * libdeflate_compress() and store the data uncompressed if
88
- * libdeflate_compress() returns 0, indicating that the compressed data
89
- * did not fit into the provided output buffer.
90
- */
91
- LIBDEFLATEEXPORT size_t
92
- libdeflate_compress_bound(size_t in_nbytes);
93
-
94
- static inline size_t
95
- libdeflate_compress_bound_block(size_t in_block_nbytes)
96
- {
97
- return libdeflate_compress_bound(in_block_nbytes) + 5;
98
- }
99
-
100
- /**
101
- * libdeflate_free_compressor() frees a compressor that was allocated with
102
- * libdeflate_alloc_compressor().
103
- * If a NULL pointer is passed in, no action is taken.
104
- */
105
- LIBDEFLATEEXPORT void
106
- libdeflate_free_compressor(struct libdeflate_compressor *compressor);
107
-
108
- /* ========================================================================== */
109
- /* Decompression */
110
- /* ========================================================================== */
111
-
112
- struct libdeflate_decompressor;
113
-
114
- /**
115
- * libdeflate_alloc_decompressor() allocates a new decompressor.
116
- * The return value is a pointer to
117
- * the new decompressor, or NULL if out of memory.
118
- *
119
- * This function takes no parameters, and the returned decompressor is valid for
120
- * decompressing data that was compressed at any compression level and with any
121
- * sliding window size.
122
- *
123
- * A single decompressor is not safe to use by multiple threads concurrently.
124
- * However, different threads may use different decompressors concurrently.
125
- */
126
- LIBDEFLATEEXPORT struct libdeflate_decompressor *
127
- libdeflate_alloc_decompressor(void);
128
-
129
- /**
130
- * Result of a call to libdeflate_decompress().
131
- */
132
- enum libdeflate_result {
133
- /**
134
- * Decompression was successful.
135
- */
136
- LIBDEFLATE_SUCCESS = 0,
137
-
138
- /**
139
- * Decompressed failed because the compressed data was invalid, corrupt,
140
- * or otherwise unsupported.
141
- */
142
- LIBDEFLATE_BAD_DATA = 1,
143
-
144
- /**
145
- * A NULL 'actual_out_nbytes_ret' was provided, but the data would have
146
- * decompressed to fewer than 'out_nbytes_avail' bytes.
147
- */
148
- LIBDEFLATE_SHORT_OUTPUT = 2,
149
-
150
- /**
151
- * The data would have decompressed to more than 'out_nbytes_avail'
152
- * bytes.
153
- */
154
- LIBDEFLATE_INSUFFICIENT_SPACE = 3,
155
-
156
- /**
157
- * More blocks availbled for decompression.
158
- * Only returned by libdeflate_decompress_block().
159
- */
160
- LIBDEFLATE_MORE = 4,
161
- };
162
-
163
- /**
164
- * libdeflate_decompress() decompresses the DEFLATE-compressed stream
165
- * from the buffer 'in' with compressed size up to 'in_nbytes' bytes.
166
- * The uncompressed data is written to 'out', a buffer with size 'out_nbytes_avail'
167
- * bytes. If decompression succeeds, then 0 (LIBDEFLATE_SUCCESS) is returned.
168
- * Otherwise, a nonzero result code such as LIBDEFLATE_BAD_DATA is returned. If
169
- * a nonzero result code is returned, then the contents of the output buffer are
170
- * undefined.
171
- *
172
- * Decompression stops at the end of the DEFLATE stream (as indicated by the
173
- * BFINAL flag), even if it is actually shorter than 'in_nbytes' bytes.
174
- *
175
- * libdeflate_decompress() can be used in cases where the actual
176
- * uncompressed size is known (recommended) or unknown (not recommended):
177
- *
178
- * - If the actual uncompressed size is known, then pass the actual
179
- * uncompressed size as 'out_nbytes_avail' and pass NULL for
180
- * 'actual_out_nbytes_ret'. This makes libdeflate_decompress() fail
181
- * with LIBDEFLATE_SHORT_OUTPUT if the data decompressed to fewer than the
182
- * specified number of bytes.
183
- *
184
- * - If the actual uncompressed size is unknown, then provide a non-NULL
185
- * 'actual_out_nbytes_ret' and provide a buffer with some size
186
- * 'out_nbytes_avail' that you think is large enough to hold all the
187
- * uncompressed data. In this case, if the data decompresses to less than
188
- * or equal to 'out_nbytes_avail' bytes, then
189
- * libdeflate_decompress() will write the actual uncompressed size
190
- * to *actual_out_nbytes_ret and return 0 (LIBDEFLATE_SUCCESS). Otherwise,
191
- * it will return LIBDEFLATE_INSUFFICIENT_SPACE if the provided buffer was
192
- * not large enough but no other problems were encountered, or another
193
- * nonzero result code if decompression failed for another reason.
194
- */
195
- LIBDEFLATEEXPORT enum libdeflate_result
196
- libdeflate_decompress(struct libdeflate_decompressor *decompressor,
197
- const void *in, size_t in_nbytes,
198
- void *out, size_t out_nbytes_avail,
199
- size_t *actual_out_nbytes_ret);
200
-
201
- /**
202
- * Like libdeflate_decompress(), but adds the 'actual_in_nbytes_ret'
203
- * argument.
204
- * If decompression succeeds and 'actual_in_nbytes_ret' is not NULL,
205
- * then the actual compressed size of the DEFLATE stream (aligned to the next
206
- * byte boundary) is written to *actual_in_nbytes_ret.
207
- */
208
- LIBDEFLATEEXPORT enum libdeflate_result
209
- libdeflate_decompress_ex(struct libdeflate_decompressor *decompressor,
210
- const void *in, size_t in_nbytes,
211
- void *out, size_t out_nbytes_avail,
212
- size_t *actual_in_nbytes_ret,
213
- size_t *actual_out_nbytes_ret);
214
-
215
- /**
216
- * ctrl libdeflate_decompress_block() stop condition
217
- */
218
- enum libdeflate_decompress_stop_by {
219
- LIBDEFLATE_STOP_BY_FINAL_BLOCK = 0,
220
- LIBDEFLATE_STOP_BY_ANY_BLOCK = 1,
221
- LIBDEFLATE_STOP_BY_ANY_BLOCK_AND_FULL_INPUT = 2,
222
- LIBDEFLATE_STOP_BY_ANY_BLOCK_AND_FULL_OUTPUT = 3,
223
- LIBDEFLATE_STOP_BY_ANY_BLOCK_AND_FULL_OUTPUT_AND_IN_BYTE_ALIGN = 4,
224
- };
225
-
226
- /**
227
- * Decompress a DEFLATE block.
228
- * Large stream data can be decompress by calling libdeflate_decompress_block()
229
- * multiple times. Each time call this function, 'out_block_with_in_dict' have
230
- * 'in_dict_nbytes' repeat of the last called's tail outputted uncompressed data
231
- * as dictionary data, and 'out_block_nbytes' new uncompressed data want be
232
- * decompressed;
233
- * The dictionary data size in_dict_nbytes<=32k, if it is greater than 32k, the extra
234
- * part of the previous part of the dictionary data is invalid.
235
- * libdeflate_compress_bound_block(out_block_nbytes) can get the upper limit
236
- * of 'in_part' required space 'in_part_nbytes_bound'.
237
- * 'is_final_block_ret' can be NULL.
238
- *
239
- * WARNING: This function must decompressed one full DEFLATE block before stop;
240
- * so 'in_part_nbytes_bound' must possess a block end flag, and "out_block_nbytes"
241
- * must be able to store uncompressed data of this block decompressed;
242
- * This feature is not compatible with the DEFLATE stream decoding standard,
243
- * this function can't support a single DEFLATE block that may have any length.
244
- */
245
- LIBDEFLATEEXPORT enum libdeflate_result
246
- libdeflate_decompress_block(struct libdeflate_decompressor *decompressor,
247
- const void *in_part, size_t in_part_nbytes_bound,
248
- void *out_block_with_in_dict, size_t in_dict_nbytes, size_t out_block_nbytes,
249
- size_t *actual_in_nbytes_ret, size_t *actual_out_nbytes_ret,
250
- enum libdeflate_decompress_stop_by stop_type);
251
-
252
- /**
253
- * Clear the block decompressor save state.
254
- * Clear the state saved between calls libdeflate_decompress_block();
255
- * if you know the next block does not depend on the inputted data of the previous
256
- * block, you can call this function reset 'decompressor';
257
- * Note: if next block depend on the inputted data of the previous block, reset will
258
- * cause libdeflate_decompress_block() to fail.
259
- */
260
- LIBDEFLATEEXPORT void
261
- libdeflate_decompress_block_reset(struct libdeflate_decompressor *decompressor);
262
-
263
- struct libdeflate_block_state {
264
- size_t cur_block_size;
265
- size_t data_cur;
266
- size_t out_cur;
267
- size_t data_buf_size;
268
- uint8_t *data_buf;
269
- };
270
-
271
- /**
272
- * Initialize a block state struct.
273
- * struct libdeflate_block_state is used with libdeflate_decompress_stream().
274
- */
275
- LIBDEFLATEEXPORT struct libdeflate_block_state
276
- libdeflate_block_state_init(size_t max_block_size);
277
-
278
- /**
279
- * Increase the buffer size in a struct libdeflate_block_state.
280
- * This function should be called if libdeflate_decompress_stream() returns with
281
- * LIBDEFLATE_INSUFFICIENT_SPACE. Decompression should be retried only if this
282
- * function returns `true`.
283
- * @return value `true` if a larger buffer was allocated;
284
- * `false` if the buffer wasn't changed.
285
- */
286
- LIBDEFLATEEXPORT bool
287
- libdeflate_block_state_growbuf(struct libdeflate_block_state *state);
288
-
289
- /**
290
- * Deinitialize struct libdeflate_block_state.
291
- * This frees data_buf.
292
- */
293
- LIBDEFLATEEXPORT void
294
- libdeflate_block_state_deinit(struct libdeflate_block_state *state);
295
-
296
- typedef int (*libdeflate_decompress_stream_cb_t)(void * ctx, const uint8_t * buf, size_t dict_len, size_t data_len);
297
-
298
- /**
299
- * Decompress deflated string in_buf block by block.
300
- * Call libdeflate_block_state_init() before and libdeflate_block_state_deinit() after.
301
- * @param cb is a callback that will be called for each decompressed block.
302
- * Decompression is interrupted if the callback returns a non-zero value.
303
- * @param result returns the non-zero return value of cb.
304
- */
305
- LIBDEFLATEEXPORT enum libdeflate_result
306
- libdeflate_decompress_stream(
307
- struct libdeflate_decompressor *decompressor,
308
- struct libdeflate_block_state *state,
309
- const char *in_buf, size_t in_len,
310
- libdeflate_decompress_stream_cb_t cb, void *ctx,
311
- int *result);
312
-
313
- /**
314
- * Free a decompressor.
315
- * libdeflate_free_decompressor() frees a decompressor that was allocated with
316
- * libdeflate_alloc_decompressor(). If a NULL pointer is passed in, no action
317
- * is taken.
318
- */
319
- LIBDEFLATEEXPORT void
320
- libdeflate_free_decompressor(struct libdeflate_decompressor *decompressor);
321
-
322
- #endif /* LIBDEFLATE_H */
@@ -1,35 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 SAULX
3
- * SPDX-License-Identifier: MIT
4
- */
5
- #pragma once
6
-
7
- #include <stddef.h>
8
- #include <stdint.h>
9
-
10
- #ifndef LIBDEFLATEEXPORT
11
- #ifdef BUILDING_LIBDEFLATE
12
- #define LIBDEFLATEEXPORT __attribute__((visibility("default")))
13
- #else
14
- #define LIBDEFLATEEXPORT
15
- #endif
16
- #endif
17
-
18
- struct libdeflate_block_state;
19
- struct libdeflate_decompressor;
20
-
21
- /**
22
- * Test if the compressed string in_buf is equivalent to the buffer poited by ptr2_buf.
23
- * First string deflated and second not
24
- * @return Same as memcmp().
25
- */
26
- LIBDEFLATEEXPORT int
27
- libdeflate_memcmp(struct libdeflate_decompressor *decompressor, struct libdeflate_block_state *state, const char *in_buf, size_t in_len, const void *ptr2_buf, size_t ptr2_len);
28
-
29
- /**
30
- * Test if the compressed string in_buf includes the string needle_buf.
31
- * First string deflated and second not
32
- * @return Same as memmem().
33
- */
34
- LIBDEFLATEEXPORT int64_t
35
- libdeflate_memmem(struct libdeflate_decompressor *decompressor, struct libdeflate_block_state *state, const char *in_buf, size_t in_len, const void *needle_buf, size_t needle_len);