~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/drizzle_protocol/oldlibdrizzle.cc

  • Committer: Tim Penhey
  • Date: 2010-01-20 02:39:01 UTC
  • mto: This revision was merged to the branch mainline in revision 1275.
  • Revision ID: tim.penhey@canonical.com-20100120023901-8teeunid6gwlthzx
Add in a rot 13 function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "config.h"
21
21
#include <drizzled/gettext.h>
22
22
#include <drizzled/error.h>
 
23
#include "drizzled/my_error.h"
23
24
#include <drizzled/query_id.h>
24
25
#include <drizzled/sql_state.h>
25
26
#include <drizzled/session.h>
29
30
 
30
31
#include "pack.h"
31
32
#include "errmsg.h"
32
 
#include "drizzle_protocol.h"
 
33
#include "oldlibdrizzle.h"
33
34
#include "options.h"
34
35
 
 
36
using namespace std;
 
37
using namespace drizzled;
 
38
 
35
39
#define PROTOCOL_VERSION 10
36
40
 
37
 
namespace drizzled
38
 
{
39
41
extern uint32_t global_thread_id;
40
 
}
41
 
 
42
 
using namespace drizzled;
43
 
using namespace std;
44
 
 
45
 
namespace drizzle_protocol
46
 
{
47
 
 
48
42
 
49
43
static const uint32_t DRIZZLE_TCP_PORT= 4427;
50
44
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
579
573
{
580
574
  char buff[12];
581
575
  return netStoreData((unsigned char*) buff,
582
 
                      (size_t) (internal::int10_to_str(from, buff, -10) - buff));
 
576
                      (size_t) (int10_to_str(from, buff, -10) - buff));
583
577
}
584
578
 
585
579
bool ClientDrizzleProtocol::store(uint32_t from)
586
580
{
587
581
  char buff[11];
588
582
  return netStoreData((unsigned char*) buff,
589
 
                      (size_t) (internal::int10_to_str(from, buff, 10) - buff));
 
583
                      (size_t) (int10_to_str(from, buff, 10) - buff));
590
584
}
591
585
 
592
586
bool ClientDrizzleProtocol::store(int64_t from)
593
587
{
594
588
  char buff[22];
595
589
  return netStoreData((unsigned char*) buff,
596
 
                      (size_t) (internal::int64_t10_to_str(from, buff, -10) - buff));
 
590
                      (size_t) (int64_t10_to_str(from, buff, -10) - buff));
597
591
}
598
592
 
599
593
bool ClientDrizzleProtocol::store(uint64_t from)
600
594
{
601
595
  char buff[21];
602
596
  return netStoreData((unsigned char*) buff,
603
 
                      (size_t) (internal::int64_t10_to_str(from, buff, 10) - buff));
 
597
                      (size_t) (int64_t10_to_str(from, buff, 10) - buff));
604
598
}
605
599
 
606
600
bool ClientDrizzleProtocol::store(double from, uint32_t decimals, String *buffer)
641
635
 
642
636
    if (drizzleclient_net_peer_addr(&net, ip, &peer_port, NI_MAXHOST))
643
637
    {
644
 
      my_error(ER_BAD_HOST_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
 
638
      my_error(ER_BAD_HOST_ERROR, MYF(0), session->security_ctx.ip.c_str());
645
639
      return false;
646
640
    }
647
641
 
648
 
    session->getSecurityContext().setIp(ip);
 
642
    session->security_ctx.ip.assign(ip);
649
643
  }
650
644
  drizzleclient_net_keepalive(&net, true);
651
645
 
700
694
        ||    (pkt_len= drizzleclient_net_read(&net)) == packet_error 
701
695
        || pkt_len < MIN_HANDSHAKE_SIZE)
702
696
    {
703
 
      my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
 
697
      my_error(ER_HANDSHAKE_ERROR, MYF(0), session->security_ctx.ip.c_str());
704
698
      return false;
705
699
    }
706
700
  }
722
716
 
723
717
  if (end >= (char*) net.read_pos + pkt_len + 2)
724
718
  {
725
 
    my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
 
719
    my_error(ER_HANDSHAKE_ERROR, MYF(0), session->security_ctx.ip.c_str());
726
720
    return false;
727
721
  }
728
722
 
752
746
 
753
747
  if (passwd + passwd_len + db_len > (char *) net.read_pos + pkt_len)
754
748
  {
755
 
    my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
 
749
    my_error(ER_HANDSHAKE_ERROR, MYF(0), session->security_ctx.ip.c_str());
756
750
    return false;
757
751
  }
758
752
 
764
758
    user_len-= 2;
765
759
  }
766
760
 
767
 
  session->getSecurityContext().setUser(user);
 
761
  session->security_ctx.user.assign(user);
768
762
 
769
763
  return session->checkUser(passwd, passwd_len, l_db);
770
764
}
814
808
 
815
809
static ListenDrizzleProtocol *listen_obj= NULL;
816
810
 
817
 
static int init(plugin::Context &context)
 
811
static int init(drizzled::plugin::Registry &registry)
818
812
{
819
813
  listen_obj= new ListenDrizzleProtocol("drizzle_protocol", false);
820
 
  context.add(listen_obj); 
 
814
  registry.add(listen_obj); 
 
815
  return 0;
 
816
}
 
817
 
 
818
static int deinit(drizzled::plugin::Registry &registry)
 
819
{
 
820
  registry.remove(listen_obj);
 
821
  delete listen_obj;
821
822
  return 0;
822
823
}
823
824
 
842
843
static DRIZZLE_SYSVAR_STR(bind_address, bind_address, PLUGIN_VAR_READONLY,
843
844
                          N_("Address to bind to."), NULL, NULL, NULL);
844
845
 
845
 
static drizzle_sys_var* sys_variables[]= {
 
846
static drizzle_sys_var* system_variables[]= {
846
847
  DRIZZLE_SYSVAR(port),
847
848
  DRIZZLE_SYSVAR(connect_timeout),
848
849
  DRIZZLE_SYSVAR(read_timeout),
853
854
  NULL
854
855
};
855
856
 
856
 
} /* namespace drizzle_protocol */
857
 
 
858
 
DRIZZLE_PLUGIN(drizzle_protocol::init, drizzle_protocol::sys_variables);
 
857
DRIZZLE_DECLARE_PLUGIN
 
858
{
 
859
  DRIZZLE_VERSION_ID,
 
860
  "drizzle_protocol",
 
861
  "0.1",
 
862
  "Eric Day",
 
863
  "Drizzle Protocol Module",
 
864
  PLUGIN_LICENSE_GPL,
 
865
  init,             /* Plugin Init */
 
866
  deinit,           /* Plugin Deinit */
 
867
  NULL,             /* status variables */
 
868
  system_variables, /* system variables */
 
869
  NULL              /* config options */
 
870
}
 
871
DRIZZLE_DECLARE_PLUGIN_END;