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
sql_print_error(_("parser plugin '%s' init() failed"),
55
int parser_finalizer(st_plugin_int *plugin)
57
parser_t *p= (parser_t *) plugin->data;
59
if (plugin->plugin->deinit)
61
if (plugin->plugin->deinit((void *)p))
63
/* TRANSLATORS: The leading word "parser" is the name
64
of the plugin api, and so should not be translated. */
65
sql_print_error(_("parser plugin '%s' deinit() failed"),
76
/* The plugin_foreach() iterator requires that we
77
convert all the parameters of a plugin api entry point
78
into just one single void ptr, plus the session.
79
So we will take all the additional paramters of parser_do1,
80
and marshall them into a struct of this type, and
81
then just pass in a pointer to it.
83
typedef struct parser_do1_parms_st
89
/* This gets called by plugin_foreach once for each loaded parser plugin */
90
static bool parser_do1_iterate (Session *session, plugin_ref plugin, void *p)
92
parser_t *l= plugin_data(plugin, parser_t *);
93
parser_do1_parms_t *parms= (parser_do1_parms_t *) p;
95
/* call this loaded parser plugin's parser_func1 function pointer */
96
if (l && l->parser_func1)
98
if (l->parser_func1(session, parms->parm1, parms->parm2))
100
/* TRANSLATORS: The leading word "parser" is the name
101
of the plugin api, and so should not be translated. */
102
sql_print_error(_("parser plugin '%s' parser_func1() failed"),
103
(char *)plugin_name(plugin));
110
/* This is the parser_do1 entry point.
111
This gets called by the rest of the Drizzle server code */
112
bool parser_do1 (Session *session, void *parm1, void *parm2)
114
parser_do1_parms_t parms;
117
/* marshall the parameters so they will fit into the foreach */
121
/* call parser_do1_iterate
122
once for each loaded parser plugin */
123
foreach_rv= plugin_foreach(session,
125
DRIZZLE_PARSER_PLUGIN,
130
/* The plugin_foreach() iterator requires that we
131
convert all the parameters of a plugin api entry point
132
into just one single void ptr, plus the session.
133
So we will take all the additional paramters of parser_do2,
134
and marshall them into a struct of this type, and
135
then just pass in a pointer to it.
137
typedef struct parser_do2_parms_st
141
} parser_do2_parms_t;
143
/* This gets called by plugin_foreach once for each loaded parser plugin */
144
static bool parser_do2_iterate (Session *session, plugin_ref plugin, void *p)
146
parser_t *l= plugin_data(plugin, parser_t *);
147
parser_do2_parms_t *parms= (parser_do2_parms_t *) p;
149
/* call this loaded parser plugin's parser_func1 function pointer */
150
if (l && l->parser_func2)
152
if (l->parser_func2(session, parms->parm3, parms->parm4))
154
/* TRANSLATORS: The leading word "parser" is the name
155
of the plugin api, and so should not be translated. */
156
sql_print_error(_("parser plugin '%s' parser_func2() failed"),
157
(char *)plugin_name(plugin));
165
/* This is the parser_do2 entry point.
166
This gets called by the rest of the Drizzle server code */
167
bool parser_do2 (Session *session, void *parm3, void *parm4)
169
parser_do2_parms_t parms;
172
/* marshall the parameters so they will fit into the foreach */
176
/* call parser_do2_iterate
177
once for each loaded parser plugin */
178
foreach_rv= plugin_foreach(session,
180
DRIZZLE_PARSER_PLUGIN,