~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to plugin/drizzle_protocol/drizzle_protocol.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

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) 2008 Sun Microsystems
 
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; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
#ifndef PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H
 
21
#define PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H
 
22
 
 
23
#include <drizzled/plugin/listen_tcp.h>
 
24
#include <drizzled/plugin/client.h>
 
25
 
 
26
#include "net_serv.h"
 
27
 
 
28
namespace drizzle_protocol
 
29
{
 
30
 
 
31
class ListenDrizzleProtocol: public drizzled::plugin::ListenTcp
 
32
{
 
33
private:
 
34
  bool using_mysql41_protocol;
 
35
 
 
36
public:
 
37
  ListenDrizzleProtocol(std::string name_arg, bool using_mysql41_protocol_arg):
 
38
   drizzled::plugin::ListenTcp(name_arg),
 
39
   using_mysql41_protocol(using_mysql41_protocol_arg)
 
40
  { }
 
41
  virtual const char* getHost(void) const;
 
42
  virtual in_port_t getPort(void) const;
 
43
  virtual drizzled::plugin::Client *getClient(int fd);
 
44
};
 
45
 
 
46
class ClientDrizzleProtocol: public drizzled::plugin::Client
 
47
{
 
48
private:
 
49
  NET net;
 
50
  drizzled::String packet;
 
51
  uint32_t client_capabilities;
 
52
  bool using_mysql41_protocol;
 
53
 
 
54
  bool checkConnection(void);
 
55
  bool netStoreData(const unsigned char *from, size_t length);
 
56
  void writeEOFPacket(uint32_t server_status, uint32_t total_warn_count);
 
57
 
 
58
public:
 
59
  ClientDrizzleProtocol(int fd, bool using_mysql41_protocol_arg);
 
60
  virtual ~ClientDrizzleProtocol();
 
61
 
 
62
  virtual int getFileDescriptor(void);
 
63
  virtual bool isConnected();
 
64
  virtual bool isReading(void);
 
65
  virtual bool isWriting(void);
 
66
  virtual bool flush(void);
 
67
  virtual void close(void);
 
68
 
 
69
  virtual bool authenticate(void);
 
70
  virtual bool readCommand(char **packet, uint32_t *packet_length);
 
71
 
 
72
  virtual void sendOK(void);
 
73
  virtual void sendEOF(void);
 
74
  virtual void sendError(uint32_t sql_errno, const char *err);
 
75
 
 
76
  virtual bool sendFields(drizzled::List<drizzled::Item> *list);
 
77
 
 
78
  using Client::store;
 
79
  virtual bool store(drizzled::Field *from);
 
80
  virtual bool store(void);
 
81
  virtual bool store(int32_t from);
 
82
  virtual bool store(uint32_t from);
 
83
  virtual bool store(int64_t from);
 
84
  virtual bool store(uint64_t from);
 
85
  virtual bool store(double from, uint32_t decimals, drizzled::String *buffer);
 
86
  virtual bool store(const char *from, size_t length);
 
87
 
 
88
  virtual bool haveError(void);
 
89
  virtual bool haveMoreData(void);
 
90
  virtual bool wasAborted(void);
 
91
};
 
92
 
 
93
} /* namespace drizzle_protocol */
 
94
 
 
95
#endif /* PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H */