| 1 | /* |
| 2 | Copyright (C) 2026 Sutou Kouhei <[email protected]> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #include "grn_extractor.h"cxx . . $ `<file>/lib/grn_extractor.h`/ |
| 20 | #include "grn_extractors.h"cxx . . $ `<file>/lib/grn_extractors.h`/ |
| 21 | |
| 22 | typedef structcxx . . $ $anonymous_type_b8799d91820bc7da_0# { |
| 23 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! remove_tagcxx . . $ $anonymous_type_b8799d91820bc7da_0#remove_tag.; |
| 24 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! expand_character_referencecxx . . $ $anonymous_type_b8799d91820bc7da_0#expand_character_reference.; |
| 25 | } html_extract_optionscxx . . $ html_extract_options#; |
| 26 | |
| 27 | static void |
| 28 | html_extract_options_initcxx . . $ html_extract_options_init(e434e7a37e901d74).(grn_ctxcxx . . $ grn_ctx# *ctx, html_extract_optionscxx . . $ html_extract_options# *options) |
| 29 | { |
| 30 | options->remove_tagcxx . . $ $anonymous_type_b8799d91820bc7da_0#remove_tag. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 31 | options->expand_character_referencecxx . . $ $anonymous_type_b8799d91820bc7da_0#expand_character_reference. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 32 | } |
| 33 | |
| 34 | static void |
| 35 | html_extract_options_fincxx . . $ html_extract_options_fin(e434e7a37e901d74).(grn_ctxcxx . . $ grn_ctx# *ctx, html_extract_optionscxx . . $ html_extract_options# *options) |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | static void |
| 40 | html_extract_close_optionscxx . . $ html_extract_close_options(b6b6153f622d9caa).(grn_ctxcxx . . $ grn_ctx# *ctx, void *data) |
| 41 | { |
| 42 | html_extract_optionscxx . . $ html_extract_options# *options = data; |
| 43 | html_extract_options_fincxx . . $ html_extract_options_fin(e434e7a37e901d74).(ctx, options); |
| 44 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(options); |
| 45 | } |
| 46 | |
| 47 | static void * |
| 48 | html_extract_open_optionscxx . . $ html_extract_open_options(935e2583f8354665).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 49 | grn_objcxx . . $ grn_obj# *extractor, |
| 50 | grn_objcxx . . $ grn_obj# *raw_options, |
| 51 | void *user_data) |
| 52 | { |
| 53 | const char *tag = "[extractor][html]"; |
| 54 | html_extract_optionscxx . . $ html_extract_options# *options = GRN_CALLOCcxx . . $ `lib/grn_alloc.h:42:9`!(sizeof(html_extract_options)); |
| 55 | if (!options) { |
| 56 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_NO_MEMORY_AVAILABLE, |
| 57 | "%s failed to allocate memory for options", |
| 58 | tag); |
| 59 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 60 | } |
| 61 | |
| 62 | html_extract_options_initcxx . . $ html_extract_options_init(e434e7a37e901d74).(ctx, options); |
| 63 | |
| 64 | GRN_OPTION_VALUES_EACH_BEGINcxx . . $ `include/groonga/option.h:29:9`!(ctx, raw_options, i, name, name_length) |
| 65 | { |
| 66 | grn_raw_stringcxx . . $ grn_raw_string# name_raw; |
| 67 | name_raw.valuecxx . . $ $anonymous_type_7f733dd816802915_0#value. = name; |
| 68 | name_raw.lengthcxx . . $ $anonymous_type_7f733dd816802915_0#length. = name_length; |
| 69 | |
| 70 | if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(name_raw, "remove_tag")) { |
| 71 | options->remove_tagcxx . . $ $anonymous_type_b8799d91820bc7da_0#remove_tag. = |
| 72 | grn_vector_get_element_boolcxx . . $ grn_vector_get_element_bool(c757f44c94d2a098).(ctx, raw_options, i, options->remove_tagcxx . . $ $anonymous_type_b8799d91820bc7da_0#remove_tag.); |
| 73 | } else if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(name_raw, |
| 74 | "expand_character_reference")) { |
| 75 | options->expand_character_referencecxx . . $ $anonymous_type_b8799d91820bc7da_0#expand_character_reference. = |
| 76 | grn_vector_get_element_boolcxx . . $ grn_vector_get_element_bool(c757f44c94d2a098).(ctx, |
| 77 | raw_options, |
| 78 | i, |
| 79 | options->expand_character_referencecxx . . $ $anonymous_type_b8799d91820bc7da_0#expand_character_reference.); |
| 80 | } |
| 81 | } |
| 82 | GRN_OPTION_VALUES_EACH_ENDcxx . . $ `include/groonga/option.h:55:9`!(); |
| 83 | |
| 84 | return options; |
| 85 | } |
| 86 | |
| 87 | static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 88 | html_expand_numeric_char_refcxx . . $ html_expand_numeric_char_ref(3e95c2896e41ada).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_objcxx . . $ grn_obj# *buffer, uint32_tcxx . . $ uint32_t# code_point) |
| 89 | { |
| 90 | /* Special code points. |
| 91 | * See also: |
| 92 | * https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state |
| 93 | */ |
| 94 | switch (code_point) { |
| 95 | case 0x80: |
| 96 | code_point = 0x20AC; |
| 97 | break; |
| 98 | case 0x82: |
| 99 | code_point = 0x201A; |
| 100 | break; |
| 101 | case 0x83: |
| 102 | code_point = 0x0192; |
| 103 | break; |
| 104 | case 0x84: |
| 105 | code_point = 0x201E; |
| 106 | break; |
| 107 | case 0x85: |
| 108 | code_point = 0x2026; |
| 109 | break; |
| 110 | case 0x86: |
| 111 | code_point = 0x2020; |
| 112 | break; |
| 113 | case 0x87: |
| 114 | code_point = 0x2021; |
| 115 | break; |
| 116 | case 0x88: |
| 117 | code_point = 0x02C6; |
| 118 | break; |
| 119 | case 0x89: |
| 120 | code_point = 0x2030; |
| 121 | break; |
| 122 | case 0x8A: |
| 123 | code_point = 0x0160; |
| 124 | break; |
| 125 | case 0x8B: |
| 126 | code_point = 0x2039; |
| 127 | break; |
| 128 | case 0x8C: |
| 129 | code_point = 0x0152; |
| 130 | break; |
| 131 | case 0x8E: |
| 132 | code_point = 0x017D; |
| 133 | break; |
| 134 | case 0x91: |
| 135 | code_point = 0x2018; |
| 136 | break; |
| 137 | case 0x92: |
| 138 | code_point = 0x2019; |
| 139 | break; |
| 140 | case 0x93: |
| 141 | code_point = 0x201C; |
| 142 | break; |
| 143 | case 0x94: |
| 144 | code_point = 0x201D; |
| 145 | break; |
| 146 | case 0x95: |
| 147 | code_point = 0x2022; |
| 148 | break; |
| 149 | case 0x96: |
| 150 | code_point = 0x2013; |
| 151 | break; |
| 152 | case 0x97: |
| 153 | code_point = 0x2014; |
| 154 | break; |
| 155 | case 0x98: |
| 156 | code_point = 0x02DC; |
| 157 | break; |
| 158 | case 0x99: |
| 159 | code_point = 0x2122; |
| 160 | break; |
| 161 | case 0x9A: |
| 162 | code_point = 0x0161; |
| 163 | break; |
| 164 | case 0x9B: |
| 165 | code_point = 0x203A; |
| 166 | break; |
| 167 | case 0x9C: |
| 168 | code_point = 0x0153; |
| 169 | break; |
| 170 | case 0x9E: |
| 171 | code_point = 0x017E; |
| 172 | break; |
| 173 | case 0x9F: |
| 174 | code_point = 0x0178; |
| 175 | break; |
| 176 | default: |
| 177 | break; |
| 178 | } |
| 179 | grn_text_code_pointcxx . . $ grn_text_code_point(aedbc3eaefbe393f).(ctx, buffer, code_point); |
| 180 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 181 | } |
| 182 | |
| 183 | #include "normalizer_html_expand_named_char_ref.c"cxx . . $ `<file>/lib/normalizer_html_expand_named_char_ref.c`/ |
| 184 | |
| 185 | typedef enumcxx . . $ $anonymous_type_b8799d91820bc7da_1# { |
| 186 | HTML_STATE_TEXTcxx . . $ HTML_STATE_TEXT., |
| 187 | HTML_STATE_IN_TAGcxx . . $ HTML_STATE_IN_TAG., |
| 188 | HTML_STATE_IN_CHAR_REFcxx . . $ HTML_STATE_IN_CHAR_REF., |
| 189 | } html_statecxx . . $ html_state#; |
| 190 | |
| 191 | static grn_objcxx . . $ grn_obj# * |
| 192 | html_extractcxx . . $ html_extract(d93ab684c9722620).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_objcxx . . $ grn_obj# *extractor, grn_extract_datacxx . . $ grn_extract_data# *data) |
| 193 | { |
| 194 | const char *tag = "[extractor][html]"; |
| 195 | |
| 196 | grn_objcxx . . $ grn_obj# *value = grn_extract_data_get_valuecxx . . $ grn_extract_data_get_value(2462385ca73b1fa3).(ctx, data); |
| 197 | if (!grn_type_id_is_text_familycxx . . $ grn_type_id_is_text_family(a2a496425acc5b40).(ctx, value->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain.)) { |
| 198 | /* Do nothing */ |
| 199 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 200 | } |
| 201 | |
| 202 | grn_objcxx . . $ grn_obj# *table = grn_extract_data_get_tablecxx . . $ grn_extract_data_get_table(2462385ca73b1fa3).(ctx, data); |
| 203 | if (!table) { |
| 204 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "%s related table information is missing", tag); |
| 205 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 206 | } |
| 207 | |
| 208 | uint32_tcxx . . $ uint32_t# i = grn_extract_data_get_indexcxx . . $ grn_extract_data_get_index(fef2bf04b7ea1182).(ctx, data); |
| 209 | html_extract_optionscxx . . $ html_extract_options# *options = |
| 210 | grn_table_cache_extractors_optionscxx . . $ grn_table_cache_extractors_options(98363f246506be11).(ctx, |
| 211 | table, |
| 212 | i, |
| 213 | html_extract_open_optionscxx . . $ html_extract_open_options(935e2583f8354665)., |
| 214 | html_extract_close_optionscxx . . $ html_extract_close_options(b6b6153f622d9caa)., |
| 215 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 216 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 217 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 218 | } |
| 219 | |
| 220 | grn_objcxx . . $ grn_obj# *output = grn_obj_opencxx . . $ grn_obj_open(688b82f5c18b4cf9).(ctx, GRN_BULKcxx . . $ `include/groonga/groonga.h:868:9`!, 0, GRN_DB_TEXTcxx . . $ GRN_DB_TEXT.); |
| 221 | const char *current = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(value); |
| 222 | const char *end = current + GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(value); |
| 223 | |
| 224 | html_statecxx . . $ html_state# state = HTML_STATE_TEXTcxx . . $ HTML_STATE_TEXT.; |
| 225 | const char *start_tag = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 226 | const char *start_char_ref = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 227 | |
| 228 | int char_length = 0; |
| 229 | for (; current < end; current += char_length) { |
| 230 | char_length = grn_charlencxx . . $ grn_charlen(d229e8bf7c87f0f0).(ctx, current, end); |
| 231 | if (char_length == 0) { |
| 232 | /* Set error? */ |
| 233 | break; |
| 234 | } |
| 235 | |
| 236 | if (char_length == 1) { |
| 237 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! processed = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 238 | switch (state) { |
| 239 | case HTML_STATE_IN_TAGcxx . . $ HTML_STATE_IN_TAG.: |
| 240 | if (*current == '>') { |
| 241 | if (!options->remove_tagcxx . . $ $anonymous_type_b8799d91820bc7da_0#remove_tag.) { |
| 242 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, start_tag, (current - start_tag + 1)); |
| 243 | } |
| 244 | state = HTML_STATE_TEXTcxx . . $ HTML_STATE_TEXT.; |
| 245 | start_tag = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 246 | processed = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 247 | } |
| 248 | break; |
| 249 | case HTML_STATE_IN_CHAR_REFcxx . . $ HTML_STATE_IN_CHAR_REF.: |
| 250 | if (*current == ';') { |
| 251 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! valid = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 252 | if (start_char_ref[1] == '#') { |
| 253 | long code_point = -1; |
| 254 | if (start_char_ref[2] == 'x' || start_char_ref[2] == 'X') { |
| 255 | /* "&#xH...;" */ |
| 256 | const char *code_point_end = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 257 | code_point = |
| 258 | grn_htouicxx . . $ grn_htoui(2da3fe788a18ce64).(start_char_ref + 3, current, &code_point_end); |
| 259 | if (code_point_end != current) { |
| 260 | code_point = -1; |
| 261 | } |
| 262 | } else { |
| 263 | /* "&#D...;" */ |
| 264 | const char *code_point_end = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 265 | code_point = |
| 266 | grn_atollcxx . . $ grn_atoll(e3438c906dd00acd).(start_char_ref + 2, current, &code_point_end); |
| 267 | if (code_point_end != current) { |
| 268 | code_point = -1; |
| 269 | } |
| 270 | } |
| 271 | if (code_point >= 0) { |
| 272 | valid = |
| 273 | html_expand_numeric_char_refcxx . . $ html_expand_numeric_char_ref(3e95c2896e41ada).(ctx, output, (uint32_tcxx . . $ uint32_t#)code_point); |
| 274 | } |
| 275 | } else { |
| 276 | /* "&NAME;" */ |
| 277 | valid = html_expand_named_char_refcxx . . $ html_expand_named_char_ref(2bd266d31ec702fe).( |
| 278 | ctx, |
| 279 | output, |
| 280 | start_char_ref + 1, |
| 281 | (size_t)(current - start_char_ref - 1)); |
| 282 | } |
| 283 | if (valid) { |
| 284 | state = HTML_STATE_TEXTcxx . . $ HTML_STATE_TEXT.; |
| 285 | start_char_ref = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 286 | processed = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 287 | } |
| 288 | } else if (((current - start_char_ref) == 1 && *current == '#') || |
| 289 | ('A' <= *current && *current <= 'Z') || |
| 290 | ('a' <= *current && *current <= 'z') || |
| 291 | ('0' <= *current && *current <= '9')) { |
| 292 | processed = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 293 | } |
| 294 | break; |
| 295 | default: |
| 296 | if (options->remove_tagcxx . . $ $anonymous_type_b8799d91820bc7da_0#remove_tag. && *current == '<') { |
| 297 | state = HTML_STATE_IN_TAGcxx . . $ HTML_STATE_IN_TAG.; |
| 298 | start_tag = current; |
| 299 | processed = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 300 | } else if (options->expand_character_referencecxx . . $ $anonymous_type_b8799d91820bc7da_0#expand_character_reference. && *current == '&') { |
| 301 | state = HTML_STATE_IN_CHAR_REFcxx . . $ HTML_STATE_IN_CHAR_REF.; |
| 302 | start_char_ref = current; |
| 303 | processed = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 304 | } |
| 305 | break; |
| 306 | } |
| 307 | if (processed) { |
| 308 | continue; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | switch (state) { |
| 313 | case HTML_STATE_IN_TAGcxx . . $ HTML_STATE_IN_TAG.: |
| 314 | break; |
| 315 | case HTML_STATE_IN_CHAR_REFcxx . . $ HTML_STATE_IN_CHAR_REF.: |
| 316 | { |
| 317 | /* "&...(any multibyte character)...;" case: Write it as-is. */ |
| 318 | size_t length = |
| 319 | (size_t)(current - start_char_ref) + (size_t)char_length; |
| 320 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, start_char_ref, length); |
| 321 | state = HTML_STATE_TEXTcxx . . $ HTML_STATE_TEXT.; |
| 322 | start_char_ref = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 323 | } |
| 324 | break; |
| 325 | default: |
| 326 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, current, (size_t)char_length); |
| 327 | break; |
| 328 | } |
| 329 | } |
| 330 | if (state == HTML_STATE_IN_TAGcxx . . $ HTML_STATE_IN_TAG.) { |
| 331 | if (!options->remove_tagcxx . . $ $anonymous_type_b8799d91820bc7da_0#remove_tag.) { |
| 332 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, start_tag, (size_t)(current - start_tag)); |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | return output; |
| 337 | } |
| 338 | |
| 339 | typedef structcxx . . $ $anonymous_type_b8799d91820bc7da_2# { |
| 340 | grn_json_pathcxx . . $ grn_json_path# *pathcxx . . $ $anonymous_type_b8799d91820bc7da_2#path.; |
| 341 | } json_extract_optionscxx . . $ json_extract_options#; |
| 342 | |
| 343 | static void |
| 344 | json_extract_options_initcxx . . $ json_extract_options_init(8eb1e4992117794a).(grn_ctxcxx . . $ grn_ctx# *ctx, json_extract_optionscxx . . $ json_extract_options# *options) |
| 345 | { |
| 346 | options->pathcxx . . $ $anonymous_type_b8799d91820bc7da_2#path. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 347 | } |
| 348 | |
| 349 | static void |
| 350 | json_extract_options_fincxx . . $ json_extract_options_fin(8eb1e4992117794a).(grn_ctxcxx . . $ grn_ctx# *ctx, json_extract_optionscxx . . $ json_extract_options# *options) |
| 351 | { |
| 352 | if (options->pathcxx . . $ $anonymous_type_b8799d91820bc7da_2#path.) { |
| 353 | grn_json_path_closecxx . . $ grn_json_path_close(21c1c787af2cfc3).(ctx, options->pathcxx . . $ $anonymous_type_b8799d91820bc7da_2#path.); |
| 354 | options->pathcxx . . $ $anonymous_type_b8799d91820bc7da_2#path. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | static void |
| 359 | json_extract_close_optionscxx . . $ json_extract_close_options(b6b6153f622d9caa).(grn_ctxcxx . . $ grn_ctx# *ctx, void *data) |
| 360 | { |
| 361 | json_extract_optionscxx . . $ json_extract_options# *options = data; |
| 362 | json_extract_options_fincxx . . $ json_extract_options_fin(8eb1e4992117794a).(ctx, options); |
| 363 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(options); |
| 364 | } |
| 365 | |
| 366 | static void * |
| 367 | json_extract_open_optionscxx . . $ json_extract_open_options(935e2583f8354665).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 368 | grn_objcxx . . $ grn_obj# *extractor, |
| 369 | grn_objcxx . . $ grn_obj# *raw_options, |
| 370 | void *user_data) |
| 371 | { |
| 372 | const char *tag = "[extractor][json]"; |
| 373 | json_extract_optionscxx . . $ json_extract_options# *options = GRN_CALLOCcxx . . $ `lib/grn_alloc.h:42:9`!(sizeof(json_extract_options)); |
| 374 | if (!options) { |
| 375 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_NO_MEMORY_AVAILABLE, |
| 376 | "%s failed to allocate memory for options", |
| 377 | tag); |
| 378 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 379 | } |
| 380 | |
| 381 | json_extract_options_initcxx . . $ json_extract_options_init(8eb1e4992117794a).(ctx, options); |
| 382 | |
| 383 | GRN_OPTION_VALUES_EACH_BEGINcxx . . $ `include/groonga/option.h:29:9`!(ctx, raw_options, i, name, name_length) |
| 384 | { |
| 385 | grn_raw_stringcxx . . $ grn_raw_string# name_raw; |
| 386 | name_raw.valuecxx . . $ $anonymous_type_7f733dd816802915_0#value. = name; |
| 387 | name_raw.lengthcxx . . $ $anonymous_type_7f733dd816802915_0#length. = name_length; |
| 388 | |
| 389 | if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(name_raw, "path")) { |
| 390 | const char *path; |
| 391 | unsigned int path_length; |
| 392 | grn_idcxx . . $ grn_id# domain; |
| 393 | |
| 394 | path_length = |
| 395 | grn_vector_get_elementcxx . . $ grn_vector_get_element(744613554bd9830c).(ctx, raw_options, i, &path, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, &domain); |
| 396 | if (grn_type_id_is_text_familycxx . . $ grn_type_id_is_text_family(a2a496425acc5b40).(ctx, domain) && path_length > 0) { |
| 397 | options->pathcxx . . $ $anonymous_type_b8799d91820bc7da_2#path. = grn_json_path_opencxx . . $ grn_json_path_open(5293b6d555fcc0ac).(ctx, path, path_length); |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | GRN_OPTION_VALUES_EACH_ENDcxx . . $ `include/groonga/option.h:55:9`!(); |
| 402 | |
| 403 | if (!options->pathcxx . . $ $anonymous_type_b8799d91820bc7da_2#path.) { |
| 404 | if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 405 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "%s path is missing", tag); |
| 406 | } |
| 407 | json_extract_close_optionscxx . . $ json_extract_close_options(b6b6153f622d9caa).(ctx, options); |
| 408 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 409 | } |
| 410 | |
| 411 | return options; |
| 412 | } |
| 413 | |
| 414 | static grn_objcxx . . $ grn_obj# * |
| 415 | json_extractcxx . . $ json_extract(d93ab684c9722620).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_objcxx . . $ grn_obj# *extractor, grn_extract_datacxx . . $ grn_extract_data# *data) |
| 416 | { |
| 417 | const char *tag = "[extractor][json]"; |
| 418 | |
| 419 | grn_objcxx . . $ grn_obj# *value = grn_extract_data_get_valuecxx . . $ grn_extract_data_get_value(2462385ca73b1fa3).(ctx, data); |
| 420 | grn_objcxx . . $ grn_obj# *json; |
| 421 | grn_objcxx . . $ grn_obj# json_buffer; |
| 422 | GRN_JSON_INITcxx . . $ `include/groonga/groonga.h:2820:9`!(&json_buffer, 0); |
| 423 | if (value->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain. == GRN_DB_JSONcxx . . $ GRN_DB_JSON.) { |
| 424 | json = value; |
| 425 | } else { |
| 426 | grn_rccxx . . $ grn_rc# rc = grn_obj_castcxx . . $ grn_obj_cast(a6fd93da1614eccd).(ctx, value, &json_buffer, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!); |
| 427 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 428 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &json_buffer); |
| 429 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 430 | } |
| 431 | json = &json_buffer; |
| 432 | } |
| 433 | |
| 434 | grn_objcxx . . $ grn_obj# *table = grn_extract_data_get_tablecxx . . $ grn_extract_data_get_table(2462385ca73b1fa3).(ctx, data); |
| 435 | if (!table) { |
| 436 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "%s related table information is missing", tag); |
| 437 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &json_buffer); |
| 438 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 439 | } |
| 440 | |
| 441 | uint32_tcxx . . $ uint32_t# i = grn_extract_data_get_indexcxx . . $ grn_extract_data_get_index(fef2bf04b7ea1182).(ctx, data); |
| 442 | json_extract_optionscxx . . $ json_extract_options# *options = |
| 443 | grn_table_cache_extractors_optionscxx . . $ grn_table_cache_extractors_options(98363f246506be11).(ctx, |
| 444 | table, |
| 445 | i, |
| 446 | json_extract_open_optionscxx . . $ json_extract_open_options(935e2583f8354665)., |
| 447 | json_extract_close_optionscxx . . $ json_extract_close_options(b6b6153f622d9caa)., |
| 448 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 449 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 450 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &json_buffer); |
| 451 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 452 | } |
| 453 | |
| 454 | grn_objcxx . . $ grn_obj# *output = grn_obj_opencxx . . $ grn_obj_open(688b82f5c18b4cf9).(ctx, GRN_VECTORcxx . . $ `include/groonga/groonga.h:877:9`!, 0, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 455 | grn_rccxx . . $ grn_rc# rc = grn_json_extractcxx . . $ grn_json_extract(7d006019447c46b0).(ctx, json, options->pathcxx . . $ $anonymous_type_b8799d91820bc7da_2#path., output); |
| 456 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 457 | grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, output); |
| 458 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &json_buffer); |
| 459 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 460 | } |
| 461 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &json_buffer); |
| 462 | return output; |
| 463 | } |
| 464 | |
| 465 | grn_rccxx . . $ grn_rc# |
| 466 | grn_db_init_builtin_extractorscxx . . $ grn_db_init_builtin_extractors(2b4fa601bf4f1e5b).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 467 | { |
| 468 | { |
| 469 | grn_objcxx . . $ grn_obj# *extractor; |
| 470 | extractor = grn_extractor_createcxx . . $ grn_extractor_create(70fde0087014f9ea).(ctx, "ExtractorHTML", -1); |
| 471 | grn_extractor_set_extract_funccxx . . $ grn_extractor_set_extract_func(46a734684d5d447b).(ctx, extractor, html_extractcxx . . $ html_extract(d93ab684c9722620).); |
| 472 | } |
| 473 | |
| 474 | { |
| 475 | grn_objcxx . . $ grn_obj# *extractor; |
| 476 | extractor = grn_extractor_createcxx . . $ grn_extractor_create(70fde0087014f9ea).(ctx, "ExtractorJSON", -1); |
| 477 | grn_extractor_set_extract_funccxx . . $ grn_extractor_set_extract_func(46a734684d5d447b).(ctx, extractor, json_extractcxx . . $ json_extract(d93ab684c9722620).); |
| 478 | } |
| 479 | |
| 480 | return GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 481 | } |