zsv 1.3.1 → 1.4.4

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 (259) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +153 -2
  3. data/README.md +132 -240
  4. data/ext/zsv/ZSV_UPSTREAM +7 -0
  5. data/ext/zsv/common.h +0 -12
  6. data/ext/zsv/extconf.rb +70 -122
  7. data/ext/zsv/options.c +63 -62
  8. data/ext/zsv/options.h +8 -11
  9. data/ext/zsv/parser.c +390 -201
  10. data/ext/zsv/parser.h +35 -22
  11. data/ext/zsv/row.c +75 -28
  12. data/ext/zsv/row.h +15 -9
  13. data/ext/zsv/upstream.rb +55 -0
  14. data/ext/zsv/vendor/zsv/LICENSE +21 -0
  15. data/ext/zsv/vendor/zsv/VENDORED_FROM +2 -0
  16. data/ext/zsv/vendor/zsv/configure +1212 -0
  17. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/api.h +39 -0
  18. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/common.h +36 -0
  19. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/sheet.h +8 -1
  20. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext.h +6 -2
  21. data/ext/zsv/vendor/zsv/include/zsv/utils/appname.h +51 -0
  22. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/arg.h +50 -1
  23. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/compiler.h +19 -8
  24. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dirs.h +2 -0
  25. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file-mem.h +1 -0
  26. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file.h +28 -2
  27. data/ext/zsv/vendor/zsv/include/zsv/utils/os.h +145 -0
  28. data/ext/zsv/vendor/zsv/include/zsv/utils/output.h +34 -0
  29. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite_writer.h +1 -1
  30. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/prop.h +16 -4
  31. data/ext/zsv/vendor/zsv/include/zsv/utils/rng.h +35 -0
  32. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/signal.h +7 -0
  33. data/ext/zsv/vendor/zsv/include/zsv/utils/sql.h +13 -0
  34. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/string.h +25 -0
  35. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/writer.h +9 -1
  36. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/zsv_export.h +1 -1
  37. data/ext/zsv/vendor/{zsv-1.3.0/include/zsv.h → zsv/include/zsv.h.in} +1 -3
  38. data/ext/zsv/vendor/zsv/src/Makefile +238 -0
  39. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv.c +152 -14
  40. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_internal.c +108 -50
  41. data/ext/zsv/vendor/zsv/src/zsv_scan_delim_fast.c +741 -0
  42. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_avx2.h +89 -0
  43. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_neon.h +80 -0
  44. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_sse2.h +93 -0
  45. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_wasm.h +79 -0
  46. data/ext/zsv/vendor/zsv/src/zsv_strencode.c +84 -0
  47. data/ext/zsv/zsv_ext.c +176 -105
  48. data/lib/zsv/errors.rb +32 -0
  49. data/lib/zsv/input.rb +88 -0
  50. data/lib/zsv/options.rb +132 -0
  51. data/lib/zsv/strict_validator.rb +124 -0
  52. data/lib/zsv/version.rb +1 -1
  53. data/lib/zsv.rb +137 -35
  54. metadata +81 -230
  55. data/ext/zsv/vendor/zsv-1.3.0/app/2db.c +0 -756
  56. data/ext/zsv/vendor/zsv-1.3.0/app/2json.c +0 -381
  57. data/ext/zsv/vendor/zsv-1.3.0/app/2tsv.c +0 -228
  58. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/help.c +0 -123
  59. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/license.c +0 -39
  60. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/register.c +0 -104
  61. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/thirdparty.c +0 -41
  62. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/unregister.c +0 -1
  63. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/version.c +0 -14
  64. data/ext/zsv/vendor/zsv-1.3.0/app/check/simdutf_wrapper.h +0 -19
  65. data/ext/zsv/vendor/zsv-1.3.0/app/check/utf8.c +0 -116
  66. data/ext/zsv/vendor/zsv-1.3.0/app/check.c +0 -194
  67. data/ext/zsv/vendor/zsv-1.3.0/app/cli.c +0 -796
  68. data/ext/zsv/vendor/zsv-1.3.0/app/cli_const.h +0 -41
  69. data/ext/zsv/vendor/zsv-1.3.0/app/cli_export.h +0 -16
  70. data/ext/zsv/vendor/zsv-1.3.0/app/cli_ini.c +0 -280
  71. data/ext/zsv/vendor/zsv-1.3.0/app/cli_internal.h +0 -36
  72. data/ext/zsv/vendor/zsv-1.3.0/app/compare.c +0 -913
  73. data/ext/zsv/vendor/zsv-1.3.0/app/compare.h +0 -23
  74. data/ext/zsv/vendor/zsv-1.3.0/app/compare_added_column.c +0 -20
  75. data/ext/zsv/vendor/zsv-1.3.0/app/compare_internal.h +0 -140
  76. data/ext/zsv/vendor/zsv-1.3.0/app/compare_sort.c +0 -91
  77. data/ext/zsv/vendor/zsv-1.3.0/app/compare_unique_colname.c +0 -81
  78. data/ext/zsv/vendor/zsv-1.3.0/app/count-pull.c +0 -82
  79. data/ext/zsv/vendor/zsv-1.3.0/app/count.c +0 -404
  80. data/ext/zsv/vendor/zsv-1.3.0/app/desc.c +0 -569
  81. data/ext/zsv/vendor/zsv-1.3.0/app/echo.c +0 -365
  82. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/my_extension.c +0 -366
  83. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/mysheet_extension.c +0 -341
  84. data/ext/zsv/vendor/zsv-1.3.0/app/ext_template/YOUR_EXTENSION_zsvext.c +0 -263
  85. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.c +0 -298
  86. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.h +0 -157
  87. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/json_numeric.c +0 -177
  88. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.c +0 -444
  89. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.h +0 -145
  90. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/utils.c +0 -110
  91. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/include/memfile.h +0 -15
  92. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/src/memfile.c +0 -64
  93. data/ext/zsv/vendor/zsv-1.3.0/app/external/sglib/sglib.h +0 -1955
  94. data/ext/zsv/vendor/zsv-1.3.0/app/external/simdutf/simdutf.h +0 -6802
  95. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.c +0 -230517
  96. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.h +0 -12174
  97. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_and_csv_vtab.c +0 -2
  98. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.c +0 -142
  99. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.h +0 -49
  100. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-zsv.c +0 -485
  101. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab.c +0 -1015
  102. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3ext.h +0 -663
  103. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/vtab_helper.c +0 -85
  104. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_common.h +0 -75
  105. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_gen.h +0 -167
  106. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_parse.h +0 -228
  107. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_tree.h +0 -186
  108. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_version.h +0 -23
  109. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_common.h +0 -76
  110. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_gen.h +0 -167
  111. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_parse.h +0 -238
  112. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_tree.h +0 -186
  113. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl.c +0 -184
  114. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.c +0 -52
  115. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.h +0 -34
  116. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.c +0 -103
  117. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.h +0 -57
  118. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_bytestack.h +0 -69
  119. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.c +0 -220
  120. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.h +0 -34
  121. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_gen.c +0 -362
  122. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.c +0 -764
  123. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.h +0 -117
  124. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.c +0 -508
  125. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.h +0 -78
  126. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_tree.c +0 -505
  127. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_version.c +0 -7
  128. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/json_value.h +0 -59
  129. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/yajl_helper.h +0 -208
  130. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper.c +0 -795
  131. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper_internal.h +0 -28
  132. data/ext/zsv/vendor/zsv-1.3.0/app/flatten.c +0 -851
  133. data/ext/zsv/vendor/zsv-1.3.0/app/jq.c +0 -106
  134. data/ext/zsv/vendor/zsv-1.3.0/app/jq.h +0 -6
  135. data/ext/zsv/vendor/zsv-1.3.0/app/mv.c +0 -113
  136. data/ext/zsv/vendor/zsv-1.3.0/app/noop.c +0 -90
  137. data/ext/zsv/vendor/zsv-1.3.0/app/overwrite.c +0 -295
  138. data/ext/zsv/vendor/zsv-1.3.0/app/paste.c +0 -175
  139. data/ext/zsv/vendor/zsv-1.3.0/app/pretty.c +0 -693
  140. data/ext/zsv/vendor/zsv-1.3.0/app/prop.c +0 -980
  141. data/ext/zsv/vendor/zsv-1.3.0/app/rm.c +0 -131
  142. data/ext/zsv/vendor/zsv-1.3.0/app/select/fixed.c +0 -130
  143. data/ext/zsv/vendor/zsv-1.3.0/app/select/internal.h +0 -118
  144. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.c +0 -45
  145. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.h +0 -41
  146. data/ext/zsv/vendor/zsv-1.3.0/app/select/processing.c +0 -107
  147. data/ext/zsv/vendor/zsv-1.3.0/app/select/rand.c +0 -20
  148. data/ext/zsv/vendor/zsv-1.3.0/app/select/regex.c +0 -61
  149. data/ext/zsv/vendor/zsv-1.3.0/app/select/search.c +0 -14
  150. data/ext/zsv/vendor/zsv-1.3.0/app/select/selection.c +0 -192
  151. data/ext/zsv/vendor/zsv-1.3.0/app/select/usage.c +0 -72
  152. data/ext/zsv/vendor/zsv-1.3.0/app/select-pull.c +0 -812
  153. data/ext/zsv/vendor/zsv-1.3.0/app/select.c +0 -753
  154. data/ext/zsv/vendor/zsv-1.3.0/app/serialize.c +0 -372
  155. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/curses.h +0 -15
  156. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/cursor.c +0 -119
  157. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/errors.c +0 -45
  158. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.c +0 -63
  159. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.h +0 -12
  160. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/filter.c +0 -166
  161. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers.c +0 -214
  162. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers_internal.h +0 -128
  163. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/help.c +0 -43
  164. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.c +0 -81
  165. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.h +0 -25
  166. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.c +0 -325
  167. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.h +0 -73
  168. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/lexer.c +0 -203
  169. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/newline_handler.c +0 -7
  170. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/pivot.c +0 -318
  171. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.c +0 -134
  172. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.h +0 -119
  173. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/read-data.c +0 -322
  174. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.c +0 -203
  175. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.h +0 -36
  176. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet-sql.c +0 -167
  177. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet_internal.h +0 -36
  178. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sqlfilter.c +0 -153
  179. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/terminfo.c +0 -32
  180. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.c +0 -312
  181. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.h +0 -29
  182. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/ui_buffer.c +0 -266
  183. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/usage.c +0 -9
  184. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/utf8-width.c +0 -60
  185. data/ext/zsv/vendor/zsv-1.3.0/app/sheet.c +0 -1007
  186. data/ext/zsv/vendor/zsv-1.3.0/app/sql.c +0 -453
  187. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.c +0 -101
  188. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.h +0 -49
  189. data/ext/zsv/vendor/zsv-1.3.0/app/stack.c +0 -393
  190. data/ext/zsv/vendor/zsv-1.3.0/app/utils/arg.c +0 -322
  191. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cache.c +0 -228
  192. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cat.c +0 -91
  193. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.c +0 -240
  194. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.h +0 -63
  195. data/ext/zsv/vendor/zsv-1.3.0/app/utils/clock.c +0 -57
  196. data/ext/zsv/vendor/zsv-1.3.0/app/utils/db.c +0 -148
  197. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs-no-jq.c +0 -2
  198. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs.c +0 -427
  199. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_from_json.c +0 -253
  200. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_to_json.c +0 -121
  201. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dl.c +0 -20
  202. data/ext/zsv/vendor/zsv-1.3.0/app/utils/emcc/fs_api.c +0 -159
  203. data/ext/zsv/vendor/zsv-1.3.0/app/utils/err.c +0 -24
  204. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file-mem.c +0 -180
  205. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file.c +0 -256
  206. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.c +0 -197
  207. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.h +0 -49
  208. data/ext/zsv/vendor/zsv-1.3.0/app/utils/jq.c +0 -400
  209. data/ext/zsv/vendor/zsv-1.3.0/app/utils/json.c +0 -120
  210. data/ext/zsv/vendor/zsv-1.3.0/app/utils/mem.c +0 -18
  211. data/ext/zsv/vendor/zsv-1.3.0/app/utils/memmem.c +0 -132
  212. data/ext/zsv/vendor/zsv-1.3.0/app/utils/os.c +0 -178
  213. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite.c +0 -258
  214. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite_writer.c +0 -246
  215. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8-test.c +0 -123
  216. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.c +0 -153
  217. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.h +0 -54
  218. data/ext/zsv/vendor/zsv-1.3.0/app/utils/prop.c +0 -267
  219. data/ext/zsv/vendor/zsv-1.3.0/app/utils/signal.c +0 -53
  220. data/ext/zsv/vendor/zsv-1.3.0/app/utils/string.c +0 -357
  221. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dir_exists_longpath.c +0 -83
  222. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dl.c +0 -33
  223. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/fopen_longpath.c +0 -184
  224. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/foreach_dirent_longpath.c +0 -292
  225. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.c +0 -259
  226. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.h +0 -13
  227. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/mkdir_longpath.c +0 -255
  228. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/remove_longpath.c +0 -96
  229. data/ext/zsv/vendor/zsv-1.3.0/app/utils/writer.c +0 -361
  230. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command.h +0 -40
  231. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command_standalone.c +0 -16
  232. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_main.h +0 -44
  233. data/ext/zsv/vendor/zsv-1.3.0/examples/js/zsv_parser_api_dummy.c +0 -3
  234. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/parse_by_chunk.c +0 -100
  235. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/print_my_column.c +0 -143
  236. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/pull.c +0 -89
  237. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/simple.c +0 -123
  238. data/ext/zsv/vendor/zsv-1.3.0/fuzz/fuzz.c +0 -16
  239. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/os.h +0 -54
  240. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/sql.h +0 -11
  241. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_strencode.c +0 -51
  242. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation.h +0 -0
  243. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation_private.h +0 -0
  244. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/cache.h +0 -0
  245. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/clock.h +0 -0
  246. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/db.h +0 -0
  247. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dl.h +0 -0
  248. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/emcc/fs_api.h +0 -0
  249. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/err.h +0 -0
  250. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/jq.h +0 -0
  251. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/json.h +0 -0
  252. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/mem.h +0 -0
  253. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/memmem.h +0 -0
  254. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite.h +0 -0
  255. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/utf8.h +0 -0
  256. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/win/dl.h +0 -0
  257. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/vector_delim.c +0 -0
  258. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_delim.c +0 -0
  259. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_fixed.c +0 -0
