| 1 | /* |
| 2 | Copyright (C) 2016 Brazil |
| 3 | Copyright (C) 2022 Sutou Kouhei <[email protected]> |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 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_config_getcxx . . $ command_config_get(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 | grn_objcxx . . $ grn_obj# *key; |
| 31 | const char *value; |
| 32 | uint32_tcxx . . $ uint32_t# value_size; |
| 33 | |
| 34 | key = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx, user_data, "key", -1); |
| 35 | if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(key) == 0) { |
| 36 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, GRN_INVALID_ARGUMENT, |
| 37 | "[config][get] key is missing"); |
| 38 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 39 | } |
| 40 | |
| 41 | grn_config_getcxx . . $ grn_config_get(55f0c7275dd3feda).(ctx, |
| 42 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(key), (int32_tcxx . . $ int32_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(key), |
| 43 | &value, &value_size); |
| 44 | if (ctx->rccxx . . $ _grn_ctx#rc.) { |
| 45 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 46 | } |
| 47 | |
| 48 | grn_ctx_output_strcxx . . $ grn_ctx_output_str(bd29ebb5071afc4b).(ctx, value, value_size); |
| 49 | |
| 50 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 51 | } |
| 52 | |
| 53 | static grn_objcxx . . $ grn_obj# * |
| 54 | command_config_setcxx . . $ command_config_set(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 55 | int nargs, |
| 56 | grn_objcxx . . $ grn_obj# **args, |
| 57 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 58 | { |
| 59 | grn_objcxx . . $ grn_obj# *key; |
| 60 | grn_objcxx . . $ grn_obj# *value; |
| 61 | |
| 62 | key = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx, user_data, "key", -1); |
| 63 | if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(key) == 0) { |
| 64 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, GRN_INVALID_ARGUMENT, |
| 65 | "[config][set] key is missing"); |
| 66 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 67 | } |
| 68 | |
| 69 | value = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx, user_data, "value", -1); |
| 70 | grn_config_setcxx . . $ grn_config_set(2afa6b044548fd83).(ctx, |
| 71 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(key), (int32_tcxx . . $ int32_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(key), |
| 72 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(value), (int32_tcxx . . $ int32_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(value)); |
| 73 | |
| 74 | grn_ctx_output_boolcxx . . $ grn_ctx_output_bool(1112b62984b2cd7f).(ctx, ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.); |
| 75 | |
| 76 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 77 | } |
| 78 | |
| 79 | static grn_objcxx . . $ grn_obj# * |
| 80 | command_config_deletecxx . . $ command_config_delete(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 81 | int nargs, |
| 82 | grn_objcxx . . $ grn_obj# **args, |
| 83 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 84 | { |
| 85 | grn_objcxx . . $ grn_obj# *key; |
| 86 | |
| 87 | key = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx, user_data, "key", -1); |
| 88 | if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(key) == 0) { |
| 89 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, GRN_INVALID_ARGUMENT, |
| 90 | "[config][delete] key is missing"); |
| 91 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 92 | } |
| 93 | |
| 94 | grn_config_deletecxx . . $ grn_config_delete(7bd03b5ef0400a0e).(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(key), (int32_tcxx . . $ int32_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(key)); |
| 95 | |
| 96 | grn_ctx_output_boolcxx . . $ grn_ctx_output_bool(1112b62984b2cd7f).(ctx, ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.); |
| 97 | |
| 98 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 99 | } |
| 100 | |
| 101 | void |
| 102 | grn_proc_init_config_getcxx . . $ grn_proc_init_config_get(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 103 | { |
| 104 | grn_expr_varcxx . . $ grn_expr_var# vars[1]; |
| 105 | |
| 106 | grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "key", -1); |
| 107 | grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx, |
| 108 | "config_get", -1, |
| 109 | command_config_getcxx . . $ command_config_get(fd082858389c8bb0)., |
| 110 | 1, |
| 111 | vars); |
| 112 | } |
| 113 | |
| 114 | void |
| 115 | grn_proc_init_config_setcxx . . $ grn_proc_init_config_set(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 116 | { |
| 117 | grn_expr_varcxx . . $ grn_expr_var# vars[2]; |
| 118 | |
| 119 | grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "key", -1); |
| 120 | grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[1]), "value", -1); |
| 121 | grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx, |
| 122 | "config_set", -1, |
| 123 | command_config_setcxx . . $ command_config_set(fd082858389c8bb0)., |
| 124 | 2, |
| 125 | vars); |
| 126 | } |
| 127 | |
| 128 | void |
| 129 | grn_proc_init_config_deletecxx . . $ grn_proc_init_config_delete(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 130 | { |
| 131 | grn_expr_varcxx . . $ grn_expr_var# vars[1]; |
| 132 | |
| 133 | grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "key", -1); |
| 134 | grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx, |
| 135 | "config_delete", -1, |
| 136 | command_config_deletecxx . . $ command_config_delete(fd082858389c8bb0)., |
| 137 | 1, |
| 138 | vars); |
| 139 | } |