~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
 
21
 
21
22
#include <cstdio>
22
 
#include "drizzled/plugin/client.h"
 
23
 
 
24
#include <drizzled/plugin/client.h>
 
25
#include <drizzled/type/time.h>
23
26
 
24
27
namespace drizzled
25
28
{
26
29
 
27
 
bool plugin::Client::store(const DRIZZLE_TIME *from)
 
30
bool plugin::Client::store(const type::Time *from)
28
31
{
29
32
  const size_t buff_len= 40;
30
33
  char buff[buff_len];
33
36
 
34
37
  switch (from->time_type)
35
38
  {
36
 
  case DRIZZLE_TIMESTAMP_DATETIME:
 
39
  case type::DRIZZLE_TIMESTAMP_DATETIME:
37
40
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
38
41
                    (int) from->year,
39
42
                    (int) from->month,
45
48
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
46
49
    break;
47
50
 
48
 
  case DRIZZLE_TIMESTAMP_DATE:
 
51
  case type::DRIZZLE_TIMESTAMP_DATE:
49
52
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
50
53
                    (int) from->year,
51
54
                    (int) from->month,
52
55
                    (int) from->day);
53
56
    break;
54
57
 
55
 
  case DRIZZLE_TIMESTAMP_TIME:
 
58
  case type::DRIZZLE_TIMESTAMP_TIME:
56
59
    day= (from->year || from->month) ? 0 : from->day;
57
60
    length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
58
61
                    from->neg ? "-" : "",
63
66
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
64
67
    break;
65
68
 
66
 
  case DRIZZLE_TIMESTAMP_NONE:
67
 
  case DRIZZLE_TIMESTAMP_ERROR:
 
69
  case type::DRIZZLE_TIMESTAMP_NONE:
 
70
  case type::DRIZZLE_TIMESTAMP_ERROR:
68
71
  default:
69
72
    assert(0);
70
73
    return false;
77
80
{
78
81
  if (from == NULL)
79
82
    return store();
 
83
 
80
84
  return store(from, strlen(from));
81
85
}
82
86