~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/protocol.cc

Cleaned up Protocol plugin interface (now a class factory) and moved libdrizzlclient to oldlibdrizzle to be clear.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <drizzled/server_includes.h>
21
21
#include <drizzled/protocol.h>
22
22
#include <drizzled/gettext.h>
23
 
#include <drizzled/connect.h>
24
 
 
25
 
typedef Protocol *(protocol_factory_t)(void);
26
 
 
27
 
protocol_factory_t *protocol_factory;
28
 
 
29
 
static bool protocol_inited= false; /* We must insist that only one of these plugins get loaded at a time */
30
 
 
31
23
 
32
24
extern char *opt_protocol;
33
25
 
 
26
ProtocolFactory *protocol_factory= NULL;
 
27
 
34
28
Protocol *get_protocol()
35
29
{
36
30
  assert(protocol_factory != NULL);
37
 
  return (protocol_factory)();
 
31
  return (*protocol_factory)();
38
32
}
39
33
 
40
34
int protocol_initializer(st_plugin_int *plugin)
42
36
  if (memcmp(plugin->plugin->name, opt_protocol, strlen(opt_protocol)))
43
37
    return 0;
44
38
 
45
 
  if (protocol_inited)
 
39
  if (protocol_factory != NULL)
46
40
  {
47
41
    fprintf(stderr, "You cannot load more then one protocol plugin\n");
48
42
    exit(1);
61
55
      return 1;
62
56
  }
63
57
 
64
 
  protocol_inited= true;
 
58
  plugin->data= protocol_factory;
65
59
 
66
60
  return 0;
67
 
 
68
61
}
69
62
 
70
63
int protocol_finalizer(st_plugin_int *plugin)
71
64
{
72
65
  /* We know which one we initialized since its data pointer is filled */
73
 
  if (plugin->plugin->deinit && protocol_inited)
 
66
  if (plugin->plugin->deinit && plugin->data)
74
67
  {
75
 
    if (plugin->plugin->deinit(NULL))
 
68
    if (plugin->plugin->deinit((void *)plugin->data))
76
69
    {
77
70
      /* TRANSLATORS: The leading word "protocol" is the name
78
71
         of the plugin api, and so should not be translated. */