~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.cc

Merge Monty - Updates to pandora-build to support features of gcc 4.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
 
20
#include "config.h"
22
21
#include <cstdio>
23
 
 
24
 
#include <drizzled/plugin/client.h>
25
 
#include <drizzled/type/time.h>
26
 
 
27
 
namespace drizzled {
28
 
 
29
 
void plugin::Client::store(const type::Time *from)
 
22
#include "drizzled/plugin/client.h"
 
23
 
 
24
namespace drizzled
 
25
{
 
26
 
 
27
bool plugin::Client::store(const DRIZZLE_TIME *from)
30
28
{
31
29
  const size_t buff_len= 40;
32
30
  char buff[buff_len];
35
33
 
36
34
  switch (from->time_type)
37
35
  {
38
 
  case type::DRIZZLE_TIMESTAMP_DATETIME:
 
36
  case DRIZZLE_TIMESTAMP_DATETIME:
39
37
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
40
38
                    (int) from->year,
41
39
                    (int) from->month,
47
45
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
48
46
    break;
49
47
 
50
 
  case type::DRIZZLE_TIMESTAMP_DATE:
 
48
  case DRIZZLE_TIMESTAMP_DATE:
51
49
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
52
50
                    (int) from->year,
53
51
                    (int) from->month,
54
52
                    (int) from->day);
55
53
    break;
56
54
 
57
 
  case type::DRIZZLE_TIMESTAMP_TIME:
 
55
  case DRIZZLE_TIMESTAMP_TIME:
58
56
    day= (from->year || from->month) ? 0 : from->day;
59
57
    length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
60
58
                    from->neg ? "-" : "",
65
63
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
66
64
    break;
67
65
 
68
 
  case type::DRIZZLE_TIMESTAMP_NONE:
69
 
  case type::DRIZZLE_TIMESTAMP_ERROR:
 
66
  case DRIZZLE_TIMESTAMP_NONE:
 
67
  case DRIZZLE_TIMESTAMP_ERROR:
70
68
  default:
71
 
    assert(false);
72
 
    return;
 
69
    assert(0);
 
70
    return false;
73
71
  }
74
72
 
75
73
  return store(buff);
76
74
}
77
75
 
78
 
void plugin::Client::store(const char *from)
 
76
bool plugin::Client::store(const char *from)
79
77
{
80
 
  return from ? store(from, strlen(from)) : store();
 
78
  if (from == NULL)
 
79
    return store();
 
80
  return store(from, strlen(from));
81
81
}
82
82
 
83
83