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/configvar.h>
22
#include <drizzled/gettext.h>
24
int configvar_initializer(st_plugin_int *plugin)
28
p= (configvar_t *) malloc(sizeof(configvar_t));
29
if (p == NULL) return 1;
30
memset(p, 0, sizeof(configvar_t));
32
plugin->data= (void *)p;
34
if (plugin->plugin->init)
36
if (plugin->plugin->init((void *)p))
38
/* TRANSLATORS: The leading word "configvar" is the name
39
of the plugin api, and so should not be translated. */
40
sql_print_error(_("configvar plugin '%s' init() failed"),
52
int configvar_finalizer(st_plugin_int *plugin)
54
configvar_t *p= (configvar_t *) plugin->data;
56
if (plugin->plugin->deinit)
58
if (plugin->plugin->deinit((void *)p))
60
/* TRANSLATORS: The leading word "configvar" is the name
61
of the plugin api, and so should not be translated. */
62
sql_print_error(_("configvar plugin '%s' deinit() failed"),
72
/* The plugin_foreach() iterator requires that we
73
convert all the parameters of a plugin api entry point
74
into just one single void ptr, plus the session.
75
So we will take all the additional paramters of configvar_do1,
76
and marshall them into a struct of this type, and
77
then just pass in a pointer to it.
79
typedef struct configvar_do1_parms_st
83
} configvar_do1_parms_t;
85
/* This gets called by plugin_foreach once for each loaded configvar plugin */
86
static bool configvar_do1_iterate (Session *session, plugin_ref plugin, void *p)
88
configvar_t *l= plugin_data(plugin, configvar_t *);
89
configvar_do1_parms_t *parms= (configvar_do1_parms_t *) p;
91
/* call this loaded configvar plugin's configvar_func1 function pointer */
92
if (l && l->configvar_func1)
94
if (l->configvar_func1(session, parms->parm1, parms->parm2))
96
/* TRANSLATORS: The leading word "configvar" is the name
97
of the plugin api, and so should not be translated. */
98
sql_print_error(_("configvar plugin '%s' configvar_func1() failed"),
99
(char *)plugin_name(plugin));
106
/* This is the configvar_do1 entry point.
107
This gets called by the rest of the Drizzle server code */
108
bool configvar_do1 (Session *session, void *parm1, void *parm2)
110
configvar_do1_parms_t parms;
113
/* marshall the parameters so they will fit into the foreach */
117
/* call configvar_do1_iterate
118
once for each loaded configvar plugin */
119
foreach_rv= plugin_foreach(session,
120
configvar_do1_iterate,
121
DRIZZLE_CONFIGVAR_PLUGIN,
126
/* The plugin_foreach() iterator requires that we
127
convert all the parameters of a plugin api entry point
128
into just one single void ptr, plus the session.
129
So we will take all the additional paramters of configvar_do2,
130
and marshall them into a struct of this type, and
131
then just pass in a pointer to it.
133
typedef struct configvar_do2_parms_st
137
} configvar_do2_parms_t;
139
/* This gets called by plugin_foreach once for each loaded configvar plugin */
140
static bool configvar_do2_iterate (Session *session, plugin_ref plugin, void *p)
142
configvar_t *l= plugin_data(plugin, configvar_t *);
143
configvar_do2_parms_t *parms= (configvar_do2_parms_t *) p;
145
/* call this loaded configvar plugin's configvar_func1 function pointer */
146
if (l && l->configvar_func2)
148
if (l->configvar_func2(session, parms->parm3, parms->parm4))
150
/* TRANSLATORS: The leading word "configvar" is the name
151
of the plugin api, and so should not be translated. */
152
sql_print_error(_("configvar plugin '%s' configvar_func2() failed"),
153
(char *)plugin_name(plugin));
161
/* This is the configvar_do2 entry point.
162
This gets called by the rest of the Drizzle server code */
163
bool configvar_do2 (Session *session, void *parm3, void *parm4)
165
configvar_do2_parms_t parms;
168
/* marshall the parameters so they will fit into the foreach */
172
/* call configvar_do2_iterate
173
once for each loaded configvar plugin */
174
foreach_rv= plugin_foreach(session,
175
configvar_do2_iterate,
176
DRIZZLE_CONFIGVAR_PLUGIN,