~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

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: