~drizzle-trunk/drizzle/development

971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
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
971.7.11 by Eric Day
Fixed header file guards and fixed test cases.
20
#ifndef PLUGIN_MYSQL_PROTOCOL_OLDLIBDRIZZLE_H
21
#define PLUGIN_MYSQL_PROTOCOL_OLDLIBDRIZZLE_H
971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
22
23
#include <drizzled/plugin/listen_tcp.h>
24
#include <drizzled/plugin/client.h>
25
26
#include "net_serv.h"
27
28
class ListenMySQLProtocol: public drizzled::plugin::ListenTcp
29
{
30
private:
31
  bool using_mysql41_protocol;
32
33
public:
34
  ListenMySQLProtocol(std::string name_arg, bool using_mysql41_protocol_arg):
35
   drizzled::plugin::ListenTcp(name_arg),
36
   using_mysql41_protocol(using_mysql41_protocol_arg)
37
  { }
38
  virtual const char* getHost(void) const;
39
  virtual in_port_t getPort(void) const;
40
  virtual drizzled::plugin::Client *getClient(int fd);
41
};
42
43
class ClientMySQLProtocol: public drizzled::plugin::Client
44
{
45
private:
46
  NET net;
47
  String packet;
48
  uint32_t client_capabilities;
49
  bool using_mysql41_protocol;
50
51
  bool checkConnection(void);
52
  bool netStoreData(const unsigned char *from, size_t length);
53
  void writeEOFPacket(uint32_t server_status, uint32_t total_warn_count);
54
55
public:
56
  ClientMySQLProtocol(int fd, bool using_mysql41_protocol_arg);
57
  virtual ~ClientMySQLProtocol();
58
59
  virtual int getFileDescriptor(void);
60
  virtual bool isConnected();
61
  virtual bool isReading(void);
62
  virtual bool isWriting(void);
63
  virtual bool flush(void);
64
  virtual void close(void);
65
66
  virtual bool authenticate(void);
67
  virtual bool readCommand(char **packet, uint32_t *packet_length);
68
69
  virtual void sendOK(void);
70
  virtual void sendEOF(void);
71
  virtual void sendError(uint32_t sql_errno, const char *err);
72
73
  virtual bool sendFields(List<Item> *list);
74
75
  using Client::store;
76
  virtual bool store(Field *from);
77
  virtual bool store(void);
78
  virtual bool store(int32_t from);
79
  virtual bool store(uint32_t from);
80
  virtual bool store(int64_t from);
81
  virtual bool store(uint64_t from);
82
  virtual bool store(double from, uint32_t decimals, String *buffer);
83
  virtual bool store(const char *from, size_t length);
84
85
  virtual bool haveError(void);
86
  virtual bool haveMoreData(void);
87
  virtual bool wasAborted(void);
88
};
89
971.7.11 by Eric Day
Fixed header file guards and fixed test cases.
90
#endif /* PLUGIN_MYSQL_PROTOCOL_OLDLIBDRIZZLE_H */