Debian Codegraph @

lib/token_filter.c

raw symbols SCIP
1 /*
2 Copyright (C) 2014-2015 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 <string.h>
21
22 #include "grn.h"cxx . . $ `<file>/lib/grn.h`/
23 #include "grn_db.h"cxx . . $ `<file>/lib/grn_db.h`/
24 #include <groonga/token_filter.h>cxx . . $ `<file>/include/groonga/token_filter.h`/
25
26 grn_rccxx . . $ grn_rc#
27 grn_token_filter_registercxx . . $ grn_token_filter_register(c4b1c8befa00c1b8).(grn_ctxcxx . . $ grn_ctx# *ctx,
28 const char *plugin_name_ptr,
29 int plugin_name_length,
30 grn_token_filter_init_funccxx . . $ grn_token_filter_init_func# *init,
31 grn_token_filter_filter_funccxx . . $ grn_token_filter_filter_func# *filter,
32 grn_token_filter_fin_funccxx . . $ grn_token_filter_fin_func# *fin)
33 {
34 if (plugin_name_length == -1) {
35 plugin_name_length = (int)strlencxx . . $ strlen(751346f8406fd082).(plugin_name_ptr);
36 }
37
38 {
39 grn_objcxx . . $ grn_obj# *token_filter_object = grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx,
40 plugin_name_ptr,
41 plugin_name_length,
42 GRN_PROC_TOKEN_FILTERcxx . . $ GRN_PROC_TOKEN_FILTER.,
43 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
44 if (token_filter_object == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
45 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, GRN_TOKEN_FILTER_ERROR,
46 "[token-filter][%.*s] failed to grn_proc_create()",
47 plugin_name_length, plugin_name_ptr);
48 return ctx->rccxx . . $ _grn_ctx#rc.;
49 }
50
51 {
52 grn_proccxx . . $ grn_proc# *token_filter = (grn_proccxx . . $ grn_proc# *)token_filter_object;
53 token_filter->callbackscxx . . $ _grn_proc#callbacks..token_filtercxx . . $ _grn_proc#$anonymous_type_5#token_filter..initcxx . . $ _grn_proc#$anonymous_type_5#$anonymous_type_9#init. = init;
54 token_filter->callbackscxx . . $ _grn_proc#callbacks..token_filtercxx . . $ _grn_proc#$anonymous_type_5#token_filter..filtercxx . . $ _grn_proc#$anonymous_type_5#$anonymous_type_9#filter. = filter;
55 token_filter->callbackscxx . . $ _grn_proc#callbacks..token_filtercxx . . $ _grn_proc#$anonymous_type_5#token_filter..fincxx . . $ _grn_proc#$anonymous_type_5#$anonymous_type_9#fin. = fin;
56 }
57 }
58
59 return GRN_SUCCESScxx . . $ GRN_SUCCESS.;
60 }
61
62 grn_objcxx . . $ grn_obj# *
63 grn_token_filter_createcxx . . $ grn_token_filter_create(70fde0087014f9ea).(grn_ctxcxx . . $ grn_ctx# *ctx, const char *name, int length)
64 {
65 grn_objcxx . . $ grn_obj# *token_filter;
66
67 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
68 token_filter = grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx,
69 name,
70 length,
71 GRN_PROC_TOKEN_FILTERcxx . . $ GRN_PROC_TOKEN_FILTER.,
72 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
73 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
74 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
75 0,
76 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
77 if (!token_filter) {
78 if (length < 0) {
79 length = (int)strlencxx . . $ strlen(751346f8406fd082).(name);
80 }
81 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
82 GRN_TOKEN_FILTER_ERROR,
83 "[token-filter][create] failed to create: <%.*s>",
84 length, name);
85 }
86
87 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(token_filter);
88 }
89
90 grn_rccxx . . $ grn_rc#
91 grn_token_filter_set_init_funccxx . . $ grn_token_filter_set_init_func(abf5fc376d5b3674).(grn_ctxcxx . . $ grn_ctx# *ctx,
92 grn_objcxx . . $ grn_obj# *token_filter,
93 grn_token_filter_init_query_funccxx . . $ grn_token_filter_init_query_func# *init)
94 {
95 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
96 if (token_filter) {
97 ((grn_proccxx . . $ grn_proc# *)token_filter)->callbackscxx . . $ _grn_proc#callbacks..token_filtercxx . . $ _grn_proc#$anonymous_type_5#token_filter..init_querycxx . . $ _grn_proc#$anonymous_type_5#$anonymous_type_9#init_query. = init;
98 } else {
99 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
100 GRN_INVALID_ARGUMENT,
101 "[token-filter][init][set] token filter is NULL");
102 }
103 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
104 }
105
106 grn_rccxx . . $ grn_rc#
107 grn_token_filter_set_filter_funccxx . . $ grn_token_filter_set_filter_func(4907789ec2eda4f8).(grn_ctxcxx . . $ grn_ctx# *ctx,
108 grn_objcxx . . $ grn_obj# *token_filter,
109 grn_token_filter_filter_funccxx . . $ grn_token_filter_filter_func# *filter)
110 {
111 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
112 if (token_filter) {
113 ((grn_proccxx . . $ grn_proc# *)token_filter)->callbackscxx . . $ _grn_proc#callbacks..token_filtercxx . . $ _grn_proc#$anonymous_type_5#token_filter..filtercxx . . $ _grn_proc#$anonymous_type_5#$anonymous_type_9#filter. = filter;
114 } else {
115 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
116 GRN_INVALID_ARGUMENT,
117 "[token-filter][filter][set] token filter is NULL");
118 }
119 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
120 }
121
122 grn_rccxx . . $ grn_rc#
123 grn_token_filter_set_fin_funccxx . . $ grn_token_filter_set_fin_func(638e0fa4e92f09de).(grn_ctxcxx . . $ grn_ctx# *ctx,
124 grn_objcxx . . $ grn_obj# *token_filter,
125 grn_token_filter_fin_funccxx . . $ grn_token_filter_fin_func# *fin)
126 {
127 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
128 if (token_filter) {
129 ((grn_proccxx . . $ grn_proc# *)token_filter)->callbackscxx . . $ _grn_proc#callbacks..token_filtercxx . . $ _grn_proc#$anonymous_type_5#token_filter..fincxx . . $ _grn_proc#$anonymous_type_5#$anonymous_type_9#fin. = fin;
130 } else {
131 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
132 GRN_INVALID_ARGUMENT,
133 "[token-filter][fin][set] token filter is NULL");
134 }
135 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
136 }