722.4.1
by Mark Atwood
integrate errmsg plugin into sql_print_* functions |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
722.4.1
by Mark Atwood
integrate errmsg plugin into sql_print_* functions |
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 |
/* This file and these functions are a stopgap until all the
|
|
21 |
sql_print_foo() function calls are replaced with calls to
|
|
22 |
errmsg_printf()
|
|
23 |
*/
|
|
24 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
25 |
#include <config.h> |
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
26 |
|
1558.2.3
by Hartmut Holzgraefe
strerror() -> strerror_r() conversion started (bug #606478) |
27 |
#include <drizzled/definitions.h> |
722.4.1
by Mark Atwood
integrate errmsg plugin into sql_print_* functions |
28 |
#include <drizzled/errmsg_print.h> |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
29 |
#include <drizzled/plugin/error_message.h> |
722.4.1
by Mark Atwood
integrate errmsg plugin into sql_print_* functions |
30 |
|
1241.9.12
by Monty Taylor
Trims more out of server_includes.h. |
31 |
#include <cerrno> |
32 |
#include <cstring> |
|
722.4.1
by Mark Atwood
integrate errmsg plugin into sql_print_* functions |
33 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
34 |
namespace drizzled |
35 |
{
|
|
1130.1.1
by Monty Taylor
Merged in plugin-slot-reorg patches. |
36 |
|
722.4.1
by Mark Atwood
integrate errmsg plugin into sql_print_* functions |
37 |
void sql_perror(const char *message) |
38 |
{
|
|
2181.2.5
by Brian Aker
strerror_r fix |
39 |
char *errmsg_ptr; |
1702.3.2
by LinuxJedi
Migrate the rest of strerror to strerror_r |
40 |
char errmsg[STRERROR_MAX]; |
2104.1.5
by Brian Aker
This fix issue where encoded schema would be lost on restart, and also fixes |
41 |
errmsg[0]= 0; |
2181.2.5
by Brian Aker
strerror_r fix |
42 |
|
2181.2.6
by Brian Aker
Merge in additional header bits for strerror_r |
43 |
#ifdef STRERROR_R_CHAR_P
|
44 |
errmsg_ptr= strerror_r(errno, errmsg, sizeof(errmsg)); |
|
2181.2.5
by Brian Aker
strerror_r fix |
45 |
#else
|
2181.2.6
by Brian Aker
Merge in additional header bits for strerror_r |
46 |
strerror_r(errno, errmsg, sizeof(errmsg)); |
47 |
errmsg_ptr= errmsg; |
|
2181.2.5
by Brian Aker
strerror_r fix |
48 |
#endif
|
49 |
||
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
50 |
errmsg_printf(error::ERROR, "%s: %s\n", message, errmsg); |
2181.2.5
by Brian Aker
strerror_r fix |
51 |
|
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
52 |
}
|
53 |
||
54 |
// @todo Cap the size of message.
|
|
55 |
void sql_perror(const std::string &message) |
|
56 |
{
|
|
57 |
static std::string empty; |
|
58 |
sql_perror(message, empty); |
|
59 |
}
|
|
60 |
||
61 |
// @todo Cap the size of message/extra.
|
|
62 |
void sql_perror(std::string message, const std::string &extra) |
|
63 |
{
|
|
2181.2.5
by Brian Aker
strerror_r fix |
64 |
char *errmsg_ptr; |
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
65 |
char errmsg[STRERROR_MAX]; |
66 |
errmsg[0]= 0; |
|
2181.2.5
by Brian Aker
strerror_r fix |
67 |
|
2181.2.6
by Brian Aker
Merge in additional header bits for strerror_r |
68 |
#ifdef STRERROR_R_CHAR_P
|
69 |
errmsg_ptr= strerror_r(errno, errmsg, sizeof(errmsg)); |
|
2181.2.5
by Brian Aker
strerror_r fix |
70 |
#else
|
2181.2.6
by Brian Aker
Merge in additional header bits for strerror_r |
71 |
strerror_r(errno, errmsg, sizeof(errmsg)); |
72 |
errmsg_ptr= errmsg; |
|
2181.2.5
by Brian Aker
strerror_r fix |
73 |
#endif
|
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
74 |
|
75 |
if (not extra.empty()) |
|
76 |
{
|
|
77 |
if (message.at(message.size()) != ' ') |
|
78 |
message+= " "; |
|
79 |
||
80 |
message+= "'"; |
|
81 |
message+= extra; |
|
82 |
message+= "'"; |
|
83 |
}
|
|
84 |
||
85 |
errmsg_printf(error::ERROR, "%s: %s\n", message.c_str(), errmsg); |
|
86 |
}
|
|
87 |
||
88 |
bool errmsg_printf (error::level_t priority, char const *format, ...) |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
89 |
{
|
90 |
bool rv; |
|
91 |
va_list args; |
|
92 |
va_start(args, format); |
|
2126.3.2
by Brian Aker
Merge in removal/need for session in error message plugins. |
93 |
rv= plugin::ErrorMessage::vprintf(priority, format, args); |
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
94 |
va_end(args); |
95 |
return rv; |
|
722.4.1
by Mark Atwood
integrate errmsg plugin into sql_print_* functions |
96 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
97 |
|
98 |
} /* namespace drizzled */ |