~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
23
 
24
 
using namespace std;
 
24
#include <drizzled/plugin/client.h>
 
25
#include <drizzled/type/time.h>
25
26
 
26
27
namespace drizzled
27
28
{
28
29
 
29
 
bool plugin::Client::store(const DRIZZLE_TIME *from)
 
30
bool plugin::Client::store(const type::Time *from)
30
31
{
31
32
  const size_t buff_len= 40;
32
33
  char buff[buff_len];
35
36
 
36
37
  switch (from->time_type)
37
38
  {
38
 
  case DRIZZLE_TIMESTAMP_DATETIME:
 
39
  case type::DRIZZLE_TIMESTAMP_DATETIME:
39
40
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
40
41
                    (int) from->year,
41
42
                    (int) from->month,
47
48
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
48
49
    break;
49
50
 
50
 
  case DRIZZLE_TIMESTAMP_DATE:
 
51
  case type::DRIZZLE_TIMESTAMP_DATE:
51
52
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
52
53
                    (int) from->year,
53
54
                    (int) from->month,
54
55
                    (int) from->day);
55
56
    break;
56
57
 
57
 
  case DRIZZLE_TIMESTAMP_TIME:
 
58
  case type::DRIZZLE_TIMESTAMP_TIME:
58
59
    day= (from->year || from->month) ? 0 : from->day;
59
60
    length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
60
61
                    from->neg ? "-" : "",
65
66
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
66
67
    break;
67
68
 
68
 
  case DRIZZLE_TIMESTAMP_NONE:
69
 
  case DRIZZLE_TIMESTAMP_ERROR:
 
69
  case type::DRIZZLE_TIMESTAMP_NONE:
 
70
  case type::DRIZZLE_TIMESTAMP_ERROR:
70
71
  default:
71
72
    assert(0);
72
73
    return false;
79
80
{
80
81
  if (from == NULL)
81
82
    return store();
 
83
 
82
84
  return store(from, strlen(from));
83
85
}
84
86