499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
499.2.10
by Mark Atwood
add editor format hints, and other useful metadata comments |
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
3 |
*
|
499.2.10
by Mark Atwood
add editor format hints, and other useful metadata comments |
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 |
*/
|
|
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
19 |
|
20 |
#include <drizzled/server_includes.h> |
|
1130.1.1
by Monty Taylor
Merged in plugin-slot-reorg patches. |
21 |
#include <drizzled/plugin/error_message.h> |
549
by Monty Taylor
Took gettext.h out of header files. |
22 |
#include <drizzled/gettext.h> |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
23 |
|
24 |
#include <stdio.h> /* for vsnprintf */ |
|
25 |
#include <stdarg.h> /* for va_list */ |
|
26 |
#include <unistd.h> /* for write(2) */ |
|
27 |
||
499.2.10
by Mark Atwood
add editor format hints, and other useful metadata comments |
28 |
/* todo, make this dynamic as needed */
|
499.2.7
by Mark Atwood
some bugs in errmsg plugin |
29 |
#define MAX_MSG_LEN 8192
|
30 |
||
1130.1.1
by Monty Taylor
Merged in plugin-slot-reorg patches. |
31 |
class Error_message_stderr : public drizzled::plugin::ErrorMessage |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
32 |
{
|
942.1.16
by Monty Taylor
Converted error message plugin to class. |
33 |
public: |
968.2.36
by Monty Taylor
Removed configvar and parser plugin types. They are not being used and they are just one more type to be converted. We can/will add them back once we have a place for them to be used. |
34 |
Error_message_stderr() : Error_message_handler("Error_message_stderr") {} |
942.1.16
by Monty Taylor
Converted error message plugin to class. |
35 |
virtual bool errmsg(Session *, int , const char *format, va_list ap) |
36 |
{
|
|
37 |
char msgbuf[MAX_MSG_LEN]; |
|
38 |
int prv, wrv; |
|
39 |
||
40 |
prv= vsnprintf(msgbuf, MAX_MSG_LEN, format, ap); |
|
41 |
if (prv < 0) return true; |
|
42 |
||
43 |
/* a single write has a OS level thread lock
|
|
44 |
so there is no need to have mutexes guarding this write,
|
|
45 |
*/
|
|
46 |
wrv= write(2, msgbuf, prv); |
|
47 |
if ((wrv < 0) || (wrv != prv)) return true; |
|
48 |
||
49 |
return false; |
|
50 |
}
|
|
51 |
};
|
|
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
52 |
|
971.1.51
by Monty Taylor
New-style plugin registration now works. |
53 |
static Error_message_stderr *handler= NULL; |
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
54 |
static int errmsg_stderr_plugin_init(drizzled::plugin::Registry ®istry) |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
55 |
{
|
971.1.51
by Monty Taylor
New-style plugin registration now works. |
56 |
handler= new Error_message_stderr(); |
1130.1.8
by Monty Taylor
Added polymorphic add/remove methods around slot add/remove methods. |
57 |
registry.add(handler); |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
58 |
|
59 |
return 0; |
|
60 |
}
|
|
61 |
||
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
62 |
static int errmsg_stderr_plugin_deinit(drizzled::plugin::Registry ®istry) |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
63 |
{
|
64 |
||
942.1.16
by Monty Taylor
Converted error message plugin to class. |
65 |
if (handler) |
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
66 |
{
|
1130.1.8
by Monty Taylor
Added polymorphic add/remove methods around slot add/remove methods. |
67 |
registry.remove(handler); |
942.1.16
by Monty Taylor
Converted error message plugin to class. |
68 |
delete handler; |
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
69 |
}
|
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
70 |
return 0; |
71 |
}
|
|
72 |
||
813.2.1
by Toru Maesaka
Renamed mysql_declare_plugin to drizzle_declare_plugin |
73 |
drizzle_declare_plugin(errmsg_stderr) |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
74 |
{
|
75 |
"errmsg_stderr", |
|
76 |
"0.1", |
|
77 |
"Mark Atwood <mark@fallenpegasus.com>", |
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
78 |
N_("Error Messages to stderr"), |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
79 |
PLUGIN_LICENSE_GPL, |
80 |
errmsg_stderr_plugin_init, |
|
81 |
errmsg_stderr_plugin_deinit, |
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
82 |
NULL, /* status variables */ |
83 |
NULL, /* system variables */ |
|
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
84 |
NULL
|
85 |
}
|
|
813.2.2
by Toru Maesaka
Renamed mysql_declare_plugin_end to drizzle_declare_plugin_end |
86 |
drizzle_declare_plugin_end; |