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>
23
int parser_initializer(st_plugin_int *plugin)
27
p= (parser_t *) malloc(sizeof(parser_t));
28
if (p == NULL) return 1;
29
memset(p, 0, sizeof(parser_t));
31
plugin->data= (void *)p;
33
if (plugin->plugin->init)
35
if (plugin->plugin->init((void *)p))
37
/* TRANSLATORS: The leading word "parser" is the name
38
of the plugin api, and so should not be translated. */
39
sql_print_error(_("parser plugin '%s' init() failed"),
51
int parser_finalizer(st_plugin_int *plugin)
53
parser_t *p= (parser_t *) plugin->data;
55
if (plugin->plugin->deinit)
57
if (plugin->plugin->deinit((void *)p))
59
/* TRANSLATORS: The leading word "parser" is the name
60
of the plugin api, and so should not be translated. */
61
sql_print_error(_("parser plugin '%s' deinit() failed"),
71
/* The plugin_foreach() iterator requires that we
72
convert all the parameters of a plugin api entry point
73
into just one single void ptr, plus the session.
74
So we will take all the additional paramters of parser_do1,
75
and marshall them into a struct of this type, and
76
then just pass in a pointer to it.
78
typedef struct parser_do1_parms_st
84
/* This gets called by plugin_foreach once for each loaded parser plugin */
85
static bool parser_do1_iterate (Session *session, plugin_ref plugin, void *p)
87
parser_t *l= plugin_data(plugin, parser_t *);
88
parser_do1_parms_t *parms= (parser_do1_parms_t *) p;
90
/* call this loaded parser plugin's parser_func1 function pointer */
91
if (l && l->parser_func1)
93
if (l->parser_func1(session, parms->parm1, parms->parm2))
95
/* TRANSLATORS: The leading word "parser" is the name
96
of the plugin api, and so should not be translated. */
97
sql_print_error(_("parser plugin '%s' parser_func1() failed"),
98
(char *)plugin_name(plugin));
105
/* This is the parser_do1 entry point.
106
This gets called by the rest of the Drizzle server code */
107
bool parser_do1 (Session *session, void *parm1, void *parm2)
109
parser_do1_parms_t parms;
112
/* marshall the parameters so they will fit into the foreach */
116
/* call parser_do1_iterate
117
once for each loaded parser plugin */
118
foreach_rv= plugin_foreach(session,
120
DRIZZLE_PARSER_PLUGIN,
125
/* The plugin_foreach() iterator requires that we
126
convert all the parameters of a plugin api entry point
127
into just one single void ptr, plus the session.
128
So we will take all the additional paramters of parser_do2,
129
and marshall them into a struct of this type, and
130
then just pass in a pointer to it.
132
typedef struct parser_do2_parms_st
136
} parser_do2_parms_t;
138
/* This gets called by plugin_foreach once for each loaded parser plugin */
139
static bool parser_do2_iterate (Session *session, plugin_ref plugin, void *p)
141
parser_t *l= plugin_data(plugin, parser_t *);
142
parser_do2_parms_t *parms= (parser_do2_parms_t *) p;
144
/* call this loaded parser plugin's parser_func1 function pointer */
145
if (l && l->parser_func2)
147
if (l->parser_func2(session, parms->parm3, parms->parm4))
149
/* TRANSLATORS: The leading word "parser" is the name
150
of the plugin api, and so should not be translated. */
151
sql_print_error(_("parser plugin '%s' parser_func2() failed"),
152
(char *)plugin_name(plugin));
160
/* This is the parser_do2 entry point.
161
This gets called by the rest of the Drizzle server code */
162
bool parser_do2 (Session *session, void *parm3, void *parm4)
164
parser_do2_parms_t parms;
167
/* marshall the parameters so they will fit into the foreach */
171
/* call parser_do2_iterate
172
once for each loaded parser plugin */
173
foreach_rv= plugin_foreach(session,
175
DRIZZLE_PARSER_PLUGIN,