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>
23
#include <drizzled/errmsg_print.h>
25
int configvar_initializer(st_plugin_int *plugin)
30
if (p == NULL) return 1;
31
memset(p, 0, sizeof(configvar_t));
33
plugin->data= (void *)p;
35
if (plugin->plugin->init)
37
if (plugin->plugin->init((void *)p))
39
/* TRANSLATORS: The leading word "configvar" is the name
40
of the plugin api, and so should not be translated. */
41
errmsg_printf(ERRMSG_LVL_ERROR, _("configvar plugin '%s' init() failed"),
46
plugin->state= PLUGIN_IS_READY;
55
int configvar_finalizer(st_plugin_int *plugin)
57
configvar_t *p= (configvar_t *) plugin->data;
59
if (plugin->plugin->deinit)
61
if (plugin->plugin->deinit((void *)p))
63
/* TRANSLATORS: The leading word "configvar" is the name
64
of the plugin api, and so should not be translated. */
65
errmsg_printf(ERRMSG_LVL_ERROR, _("configvar plugin '%s' deinit() failed"),
75
/* The plugin_foreach() iterator requires that we
76
convert all the parameters of a plugin api entry point
77
into just one single void ptr, plus the session.
78
So we will take all the additional paramters of configvar_do1,
79
and marshall them into a struct of this type, and
80
then just pass in a pointer to it.
82
typedef struct configvar_do1_parms_st
86
} configvar_do1_parms_t;
88
/* This gets called by plugin_foreach once for each loaded configvar plugin */
89
static bool configvar_do1_iterate (Session *session, plugin_ref plugin, void *p)
91
configvar_t *l= plugin_data(plugin, configvar_t *);
92
configvar_do1_parms_t *parms= (configvar_do1_parms_t *) p;
94
/* call this loaded configvar plugin's configvar_func1 function pointer */
95
if (l && l->configvar_func1)
97
if (l->configvar_func1(session, parms->parm1, parms->parm2))
99
/* TRANSLATORS: The leading word "configvar" is the name
100
of the plugin api, and so should not be translated. */
101
errmsg_printf(ERRMSG_LVL_ERROR, _("configvar plugin '%s' configvar_func1() failed"),
102
(char *)plugin_name(plugin));
109
/* This is the configvar_do1 entry point.
110
This gets called by the rest of the Drizzle server code */
111
bool configvar_do1 (Session *session, void *parm1, void *parm2)
113
configvar_do1_parms_t parms;
116
/* marshall the parameters so they will fit into the foreach */
120
/* call configvar_do1_iterate
121
once for each loaded configvar plugin */
122
foreach_rv= plugin_foreach(session,
123
configvar_do1_iterate,
124
DRIZZLE_CONFIGVAR_PLUGIN,
129
/* The plugin_foreach() iterator requires that we
130
convert all the parameters of a plugin api entry point
131
into just one single void ptr, plus the session.
132
So we will take all the additional paramters of configvar_do2,
133
and marshall them into a struct of this type, and
134
then just pass in a pointer to it.
136
typedef struct configvar_do2_parms_st
140
} configvar_do2_parms_t;
142
/* This gets called by plugin_foreach once for each loaded configvar plugin */
143
static bool configvar_do2_iterate (Session *session, plugin_ref plugin, void *p)
145
configvar_t *l= plugin_data(plugin, configvar_t *);
146
configvar_do2_parms_t *parms= (configvar_do2_parms_t *) p;
148
/* call this loaded configvar plugin's configvar_func1 function pointer */
149
if (l && l->configvar_func2)
151
if (l->configvar_func2(session, parms->parm3, parms->parm4))
153
/* TRANSLATORS: The leading word "configvar" is the name
154
of the plugin api, and so should not be translated. */
155
errmsg_printf(ERRMSG_LVL_ERROR, _("configvar plugin '%s' configvar_func2() failed"),
156
(char *)plugin_name(plugin));
164
/* This is the configvar_do2 entry point.
165
This gets called by the rest of the Drizzle server code */
166
bool configvar_do2 (Session *session, void *parm3, void *parm4)
168
configvar_do2_parms_t parms;
171
/* marshall the parameters so they will fit into the foreach */
175
/* call configvar_do2_iterate
176
once for each loaded configvar plugin */
177
foreach_rv= plugin_foreach(session,
178
configvar_do2_iterate,
179
DRIZZLE_CONFIGVAR_PLUGIN,