971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
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.
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
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 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
20 |
#include <config.h> |
2154.2.4
by Brian Aker
This fixes 716459 |
21 |
|
1502.3.1
by iwamatsu at nigauri
Add cstdio include to files needing it. Fixes the build on some debian |
22 |
#include <cstdio> |
2154.2.4
by Brian Aker
This fixes 716459 |
23 |
|
24 |
#include <drizzled/plugin/client.h> |
|
25 |
#include <drizzled/type/time.h> |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
26 |
|
2313.3.6
by Olaf van der Spek
Return void |
27 |
namespace drizzled { |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
28 |
|
2313.3.6
by Olaf van der Spek
Return void |
29 |
void plugin::Client::store(const type::Time *from) |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
30 |
{
|
1366.1.9
by Siddharth Prakash Singh
sprintf->snprintf in drizzled/plugin/client.cc |
31 |
const size_t buff_len= 40; |
32 |
char buff[buff_len]; |
|
33 |
uint32_t length= 0; |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
34 |
uint32_t day; |
35 |
||
36 |
switch (from->time_type) |
|
37 |
{
|
|
2088.8.9
by Brian Aker
Merge in namespace of enum. |
38 |
case type::DRIZZLE_TIMESTAMP_DATETIME: |
1366.1.9
by Siddharth Prakash Singh
sprintf->snprintf in drizzled/plugin/client.cc |
39 |
length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d", |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
40 |
(int) from->year, |
41 |
(int) from->month, |
|
42 |
(int) from->day, |
|
43 |
(int) from->hour, |
|
44 |
(int) from->minute, |
|
45 |
(int) from->second); |
|
46 |
if (from->second_part) |
|
1366.1.9
by Siddharth Prakash Singh
sprintf->snprintf in drizzled/plugin/client.cc |
47 |
length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part); |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
48 |
break; |
49 |
||
2088.8.9
by Brian Aker
Merge in namespace of enum. |
50 |
case type::DRIZZLE_TIMESTAMP_DATE: |
1366.1.9
by Siddharth Prakash Singh
sprintf->snprintf in drizzled/plugin/client.cc |
51 |
length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d", |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
52 |
(int) from->year, |
53 |
(int) from->month, |
|
54 |
(int) from->day); |
|
55 |
break; |
|
56 |
||
2088.8.9
by Brian Aker
Merge in namespace of enum. |
57 |
case type::DRIZZLE_TIMESTAMP_TIME: |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
58 |
day= (from->year || from->month) ? 0 : from->day; |
1366.1.9
by Siddharth Prakash Singh
sprintf->snprintf in drizzled/plugin/client.cc |
59 |
length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d", |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
60 |
from->neg ? "-" : "", |
61 |
(long) day*24L+(long) from->hour, |
|
62 |
(int) from->minute, |
|
63 |
(int) from->second); |
|
64 |
if (from->second_part) |
|
1366.1.9
by Siddharth Prakash Singh
sprintf->snprintf in drizzled/plugin/client.cc |
65 |
length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part); |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
66 |
break; |
67 |
||
2088.8.9
by Brian Aker
Merge in namespace of enum. |
68 |
case type::DRIZZLE_TIMESTAMP_NONE: |
69 |
case type::DRIZZLE_TIMESTAMP_ERROR: |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
70 |
default: |
2313.3.6
by Olaf van der Spek
Return void |
71 |
assert(false); |
72 |
return; |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
73 |
}
|
74 |
||
75 |
return store(buff); |
|
76 |
}
|
|
77 |
||
2313.3.6
by Olaf van der Spek
Return void |
78 |
void plugin::Client::store(const char *from) |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
79 |
{
|
2385.2.13
by Olaf van der Spek
Refactor |
80 |
return from ? store(from, strlen(from)) : store(); |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
81 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
82 |
|
83 |
||
84 |
} /* namespace drizzled */ |