Groonga 3.0.9 Source Code Document
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
groonga
include
groonga
plugin.h
Go to the documentation of this file.
1
/* -*- c-basic-offset: 2 -*- */
2
/*
3
Copyright(C) 2010-2012 Brazil
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 version 2.1 as published by the Free Software Foundation.
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
#ifndef GRN_PLUGIN_H
19
#define GRN_PLUGIN_H
20
21
#include <stddef.h>
22
23
#include <
groonga.h
>
24
25
#ifdef __cplusplus
26
extern
"C"
{
27
#endif
28
29
#define GRN_PLUGIN_INIT grn_plugin_impl_init
30
#define GRN_PLUGIN_REGISTER grn_plugin_impl_register
31
#define GRN_PLUGIN_FIN grn_plugin_impl_fin
32
33
#if defined(_WIN32) || defined(_WIN64)
34
# define GRN_PLUGIN_EXPORT __declspec(dllexport)
35
#else
/* defined(_WIN32) || defined(_WIN64) */
36
# define GRN_PLUGIN_EXPORT
37
#endif
/* defined(_WIN32) || defined(_WIN64) */
38
39
GRN_PLUGIN_EXPORT
grn_rc
GRN_PLUGIN_INIT
(
grn_ctx
*ctx);
40
GRN_PLUGIN_EXPORT
grn_rc
GRN_PLUGIN_REGISTER
(
grn_ctx
*ctx);
41
GRN_PLUGIN_EXPORT
grn_rc
GRN_PLUGIN_FIN
(
grn_ctx
*ctx);
42
43
/*
44
Don't call these functions directly. Use GRN_PLUGIN_MALLOC(),
45
GRN_PLUGIN_REALLOC() and GRN_PLUGIN_FREE() instead.
46
*/
47
GRN_API
void
*
grn_plugin_malloc
(
grn_ctx
*ctx,
size_t
size,
const
char
*file,
48
int
line,
const
char
*func);
49
GRN_API
void
*
grn_plugin_realloc
(
grn_ctx
*ctx,
void
*ptr,
size_t
size,
50
const
char
*file,
int
line,
const
char
*func);
51
GRN_API
void
grn_plugin_free
(
grn_ctx
*ctx,
void
*ptr,
const
char
*file,
52
int
line,
const
char
*func);
53
54
/*
55
GRN_PLUGIN_MALLOC() allocates `size' bytes and returns a pointer to the
56
allocated memory space. Note that the memory space is associated with `ctx'.
57
*/
58
#define GRN_PLUGIN_MALLOC(ctx, size) \
59
grn_plugin_malloc((ctx), (size), __FILE__, __LINE__, __FUNCTION__)
60
/*
61
GRN_PLUGIN_REALLOC() resizes the memory space pointed to by `ptr' or
62
allocates a new memory space of `size' bytes. GRN_PLUGIN_REALLOC() returns
63
a pointer to the memory space. The contents is unchanged or copied from the
64
old memory space to the new memory space.
65
*/
66
#define GRN_PLUGIN_REALLOC(ctx, ptr, size) \
67
grn_plugin_realloc((ctx), (ptr), (size), __FILE__, __LINE__, __FUNCTION__)
68
/*
69
GRN_PLUGIN_FREE() frees a memory space allocated by GRN_PLUGIN_MALLOC() or
70
GRN_PLUGIN_REALLOC(). This means that `ptr' must be a pointer returned by
71
GRN_PLUGIN_MALLOC() or GRN_PLUGIN_REALLOC().
72
*/
73
#define GRN_PLUGIN_FREE(ctx, ptr) \
74
grn_plugin_free((ctx), (ptr), __FILE__, __LINE__, __FUNCTION__)
75
76
/*
77
GRN_PLUGIN_LOG() reports a log of `level'. Its error message is generated
78
from the varying number of arguments, in which the first one is the format
79
string and the rest are its arguments. See grn_log_level in "groonga.h" for
80
more details of `level'.
81
*/
82
#define GRN_PLUGIN_LOG(ctx, level, ...) \
83
GRN_LOG((ctx), (level), __VA_ARGS__)
84
85
/*
86
Don't call grn_plugin_set_error() directly. This function is used in
87
GRN_PLUGIN_SET_ERROR().
88
*/
89
GRN_API
void
grn_plugin_set_error
(
grn_ctx
*ctx,
grn_log_level
level,
90
grn_rc
error_code,
91
const
char
*file,
int
line,
const
char
*func,
92
const
char
*format, ...)
GRN_ATTRIBUTE_PRINTF
(7);
93
94
/*
95
Don't call these functions directly. grn_plugin_backtrace() and
96
grn_plugin_logtrace() are used in GRN_PLUGIN_SET_ERROR().
97
*/
98
GRN_API
void
grn_plugin_backtrace
(
grn_ctx
*ctx);
99
GRN_API
void
grn_plugin_logtrace
(
grn_ctx
*ctx,
grn_log_level
level);
100
101
/*
102
Don't use GRN_PLUGIN_SET_ERROR() directly. This macro is used in
103
GRN_PLUGIN_ERROR().
104
*/
105
#define GRN_PLUGIN_SET_ERROR(ctx, level, error_code, ...) do { \
106
grn_plugin_set_error(ctx, level, error_code, \
107
__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); \
108
GRN_LOG(ctx, level, __VA_ARGS__); \
109
grn_plugin_backtrace(ctx); \
110
grn_plugin_logtrace(ctx, level); \
111
} while (0)
112
113
/*
114
GRN_PLUGIN_ERROR() reports an error of `error_code'. Its error message is
115
generated from the varying number of arguments, in which the first one is the
116
format string and the rest are its arguments. See grn_rc in "groonga.h" for
117
more details of `error_code'.
118
*/
119
#define GRN_PLUGIN_ERROR(ctx, error_code, ...) \
120
GRN_PLUGIN_SET_ERROR(ctx, GRN_LOG_ERROR, error_code, __VA_ARGS__)
121
122
/*
123
grn_plugin_mutex is available to make a critical section. See the
124
following functions.
125
*/
126
typedef
struct
_grn_plugin_mutex
grn_plugin_mutex
;
127
128
/*
129
grn_plugin_mutex_open() returns a pointer to a new object of
130
grn_plugin_mutex. Memory for the new object is obtained with
131
GRN_PLUGIN_MALLOC(). grn_plugin_mutex_open() returns NULL if sufficient
132
memory is not available.
133
*/
134
GRN_API
grn_plugin_mutex
*
grn_plugin_mutex_open
(
grn_ctx
*ctx);
135
136
/*
137
grn_plugin_mutex_create() is deprecated. Use grn_plugin_mutex_open()
138
instead.
139
*/
140
GRN_API
grn_plugin_mutex
*
grn_plugin_mutex_create
(
grn_ctx
*ctx);
141
142
/*
143
grn_plugin_mutex_close() finalizes an object of grn_plugin_mutex and then
144
frees memory allocated for that object.
145
*/
146
GRN_API
void
grn_plugin_mutex_close
(
grn_ctx
*ctx,
grn_plugin_mutex
*mutex);
147
148
/*
149
grn_plugin_mutex_destroy() is deprecated. Use grn_plugin_mutex_close()
150
instead.
151
*/
152
GRN_API
void
grn_plugin_mutex_destroy
(
grn_ctx
*ctx,
grn_plugin_mutex
*mutex);
153
154
/*
155
grn_plugin_mutex_lock() locks a mutex object. If the object is already
156
locked, the calling thread waits until the object will be unlocked.
157
*/
158
GRN_API
void
grn_plugin_mutex_lock
(
grn_ctx
*ctx,
grn_plugin_mutex
*mutex);
159
160
/*
161
grn_plugin_mutex_unlock() unlocks a mutex object. grn_plugin_mutex_unlock()
162
should not be called for an unlocked object.
163
*/
164
GRN_API
void
grn_plugin_mutex_unlock
(
grn_ctx
*ctx,
grn_plugin_mutex
*mutex);
165
166
/*
167
grn_plugin_proc_alloc() allocates a `grn_obj` object.
168
You can use it in function that is registered as GRN_PROC_FUNCTION.
169
*/
170
GRN_API
grn_obj
*
grn_plugin_proc_alloc
(
grn_ctx
*ctx,
grn_user_data
*user_data,
171
grn_id
domain,
grn_obj_flags
flags);
172
173
/*
174
grn_plugin_win32_base_dir() returns the groonga install directory.
175
The install directory is computed from the directory that has
176
`groonga.dll`. You can use the directory to generate install
177
directory aware path.
178
179
It only works on Windows. It returns `NULL` on other platforms.
180
*/
181
GRN_API
const
char
*
grn_plugin_win32_base_dir
(
void
);
182
183
/*
184
grn_plugin_charlen() returns the length (#bytes) of the first character
185
in the string specified by `str_ptr' and `str_length'. If the starting bytes
186
are invalid as a character, grn_plugin_charlen() returns 0. See
187
grn_encoding in "groonga.h" for more details of `encoding'
188
*/
189
GRN_API
int
grn_plugin_charlen
(
grn_ctx
*ctx,
const
char
*str_ptr,
190
unsigned
int
str_length,
grn_encoding
encoding);
191
192
/*
193
grn_plugin_isspace() returns the length (#bytes) of the first character
194
in the string specified by `str_ptr' and `str_length' if it is a space
195
character. Otherwise, grn_plugin_isspace() returns 0.
196
*/
197
GRN_API
int
grn_plugin_isspace
(
grn_ctx
*ctx,
const
char
*str_ptr,
198
unsigned
int
str_length,
grn_encoding
encoding);
199
200
201
202
#ifdef __cplusplus
203
}
204
#endif
205
206
#endif
/* GRN_PLUGIN_H */
Generated on Sun Nov 10 2013 09:49:01 for Groonga 3.0.9 Source Code Document by
1.8.1.2