zsv 1.3.0

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 (240) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +36 -0
  3. data/LICENSE +21 -0
  4. data/README.md +311 -0
  5. data/ext/zsv/common.h +34 -0
  6. data/ext/zsv/extconf.rb +137 -0
  7. data/ext/zsv/options.c +126 -0
  8. data/ext/zsv/options.h +31 -0
  9. data/ext/zsv/options_internal.h +8 -0
  10. data/ext/zsv/parser.c +300 -0
  11. data/ext/zsv/parser.h +62 -0
  12. data/ext/zsv/row.c +122 -0
  13. data/ext/zsv/row.h +39 -0
  14. data/ext/zsv/vendor/zsv-1.3.0/app/2db.c +756 -0
  15. data/ext/zsv/vendor/zsv-1.3.0/app/2json.c +381 -0
  16. data/ext/zsv/vendor/zsv-1.3.0/app/2tsv.c +228 -0
  17. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/help.c +123 -0
  18. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/license.c +39 -0
  19. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/register.c +104 -0
  20. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/thirdparty.c +41 -0
  21. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/unregister.c +1 -0
  22. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/version.c +14 -0
  23. data/ext/zsv/vendor/zsv-1.3.0/app/check/simdutf_wrapper.h +19 -0
  24. data/ext/zsv/vendor/zsv-1.3.0/app/check/utf8.c +116 -0
  25. data/ext/zsv/vendor/zsv-1.3.0/app/check.c +194 -0
  26. data/ext/zsv/vendor/zsv-1.3.0/app/cli.c +796 -0
  27. data/ext/zsv/vendor/zsv-1.3.0/app/cli_const.h +41 -0
  28. data/ext/zsv/vendor/zsv-1.3.0/app/cli_export.h +16 -0
  29. data/ext/zsv/vendor/zsv-1.3.0/app/cli_ini.c +280 -0
  30. data/ext/zsv/vendor/zsv-1.3.0/app/cli_internal.h +36 -0
  31. data/ext/zsv/vendor/zsv-1.3.0/app/compare.c +913 -0
  32. data/ext/zsv/vendor/zsv-1.3.0/app/compare.h +23 -0
  33. data/ext/zsv/vendor/zsv-1.3.0/app/compare_added_column.c +20 -0
  34. data/ext/zsv/vendor/zsv-1.3.0/app/compare_internal.h +140 -0
  35. data/ext/zsv/vendor/zsv-1.3.0/app/compare_sort.c +91 -0
  36. data/ext/zsv/vendor/zsv-1.3.0/app/compare_unique_colname.c +81 -0
  37. data/ext/zsv/vendor/zsv-1.3.0/app/count-pull.c +82 -0
  38. data/ext/zsv/vendor/zsv-1.3.0/app/count.c +404 -0
  39. data/ext/zsv/vendor/zsv-1.3.0/app/desc.c +569 -0
  40. data/ext/zsv/vendor/zsv-1.3.0/app/echo.c +365 -0
  41. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/my_extension.c +366 -0
  42. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/mysheet_extension.c +341 -0
  43. data/ext/zsv/vendor/zsv-1.3.0/app/ext_template/YOUR_EXTENSION_zsvext.c +263 -0
  44. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.c +298 -0
  45. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.h +157 -0
  46. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/json_numeric.c +177 -0
  47. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.c +444 -0
  48. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.h +145 -0
  49. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/utils.c +110 -0
  50. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/include/memfile.h +15 -0
  51. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/src/memfile.c +64 -0
  52. data/ext/zsv/vendor/zsv-1.3.0/app/external/sglib/sglib.h +1955 -0
  53. data/ext/zsv/vendor/zsv-1.3.0/app/external/simdutf/simdutf.h +6802 -0
  54. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.c +230517 -0
  55. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.h +12174 -0
  56. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_and_csv_vtab.c +2 -0
  57. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.c +142 -0
  58. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.h +49 -0
  59. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-zsv.c +485 -0
  60. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab.c +1015 -0
  61. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3ext.h +663 -0
  62. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/vtab_helper.c +85 -0
  63. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_common.h +75 -0
  64. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_gen.h +167 -0
  65. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_parse.h +228 -0
  66. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_tree.h +186 -0
  67. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_version.h +23 -0
  68. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_common.h +76 -0
  69. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_gen.h +167 -0
  70. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_parse.h +238 -0
  71. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_tree.h +186 -0
  72. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl.c +184 -0
  73. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.c +52 -0
  74. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.h +34 -0
  75. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.c +103 -0
  76. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.h +57 -0
  77. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_bytestack.h +69 -0
  78. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.c +220 -0
  79. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.h +34 -0
  80. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_gen.c +362 -0
  81. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.c +764 -0
  82. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.h +117 -0
  83. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.c +508 -0
  84. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.h +78 -0
  85. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_tree.c +505 -0
  86. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_version.c +7 -0
  87. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/json_value.h +59 -0
  88. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/yajl_helper.h +208 -0
  89. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper.c +795 -0
  90. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper_internal.h +28 -0
  91. data/ext/zsv/vendor/zsv-1.3.0/app/flatten.c +851 -0
  92. data/ext/zsv/vendor/zsv-1.3.0/app/jq.c +106 -0
  93. data/ext/zsv/vendor/zsv-1.3.0/app/jq.h +6 -0
  94. data/ext/zsv/vendor/zsv-1.3.0/app/mv.c +113 -0
  95. data/ext/zsv/vendor/zsv-1.3.0/app/noop.c +90 -0
  96. data/ext/zsv/vendor/zsv-1.3.0/app/overwrite.c +295 -0
  97. data/ext/zsv/vendor/zsv-1.3.0/app/paste.c +175 -0
  98. data/ext/zsv/vendor/zsv-1.3.0/app/pretty.c +693 -0
  99. data/ext/zsv/vendor/zsv-1.3.0/app/prop.c +980 -0
  100. data/ext/zsv/vendor/zsv-1.3.0/app/rm.c +131 -0
  101. data/ext/zsv/vendor/zsv-1.3.0/app/select/fixed.c +130 -0
  102. data/ext/zsv/vendor/zsv-1.3.0/app/select/internal.h +118 -0
  103. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.c +45 -0
  104. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.h +41 -0
  105. data/ext/zsv/vendor/zsv-1.3.0/app/select/processing.c +107 -0
  106. data/ext/zsv/vendor/zsv-1.3.0/app/select/rand.c +20 -0
  107. data/ext/zsv/vendor/zsv-1.3.0/app/select/regex.c +61 -0
  108. data/ext/zsv/vendor/zsv-1.3.0/app/select/search.c +14 -0
  109. data/ext/zsv/vendor/zsv-1.3.0/app/select/selection.c +192 -0
  110. data/ext/zsv/vendor/zsv-1.3.0/app/select/usage.c +72 -0
  111. data/ext/zsv/vendor/zsv-1.3.0/app/select-pull.c +812 -0
  112. data/ext/zsv/vendor/zsv-1.3.0/app/select.c +753 -0
  113. data/ext/zsv/vendor/zsv-1.3.0/app/serialize.c +372 -0
  114. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/curses.h +15 -0
  115. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/cursor.c +119 -0
  116. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/errors.c +45 -0
  117. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.c +63 -0
  118. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.h +12 -0
  119. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/filter.c +166 -0
  120. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers.c +214 -0
  121. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers_internal.h +128 -0
  122. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/help.c +43 -0
  123. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.c +81 -0
  124. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.h +25 -0
  125. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.c +325 -0
  126. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.h +73 -0
  127. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/lexer.c +203 -0
  128. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/newline_handler.c +7 -0
  129. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/pivot.c +318 -0
  130. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.c +134 -0
  131. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.h +119 -0
  132. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/read-data.c +322 -0
  133. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.c +203 -0
  134. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.h +36 -0
  135. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet-sql.c +167 -0
  136. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet_internal.h +36 -0
  137. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sqlfilter.c +153 -0
  138. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/terminfo.c +32 -0
  139. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.c +312 -0
  140. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.h +29 -0
  141. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/ui_buffer.c +266 -0
  142. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/usage.c +9 -0
  143. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/utf8-width.c +60 -0
  144. data/ext/zsv/vendor/zsv-1.3.0/app/sheet.c +1007 -0
  145. data/ext/zsv/vendor/zsv-1.3.0/app/sql.c +453 -0
  146. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.c +101 -0
  147. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.h +49 -0
  148. data/ext/zsv/vendor/zsv-1.3.0/app/stack.c +393 -0
  149. data/ext/zsv/vendor/zsv-1.3.0/app/utils/arg.c +322 -0
  150. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cache.c +228 -0
  151. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cat.c +91 -0
  152. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.c +240 -0
  153. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.h +63 -0
  154. data/ext/zsv/vendor/zsv-1.3.0/app/utils/clock.c +57 -0
  155. data/ext/zsv/vendor/zsv-1.3.0/app/utils/db.c +148 -0
  156. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs-no-jq.c +2 -0
  157. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs.c +427 -0
  158. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_from_json.c +253 -0
  159. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_to_json.c +121 -0
  160. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dl.c +20 -0
  161. data/ext/zsv/vendor/zsv-1.3.0/app/utils/emcc/fs_api.c +159 -0
  162. data/ext/zsv/vendor/zsv-1.3.0/app/utils/err.c +24 -0
  163. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file-mem.c +180 -0
  164. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file.c +256 -0
  165. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.c +197 -0
  166. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.h +49 -0
  167. data/ext/zsv/vendor/zsv-1.3.0/app/utils/jq.c +400 -0
  168. data/ext/zsv/vendor/zsv-1.3.0/app/utils/json.c +120 -0
  169. data/ext/zsv/vendor/zsv-1.3.0/app/utils/mem.c +18 -0
  170. data/ext/zsv/vendor/zsv-1.3.0/app/utils/memmem.c +132 -0
  171. data/ext/zsv/vendor/zsv-1.3.0/app/utils/os.c +178 -0
  172. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite.c +258 -0
  173. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite_writer.c +246 -0
  174. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8-test.c +123 -0
  175. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.c +153 -0
  176. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.h +54 -0
  177. data/ext/zsv/vendor/zsv-1.3.0/app/utils/prop.c +267 -0
  178. data/ext/zsv/vendor/zsv-1.3.0/app/utils/signal.c +53 -0
  179. data/ext/zsv/vendor/zsv-1.3.0/app/utils/string.c +357 -0
  180. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dir_exists_longpath.c +83 -0
  181. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dl.c +33 -0
  182. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/fopen_longpath.c +184 -0
  183. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/foreach_dirent_longpath.c +292 -0
  184. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.c +259 -0
  185. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.h +13 -0
  186. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/mkdir_longpath.c +255 -0
  187. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/remove_longpath.c +96 -0
  188. data/ext/zsv/vendor/zsv-1.3.0/app/utils/writer.c +361 -0
  189. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command.h +40 -0
  190. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command_standalone.c +16 -0
  191. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_main.h +44 -0
  192. data/ext/zsv/vendor/zsv-1.3.0/examples/js/zsv_parser_api_dummy.c +3 -0
  193. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/parse_by_chunk.c +100 -0
  194. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/print_my_column.c +143 -0
  195. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/pull.c +89 -0
  196. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/simple.c +123 -0
  197. data/ext/zsv/vendor/zsv-1.3.0/fuzz/fuzz.c +16 -0
  198. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/api.h +336 -0
  199. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/common.h +361 -0
  200. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/implementation.h +62 -0
  201. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/implementation_private.h +113 -0
  202. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/sheet.h +73 -0
  203. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext.h +329 -0
  204. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/arg.h +90 -0
  205. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/cache.h +49 -0
  206. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/clock.h +36 -0
  207. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/compiler.h +58 -0
  208. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/db.h +19 -0
  209. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/dirs.h +147 -0
  210. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/dl.h +22 -0
  211. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/emcc/fs_api.h +28 -0
  212. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/err.h +22 -0
  213. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/file-mem.h +17 -0
  214. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/file.h +99 -0
  215. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/jq.h +65 -0
  216. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/json.h +19 -0
  217. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/mem.h +19 -0
  218. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/memmem.h +13 -0
  219. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/os.h +54 -0
  220. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/overwrite.h +71 -0
  221. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/overwrite_writer.h +53 -0
  222. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/prop.h +107 -0
  223. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/signal.h +18 -0
  224. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/sql.h +11 -0
  225. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/string.h +148 -0
  226. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/utf8.h +41 -0
  227. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/win/dl.h +25 -0
  228. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/writer.h +101 -0
  229. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/zsv_export.h +33 -0
  230. data/ext/zsv/vendor/zsv-1.3.0/include/zsv.h +20 -0
  231. data/ext/zsv/vendor/zsv-1.3.0/src/vector_delim.c +60 -0
  232. data/ext/zsv/vendor/zsv-1.3.0/src/zsv.c +484 -0
  233. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_internal.c +731 -0
  234. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_scan_delim.c +285 -0
  235. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_scan_fixed.c +88 -0
  236. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_strencode.c +51 -0
  237. data/ext/zsv/zsv_ext.c +343 -0
  238. data/lib/zsv/version.rb +5 -0
  239. data/lib/zsv.rb +81 -0
  240. metadata +340 -0
