~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/oldlibdrizzle/oldlibdrizzle.h

  • Committer: Devananda
  • Date: 2009-07-04 01:55:13 UTC
  • mto: (1086.10.1 length-plugin)
  • mto: This revision was merged to the branch mainline in revision 1095.
  • Revision ID: deva@myst-20090704015513-gtqliazxtfm7sdvf
refactored function/length into plugin/length

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2010 Brian Aker
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
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.
 
8
 *  the Free Software Foundation; version 2 of the License.
10
9
 *
11
10
 *  This program is distributed in the hope that it will be useful,
12
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
18
 */
20
19
 
21
 
 
22
 
#ifndef PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H
23
 
#define PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H
24
 
 
25
 
#include <drizzled/plugin/listen_tcp.h>
26
 
#include <drizzled/plugin/client.h>
27
 
#include <drizzled/atomics.h>
28
 
#include "drizzled/plugin/table_function.h"
29
 
 
30
 
#include "plugin/mysql_protocol/mysql_protocol.h"
31
 
 
32
 
namespace drizzle_plugin
33
 
{
34
 
namespace drizzle_protocol
35
 
{
36
 
 
37
 
class ListenDrizzleProtocol: public ListenMySQLProtocol
38
 
{
39
 
public:
40
 
  ListenDrizzleProtocol(std::string name, 
41
 
                        const std::string &bind_address,
42
 
                        bool using_mysql41_protocol):
43
 
    ListenMySQLProtocol(name, bind_address, using_mysql41_protocol)
44
 
  { }
45
 
 
46
 
  ~ListenDrizzleProtocol();
47
 
  in_port_t getPort(void) const;
48
 
  static ProtocolCounters *drizzle_counters;
49
 
  virtual ProtocolCounters *getCounters(void) const { return drizzle_counters; }
50
 
  drizzled::plugin::Client *getClient(int fd);
51
 
};
52
 
 
53
 
class ClientDrizzleProtocol: public ClientMySQLProtocol
54
 
{
55
 
public:
56
 
  ClientDrizzleProtocol(int fd, ProtocolCounters *set_counters): ClientMySQLProtocol(fd, true, set_counters) {}
57
 
 
58
 
  static std::vector<std::string> drizzle_admin_ip_addresses;
59
 
  static void drizzle_compose_ip_addresses(std::vector<std::string> options);
60
 
  bool isAdminAllowed(void);
61
 
};
62
 
 
63
 
} /* namespace drizzle_protocol */
64
 
} /* namespace drizzle_plugin */
65
 
 
66
 
#endif /* PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H */
 
20
#ifndef DRIZZLED_PLUGIN_OLDLIBDRIZZLE_H
 
21
#define DRIZZLED_PLUGIN_OLDLIBDRIZZLE_H
 
22
 
 
23
#include <drizzled/plugin/listen.h>
 
24
#include <drizzled/plugin/protocol.h>
 
25
 
 
26
#include "net_serv.h"
 
27
#include "password.h"
 
28
 
 
29
class ListenOldLibdrizzle: public Listen
 
30
{
 
31
private:
 
32
  in_port_t port;
 
33
 
 
34
public:
 
35
  ListenOldLibdrizzle();
 
36
  ListenOldLibdrizzle(in_port_t port_arg): port(port_arg) {}
 
37
  virtual in_port_t getPort(void) const;
 
38
  virtual Protocol *protocolFactory(void) const;
 
39
};
 
40
 
 
41
class ProtocolOldLibdrizzle: public Protocol
 
42
{
 
43
private:
 
44
  NET net;
 
45
  Vio* save_vio;
 
46
  struct rand_struct rand;
 
47
  char scramble[SCRAMBLE_LENGTH+1];
 
48
  String *packet;
 
49
  String *convert;
 
50
  uint32_t field_pos;
 
51
  uint32_t field_count;
 
52
  bool netStoreData(const unsigned char *from, size_t length);
 
53
 
 
54
  /**
 
55
   * Performs handshake with client and authorizes user.
 
56
   *
 
57
   * Returns true is the connection is valid and the
 
58
   * user is authorized, otherwise false.
 
59
   */  
 
60
  bool checkConnection(void);
 
61
 
 
62
public:
 
63
  ProtocolOldLibdrizzle();
 
64
  ~ProtocolOldLibdrizzle();
 
65
  virtual void setSession(Session *session_arg);
 
66
  virtual bool isConnected();
 
67
  virtual void setReadTimeout(uint32_t timeout);
 
68
  virtual void setWriteTimeout(uint32_t timeout);
 
69
  virtual void setRetryCount(uint32_t count);
 
70
  virtual void setError(char error);
 
71
  virtual bool haveError(void);
 
72
  virtual bool wasAborted(void);
 
73
  virtual void enableCompression(void);
 
74
  virtual bool haveMoreData(void);
 
75
  virtual bool isReading(void);
 
76
  virtual bool isWriting(void);
 
77
  virtual bool setFileDescriptor(int fd);
 
78
  virtual int fileDescriptor(void);
 
79
  virtual void setRandom(uint64_t seed1, uint64_t seed2);
 
80
  virtual bool authenticate(void);
 
81
  virtual bool readCommand(char **packet, uint32_t *packet_length);
 
82
  virtual void sendOK();
 
83
  virtual void sendEOF();
 
84
  virtual void sendError(uint32_t sql_errno, const char *err);
 
85
  virtual void close();
 
86
  virtual void forceClose();
 
87
  virtual void prepareForResend();
 
88
  virtual void free();
 
89
  virtual bool write();
 
90
 
 
91
  virtual bool sendFields(List<Item> *list, uint32_t flags);
 
92
 
 
93
  using Protocol::store;
 
94
  virtual bool store(Field *from);
 
95
  virtual bool store(void);
 
96
  virtual bool store(int32_t from);
 
97
  virtual bool store(uint32_t from);
 
98
  virtual bool store(int64_t from);
 
99
  virtual bool store(uint64_t from);
 
100
  virtual bool store(double from, uint32_t decimals, String *buffer);
 
101
  virtual bool store(const DRIZZLE_TIME *from);
 
102
  virtual bool store(const char *from, size_t length);
 
103
};
 
104
 
 
105
#endif /* DRIZZLED_PLUGIN_OLDLIBDRIZZLE_H */