~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/errmsg.cc

  • Committer: Brian Aker
  • Date: 2009-03-20 18:52:05 UTC
  • mfrom: (950.1.1 mordred)
  • Revision ID: brian@tangent.org-20090320185205-g7o6kq17r25b6odf
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
int errmsg_initializer(st_plugin_int *plugin)
27
27
{
28
 
  errmsg_t *p;
29
 
 
30
 
  p= new errmsg_t;
31
 
  if (p == NULL) return 1;
32
 
  memset(p, 0, sizeof(errmsg_t));
33
 
 
34
 
  plugin->data= (void *)p;
 
28
  Error_message_handler *p;
35
29
 
36
30
  if (plugin->plugin->init)
37
31
  {
38
 
    if (plugin->plugin->init((void *)p))
 
32
    if (plugin->plugin->init(&p))
39
33
    {
40
34
      /* we're doing the errmsg plugin api,
41
35
        so we can't trust the errmsg api to emit our error messages
49
43
    }
50
44
  }
51
45
 
 
46
  plugin->data= (void *)p;
52
47
  errmsg_has= true;
53
48
  plugin->state= PLUGIN_IS_READY;
54
49
 
61
56
 
62
57
int errmsg_finalizer(st_plugin_int *plugin)
63
58
{
64
 
  errmsg_t *p = (errmsg_t *) plugin->data;
 
59
  Error_message_handler *p= static_cast<Error_message_handler *>(plugin->data);
65
60
 
66
61
  if (plugin->plugin->deinit)
67
62
  {
68
 
    if (plugin->plugin->deinit((void *)p))
 
63
    if (plugin->plugin->deinit(p))
69
64
    {
70
65
      /* we're doing the errmsg plugin api,
71
66
         so we can't trust the errmsg api to emit our error messages
73
68
      /* TRANSLATORS: The leading word "errmsg" is the name
74
69
         of the plugin api, and so should not be translated. */
75
70
      fprintf(stderr,
76
 
              _("errmsg plugin '%s' deinit() failed."),
77
 
              plugin->name.str);
 
71
              _("errmsg plugin '%s' deinit() failed."),
 
72
              plugin->name.str);
78
73
    }
79
74
  }
80
75
 
81
 
  if (p) delete p;
82
 
 
83
76
  return 0;
84
77
}
85
78
 
101
94
/* This gets called by plugin_foreach once for each loaded errmsg plugin */
102
95
static bool errmsg_iterate (Session *session, plugin_ref plugin, void *p)
103
96
{
104
 
  errmsg_t *l= plugin_data(plugin, errmsg_t *);
 
97
  Error_message_handler *handler= plugin_data(plugin, Error_message_handler *);
105
98
  errmsg_parms_t *parms= (errmsg_parms_t *) p;
106
99
 
107
 
  if (l && l->errmsg_func)
 
100
  if (handler)
108
101
  {
109
 
    if (l->errmsg_func(session, parms->priority, parms->format, parms->ap))
 
102
    if (handler->errmsg(session, parms->priority, parms->format, parms->ap))
110
103
    {
111
104
      /* we're doing the errmsg plugin api,
112
105
         so we can't trust the errmsg api to emit our error messages
114
107
      /* TRANSLATORS: The leading word "errmsg" is the name
115
108
         of the plugin api, and so should not be translated. */
116
109
      fprintf(stderr,
117
 
              _("errmsg plugin '%s' errmsg_func() failed"),
118
 
              (char *)plugin_name(plugin));
 
110
              _("errmsg plugin '%s' errmsg() failed"),
 
111
              (char *)plugin_name(plugin));
119
112
      return true;
120
113
    }
121
114
  }
122
115
  return false;
123
116
}
124
117
 
125
 
bool errmsg_vprintf (Session *session, int priority, char const *format, va_list ap)
 
118
bool errmsg_vprintf (Session *session, int priority,
 
119
                     char const *format, va_list ap)
126
120
{
127
121
  bool foreach_rv;
128
122
  errmsg_parms_t parms;