@@ -0,0 +1,49 @@
1
+ #ifndef ZSV_CACHE_H
2
+ #define ZSV_CACHE_H
3
+
4
+ /**
5
+ * Overridable constants: ZSV_CACHE_PREFIX and ZSV_TEMPFILE_SUFFIX
6
+ */
7
+
8
+ #ifndef ZSV_CACHE_PREFIX
9
+ #define ZSV_CACHE_PREFIX "zsv"
10
+ #endif
11
+
12
+ #ifndef ZSV_TEMPFILE_SUFFIX
13
+ #define ZSV_TEMPFILE_SUFFIX ".~zsv"
14
+ #endif
15
+
16
+ /**
17
+ * Cache path definitions
18
+ */
19
+ #ifdef _WIN32
20
+ #define ZSV_CACHE_DIR "." ZSV_CACHE_PREFIX "\\data"
21
+ #else
22
+ #define ZSV_CACHE_DIR "." ZSV_CACHE_PREFIX "/data"
23
+ #endif
24
+
25
+ #define ZSV_CACHE_PROPERTIES_NAME "props"
26
+
27
+ /**
28
+ * Return the folder or file path to the cache for a given data file
29
+ * Caller must free the returned result
30
+ */
31
+ unsigned char *zsv_cache_path(const unsigned char *data_filepath, const unsigned char *cache_filename, char temp_file);
32
+
33
+ enum zsv_cache_type {
34
+ zsv_cache_type_property = 1,
35
+ zsv_cache_type_tag,
36
+ zsv_cache_type_overwrite
37
+ };
38
+
39
+ unsigned char *zsv_cache_filepath(const unsigned char *data_filepath, enum zsv_cache_type type, char create_dir,
40
+ char temp_file);
41
+
42
+ int zsv_cache_print(const unsigned char *filepath, enum zsv_cache_type ctype, const unsigned char *default_value);
43
+
44
+ int zsv_cache_remove(const unsigned char *filepath, enum zsv_cache_type ctype);
45
+
46
+ int zsv_modify_cache_file(const unsigned char *filepath, enum zsv_cache_type ctype, const unsigned char *json_value1,
47
+ const unsigned char *json_value2, const unsigned char *filter);
48
+
49
+ #endif
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef __ZSV_UTIL_CLOCK_H__
10
+ #define __ZSV_UTIL_CLOCK_H__
11
+
12
+ #include <time.h>
13
+ #include <stdio.h>
14
+
15
+ void zsv_clocks_begin(void);
16
+ void zsv_clocks_end(void);
17
+
18
+ size_t zsv_fread_clock(void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
19
+ size_t zsv_fwrite_clock(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
20
+ int zsv_fflush_clock(FILE *stream);
21
+
22
+ #if USE_CLOCK
23
+
24
+ #define ZSV_FREAD zsv_fread_clock
25
+ #define ZSV_FWRITE zsv_fwrite_clock
26
+ #define ZSV_FFLUSH zsv_fflush_clock
27
+
28
+ #else
29
+
30
+ #define ZSV_FREAD fread
31
+ #define ZSV_FWRITE fwrite
32
+ #define ZSV_FFLUSH fflush
33
+
34
+ #endif
35
+
36
+ #endif
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright (C) 2021 Tai Chi Minh Ralph Eastwood
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_UTILS_COMPILER
10
+ #define ZSV_UTILS_COMPILER
11
+
12
+ #ifdef HAVE___BUILTIN_EXPECT
13
+
14
+ #ifndef LIKELY
15
+ #define LIKELY(x) __builtin_expect(x, 1)
16
+ #endif
17
+
18
+ #ifndef UNLIKELY
19
+ #define UNLIKELY(x) __builtin_expect(x, 0)
20
+ #endif
21
+
22
+ #ifndef VERY_LIKELY
23
+ #ifdef NO___BUILTIN_EXPECT_WITH_PROBABILITY
24
+ #define VERY_LIKELY(x) LIKELY(x)
25
+ #else
26
+ #define VERY_LIKELY(x) __builtin_expect_with_probability(x, 1, 0.999)
27
+ #endif
28
+ #endif
29
+
30
+ #ifndef VERY_UNLIKELY
31
+ #ifdef NO___BUILTIN_EXPECT_WITH_PROBABILITY
32
+ #define VERY_UNLIKELY(x) UNLIKELY(x)
33
+ #else
34
+ #define VERY_UNLIKELY(x) __builtin_expect_with_probability(x, 0, 0.999)
35
+ #endif
36
+ #endif
37
+
38
+ #else
39
+ /* no HAVE___BUILTIN_EXPECT */
40
+ #ifndef LIKELY
41
+ #define LIKELY(x) (x)
42
+ #endif
43
+
44
+ #ifndef UNLIKELY
45
+ #define UNLIKELY(x) (x)
46
+ #endif
47
+
48
+ #ifndef VERY_LIKELY
49
+ #define VERY_LIKELY(x) (x)
50
+ #endif
51
+
52
+ #ifndef VERY_UNLIKELY
53
+ #define VERY_UNLIKELY(x) (x)
54
+ #endif
55
+
56
+ #endif /* HAVE___BUILTIN_EXPECT */
57
+
58
+ #endif
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_DB_H
10
+ #define ZSV_DB_H
11
+
12
+ #include <sqlite3.h>
13
+ #include <jsonwriter.h>
14
+
15
+ // zsv_dbtable2json: convert a db table to json
16
+ // @limit: if nonzero, limit number of rows processed
17
+ int zsv_dbtable2json(sqlite3 *db, const char *tname, jsonwriter_handle jsw, size_t limit);
18
+
19
+ #endif
@@ -0,0 +1,147 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_DIRS_H
10
+ #define ZSV_DIRS_H
11
+
12
+ #include <stdio.h>
13
+
14
+ /* Maximum length of file name */
15
+ #if !defined(FILENAME_MAX)
16
+ #define FILENAME_MAX MAX_PATH
17
+ #endif
18
+
19
+ /* file slash */
20
+ #if !defined(FILESLASH)
21
+ #ifdef _WIN32
22
+ #define FILESLASH '\\'
23
+ #else
24
+ #define FILESLASH '/'
25
+ #endif
26
+ #endif
27
+
28
+ /**
29
+ * Get os-independent configuration file path
30
+ * prefix should be determined at compile time e.g. /usr/local or ""
31
+ * @return length written to buff, or 0 if failed
32
+ */
33
+ size_t zsv_get_config_dir(char *buff, size_t buffsize, const char *prefix);
34
+
35
+ /**
36
+ * Get the path of the current executable
37
+ */
38
+ size_t zsv_get_executable_path(char *buff, size_t buffsize);
39
+
40
+ /**
41
+ * Get current user's home dir, without trailing slash
42
+ * On win, any backslashes are replaced with fwd slash
43
+ * ex: zsv_get_home_dir(char[MAX_PATH], MAX_PATH)
44
+ * returns 0 if no home dir could be found
45
+ * returns > 0 and < bufflen on success
46
+ * returns > 0 and >= bufflen if buffer was too small
47
+ */
48
+ int zsv_get_home_dir(char *buff, size_t bufflen);
49
+
50
+ /**
51
+ * Check if a directory exists
52
+ * return true (non-zero) or false (zero)
53
+ */
54
+ int zsv_dir_exists(const char *path);
55
+
56
+ /**
57
+ * mkdir that works with UNC paths on Win
58
+ * if fail, use zsv_perror() instead of perror()
59
+ */
60
+ int zsv_mkdir(const char *path);
61
+
62
+ /**
63
+ * Make a directory, as well as any intermediate dirs
64
+ * return zero on success
65
+ */
66
+ int zsv_mkdirs(const char *path, char path_is_filename);
67
+
68
+ /**
69
+ * Recursively remove a directory and all of its contents
70
+ * return zero on success
71
+ */
72
+ int zsv_remove_dir_recursive(const unsigned char *path);
73
+
74
+ #include <sys/stat.h>
75
+
76
+ struct zsv_foreach_dirent_handle {
77
+ const char *parent; /* name of the parent directory */
78
+ const char *entry; /* file / dir name of current entry being processed */
79
+ const char *parent_and_entry; /* parent + entry separated by file separator */
80
+ const struct stat stat; /* stat of current entry */
81
+
82
+ void *ctx; /* caller-provided context to pass to handler */
83
+
84
+ unsigned char verbose : 1;
85
+ unsigned char is_dir : 1; /* non-zero if this entry is a directory */
86
+ unsigned char no_recurse : 1; /* set to 1 when handling a dir to prevent recursing into it */
87
+ unsigned char _ : 5;
88
+ };
89
+
90
+ typedef int (*zsv_foreach_dirent_handler)(struct zsv_foreach_dirent_handle *h, size_t depth);
91
+
92
+ /**
93
+ * Recursively process entries (files and folders) in a directory
94
+ *
95
+ * @param dir_path : path of directory to begin processing children of
96
+ * @param max_depth : maximum depth to recurse, or 0 for no maximum
97
+ * @param handler : caller-provided entry handler. return 0 on success, non-zero on error
98
+ * @param ctx : pointer passed to the handler
99
+ * @param verbose : non-zero for verbose output
100
+ *
101
+ * returns error
102
+ */
103
+ int zsv_foreach_dirent(const char *dir_path, size_t max_depth, zsv_foreach_dirent_handler handler, void *ctx,
104
+ char verbose);
105
+
106
+ struct zsv_dir_filter {
107
+ zsv_foreach_dirent_handler
108
+ filter; /* filter function; return 1 to process this node. if node is dir, return 0 to skip entirely */
109
+ size_t max_depth; /* max depth to recurse */
110
+ void *ctx; /* pointer to pass to filter function */
111
+ };
112
+
113
+ /**
114
+ * Convert directory contents into a single JSON file
115
+ * Output schema is a dictionary where key = path and value = contents
116
+ * Files named with .json suffix will be exported as JSON (content must be valid JSON)
117
+ * Files named with any other suffix will be exported as a single string value (do not try with large files)
118
+ *
119
+ * @param parent_dir : directory to export
120
+ * @param output_filename : file path to output to, or NULL to output to stdout
121
+ * @param file_filter : filter determining which files to export
122
+ */
123
+ int zsv_dir_to_json(const unsigned char *parent_dir, const unsigned char *output_filename,
124
+ struct zsv_dir_filter *file_filter, unsigned char verbose);
125
+
126
+ /**
127
+ * Convert a JSON stream into file and directory contents
128
+ * This function is the inverse of zsv_dir_to_json()
129
+ * Output schema is a dictionary where key = path and value = contents
130
+ * Files named with .json suffix will be exported as JSON (content must be valid JSON)
131
+ * Files named with any other suffix will be exported as a single string value (do not try with large files)
132
+ *
133
+ * @param target_dir : directory to create / import into
134
+ * @param : file path to output to, or NULL to output to stdout
135
+ * @flags : ZSV_DIR_FLAG_xxx values as defined below
136
+ *
137
+ * Returns 0 on success, non-zero on error
138
+ */
139
+
140
+ #define ZSV_DIR_FLAG_FORCE 1 /* overwrite target files if they already exist */
141
+ #define ZSV_DIR_FLAG_DRY 2 /* dry run, output names of files that would be created/overwritten */
142
+
143
+ int zsv_dir_from_json(const unsigned char *target_dir, FILE *fsrc,
144
+ unsigned int flags, // ZSV_DIR_FLAG_XX
145
+ unsigned char verbose);
146
+
147
+ #endif
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_DL_H
10
+ #define ZSV_DL_H
11
+
12
+ #ifdef _WIN32
13
+ #include <zsv/utils/win/dl.h>
14
+ #define DL_SUFFIX "dll"
15
+ #else
16
+ #include <dlfcn.h>
17
+ #define DL_SUFFIX "so"
18
+ #endif
19
+
20
+ void (*zsv_dlsym(void *restrict handle, const char *restrict name))(void);
21
+
22
+ #endif
@@ -0,0 +1,28 @@
1
+ #ifndef LQ_FS_API_H
2
+ #define LQ_FS_API_H
3
+
4
+ typedef struct fs_data *fshandle;
5
+
6
+ fshandle fsopen(const char *fn, const char *mode);
7
+
8
+ int fsclose(fshandle h);
9
+
10
+ size_t fswrite(const void *ptr, size_t n, size_t m, fshandle h);
11
+
12
+ void stdflush(int addNewline);
13
+
14
+ size_t bytesum(const char *fn);
15
+
16
+ size_t fsread(void *ptr, size_t n, size_t m, fshandle h);
17
+
18
+ int fsrm(const char *fn);
19
+
20
+ int fsmkdir(const char *path);
21
+
22
+ int fsprint(const char *s);
23
+
24
+ int fsprinterr(const char *s);
25
+
26
+ char *fsls(const char *dir);
27
+
28
+ #endif
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_ERR_H
10
+ #define ZSV_ERR_H
11
+
12
+ int zsv_app_printerr(const char *appname, int eno, const char *fmt, ...);
13
+
14
+ #ifdef APPNAME
15
+ #define zsv_printerr(...) zsv_app_printerr(APPNAME, __VA_ARGS__)
16
+ #else
17
+ #pragma message("zsv_printerr defined without APPNAME")
18
+ #pragma message("to avoid this, include err.h after defining APPNAME to quoted string")
19
+ #define zsv_printerr(...) zsv_app_printerr(0x0, __VA_ARGS__)
20
+ #endif
21
+
22
+ #endif
@@ -0,0 +1,17 @@
1
+ #ifndef ZSV_MEMFILE_H_H
2
+ #define ZSV_MEMFILE_H_H
3
+
4
+ #include <stdio.h>
5
+ #include <stdlib.h>
6
+ #include <stdbool.h>
7
+
8
+ typedef struct zsv_memfile zsv_memfile;
9
+
10
+ // Public API Functions
11
+ zsv_memfile *zsv_memfile_open(size_t buffsz);
12
+ size_t zsv_memfile_write(const void *data, size_t sz, size_t n, zsv_memfile *zfm);
13
+ int zsv_memfile_rewind(zsv_memfile *zfm);
14
+ size_t zsv_memfile_read(void *buffer, size_t size, size_t nitems, zsv_memfile *zfm);
15
+ void zsv_memfile_close(zsv_memfile *zfm);
16
+
17
+ #endif // ZSV_FILEMEM_H_H
@@ -0,0 +1,99 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_FILE_H
10
+ #define ZSV_FILE_H
11
+
12
+ #include <stdio.h>
13
+ #include "file-mem.h"
14
+
15
+ #ifndef LINEEND
16
+ #if defined(WIN32) || defined(_WIN64) || defined(_WIN32)
17
+ #define LINEEND "\r\n"
18
+ #else
19
+ #define LINEEND "\n"
20
+ #endif
21
+ #endif // LINEEND
22
+ /**
23
+ * Get a temp file name. The returned value, if any, will have been allocated
24
+ * on the heap, and the caller should `free()`
25
+ *
26
+ * @param prefix string with which the resulting file name will be prefixed
27
+ */
28
+ char *zsv_get_temp_filename(const char *prefix);
29
+
30
+ /**
31
+ * Replacement for tmpfile().
32
+ * Returns filename; file must be manually removed after fclose
33
+ *
34
+ * @param mode optional mode passed to fopen(); if NULL, defaults to "wb"
35
+ */
36
+ FILE *zsv_tmpfile(const char *prefix, char **filename, const char *mode);
37
+
38
+ /**
39
+ * Check if a file exists and is readable (with fopen + "rb")
40
+ *
41
+ * @param filename
42
+ * @returns: true (1) if file exists
43
+ */
44
+ int zsv_file_exists(const char *filename);
45
+
46
+ /**
47
+ * Check if a file exists and is readable (with fopen + "rb")
48
+ *
49
+ * @param filename
50
+ * @param err if file is not readbale, *err is set to a code as defined in errno.h
51
+ * @param f_out: if provided, on success, set to the opened file ptr
52
+ * @returns: true (1) if file exists and is readable
53
+ */
54
+ int zsv_file_readable(const char *filename, int *err, FILE **f_out);
55
+
56
+ /**
57
+ * Function that is the same as `fwrite()`, but can be used as a callback
58
+ * argument to `zsv_set_scan_filter()`
59
+ *
60
+ * @param FILEp pointer to a FILE object, cast as a void *, to write to
61
+ * @param buff pointer to the buffer of data to write
62
+ * @param bytes_read number of bytes in the buffer to write
63
+ */
64
+ size_t zsv_filter_write(void *FILEp, unsigned char *buff, size_t bytes_read);
65
+
66
+ /**
67
+ * Get a file path's directory length and base name
68
+ * Returns the length of the directory portion of the path
69
+ * and the base name portion of the path
70
+ */
71
+ size_t zsv_dir_len_basename(const char *filepath, const char **basename);
72
+
73
+ /**
74
+ * Copy a file. Create any needed directories
75
+ * On error, prints error message and returns non-zero
76
+ */
77
+ int zsv_copy_file(const char *src, const char *dest);
78
+
79
+ /**
80
+ * Copy a file, given source and destination FILE pointers
81
+ * Return error number per errno.h
82
+ */
83
+ int zsv_copy_file_ptr(FILE *src, FILE *dest);
84
+
85
+ /**
86
+ * Copy a file-like, given source and destination handles
87
+ * and read/write functions
88
+ * Return error number per errno.h
89
+ */
90
+ int zsv_copy_filelike_ptr(
91
+ FILE *src, size_t (*freadx)(void *restrict ptr, size_t size, size_t nitems, void *restrict stream), FILE *dest,
92
+ size_t (*fwritex)(const void *restrict ptr, size_t size, size_t nitems, void *restrict stream));
93
+ /**
94
+ * printf that does nothing. useful in certain circumstances for ignoring
95
+ * errors e.g. opening the same file twice and not dupicating error logs
96
+ */
97
+ int zsv_no_printf(void *, const char *format, ...);
98
+
99
+ #endif
@@ -0,0 +1,65 @@
1
+ #ifndef LQJQ_INTERNAL_H
2
+ #define LQJQ_INTERNAL_H
3
+
4
+ #include <ctype.h>
5
+ #include <jq.h>
6
+
7
+ enum zsv_jq_status {
8
+ zsv_jq_status_ok = 0,
9
+ zsv_jq_status_compile,
10
+ zsv_jq_status_memory,
11
+ zsv_jq_status_error
12
+ };
13
+
14
+ size_t zsv_jq_fwrite1(void *restrict FILE_ptr, const void *restrict buff, size_t len);
15
+
16
+ struct jv_to_json_ctx {
17
+ size_t (*write1)(void *restrict ctx, const void *restrict buff, size_t len); // e.g. zsv_jq_fwrite1
18
+ void *ctx; // e.g. FILE *
19
+ int flags; // passed on to jv_dumpf / jv_dump_string
20
+ char raw_output;
21
+ char output_started;
22
+ };
23
+
24
+ void jv_to_json_w_ctx(jv value, void *jv_to_json_ctx);
25
+
26
+ typedef struct zsv_jq_data *zsv_jq_handle;
27
+
28
+ zsv_jq_handle zsv_jq_new(const unsigned char *filter, void (*func)(jv, void *), void *ctx, enum zsv_jq_status *statusp);
29
+
30
+ // for streaming parsing
31
+ zsv_jq_handle zsv_jq_new_stream(const unsigned char *filter, void (*func)(jv, void *), void *ctx,
32
+ enum zsv_jq_status *statusp);
33
+
34
+ enum zsv_jq_status zsv_jq_parse_file(zsv_jq_handle h, FILE *f);
35
+
36
+ enum zsv_jq_status zsv_jq_parse(zsv_jq_handle restrict h, const void *restrict s, size_t len);
37
+
38
+ size_t zsv_jq_write(const char *s, size_t n, size_t m, zsv_jq_handle h);
39
+
40
+ enum zsv_jq_status zsv_jq_finish(zsv_jq_handle h);
41
+
42
+ void zsv_jq_trace(zsv_jq_handle h, FILE *);
43
+
44
+ void zsv_jq_delete(zsv_jq_handle h);
45
+
46
+ // helper functions
47
+ void jv_to_lqjq(jv value, void *zsv_jq_handle);
48
+
49
+ void jv_to_csv(jv value, void *file);
50
+
51
+ void jv_to_bool(jv value, void *char_result);
52
+
53
+ void jv_to_txt(jv value, void *file);
54
+
55
+ struct jv_to_csv_multi_ctx {
56
+ FILE *(*get_file)(void *ctx);
57
+ void *ctx;
58
+ };
59
+
60
+ // jv_to_csv_multi: write csv rows to different files
61
+ void jv_to_csv_multi(jv value, void *jv_to_csv_multi_ctx);
62
+
63
+ void jv_to_json_func(jv value, void *jv_to_json_func_dat);
64
+
65
+ #endif
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_JSON_H
10
+ #define ZSV_JSON_H
11
+
12
+ /**
13
+ * Convert a string to json (including the surrounding quotes)
14
+ * Returns newly-allocated string (caller must free())
15
+ */
16
+ unsigned char *zsv_json_from_str(const unsigned char *s);
17
+ unsigned char *zsv_json_from_str_n(const unsigned char *s, size_t len);
18
+
19
+ #endif
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_MEM_H
10
+ #define ZSV_MEM_H
11
+
12
+ /* zsv_memdup(): return copy with double-NULL terminator. caller must free() */
13
+ void *zsv_memdup(const void *src, size_t n);
14
+
15
+ #ifndef MEMDUP
16
+ #define MEMDUP zsv_memdup
17
+ #endif
18
+
19
+ #endif
@@ -0,0 +1,13 @@
1
+ #ifndef ZSV_MEMMEM_H
2
+ #define ZSV_MEMMEM_H
3
+
4
+ #ifdef NO_MEMMEM
5
+
6
+ #include <stdint.h>
7
+ void *zsvmemmem(const void *h0, size_t k, const void *n0, size_t l);
8
+
9
+ #define memmem zsvmemmem
10
+
11
+ #endif
12
+
13
+ #endif
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_OS_H
10
+ #define ZSV_OS_H
11
+
12
+ void zsv_perror(const char *);
13
+
14
+ /**
15
+ * zsv_fopen(): same as normal fopen(), except on Win it also works with long filenames
16
+ */
17
+ #ifndef _WIN32
18
+ #define zsv_fopen fopen
19
+ #else
20
+ #include <stdio.h>
21
+ FILE *zsv_fopen(const char *fname, const char *mode);
22
+ char *zsv_ensureLongPathPrefix(const char *original_path, unsigned char always_prefix);
23
+ #endif
24
+
25
+ /**
26
+ * zsv_remove(): same as normal remove()
27
+ but for files only, and on Win it also works with long filenames
28
+ */
29
+ #ifndef _WIN32
30
+ #define zsv_remove remove
31
+ #else
32
+ #include <stdio.h>
33
+ int zsv_remove_winlp(const char *path_utf8);
34
+ #define zsv_remove zsv_remove_winlp
35
+ #endif
36
+
37
+ int zsv_replace_file(const char *src, const char *dest);
38
+
39
+ #ifdef _WIN32
40
+ #include <windows.h>
41
+
42
+ #ifndef ARRAY_SIZE
43
+ #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
44
+ #endif
45
+
46
+ void zsv_win_to_unicode(const void *path, wchar_t *wbuf, size_t wbuf_len);
47
+
48
+ #endif // #ifdef _WIN32
49
+
50
+ /**
51
+ * get number of cores
52
+ */
53
+ unsigned int zsv_get_number_of_cores();
54
+ #endif // ZSV_OS_H