Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ctx_impl.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2 -*- */
2 /*
3  Copyright(C) 2009-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_CTX_IMPL_H
19 #define GRN_CTX_IMPL_H
20 
21 #ifndef GRN_CTX_H
22 #include "ctx.h"
23 #endif /* GRN_CTX_H */
24 
25 #ifndef GRN_COM_H
26 #include "com.h"
27 #endif /* GRN_COM_H */
28 
29 #ifdef GRN_WITH_MESSAGE_PACK
30 #include <msgpack.h>
31 #endif
32 
33 #ifdef GRN_WITH_MRUBY
34 # include <mruby.h>
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /**** grn_expr ****/
42 
43 #define GRN_EXPR_MISSING_NAME "expr_missing"
44 
45 /**** grn_ctx_impl ****/
46 
47 #define GRN_CTX_INITED 0x00
48 #define GRN_CTX_QUITTING 0x0f
49 
50 typedef enum {
63 
64 typedef struct {
68  uint32_t emit_level;
69  int32_t key_offset;
74  uint32_t unichar;
75  uint32_t values_size;
76  uint32_t nrecords;
79 } grn_loader;
80 
81 #define GRN_CTX_N_SEGMENTS 512
82 
83 #ifdef USE_MEMORY_DEBUG
84 typedef struct _grn_alloc_info grn_alloc_info;
85 struct _grn_alloc_info
86 {
87  void *address;
88  int freed;
89  char alloc_backtrace[4096];
90  char free_backtrace[4096];
91  grn_alloc_info *next;
92 };
93 #endif
94 
95 struct _grn_ctx_impl {
97 
98  /* memory pool portion */
99  int32_t lifoseg;
100  int32_t currseg;
101  grn_critical_section lock;
103 
104 #ifdef USE_DYNAMIC_MALLOC_CHANGE
105  /* memory allocation portion */
106  grn_malloc_func malloc_func;
107  grn_calloc_func calloc_func;
108  grn_realloc_func realloc_func;
109  grn_strdup_func strdup_func;
110 #endif
111 
112 #ifdef USE_MEMORY_DEBUG
113  /* memory debug portion */
114  grn_alloc_info *alloc_info;
115 #endif
116 
117  /* qe portion */
119  uint32_t stack_curr;
123  void *parser;
125 
126  /* loader portion */
129 
130  /* plugin portion */
131  const char *plugin_path;
132 
133  /* output portion */
135  const char *mime_type;
138 
139  /* command portion */
141 
142  /* match escalation portion */
144 
145  /* lifetime portion */
147 
148  /* ql portion */
149  uint8_t batchmode;
150  uint8_t op;
151  int tok;
152  char *cur;
153  char *str_end;
155  uint32_t n_entries;
156  grn_array *values; /* temporary objects */
157  grn_hash *ios; /* IOs */
158  char *inbuf;
161  unsigned int bufcur;
162  void (*output)(grn_ctx *, int, void *);
164  unsigned int com_status;
165  union {
166  void *ptr;
167  int fd;
168  uint32_t u32;
169  uint64_t u64;
170  } data;
171 
173  unsigned int n_same_error_messages;
174 
175 #ifdef GRN_WITH_MESSAGE_PACK
176  msgpack_packer msgpacker;
177 #endif
178 #ifdef GRN_WITH_MRUBY
179  struct {
180  mrb_state *state;
181  struct RClass *module;
182  } mrb;
183 #endif
184 };
185 
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif /* GRN_CTX_IMPL_H */