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"),
56
int parser_finalizer(st_plugin_int *plugin)
58
parser_t *p= (parser_t *) plugin->data;
60
if (plugin->plugin->deinit)
62
if (plugin->plugin->deinit((void *)p))
64
/* TRANSLATORS: The leading word "parser" is the name
65
of the plugin api, and so should not be translated. */
66
errmsg_printf(ERRMSG_LVL_ERROR, _("parser plugin '%s' deinit() failed"),
77
/* The plugin_foreach() iterator requires that we
78
convert all the parameters of a plugin api entry point
79
into just one single void ptr, plus the session.
80
So we will take all the additional paramters of parser_do1,
81
and marshall them into a struct of this type, and
82
then just pass in a pointer to it.
84
typedef struct parser_do1_parms_st
90
/* This gets called by plugin_foreach once for each loaded parser plugin */
91
static bool parser_do1_iterate (Session *session, plugin_ref plugin, void *p)
93
parser_t *l= plugin_data(plugin, parser_t *);
94
parser_do1_parms_t *parms= (parser_do1_parms_t *) p;
96
/* call this loaded parser plugin's parser_func1 function pointer */
97
if (l && l->parser_func1)
99
if (l->parser_func1(session, parms->parm1, parms->parm2))
101
/* TRANSLATORS: The leading word "parser" is the name
102
of the plugin api, and so should not be translated. */
103
errmsg_printf(ERRMSG_LVL_ERROR, _("parser plugin '%s' parser_func1() failed"),
104
(char *)plugin_name(plugin));
111
/* This is the parser_do1 entry point.
112
This gets called by the rest of the Drizzle server code */
113
bool parser_do1 (Session *session, void *parm1, void *parm2)
115
parser_do1_parms_t parms;
118
/* marshall the parameters so they will fit into the foreach */
122
/* call parser_do1_iterate
123
once for each loaded parser plugin */
124
foreach_rv= plugin_foreach(session,
126
DRIZZLE_PARSER_PLUGIN,
131
/* The plugin_foreach() iterator requires that we
132
convert all the parameters of a plugin api entry point
133
into just one single void ptr, plus the session.
134
So we will take all the additional paramters of parser_do2,
135
and marshall them into a struct of this type, and
136
then just pass in a pointer to it.
138
typedef struct parser_do2_parms_st
142
} parser_do2_parms_t;
144
/* This gets called by plugin_foreach once for each loaded parser plugin */
145
static bool parser_do2_iterate (Session *session, plugin_ref plugin, void *p)
147
parser_t *l= plugin_data(plugin, parser_t *);
148
parser_do2_parms_t *parms= (parser_do2_parms_t *) p;
150
/* call this loaded parser plugin's parser_func1 function pointer */
151
if (l && l->parser_func2)
153
if (l->parser_func2(session, parms->parm3, parms->parm4))
155
/* TRANSLATORS: The leading word "parser" is the name
156
of the plugin api, and so should not be translated. */
157
errmsg_printf(ERRMSG_LVL_ERROR, _("parser plugin '%s' parser_func2() failed"),
158
(char *)plugin_name(plugin));
166
/* This is the parser_do2 entry point.
167
This gets called by the rest of the Drizzle server code */
168
bool parser_do2 (Session *session, void *parm3, void *parm4)
170
parser_do2_parms_t parms;
173
/* marshall the parameters so they will fit into the foreach */
177
/* call parser_do2_iterate
178
once for each loaded parser plugin */
179
foreach_rv= plugin_foreach(session,
181
DRIZZLE_PARSER_PLUGIN,