| 1 | /* |
| 2 | Copyright (C) 2025 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_db.h"cxx . . $ `<file>/lib/grn_db.h`/ |
| 20 | #include "../grn_proc.h"cxx . . $ `<file>/lib/grn_proc.h`/ |
| 21 | |
| 22 | #include <groonga/plugin.h>cxx . . $ `<file>/include/groonga/plugin.h`/ |
| 23 | |
| 24 | static grn_objcxx . . $ grn_obj# * |
| 25 | command_command_listcxx . . $ command_command_list(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 26 | int nargs, |
| 27 | grn_objcxx . . $ grn_obj# **args, |
| 28 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 29 | { |
| 30 | const boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_close_opened_object_mode = (grn_thread_get_limitcxx . . $ grn_thread_get_limit(db52760e79bf9054).() == 1); |
| 31 | grn_objcxx . . $ grn_obj# command_ids; |
| 32 | |
| 33 | GRN_RECORD_INITcxx . . $ `include/groonga/groonga.h:2868:9`!(&command_ids, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 34 | GRN_DB_EACH_BEGIN_BY_KEYcxx . . $ `include/groonga/db.h:142:9`!(ctx, cursor, id) |
| 35 | { |
| 36 | if (id == GRN_DB_MECABcxx . . $ GRN_DB_MECAB.) { |
| 37 | /* TokenMecab must not be a command. TokenMecab may exist as a |
| 38 | * dummy object for historical reason. */ |
| 39 | continue; |
| 40 | } |
| 41 | |
| 42 | void *name; |
| 43 | int name_size = grn_table_cursor_get_keycxx . . $ grn_table_cursor_get_key(7d620ebe94cee13a).(ctx, cursor, &name); |
| 44 | if (grn_obj_name_is_columncxx . . $ grn_obj_name_is_column(da3161f0ad1ba10a).(ctx, name, name_size)) { |
| 45 | continue; |
| 46 | } |
| 47 | |
| 48 | if (is_close_opened_object_mode) { |
| 49 | grn_ctx_push_temporary_open_spacecxx . . $ grn_ctx_push_temporary_open_space(2b4fa601bf4f1e5b).(ctx); |
| 50 | } |
| 51 | |
| 52 | grn_objcxx . . $ grn_obj# *object = grn_ctx_atcxx . . $ grn_ctx_at(ac4544c8400954c9).(ctx, id); |
| 53 | if (object) { |
| 54 | if (grn_obj_is_command_proccxx . . $ grn_obj_is_command_proc(a5760e5c319a06ee).(ctx, object)) { |
| 55 | GRN_RECORD_PUTcxx . . $ `include/groonga/groonga.h:3213:9`!(ctx, &command_ids, id); |
| 56 | } |
| 57 | } else { |
| 58 | GRN_PLUGIN_CLEAR_ERRORcxx . . $ `include/groonga/plugin.h:148:9`!(ctx); |
| 59 | } |
| 60 | |
| 61 | if (is_close_opened_object_mode) { |
| 62 | grn_ctx_pop_temporary_open_spacecxx . . $ grn_ctx_pop_temporary_open_space(2b4fa601bf4f1e5b).(ctx); |
| 63 | } |
| 64 | } |
| 65 | GRN_DB_EACH_ENDcxx . . $ `include/groonga/db.h:148:9`!(ctx, cursor); |
| 66 | |
| 67 | size_t n = GRN_RECORD_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3264:9`!(&command_ids); |
| 68 | grn_ctx_output_map_opencxx . . $ grn_ctx_output_map_open(f0f392d632556531).(ctx, "commands", (int)n); |
| 69 | for (size_t i = 0; i < n; i++) { |
| 70 | if (is_close_opened_object_mode) { |
| 71 | grn_ctx_push_temporary_open_spacecxx . . $ grn_ctx_push_temporary_open_space(2b4fa601bf4f1e5b).(ctx); |
| 72 | } |
| 73 | |
| 74 | grn_idcxx . . $ grn_id# command_id = GRN_RECORD_VALUE_ATcxx . . $ `include/groonga/groonga.h:3148:9`!(&command_ids, i); |
| 75 | grn_objcxx . . $ grn_obj# *command = grn_ctx_atcxx . . $ grn_ctx_at(ac4544c8400954c9).(ctx, command_id); |
| 76 | |
| 77 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(command); |
| 78 | |
| 79 | grn_ctx_output_strcxx . . $ grn_ctx_output_str(bd29ebb5071afc4b).(ctx, name, name_size); |
| 80 | |
| 81 | grn_ctx_output_map_opencxx . . $ grn_ctx_output_map_open(f0f392d632556531).(ctx, "command", 3); |
| 82 | |
| 83 | grn_ctx_output_cstrcxx . . $ grn_ctx_output_cstr(777524e3d10dd7b4).(ctx, "id"); |
| 84 | grn_ctx_output_uint32cxx . . $ grn_ctx_output_uint32(969b9cdb234920c4).(ctx, command_id); |
| 85 | |
| 86 | grn_ctx_output_cstrcxx . . $ grn_ctx_output_cstr(777524e3d10dd7b4).(ctx, "name"); |
| 87 | grn_ctx_output_strcxx . . $ grn_ctx_output_str(bd29ebb5071afc4b).(ctx, name, name_size); |
| 88 | |
| 89 | grn_ctx_output_cstrcxx . . $ grn_ctx_output_cstr(777524e3d10dd7b4).(ctx, "arguments"); |
| 90 | { |
| 91 | unsigned int n_vars; |
| 92 | grn_hashcxx . . $ grn_hash# *vars = grn_expr_get_varscxx . . $ grn_expr_get_vars(e36cbecf8e2560ff).(ctx, command, &n_vars); |
| 93 | grn_ctx_output_array_opencxx . . $ grn_ctx_output_array_open(f0f392d632556531).(ctx, "arguments", n_vars); |
| 94 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, vars, cursor, id) |
| 95 | { |
| 96 | grn_ctx_output_map_opencxx . . $ grn_ctx_output_map_open(f0f392d632556531).(ctx, "argument", 1); |
| 97 | { |
| 98 | void *key; |
| 99 | int key_size = grn_hash_cursor_get_keycxx . . $ grn_hash_cursor_get_key(248c0d78df691c42).(ctx, cursor, &key); |
| 100 | grn_ctx_output_cstrcxx . . $ grn_ctx_output_cstr(777524e3d10dd7b4).(ctx, "name"); |
| 101 | grn_ctx_output_strcxx . . $ grn_ctx_output_str(bd29ebb5071afc4b).(ctx, key, key_size); |
| 102 | |
| 103 | /* TODO: Output more information. */ |
| 104 | } |
| 105 | grn_ctx_output_map_closecxx . . $ grn_ctx_output_map_close(b578cd6e53d5fe91).(ctx); |
| 106 | } |
| 107 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 108 | grn_ctx_output_array_closecxx . . $ grn_ctx_output_array_close(b578cd6e53d5fe91).(ctx); |
| 109 | } |
| 110 | |
| 111 | /* TODO: Output more information. */ |
| 112 | |
| 113 | grn_ctx_output_map_closecxx . . $ grn_ctx_output_map_close(b578cd6e53d5fe91).(ctx); |
| 114 | |
| 115 | if (is_close_opened_object_mode) { |
| 116 | grn_ctx_pop_temporary_open_spacecxx . . $ grn_ctx_pop_temporary_open_space(2b4fa601bf4f1e5b).(ctx); |
| 117 | } |
| 118 | } |
| 119 | grn_ctx_output_map_closecxx . . $ grn_ctx_output_map_close(b578cd6e53d5fe91).(ctx); |
| 120 | |
| 121 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &command_ids); |
| 122 | |
| 123 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 124 | } |
| 125 | |
| 126 | void |
| 127 | grn_proc_init_command_listcxx . . $ grn_proc_init_command_list(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 128 | { |
| 129 | grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx, |
| 130 | "command_list", |
| 131 | -1, |
| 132 | command_command_listcxx . . $ command_command_list(fd082858389c8bb0)., |
| 133 | 0, |
| 134 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 135 | } |