~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/protocol.cc

  • Committer: Brian Aker
  • Date: 2009-04-13 16:22:40 UTC
  • mfrom: (971.1.78 mordred)
  • Revision ID: brian@gaz-20090413162240-ugi3gvhofmcuglzl
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include <drizzled/server_includes.h>
21
21
#include <drizzled/protocol.h>
 
22
#include "drizzled/plugin_registry.h"
22
23
#include <drizzled/gettext.h>
23
24
 
 
25
 
24
26
extern char *opt_protocol;
25
27
 
26
28
ProtocolFactory *protocol_factory= NULL;
31
33
  return (*protocol_factory)();
32
34
}
33
35
 
34
 
int protocol_initializer(st_plugin_int *plugin)
 
36
bool add_protocol_factory(ProtocolFactory *factory)
35
37
{
36
 
  if (memcmp(plugin->plugin->name, opt_protocol, strlen(opt_protocol)))
37
 
    return 0;
 
38
  if (factory->getName() != opt_protocol)
 
39
    return true;
38
40
 
39
41
  if (protocol_factory != NULL)
40
42
  {
41
43
    fprintf(stderr, "You cannot load more then one protocol plugin\n");
42
44
    exit(1);
43
45
  }
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;
 
46
  protocol_factory= factory;
 
47
 
 
48
  return false;
61
49
}
62
50
 
63
 
int protocol_finalizer(st_plugin_int *plugin)
 
51
bool remove_protocol_factory(ProtocolFactory *)
64
52
{
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;
 
53
  protocol_factory= NULL;
 
54
  return false;
79
55
}