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/protocol.h>
22
#include <drizzled/gettext.h>
23
#include <drizzled/connect.h>
25
typedef Protocol *(protocol_factory_t)(void);
27
protocol_factory_t *protocol_factory;
29
static bool protocol_inited= false; /* We must insist that only one of these plugins get loaded at a time */
32
extern char *opt_protocol;
34
Protocol *get_protocol()
36
assert(protocol_factory != NULL);
37
return (protocol_factory)();
40
int protocol_initializer(st_plugin_int *plugin)
42
if (memcmp(plugin->plugin->name, opt_protocol, strlen(opt_protocol)))
47
fprintf(stderr, "You cannot load more then one protocol plugin\n");
51
assert(plugin->plugin->init); /* Find poorly designed plugins */
53
if (plugin->plugin->init((void *)&protocol_factory))
56
TRANSLATORS> The leading word "protocol" is the name
57
of the plugin api, and so should not be translated.
59
errmsg_printf(ERRMSG_LVL_ERROR, _("protocol plugin '%s' init() failed"),
64
protocol_inited= true;
70
int protocol_finalizer(st_plugin_int *plugin)
72
/* We know which one we initialized since its data pointer is filled */
73
if (plugin->plugin->deinit && protocol_inited)
75
if (plugin->plugin->deinit(NULL))
77
/* TRANSLATORS: The leading word "protocol" is the name
78
of the plugin api, and so should not be translated. */
79
errmsg_printf(ERRMSG_LVL_ERROR,
80
_("protocol plugin '%s' deinit() failed"),