~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.cc

  • Committer: Brian Aker
  • Date: 2010-12-02 05:20:13 UTC
  • mto: This revision was merged to the branch mainline in revision 1968.
  • Revision ID: brian@tangent.org-20101202052013-idifz62qat1ayhsn
Style change around session list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "config.h"
 
21
#include <cstdio>
21
22
#include "drizzled/plugin/client.h"
22
23
 
23
24
using namespace std;
27
28
 
28
29
bool plugin::Client::store(const DRIZZLE_TIME *from)
29
30
{
30
 
  char buff[40];
31
 
  uint32_t length;
 
31
  const size_t buff_len= 40;
 
32
  char buff[buff_len];
 
33
  uint32_t length= 0;
32
34
  uint32_t day;
33
35
 
34
36
  switch (from->time_type)
35
37
  {
36
38
  case DRIZZLE_TIMESTAMP_DATETIME:
37
 
    length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d",
 
39
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
38
40
                    (int) from->year,
39
41
                    (int) from->month,
40
42
                    (int) from->day,
42
44
                    (int) from->minute,
43
45
                    (int) from->second);
44
46
    if (from->second_part)
45
 
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
 
47
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
46
48
    break;
47
49
 
48
50
  case DRIZZLE_TIMESTAMP_DATE:
49
 
    length= sprintf(buff, "%04d-%02d-%02d",
 
51
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
50
52
                    (int) from->year,
51
53
                    (int) from->month,
52
54
                    (int) from->day);
54
56
 
55
57
  case DRIZZLE_TIMESTAMP_TIME:
56
58
    day= (from->year || from->month) ? 0 : from->day;
57
 
    length= sprintf(buff, "%s%02ld:%02d:%02d",
 
59
    length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
58
60
                    from->neg ? "-" : "",
59
61
                    (long) day*24L+(long) from->hour,
60
62
                    (int) from->minute,
61
63
                    (int) from->second);
62
64
    if (from->second_part)
63
 
      length+= sprintf(buff+length, ".%06d", (int)from->second_part);
 
65
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
64
66
    break;
65
67
 
66
68
  case DRIZZLE_TIMESTAMP_NONE: