~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/configvar.cc

  • Committer: Monty Taylor
  • Date: 2009-04-03 06:10:22 UTC
  • mto: (971.1.10 mordred)
  • mto: This revision was merged to the branch mainline in revision 978.
  • Revision ID: mordred@inaugust.com-20090403061022-pikvf9251i41sbak
Removed configvar and parser plugin types. They are not being used and they are just one more type to be converted. We can/will add them back once we have a place for them to be used.
Migrated error_message_handler off of plugin_foreach.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Mark Atwood
5
 
 *
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.
9
 
 *
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.
14
 
 *
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
18
 
 */
19
 
 
20
 
#include <drizzled/server_includes.h>
21
 
#include <drizzled/configvar.h>
22
 
#include <drizzled/gettext.h>
23
 
#include <drizzled/errmsg_print.h>
24
 
 
25
 
int configvar_initializer(st_plugin_int *plugin)
26
 
{
27
 
  configvar_t *p;
28
 
 
29
 
  p= new configvar_t;
30
 
  if (p == NULL) return 1;
31
 
  memset(p, 0, sizeof(configvar_t));
32
 
 
33
 
  plugin->data= (void *)p;
34
 
 
35
 
  if (plugin->plugin->init)
36
 
  {
37
 
    if (plugin->plugin->init((void *)p))
38
 
    {
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"),
42
 
                      plugin->name.str);
43
 
      goto err;
44
 
    }
45
 
  }
46
 
 
47
 
  return 0;
48
 
 
49
 
err:
50
 
  delete p;
51
 
  return 1;
52
 
}
53
 
 
54
 
int configvar_finalizer(st_plugin_int *plugin)
55
 
{
56
 
  configvar_t *p= (configvar_t *) plugin->data;
57
 
 
58
 
  if (plugin->plugin->deinit)
59
 
  {
60
 
    if (plugin->plugin->deinit((void *)p))
61
 
    {
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"),
65
 
                      plugin->name.str);
66
 
    }
67
 
  }
68
 
 
69
 
  if (p) delete p;
70
 
 
71
 
  return 0;
72
 
}
73
 
 
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.
80
 
*/
81
 
typedef struct configvar_do1_parms_st
82
 
{
83
 
  void *parm1;
84
 
  void *parm2;
85
 
} configvar_do1_parms_t;
86
 
 
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)
89
 
{
90
 
  configvar_t *l= plugin_data(plugin, configvar_t *);
91
 
  configvar_do1_parms_t *parms= (configvar_do1_parms_t *) p;
92
 
 
93
 
  /* call this loaded configvar plugin's configvar_func1 function pointer */
94
 
  if (l && l->configvar_func1)
95
 
  {
96
 
    if (l->configvar_func1(session, parms->parm1, parms->parm2))
97
 
    {
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));
102
 
      return true;
103
 
    }
104
 
  }
105
 
  return false;
106
 
}
107
 
 
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)
111
 
{
112
 
  configvar_do1_parms_t parms;
113
 
  bool foreach_rv;
114
 
 
115
 
  /* marshall the parameters so they will fit into the foreach */
116
 
  parms.parm1= parm1;
117
 
  parms.parm2= parm2;
118
 
 
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,
124
 
                             (void *) &parms);
125
 
  return foreach_rv;
126
 
}
127
 
 
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.
134
 
*/
135
 
typedef struct configvar_do2_parms_st
136
 
{
137
 
  void *parm3;
138
 
  void *parm4;
139
 
} configvar_do2_parms_t;
140
 
 
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)
143
 
{
144
 
  configvar_t *l= plugin_data(plugin, configvar_t *);
145
 
  configvar_do2_parms_t *parms= (configvar_do2_parms_t *) p;
146
 
 
147
 
  /* call this loaded configvar plugin's configvar_func1 function pointer */
148
 
  if (l && l->configvar_func2)
149
 
  {
150
 
    if (l->configvar_func2(session, parms->parm3, parms->parm4))
151
 
    {
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));
156
 
 
157
 
      return true;
158
 
    }
159
 
  }
160
 
  return false;
161
 
}
162
 
 
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)
166
 
{
167
 
  configvar_do2_parms_t parms;
168
 
  bool foreach_rv;
169
 
 
170
 
  /* marshall the parameters so they will fit into the foreach */
171
 
  parms.parm3= parm3;
172
 
  parms.parm4= parm4;
173
 
 
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,
179
 
                             (void *) &parms);
180
 
  return foreach_rv;
181
 
}