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/scheduling.h>
23
int scheduling_initializer(st_plugin_int *plugin)
27
p= (scheduling_t *) malloc(sizeof(scheduling_t));
28
if (p == NULL) return 1;
29
memset(p, 0, sizeof(scheduling_t));
31
plugin->data= (void *)p;
33
if (plugin->plugin->init)
35
if (plugin->plugin->init((void *)p))
37
/* TRANSLATORS: The leading word "scheduling" is the name
38
of the plugin api, and so should not be translated. */
39
sql_print_error(_("scheduling plugin '%s' init() failed"),
51
int scheduling_finalizer(st_plugin_int *plugin)
53
scheduling_t *p= (scheduling_t *) plugin->data;
55
if (plugin->plugin->deinit)
57
if (plugin->plugin->deinit((void *)p))
59
/* TRANSLATORS: The leading word "scheduling" is the name
60
of the plugin api, and so should not be translated. */
61
sql_print_error(_("scheduling plugin '%s' deinit() failed"),
71
/* The plugin_foreach() iterator requires that we
72
convert all the parameters of a plugin api entry point
73
into just one single void ptr, plus the session.
74
So we will take all the additional paramters of scheduling_do1,
75
and marshall them into a struct of this type, and
76
then just pass in a pointer to it.
78
typedef struct scheduling_do1_parms_st
82
} scheduling_do1_parms_t;
84
/* This gets called by plugin_foreach once for each loaded scheduling plugin */
85
static bool scheduling_do1_iterate (Session *session, plugin_ref plugin, void *p)
87
scheduling_t *l= plugin_data(plugin, scheduling_t *);
88
scheduling_do1_parms_t *parms= (scheduling_do1_parms_t *) p;
90
/* call this loaded scheduling plugin's scheduling_func1 function pointer */
91
if (l && l->scheduling_func1)
93
if (l->scheduling_func1(session, parms->parm1, parms->parm2))
95
/* TRANSLATORS: The leading word "scheduling" is the name
96
of the plugin api, and so should not be translated. */
97
sql_print_error(_("scheduling plugin '%s' scheduling_func1() failed"),
98
(char *)plugin_name(plugin));
105
/* This is the scheduling_do1 entry point.
106
This gets called by the rest of the Drizzle server code */
107
bool scheduling_do1 (Session *session, void *parm1, void *parm2)
109
scheduling_do1_parms_t parms;
112
/* marshall the parameters so they will fit into the foreach */
116
/* call scheduling_do1_iterate
117
once for each loaded scheduling plugin */
118
foreach_rv= plugin_foreach(session,
119
scheduling_do1_iterate,
120
DRIZZLE_SCHEDULING_PLUGIN,
125
/* The plugin_foreach() iterator requires that we
126
convert all the parameters of a plugin api entry point
127
into just one single void ptr, plus the session.
128
So we will take all the additional paramters of scheduling_do2,
129
and marshall them into a struct of this type, and
130
then just pass in a pointer to it.
132
typedef struct scheduling_do2_parms_st
136
} scheduling_do2_parms_t;
138
/* This gets called by plugin_foreach once for each loaded scheduling plugin */
139
static bool scheduling_do2_iterate (Session *session, plugin_ref plugin, void *p)
141
scheduling_t *l= plugin_data(plugin, scheduling_t *);
142
scheduling_do2_parms_t *parms= (scheduling_do2_parms_t *) p;
144
/* call this loaded scheduling plugin's scheduling_func1 function pointer */
145
if (l && l->scheduling_func2)
147
if (l->scheduling_func2(session, parms->parm3, parms->parm4))
149
/* TRANSLATORS: The leading word "scheduling" is the name
150
of the plugin api, and so should not be translated. */
151
sql_print_error(_("scheduling plugin '%s' scheduling_func2() failed"),
152
(char *)plugin_name(plugin));
160
/* This is the scheduling_do2 entry point.
161
This gets called by the rest of the Drizzle server code */
162
bool scheduling_do2 (Session *session, void *parm3, void *parm4)
164
scheduling_do2_parms_t parms;
167
/* marshall the parameters so they will fit into the foreach */
171
/* call scheduling_do2_iterate
172
once for each loaded scheduling plugin */
173
foreach_rv= plugin_foreach(session,
174
scheduling_do2_iterate,
175
DRIZZLE_SCHEDULING_PLUGIN,