1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Mark Atwood
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program 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
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/server_includes.h>
21
#include <drizzled/parser.h>
22
#include <drizzled/gettext.h>
24
int parser_initializer(st_plugin_int *plugin)
32
memset(p, 0, sizeof(parser_t));
34
plugin->data= (void *)p;
36
if (plugin->plugin->init)
38
if (plugin->plugin->init((void *)p))
40
/* TRANSLATORS: The leading word "parser" is the name
41
of the plugin api, and so should not be translated. */
42
errmsg_printf(ERRMSG_LVL_ERROR, _("parser plugin '%s' init() failed"),
47
plugin->state= PLUGIN_IS_READY;
57
int parser_finalizer(st_plugin_int *plugin)
59
parser_t *p= (parser_t *) plugin->data;
61
if (plugin->plugin->deinit)
63
if (plugin->plugin->deinit((void *)p))
65
/* TRANSLATORS: The leading word "parser" is the name
66
of the plugin api, and so should not be translated. */
67
errmsg_printf(ERRMSG_LVL_ERROR, _("parser plugin '%s' deinit() failed"),
78
/* The plugin_foreach() iterator requires that we
79
convert all the parameters of a plugin api entry point
80
into just one single void ptr, plus the session.
81
So we will take all the additional paramters of parser_do1,
82
and marshall them into a struct of this type, and
83
then just pass in a pointer to it.
85
typedef struct parser_do1_parms_st
91
/* This gets called by plugin_foreach once for each loaded parser plugin */
92
static bool parser_do1_iterate (Session *session, plugin_ref plugin, void *p)
94
parser_t *l= plugin_data(plugin, parser_t *);
95
parser_do1_parms_t *parms= (parser_do1_parms_t *) p;
97
/* call this loaded parser plugin's parser_func1 function pointer */
98
if (l && l->parser_func1)
100
if (l->parser_func1(session, parms->parm1, parms->parm2))
102
/* TRANSLATORS: The leading word "parser" is the name
103
of the plugin api, and so should not be translated. */
104
errmsg_printf(ERRMSG_LVL_ERROR, _("parser plugin '%s' parser_func1() failed"),
105
(char *)plugin_name(plugin));
112
/* This is the parser_do1 entry point.
113
This gets called by the rest of the Drizzle server code */
114
bool parser_do1 (Session *session, void *parm1, void *parm2)
116
parser_do1_parms_t parms;
119
/* marshall the parameters so they will fit into the foreach */
123
/* call parser_do1_iterate
124
once for each loaded parser plugin */
125
foreach_rv= plugin_foreach(session,
127
DRIZZLE_PARSER_PLUGIN,
132
/* The plugin_foreach() iterator requires that we
133
convert all the parameters of a plugin api entry point
134
into just one single void ptr, plus the session.
135
So we will take all the additional paramters of parser_do2,
136
and marshall them into a struct of this type, and
137
then just pass in a pointer to it.
139
typedef struct parser_do2_parms_st
143
} parser_do2_parms_t;
145
/* This gets called by plugin_foreach once for each loaded parser plugin */
146
static bool parser_do2_iterate (Session *session, plugin_ref plugin, void *p)
148
parser_t *l= plugin_data(plugin, parser_t *);
149
parser_do2_parms_t *parms= (parser_do2_parms_t *) p;
151
/* call this loaded parser plugin's parser_func1 function pointer */
152
if (l && l->parser_func2)
154
if (l->parser_func2(session, parms->parm3, parms->parm4))
156
/* TRANSLATORS: The leading word "parser" is the name
157
of the plugin api, and so should not be translated. */
158
errmsg_printf(ERRMSG_LVL_ERROR, _("parser plugin '%s' parser_func2() failed"),
159
(char *)plugin_name(plugin));
167
/* This is the parser_do2 entry point.
168
This gets called by the rest of the Drizzle server code */
169
bool parser_do2 (Session *session, void *parm3, void *parm4)
171
parser_do2_parms_t parms;
174
/* marshall the parameters so they will fit into the foreach */
178
/* call parser_do2_iterate
179
once for each loaded parser plugin */
180
foreach_rv= plugin_foreach(session,
182
DRIZZLE_PARSER_PLUGIN,