~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/configvar.cc

  • Committer: Monty Taylor
  • Date: 2009-03-04 02:16:28 UTC
  • mto: (917.1.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 912.
  • Revision ID: mordred@inaugust.com-20090304021628-rfq0b16uoi09g8tx
Fix to make VPATH builds work again.

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
  plugin->state= PLUGIN_IS_READY;
 
47
 
 
48
  return 0;
 
49
 
 
50
err:
 
51
  delete p;
 
52
  return 1;
 
53
}
 
54
 
 
55
int configvar_finalizer(st_plugin_int *plugin)
 
56
{
 
57
  configvar_t *p= (configvar_t *) plugin->data;
 
58
 
 
59
  if (plugin->plugin->deinit)
 
60
  {
 
61
    if (plugin->plugin->deinit((void *)p))
 
62
    {
 
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"),
 
66
                      plugin->name.str);
 
67
    }
 
68
  }
 
69
 
 
70
  if (p) delete p;
 
71
 
 
72
  return 0;
 
73
}
 
74
 
 
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.
 
81
*/
 
82
typedef struct configvar_do1_parms_st
 
83
{
 
84
  void *parm1;
 
85
  void *parm2;
 
86
} configvar_do1_parms_t;
 
87
 
 
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)
 
90
{
 
91
  configvar_t *l= plugin_data(plugin, configvar_t *);
 
92
  configvar_do1_parms_t *parms= (configvar_do1_parms_t *) p;
 
93
 
 
94
  /* call this loaded configvar plugin's configvar_func1 function pointer */
 
95
  if (l && l->configvar_func1)
 
96
  {
 
97
    if (l->configvar_func1(session, parms->parm1, parms->parm2))
 
98
    {
 
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));
 
103
      return true;
 
104
    }
 
105
  }
 
106
  return false;
 
107
}
 
108
 
 
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)
 
112
{
 
113
  configvar_do1_parms_t parms;
 
114
  bool foreach_rv;
 
115
 
 
116
  /* marshall the parameters so they will fit into the foreach */
 
117
  parms.parm1= parm1;
 
118
  parms.parm2= parm2;
 
119
 
 
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,
 
125
                             (void *) &parms);
 
126
  return foreach_rv;
 
127
}
 
128
 
 
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.
 
135
*/
 
136
typedef struct configvar_do2_parms_st
 
137
{
 
138
  void *parm3;
 
139
  void *parm4;
 
140
} configvar_do2_parms_t;
 
141
 
 
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)
 
144
{
 
145
  configvar_t *l= plugin_data(plugin, configvar_t *);
 
146
  configvar_do2_parms_t *parms= (configvar_do2_parms_t *) p;
 
147
 
 
148
  /* call this loaded configvar plugin's configvar_func1 function pointer */
 
149
  if (l && l->configvar_func2)
 
150
  {
 
151
    if (l->configvar_func2(session, parms->parm3, parms->parm4))
 
152
    {
 
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));
 
157
 
 
158
      return true;
 
159
    }
 
160
  }
 
161
  return false;
 
162
}
 
163
 
 
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)
 
167
{
 
168
  configvar_do2_parms_t parms;
 
169
  bool foreach_rv;
 
170
 
 
171
  /* marshall the parameters so they will fit into the foreach */
 
172
  parms.parm3= parm3;
 
173
  parms.parm4= parm4;
 
174
 
 
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,
 
180
                             (void *) &parms);
 
181
  return foreach_rv;
 
182
}