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"),
54
int configvar_finalizer(st_plugin_int *plugin)
56
configvar_t *p= (configvar_t *) plugin->data;
58
if (plugin->plugin->deinit)
60
if (plugin->plugin->deinit((void *)p))
62
/* TRANSLATORS: The leading word "configvar" is the name
63
of the plugin api, and so should not be translated. */
64
errmsg_printf(ERRMSG_LVL_ERROR, _("configvar plugin '%s' deinit() failed"),
74
/* The plugin_foreach() iterator requires that we
75
convert all the parameters of a plugin api entry point
76
into just one single void ptr, plus the session.
77
So we will take all the additional paramters of configvar_do1,
78
and marshall them into a struct of this type, and
79
then just pass in a pointer to it.
81
typedef struct configvar_do1_parms_st
85
} configvar_do1_parms_t;
87
/* This gets called by plugin_foreach once for each loaded configvar plugin */
88
static bool configvar_do1_iterate (Session *session, plugin_ref plugin, void *p)
90
configvar_t *l= plugin_data(plugin, configvar_t *);
91
configvar_do1_parms_t *parms= (configvar_do1_parms_t *) p;
93
/* call this loaded configvar plugin's configvar_func1 function pointer */
94
if (l && l->configvar_func1)
96
if (l->configvar_func1(session, parms->parm1, parms->parm2))
98
/* TRANSLATORS: The leading word "configvar" is the name
99
of the plugin api, and so should not be translated. */
100
errmsg_printf(ERRMSG_LVL_ERROR, _("configvar plugin '%s' configvar_func1() failed"),
101
(char *)plugin_name(plugin));
108
/* This is the configvar_do1 entry point.
109
This gets called by the rest of the Drizzle server code */
110
bool configvar_do1 (Session *session, void *parm1, void *parm2)
112
configvar_do1_parms_t parms;
115
/* marshall the parameters so they will fit into the foreach */
119
/* call configvar_do1_iterate
120
once for each loaded configvar plugin */
121
foreach_rv= plugin_foreach(session,
122
configvar_do1_iterate,
123
DRIZZLE_CONFIGVAR_PLUGIN,
128
/* The plugin_foreach() iterator requires that we
129
convert all the parameters of a plugin api entry point
130
into just one single void ptr, plus the session.
131
So we will take all the additional paramters of configvar_do2,
132
and marshall them into a struct of this type, and
133
then just pass in a pointer to it.
135
typedef struct configvar_do2_parms_st
139
} configvar_do2_parms_t;
141
/* This gets called by plugin_foreach once for each loaded configvar plugin */
142
static bool configvar_do2_iterate (Session *session, plugin_ref plugin, void *p)
144
configvar_t *l= plugin_data(plugin, configvar_t *);
145
configvar_do2_parms_t *parms= (configvar_do2_parms_t *) p;
147
/* call this loaded configvar plugin's configvar_func1 function pointer */
148
if (l && l->configvar_func2)
150
if (l->configvar_func2(session, parms->parm3, parms->parm4))
152
/* TRANSLATORS: The leading word "configvar" is the name
153
of the plugin api, and so should not be translated. */
154
errmsg_printf(ERRMSG_LVL_ERROR, _("configvar plugin '%s' configvar_func2() failed"),
155
(char *)plugin_name(plugin));
163
/* This is the configvar_do2 entry point.
164
This gets called by the rest of the Drizzle server code */
165
bool configvar_do2 (Session *session, void *parm3, void *parm4)
167
configvar_do2_parms_t parms;
170
/* marshall the parameters so they will fit into the foreach */
174
/* call configvar_do2_iterate
175
once for each loaded configvar plugin */
176
foreach_rv= plugin_foreach(session,
177
configvar_do2_iterate,
178
DRIZZLE_CONFIGVAR_PLUGIN,