~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/protocol.cc

  • Committer: Brian Aker
  • Date: 2009-04-09 01:50:49 UTC
  • mfrom: (971.3.21 eday-dev)
  • Revision ID: brian@gaz-20090409015049-ohyn58r972hkccj2
MergeĀ Eric

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/protocol.h>
 
22
#include <drizzled/gettext.h>
 
23
 
 
24
extern char *opt_protocol;
 
25
 
 
26
ProtocolFactory *protocol_factory= NULL;
 
27
 
 
28
Protocol *get_protocol()
 
29
{
 
30
  assert(protocol_factory != NULL);
 
31
  return (*protocol_factory)();
 
32
}
 
33
 
 
34
int protocol_initializer(st_plugin_int *plugin)
 
35
{
 
36
  if (memcmp(plugin->plugin->name, opt_protocol, strlen(opt_protocol)))
 
37
    return 0;
 
38
 
 
39
  if (protocol_factory != NULL)
 
40
  {
 
41
    fprintf(stderr, "You cannot load more then one protocol plugin\n");
 
42
    exit(1);
 
43
  }
 
44
 
 
45
  assert(plugin->plugin->init); /* Find poorly designed plugins */
 
46
 
 
47
  if (plugin->plugin->init((void *)&protocol_factory))
 
48
  {
 
49
    /* 
 
50
      TRANSLATORS> The leading word "protocol" is the name
 
51
      of the plugin api, and so should not be translated. 
 
52
    */
 
53
    errmsg_printf(ERRMSG_LVL_ERROR, _("protocol plugin '%s' init() failed"),
 
54
                        plugin->name.str);
 
55
      return 1;
 
56
  }
 
57
 
 
58
  plugin->data= protocol_factory;
 
59
 
 
60
  return 0;
 
61
}
 
62
 
 
63
int protocol_finalizer(st_plugin_int *plugin)
 
64
{
 
65
  /* We know which one we initialized since its data pointer is filled */
 
66
  if (plugin->plugin->deinit && plugin->data)
 
67
  {
 
68
    if (plugin->plugin->deinit((void *)plugin->data))
 
69
    {
 
70
      /* TRANSLATORS: The leading word "protocol" is the name
 
71
         of the plugin api, and so should not be translated. */
 
72
      errmsg_printf(ERRMSG_LVL_ERROR,
 
73
                    _("protocol plugin '%s' deinit() failed"),
 
74
                    plugin->name.str);
 
75
    }
 
76
  }
 
77
 
 
78
  return 0;
 
79
}