| 1 | /* |
| 2 | Copyright (C) 2009-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 "../grn_ctx.h"cxx . . $ `<file>/lib/grn_ctx.h`/ |
| 23 | |
| 24 | #include <groonga/plugin.h>cxx . . $ `<file>/include/groonga/plugin.h`/ |
| 25 | |
| 26 | static grn_objcxx . . $ grn_obj# * |
| 27 | command_lock_clearcxx . . $ command_lock_clear(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 28 | int nargs, |
| 29 | grn_objcxx . . $ grn_obj# **args, |
| 30 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 31 | { |
| 32 | int target_name_len; |
| 33 | grn_objcxx . . $ grn_obj# *target_name; |
| 34 | grn_objcxx . . $ grn_obj# *obj; |
| 35 | |
| 36 | target_name = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx, user_data, "target_name", -1); |
| 37 | target_name_len = (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target_name); |
| 38 | |
| 39 | if (target_name_len) { |
| 40 | obj = grn_ctx_getcxx . . $ grn_ctx_get(70fde0087014f9ea).(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target_name), target_name_len); |
| 41 | } else { |
| 42 | obj = grn_ctx_dbcxx . . $ grn_ctx_db(ddec8e3b1327ceae).(ctx); |
| 43 | } |
| 44 | |
| 45 | if (obj) { |
| 46 | grn_obj_clear_lockcxx . . $ grn_obj_clear_lock(4865d068a46d0f83).(ctx, obj); |
| 47 | } else { |
| 48 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, GRN_INVALID_ARGUMENT, |
| 49 | "[lock][clear] target object not found: <%.*s>", |
| 50 | target_name_len, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target_name)); |
| 51 | } |
| 52 | |
| 53 | grn_ctx_output_boolcxx . . $ grn_ctx_output_bool(1112b62984b2cd7f).(ctx, ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.); |
| 54 | |
| 55 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 56 | } |
| 57 | |
| 58 | void |
| 59 | grn_proc_init_clearlockcxx . . $ grn_proc_init_clearlock(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 60 | { |
| 61 | grn_expr_varcxx . . $ grn_expr_var# vars[1]; |
| 62 | |
| 63 | /* Deprecated. Use "lock_clear" instead. */ |
| 64 | grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "target_name", -1); |
| 65 | grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx, |
| 66 | "clearlock", -1, |
| 67 | command_lock_clearcxx . . $ command_lock_clear(fd082858389c8bb0)., |
| 68 | 1, |
| 69 | vars); |
| 70 | } |
| 71 | |
| 72 | void |
| 73 | grn_proc_init_lock_clearcxx . . $ grn_proc_init_lock_clear(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 74 | { |
| 75 | grn_expr_varcxx . . $ grn_expr_var# vars[1]; |
| 76 | |
| 77 | grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "target_name", -1); |
| 78 | grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx, |
| 79 | "lock_clear", -1, |
| 80 | command_lock_clearcxx . . $ command_lock_clear(fd082858389c8bb0)., |
| 81 | 1, |
| 82 | vars); |
| 83 | } |
| 84 | |
| 85 | static grn_objcxx . . $ grn_obj# * |
| 86 | command_lock_acquirecxx . . $ command_lock_acquire(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 87 | int nargs, |
| 88 | grn_objcxx . . $ grn_obj# **args, |
| 89 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 90 | { |
| 91 | int target_name_len; |
| 92 | grn_objcxx . . $ grn_obj# *target_name; |
| 93 | grn_objcxx . . $ grn_obj# *obj; |
| 94 | |
| 95 | target_name = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx, user_data, "target_name", -1); |
| 96 | target_name_len = (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target_name); |
| 97 | |
| 98 | if (target_name_len) { |
| 99 | obj = grn_ctx_getcxx . . $ grn_ctx_get(70fde0087014f9ea).(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target_name), target_name_len); |
| 100 | } else { |
| 101 | obj = grn_ctx_dbcxx . . $ grn_ctx_db(ddec8e3b1327ceae).(ctx); |
| 102 | } |
| 103 | |
| 104 | if (obj) { |
| 105 | grn_obj_lockcxx . . $ grn_obj_lock(2b9be484d9e3ae43).(ctx, obj, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!, grn_lock_timeoutcxx . . $ grn_lock_timeout.); |
| 106 | } else { |
| 107 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, GRN_INVALID_ARGUMENT, |
| 108 | "[lock][acquire] target object not found: <%.*s>", |
| 109 | target_name_len, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target_name)); |
| 110 | } |
| 111 | |
| 112 | grn_ctx_output_boolcxx . . $ grn_ctx_output_bool(1112b62984b2cd7f).(ctx, ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.); |
| 113 | |
| 114 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 115 | } |
| 116 | |
| 117 | void |
| 118 | grn_proc_init_lock_acquirecxx . . $ grn_proc_init_lock_acquire(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 119 | { |
| 120 | grn_expr_varcxx . . $ grn_expr_var# vars[1]; |
| 121 | |
| 122 | grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "target_name", -1); |
| 123 | grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx, |
| 124 | "lock_acquire", -1, |
| 125 | command_lock_acquirecxx . . $ command_lock_acquire(fd082858389c8bb0)., |
| 126 | 1, |
| 127 | vars); |
| 128 | } |
| 129 | |
| 130 | static grn_objcxx . . $ grn_obj# * |
| 131 | command_lock_releasecxx . . $ command_lock_release(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 132 | int nargs, |
| 133 | grn_objcxx . . $ grn_obj# **args, |
| 134 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 135 | { |
| 136 | int target_name_len; |
| 137 | grn_objcxx . . $ grn_obj# *target_name; |
| 138 | grn_objcxx . . $ grn_obj# *obj; |
| 139 | |
| 140 | target_name = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx, user_data, "target_name", -1); |
| 141 | target_name_len = (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target_name); |
| 142 | |
| 143 | if (target_name_len) { |
| 144 | obj = grn_ctx_getcxx . . $ grn_ctx_get(70fde0087014f9ea).(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target_name), target_name_len); |
| 145 | } else { |
| 146 | obj = grn_ctx_dbcxx . . $ grn_ctx_db(ddec8e3b1327ceae).(ctx); |
| 147 | } |
| 148 | |
| 149 | if (obj) { |
| 150 | grn_obj_unlockcxx . . $ grn_obj_unlock(aedbc3eaefbe393f).(ctx, obj, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 151 | } else { |
| 152 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, GRN_INVALID_ARGUMENT, |
| 153 | "[lock][release] target object not found: <%.*s>", |
| 154 | target_name_len, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target_name)); |
| 155 | } |
| 156 | |
| 157 | grn_ctx_output_boolcxx . . $ grn_ctx_output_bool(1112b62984b2cd7f).(ctx, ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.); |
| 158 | |
| 159 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 160 | } |
| 161 | |
| 162 | void |
| 163 | grn_proc_init_lock_releasecxx . . $ grn_proc_init_lock_release(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 164 | { |
| 165 | grn_expr_varcxx . . $ grn_expr_var# vars[1]; |
| 166 | |
| 167 | grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "target_name", -1); |
| 168 | grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx, |
| 169 | "lock_release", -1, |
| 170 | command_lock_releasecxx . . $ command_lock_release(fd082858389c8bb0)., |
| 171 | 1, |
| 172 | vars); |
| 173 | } |