| 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 | #ifdef GRN_EMBEDDED |
| 20 | # define GRN_PLUGIN_FUNCTION_TAG functions_binary |
| 21 | #endif |
| 22 | |
| 23 | #include <groonga/plugin.h>cxx . . $ `<file>/include/groonga/plugin.h`/ |
| 24 | |
| 25 | static grn_objcxx . . $ grn_obj# * |
| 26 | func_binary_lengthcxx . . $ func_binary_length(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 27 | int n_args, |
| 28 | grn_objcxx . . $ grn_obj# **args, |
| 29 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 30 | { |
| 31 | if (n_args != 1) { |
| 32 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 33 | GRN_INVALID_ARGUMENT, |
| 34 | "binary_length(): wrong number of arguments (%d for 1)", |
| 35 | n_args); |
| 36 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 37 | } |
| 38 | |
| 39 | grn_objcxx . . $ grn_obj# *target = args[0]; |
| 40 | if (target->headercxx . . $ _grn_obj#header..typecxx . . $ _grn_obj_header#type. != GRN_BULKcxx . . $ `include/groonga/groonga.h:868:9`!) { |
| 41 | grn_objcxx . . $ grn_obj# inspected; |
| 42 | |
| 43 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 44 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, target); |
| 45 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 46 | GRN_INVALID_ARGUMENT, |
| 47 | "binary_length(): target object must be a bulk: " |
| 48 | "<%.*s>", |
| 49 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 50 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 51 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 52 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 53 | } |
| 54 | |
| 55 | size_t length = GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(target); |
| 56 | grn_objcxx . . $ grn_obj# *grn_length = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_UINT32cxx . . $ GRN_DB_UINT32., 0); |
| 57 | if (!grn_length) { |
| 58 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 59 | } |
| 60 | |
| 61 | GRN_UINT32_SETcxx . . $ `include/groonga/groonga.h:2909:9`!(ctx, grn_length, length); |
| 62 | |
| 63 | return grn_length; |
| 64 | } |
| 65 | |
| 66 | grn_rccxx . . $ grn_rc# |
| 67 | GRN_PLUGIN_INITcxx . . $ `include/groonga/plugin.h:43:9`!(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 68 | { |
| 69 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 70 | } |
| 71 | |
| 72 | grn_rccxx . . $ grn_rc# |
| 73 | GRN_PLUGIN_REGISTERcxx . . $ `include/groonga/plugin.h:44:9`!(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 74 | { |
| 75 | grn_rccxx . . $ grn_rc# rc = GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 76 | |
| 77 | grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx, |
| 78 | "binary_length", |
| 79 | -1, |
| 80 | GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION., |
| 81 | func_binary_lengthcxx . . $ func_binary_length(fd082858389c8bb0)., |
| 82 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 83 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 84 | 0, |
| 85 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 86 | |
| 87 | return rc; |
| 88 | } |
| 89 | |
| 90 | grn_rccxx . . $ grn_rc# |
| 91 | GRN_PLUGIN_FINcxx . . $ `include/groonga/plugin.h:45:9`!(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 92 | { |
| 93 | return GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 94 | } |