@@ -1,148 +0,0 @@
1
- #include <stdio.h>
2
- #include <string.h>
3
- #include <sqlite3.h>
4
- #include <jsonwriter.h>
5
- #include <zsv/utils/string.h>
6
-
7
- // starts_w_str_underscore(): helper function
8
- // returns 1 if s starts with prefix (case-insensitive), followed by underscore
9
- static char starts_w_str_underscore(const unsigned char *s, size_t s_len, const unsigned char *prefix) {
10
- char result = 0;
11
- unsigned char *s_lc = zsv_strtolowercase(s, &s_len);
12
- size_t pfx_len = strlen((const char *)prefix);
13
- unsigned char *prefix_lc = zsv_strtolowercase(prefix, &pfx_len);
14
- if (pfx_len + 1 < s_len && !memcmp(s_lc, prefix_lc, pfx_len) && s_lc[pfx_len] == '_')
15
- result = 1;
16
- free(s_lc);
17
- free(prefix_lc);
18
- return result;
19
- }
20
-
21
- int zsv_dbtable2json(sqlite3 *db, const char *tname, jsonwriter_handle jsw, size_t limit) {
22
- int err = 0;
23
- const char *index_sql = "select name, sql from sqlite_master where type = 'index' and tbl_name = :tbl_name";
24
- const char *unique_sql = "select 1 from PRAGMA_index_list(?) where name = ? and [unique] <> 0";
25
- sqlite3_str *data_sql = sqlite3_str_new(db);
26
- if (data_sql) {
27
- sqlite3_str_appendf(data_sql, "select * from \"%w\"", tname);
28
- sqlite3_stmt *data_stmt = NULL;
29
- sqlite3_stmt *index_stmt = NULL;
30
- sqlite3_stmt *unique_stmt = NULL;
31
- int colcount = 0;
32
-
33
- err = 1;
34
- if (sqlite3_prepare_v2(db, sqlite3_str_value(data_sql), -1, &data_stmt, NULL) != SQLITE_OK)
35
- fprintf(stderr, "Unable to prepare %s: %s\n", sqlite3_str_value(data_sql), sqlite3_errmsg(db));
36
- else if (!(colcount = sqlite3_column_count(data_stmt)))
37
- fprintf(stderr, "No columns found in table %s\n", tname);
38
- else if (sqlite3_prepare_v2(db, index_sql, -1, &index_stmt, NULL) != SQLITE_OK)
39
- fprintf(stderr, "Unable to prepare %s: %s\n", index_sql, sqlite3_errmsg(db));
40
- else if (sqlite3_prepare_v2(db, unique_sql, -1, &unique_stmt, NULL) != SQLITE_OK)
41
- fprintf(stderr, "Unable to prepare %s: %s\n", unique_sql, sqlite3_errmsg(db));
42
- else {
43
- err = 0;
44
- jsonwriter_start_array(jsw); // output is an array with 2 items: meta and data
45
-
46
- // ----- meta: columns and index info
47
- jsonwriter_start_object(jsw);
48
-
49
- jsonwriter_object_cstr(jsw, "name", tname);
50
-
51
- // indexes
52
- jsonwriter_object_object(jsw, "indexes"); // indexes
53
- sqlite3_bind_text(index_stmt, 1, tname, (int)strlen(tname), SQLITE_STATIC);
54
- while (sqlite3_step(index_stmt) == SQLITE_ROW) {
55
- const unsigned char *text = sqlite3_column_text(index_stmt, 0);
56
- const unsigned char *ix_sql = sqlite3_column_text(index_stmt, 1);
57
- size_t len = text ? sqlite3_column_bytes(index_stmt, 0) : 0;
58
- size_t ix_sql_len = ix_sql ? sqlite3_column_bytes(index_stmt, 1) : 0;
59
-
60
- if (text && ix_sql && len && ix_sql_len) {
61
- // on: for now we just look for the first and last parens
62
- const unsigned char *first_paren = memchr(ix_sql, '(', ix_sql_len);
63
- const unsigned char *last_paren = ix_sql + ix_sql_len;
64
- while (first_paren && last_paren > first_paren + 1 && *last_paren != ')')
65
- last_paren--;
66
- if (first_paren && last_paren > first_paren) {
67
- // name
68
-
69
- // strip the leading "tablename_" from the index name
70
- const char *ix_name = (const char *)text;
71
- size_t ix_name_len = len;
72
- if (ix_name_len > strlen(tname) + 1 &&
73
- starts_w_str_underscore((const unsigned char *)ix_name, ix_name_len, (const unsigned char *)tname)) {
74
- ix_name += strlen(tname) + 1;
75
- ix_name_len -= strlen(tname) + 1;
76
- }
77
- jsonwriter_object_keyn(jsw, (const char *)ix_name, ix_name_len);
78
-
79
- // ix obj
80
- jsonwriter_start_object(jsw);
81
-
82
- // on
83
- jsonwriter_object_strn(jsw, "on", first_paren + 1, last_paren - first_paren - 1);
84
-
85
- // unique
86
- sqlite3_bind_text(unique_stmt, 1, tname, (int)strlen(tname), SQLITE_STATIC);
87
- sqlite3_bind_text(unique_stmt, 2, (const char *)text, len, SQLITE_STATIC);
88
- if (sqlite3_step(unique_stmt) == SQLITE_ROW)
89
- jsonwriter_object_bool(jsw, "unique", 1);
90
- sqlite3_reset(unique_stmt);
91
-
92
- // end ix obj
93
- jsonwriter_end_object(jsw);
94
- }
95
- }
96
- }
97
- jsonwriter_end_object(jsw); // end indexes
98
-
99
- // columns
100
- jsonwriter_object_array(jsw, "columns");
101
- for (int i = 0; i < colcount; i++) {
102
- const char *colname = sqlite3_column_name(data_stmt, i);
103
- jsonwriter_start_object(jsw);
104
- jsonwriter_object_cstr(jsw, "name", colname);
105
- const char *dtype = sqlite3_column_decltype(data_stmt, i);
106
- if (dtype)
107
- jsonwriter_object_cstr(jsw, "datatype", dtype);
108
-
109
- // TO DO: collate nocase etc
110
- jsonwriter_end_object(jsw);
111
- }
112
- jsonwriter_end_array(jsw); // end columns
113
-
114
- jsonwriter_end_object(jsw); // end meta obj
115
-
116
- // ------ data: array of rows
117
- jsonwriter_start_array(jsw);
118
- // for each row
119
- size_t count = 0;
120
- while (sqlite3_step(data_stmt) == SQLITE_ROW) {
121
- jsonwriter_start_array(jsw); // start row
122
- for (int i = 0; i < colcount; i++) {
123
- const unsigned char *text = sqlite3_column_text(data_stmt, i);
124
- if (text) {
125
- int len = sqlite3_column_bytes(data_stmt, i);
126
- jsonwriter_strn(jsw, text, len);
127
- } else
128
- jsonwriter_null(jsw);
129
- }
130
- jsonwriter_end_array(jsw); // end row
131
- if (limit && ++count >= limit)
132
- break;
133
- }
134
- jsonwriter_end_array(jsw);
135
-
136
- jsonwriter_end_array(jsw); // end of output
137
- }
138
- if (data_stmt)
139
- sqlite3_finalize(data_stmt);
140
- if (index_stmt)
141
- sqlite3_finalize(index_stmt);
142
- if (unique_stmt)
143
- sqlite3_finalize(unique_stmt);
144
-
145
- sqlite3_free(sqlite3_str_finish(data_sql));
146
- } // if data_sql
147
- return err;
148
- }
@@ -1,2 +0,0 @@
1
- #define ZSV_NO_JQ
2
- #include "dirs.c"
@@ -1,427 +0,0 @@
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
- #include <stddef.h>
10
- #include <stdlib.h>
11
- #include <stdio.h>
12
- #include <string.h>
13
- #include <dirent.h>
14
- #include <errno.h>
15
- #include <zsv/utils/os.h>
16
- #ifndef ZSV_NO_JQ
17
- #include <zsv/utils/json.h>
18
- #include <zsv/utils/jq.h>
19
- #endif
20
- #include <zsv/utils/dirs.h>
21
- #include <zsv/utils/string.h>
22
- #include <unistd.h> // unlink
23
- #include <sys/stat.h>
24
- #ifndef ZSV_NO_JQ
25
- #include <yajl_helper/yajl_helper.h>
26
- #endif
27
-
28
- #if defined(_WIN32)
29
- #include <windows.h>
30
- #include "win/io.c"
31
- #endif
32
-
33
- /**
34
- * Most of these functions require the caller to provide a buffer, in which case
35
- * the buffer size should be at least FILENAME_MAX
36
- */
37
-
38
- static size_t chop_slash(char *buff, size_t len) {
39
- if (buff[len - 1] == '\\' || buff[len - 1] == '/') {
40
- buff[len - 1] = '\0';
41
- len--;
42
- }
43
- return (size_t)len;
44
- }
45
-
46
- /**
47
- * Get os-independent configuration file path
48
- * prefix should be determined at compile time e.g. /usr/local or ""
49
- * @return length written to buff, or 0 if failed
50
- */
51
- size_t zsv_get_config_dir(char *buff, size_t buffsize, const char *prefix) {
52
- #if defined(_WIN32)
53
- const char *env_val = getenv("ZSV_CONFIG_DIR");
54
- (void)(prefix);
55
- // if(!(env_val && *env_val))
56
- // env_val = getenv(prefix);
57
- if (!(env_val && *env_val))
58
- env_val = getenv("LOCALAPPDATA");
59
- if (!(env_val && *env_val))
60
- env_val = "C:\\temp";
61
- int written = snprintf(buff, buffsize, "%s", env_val);
62
- #elif defined(__EMSCRIPTEN__)
63
- (void)(prefix);
64
- int written = snprintf(buff, buffsize, "/tmp");
65
- #else
66
- int written;
67
- const char *env_val = getenv("ZSV_CONFIG_DIR");
68
- if (env_val && *env_val)
69
- written = snprintf(buff, buffsize, "%s", env_val);
70
- else
71
- written = snprintf(buff, buffsize, "%s/etc", prefix ? prefix : "");
72
- #endif
73
- if (written > 0 && ((size_t)written) < buffsize)
74
- return chop_slash(buff, written);
75
- return 0;
76
- }
77
-
78
- /**
79
- * Check if a directory exists
80
- * return true (non-zero) or false (zero)
81
- */
82
- #ifdef WIN32
83
- #include "win/dir_exists_longpath.c"
84
- #endif
85
- int zsv_dir_exists(const char *path) {
86
- #ifdef WIN32
87
- if (strlen(path) >= MAX_PATH)
88
- return zsv_dir_exists_winlp(path);
89
-
90
- // TO DO: support win long filepath prefix
91
- // TO DO: work properly if dir exists but we don't have permission
92
- wchar_t wpath[MAX_PATH];
93
- mbstowcs(wpath, path, MAX_PATH);
94
-
95
- DWORD attrs = GetFileAttributesW(wpath);
96
- if (attrs == INVALID_FILE_ATTRIBUTES)
97
- // Could check GetLastError() to see if it's a permission issue vs. not-found
98
- return 0;
99
-
100
- // If it has the directory attribute, it's presumably a directory
101
- return (attrs & FILE_ATTRIBUTE_DIRECTORY) != 0;
102
-
103
- #else
104
- struct stat path_stat;
105
- if (!stat(path, &path_stat))
106
- return S_ISDIR(path_stat.st_mode);
107
- return 0;
108
- #endif
109
- }
110
-
111
- /**
112
- * Make a directory, as well as any intermediate dirs
113
- * return zero on success
114
- */
115
- #ifdef WIN32
116
- #include "win/mkdir_longpath.c"
117
- #define zsv_mkdir zsv_mkdir_winlp
118
- #else
119
- #define zsv_mkdir mkdir
120
- #endif
121
-
122
- int zsv_mkdirs(const char *path, char path_is_filename) {
123
- // int rc = 0;
124
- if (!path || !*path)
125
- return -1;
126
- size_t len = strlen(path);
127
- if (len < 1)
128
- return -1;
129
-
130
- char *tmp = strdup(path);
131
- if (!tmp) {
132
- perror(path);
133
- return -1;
134
- }
135
-
136
- if (len && strchr("/\\", tmp[len - 1]))
137
- tmp[--len] = 0;
138
-
139
- int offset = 0;
140
- #ifdef WIN32
141
- if (len > 1) {
142
- // starts with two slashes
143
- if (strchr("/\\", tmp[0]) && strchr("/\\", tmp[1])) {
144
- offset = 2;
145
- // find the next slash
146
- char *path_end = tmp + 3;
147
- while (*path_end && !strchr("/\\", *path_end))
148
- path_end++;
149
- if (*path_end)
150
- path_end++;
151
- if (*path_end)
152
- offset = path_end - tmp;
153
- else {
154
- fprintf(stderr, "Invalid path: %s\n", path);
155
- free(tmp);
156
- return -1;
157
- }
158
- }
159
- // starts with *:
160
- else if (tmp[1] == ':')
161
- offset = 2;
162
- }
163
- #else
164
- offset = 1;
165
- #endif
166
-
167
- // TO DO: first find the longest subdir that exists, in *reverse* order so as
168
- // to properly handle case where no access to intermediate dir,
169
- // and then only start mkdir from there
170
- int last_dir_exists_rc = 0;
171
- int last_errno = -1;
172
- for (char *p = tmp + offset; /* !rc && */ *p; p++) {
173
- if (strchr("/\\", *p)) {
174
- char tmp_c = p[1];
175
- p[0] = FILESLASH;
176
- p[1] = '\0';
177
- if (*tmp && !(last_dir_exists_rc = zsv_dir_exists(tmp))) {
178
- if (zsv_mkdir(tmp
179
- #ifndef WIN32
180
- ,
181
- S_IRWXU
182
- #endif
183
- )) {
184
- if (errno == EEXIST)
185
- last_dir_exists_rc = 1;
186
- else { // errno could be EEXIST if we have no permissions to an intermediate directory
187
- last_errno = errno;
188
- perror(tmp);
189
- // rc = -1;
190
- }
191
- } else
192
- last_dir_exists_rc = 1;
193
- }
194
- p[1] = tmp_c;
195
- }
196
- }
197
-
198
- if (/* !rc && */ path_is_filename == 0 && *tmp && !(last_dir_exists_rc = zsv_dir_exists(tmp))) {
199
- if (zsv_mkdir(tmp
200
- #ifndef WIN32
201
- ,
202
- S_IRWXU
203
- #endif
204
- )) {
205
- if (errno == EEXIST)
206
- last_dir_exists_rc = 1;
207
- else {
208
- last_errno = errno;
209
- perror(tmp);
210
- // rc = -1;
211
- }
212
- } else
213
- last_dir_exists_rc = 1;
214
- }
215
-
216
- free(tmp);
217
- return last_dir_exists_rc ? 0 : last_errno ? last_errno : -1;
218
- }
219
-
220
- #if defined(_WIN32)
221
- size_t zsv_get_executable_path(char *buff, size_t buffsize) {
222
- return GetModuleFileNameA(NULL, buff, (DWORD)buffsize);
223
- }
224
-
225
- #elif defined(__APPLE__)
226
- #include <mach-o/dyld.h>
227
- size_t zsv_get_executable_path(char *buff, size_t bufflen) {
228
- uint32_t pathlen = bufflen;
229
- if (!_NSGetExecutablePath(buff, &pathlen)) {
230
- char real[FILENAME_MAX];
231
- if (realpath(buff, real) != NULL && strlen(real) < bufflen) {
232
- bufflen = strlen(real);
233
- memcpy(buff, real, bufflen);
234
- buff[bufflen] = '\0';
235
- } else
236
- bufflen = pathlen;
237
- return bufflen;
238
- }
239
- return 0;
240
- }
241
- #elif defined(__linux__) || defined(__EMSCRIPTEN__)
242
- #include <unistd.h>
243
- size_t zsv_get_executable_path(char *buff, size_t buffsize) {
244
- buffsize = readlink("/proc/self/exe", buff, buffsize - 1);
245
- buff[buffsize] = '\0';
246
- return buffsize;
247
- }
248
- #elif defined(__FreeBSD__)
249
- #include <sys/stat.h>
250
- #include <sys/sysctl.h>
251
- size_t zsv_get_executable_path(char *buff, size_t buffsize) {
252
- int mib[4];
253
- mib[0] = CTL_KERN;
254
- mib[1] = KERN_PROC;
255
- mib[2] = KERN_PROC_PATHNAME;
256
- mib[3] = -1;
257
- sysctl(mib, 4, buff, &buffsize, NULL, 0);
258
- buff[buffsize] = '\0';
259
- return buffsize;
260
- }
261
- #else
262
- // TODO: Add support for this OS!
263
- #endif /* end of: #if defined(_WIN32) */
264
-
265
- /**
266
- * Get current user's home dir, without trailing slash
267
- * On win, any backslashes are replaced with fwd slash
268
- * ex: zsv_get_home_dir(char[MAX_PATH], MAX_PATH)
269
- * returns 0 if no home dir could be found
270
- * returns > 0 and < bufflen on success
271
- * returns > 0 and >= bufflen if buffer was too small
272
- */
273
- int zsv_get_home_dir(char *buff, size_t bufflen) {
274
- int written = 0;
275
- if (getenv("HOME"))
276
- written = snprintf(buff, bufflen, "%s", getenv("HOME"));
277
- #if defined(WIN32) || defined(_WIN32)
278
- if (!written && getenv("HOMEDRIVE") && getenv("HOMEPATH"))
279
- written = snprintf(buff, bufflen, "%s%s", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
280
- #endif
281
- if (written > 0 && ((size_t)written) < bufflen) {
282
- if (buff[written - 1] == '\\' || buff[written - 1] == '/') {
283
- buff[written - 1] = '\0';
284
- written--;
285
- }
286
- }
287
- #if defined(WIN32) || defined(_WIN32)
288
- for (int i = 0; i < written; i++)
289
- if (buff[i] == '\\')
290
- buff[i] = '/';
291
- #endif
292
- return written;
293
- }
294
-
295
- struct dir_path {
296
- struct dir_path *next;
297
- char *path;
298
- };
299
-
300
- /**
301
- * remove an empty directory; on error print msg to stderr
302
- * return 0 on success
303
- */
304
- static int rmdir_w_msg(const char *path, int *err) {
305
- #ifdef WIN32
306
- if (!RemoveDirectoryA(path)) {
307
- zsv_perror(path);
308
- // zsv_win_printLastError();
309
- *err = 1;
310
- }
311
- #else
312
- if (remove(path)) {
313
- perror(path);
314
- *err = 1;
315
- }
316
- #endif
317
- return *err;
318
- }
319
-
320
- static int zsv_foreach_dirent_remove(struct zsv_foreach_dirent_handle *h, size_t depth) {
321
- (void)(depth);
322
- if (!h->is_dir) { // file
323
- if (h->parent_and_entry) {
324
- if (zsv_remove(h->parent_and_entry)) {
325
- perror(h->parent_and_entry); // "Unable to remove file");
326
- return 1;
327
- }
328
- }
329
- } else { // dir
330
- if (h->parent_and_entry) {
331
- struct dir_path *dn = calloc(1, sizeof(*dn));
332
- if (!dn) {
333
- fprintf(stderr, "Out of memory!\n");
334
- return 1;
335
- }
336
- dn->path = strdup(h->parent_and_entry);
337
- dn->next = *((struct dir_path **)h->ctx);
338
- *((struct dir_path **)h->ctx) = dn;
339
- }
340
- }
341
- return 0;
342
- }
343
-
344
- #ifdef _WIN32
345
- #include "win/foreach_dirent_longpath.c"
346
- #else
347
- // return error
348
- static int zsv_foreach_dirent_aux(const char *dir_path, size_t depth, size_t max_depth,
349
- zsv_foreach_dirent_handler handler, void *ctx, char verbose) {
350
- int err = 0;
351
- if (!dir_path)
352
- return 1;
353
-
354
- if (max_depth > 0 && depth >= max_depth)
355
- return 0;
356
-
357
- DIR *dr;
358
- if ((dr = opendir(dir_path))) {
359
- struct dirent *de;
360
- while ((de = readdir(dr)) != NULL) {
361
- if (!*de->d_name || !strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
362
- continue;
363
- char *tmp;
364
- asprintf(&tmp, "%s%c%s", dir_path, FILESLASH, de->d_name);
365
- if (!tmp)
366
- fprintf(stderr, "Out of memory!\n"), err = 1;
367
- else {
368
- struct zsv_foreach_dirent_handle h = {0};
369
- h.verbose = verbose;
370
- stat(tmp, (struct stat *)&h.stat);
371
- h.parent = dir_path;
372
- h.entry = de->d_name;
373
- h.parent_and_entry = tmp;
374
- h.ctx = ctx;
375
- char is_dir = h.stat.st_mode & S_IFDIR ? 1 : 0;
376
- h.is_dir = is_dir;
377
- if (handler)
378
- handler(&h, depth + 1);
379
-
380
- if (is_dir && !h.no_recurse)
381
- // recurse!
382
- err = zsv_foreach_dirent_aux(tmp, depth + 1, max_depth, handler, ctx, verbose);
383
- free(tmp);
384
- }
385
- }
386
- closedir(dr);
387
- }
388
- return err;
389
- }
390
- #endif
391
-
392
- int zsv_foreach_dirent(const char *dir_path, size_t max_depth, zsv_foreach_dirent_handler handler, void *ctx,
393
- char verbose) {
394
- return zsv_foreach_dirent_aux(dir_path, 0, max_depth, handler, ctx, verbose);
395
- }
396
-
397
- /**
398
- * Remove a directory and all of its contents
399
- */
400
- int zsv_remove_dir_recursive(const unsigned char *path) {
401
- // we will delete all files first, then
402
- // delete directories in the reverse order we received them
403
- struct dir_path *reverse_dirs = NULL;
404
- int err = zsv_foreach_dirent((const char *)path, 0, zsv_foreach_dirent_remove, &reverse_dirs, 0);
405
-
406
- // unlink each dir
407
- for (struct dir_path *dn = reverse_dirs; !err && dn; dn = dn->next)
408
- rmdir_w_msg(dn->path, &err);
409
-
410
- // free each dir
411
- for (struct dir_path *next, *dn = reverse_dirs; !err && dn; dn = next) {
412
- next = dn->next;
413
- free(dn->path);
414
- free(dn);
415
- }
416
- if (!err)
417
- rmdir_w_msg((const char *)path, &err);
418
-
419
- return err;
420
- }
421
-
422
- #ifndef ZSV_NO_JQ
423
- #include "dirs_to_json.c"
424
-
425
- #include "dirs_from_json.c"
426
-
427
- #endif