~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session/state.cc

  • Committer: Stewart Smith
  • Date: 2011-03-29 01:30:47 UTC
  • mto: (2257.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2258.
  • Revision ID: stewart@flamingspork.com-20110329013047-5ujzfx6pahmwuko2
have CachedDirectory print out a warning if we can't stat() something in a directory. We should always have access to at least stat() things in directories Drizzle is running in (otherwise there is likely a problem)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2011 Brian Aker
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#include <config.h>
 
22
 
 
23
#include <drizzled/session/state.h>
 
24
#include <drizzled/definitions.h>
 
25
#include <cstring>
 
26
#include <string>
 
27
 
 
28
namespace drizzled {
 
29
namespace session {
 
30
 
 
31
State::State(const char *in_packet, size_t in_packet_length)
 
32
{
 
33
  if (in_packet_length)
 
34
  {
 
35
    size_t minimum= std::min(in_packet_length, static_cast<size_t>(PROCESS_LIST_WIDTH));
 
36
    _query.resize(minimum + 1);
 
37
    memcpy(&_query[0], in_packet, minimum);
 
38
  }
 
39
  else
 
40
  {
 
41
    _query.resize(0);
 
42
  }
 
43
}
 
44
 
 
45
const char *State::query() const
 
46
{
 
47
  if (_query.size())
 
48
    return &_query[0];
 
49
 
 
50
  return "";
 
51
}
 
52
 
 
53
const char *State::query(size_t &size) const
 
54
{
 
55
  if (_query.size())
 
56
  {
 
57
    size= _query.size() -1;
 
58
    return &_query[0];
 
59
  }
 
60
 
 
61
  size= 0;
 
62
  return "";
 
63
}
 
64
 
 
65
} /* namespace session */
 
66
} /* namespace drizzled */