grn_rc GRN_PLUGIN_REGISTER(grn_ctx *ctx) { grn_proc_create(ctx, "str_len", strlen("str_len"), GRN_PROC_FUNCTION, func_str_len, NULL, NULL, 0, NULL); return ctx->rc; }
grn_rc GRN_PLUGIN_REGISTER(grn_ctx *ctx) { grn_proc_create(ctx, "QueryExpanderTSV", strlen("QueryExpanderTSV"), GRN_PROC_FUNCTION, func_query_expander_tsv, NULL, NULL, 0, NULL); return GRN_SUCCESS; }
void grn_proc_init_fuzzy_search(grn_ctx *ctx) { grn_obj *selector_proc; selector_proc = grn_proc_create(ctx, "fuzzy_search", -1, GRN_PROC_FUNCTION, NULL, NULL, NULL, 0, NULL); grn_proc_set_selector(ctx, selector_proc, selector_fuzzy_search); }
static grn_obj * proc_define_selector(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) { uint32_t nvars; grn_expr_var *vars; grn_obj *outbuf = args[0]; grn_proc_get_info(ctx, user_data, &vars, &nvars, NULL); if (grn_proc_create(ctx, GRN_TEXT_VALUE(&vars[0].value), GRN_TEXT_LEN(&vars[0].value), NULL, proc_select, NULL, NULL, nvars - 1, vars + 1)) { GRN_TEXT_PUT(ctx, outbuf, GRN_TEXT_VALUE(&vars[0].value), GRN_TEXT_LEN(&vars[0].value)); } return outbuf; }
grn_rc GRN_PLUGIN_REGISTER(grn_ctx *ctx) { grn_rc rc = GRN_SUCCESS; grn_proc_create(ctx, "time_classify_second", -1, GRN_PROC_FUNCTION, func_time_classify_second, NULL, NULL, 0, NULL); grn_proc_create(ctx, "time_classify_minute", -1, GRN_PROC_FUNCTION, func_time_classify_minute, NULL, NULL, 0, NULL); grn_proc_create(ctx, "time_classify_hour", -1, GRN_PROC_FUNCTION, func_time_classify_hour, NULL, NULL, 0, NULL); grn_proc_create(ctx, "time_classify_day", -1, GRN_PROC_FUNCTION, func_time_classify_day, NULL, NULL, 0, NULL); grn_proc_create(ctx, "time_classify_week", -1, GRN_PROC_FUNCTION, func_time_classify_week, NULL, NULL, 0, NULL); grn_proc_create(ctx, "time_classify_month", -1, GRN_PROC_FUNCTION, func_time_classify_month, NULL, NULL, 0, NULL); grn_proc_create(ctx, "time_classify_year", -1, GRN_PROC_FUNCTION, func_time_classify_year, NULL, NULL, 0, NULL); return rc; }
grn_rc grn_command_register(grn_ctx *ctx, const char *command_name, int command_name_size, grn_command_run_func *run, grn_expr_var *vars, unsigned int n_vars, void *user_data) { GRN_API_ENTER; if (command_name_size == -1) { command_name_size = strlen(command_name); } { grn_obj *command_object; command_object = grn_proc_create(ctx, command_name, command_name_size, GRN_PROC_COMMAND, NULL, NULL, NULL, n_vars, vars); if (!command_object) { GRN_PLUGIN_ERROR(ctx, GRN_COMMAND_ERROR, "[command][%.*s] failed to grn_proc_create()", command_name_size, command_name); GRN_API_RETURN(ctx->rc); } { grn_proc *command = (grn_proc *)command_object; command->callbacks.command.run = run; command->user_data = user_data; } } GRN_API_RETURN(GRN_SUCCESS); }
/* This function registers a plugin to a database. */ grn_rc GRN_PLUGIN_REGISTER(grn_ctx *ctx) { grn_obj *obj; grn_expr_var vars[] = { {NULL, 0}, {NULL, 0}, {NULL, 0} }; GRN_TEXT_INIT(&vars[0].value, 0); GRN_TEXT_INIT(&vars[1].value, 0); GRN_UINT32_INIT(&vars[2].value, 0); /* grn_proc_create() registers a plugin to a database which is associated with `ctx'. A returned object must not be finalized here. */ obj = grn_proc_create(ctx, "TokenMecab", 10, GRN_PROC_TOKENIZER, mecab_init, mecab_next, mecab_fin, 3, vars); if (!obj || ((grn_db_obj *)obj)->id != GRN_DB_MECAB) { return GRN_FILE_CORRUPT; } return GRN_SUCCESS; }
void grn_proc_init_snippet_html(grn_ctx *ctx) { grn_proc_create(ctx, "snippet_html", -1, GRN_PROC_FUNCTION, func_snippet_html, NULL, NULL, 0, NULL); }
void grn_proc_init_edit_distance(grn_ctx *ctx) { grn_proc_create(ctx, "edit_distance", -1, GRN_PROC_FUNCTION, func_edit_distance, NULL, NULL, 0, NULL); }
void grn_proc_init_highlight_html(grn_ctx *ctx) { grn_proc_create(ctx, "highlight_html", -1, GRN_PROC_FUNCTION, func_highlight_html, NULL, NULL, 0, NULL); }