Drizzled Public API Documentation

net_serv.h

00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 
00021 #pragma once
00022 
00023 #include "vio.h"
00024 
00025 #define LIBDRIZZLE_ERRMSG_SIZE 512
00026 #define LIBDRIZZLE_SQLSTATE_LENGTH 5
00027 
00028 namespace drizzle_plugin
00029 {
00030 
00031 typedef struct st_net {
00032   Vio *vio;
00033   unsigned char *buff,*buff_end,*write_pos,*read_pos;
00034   int fd;         /* For Perl DBI/dbd */
00035   /*
00036     The following variable is set if we are doing several queries in one
00037     command ( as in LOAD TABLE ... FROM MASTER ),
00038     and do not want to confuse the client with OK at the wrong time
00039   */
00040   unsigned long remain_in_buf,length, buf_length, where_b;
00041   unsigned long max_packet,max_packet_size;
00042   unsigned int pkt_nr,compress_pkt_nr;
00043   unsigned int write_timeout;
00044   unsigned int read_timeout;
00045   unsigned int retry_count;
00046   int fcntl;
00047   unsigned int *return_status;
00048   unsigned char reading_or_writing;
00049   char save_char;
00050   bool compress;
00051   /*
00052     Pointer to query object in query cache, do not equal NULL (0) for
00053     queries in cache that have not stored its results yet
00054   */
00055   /*
00056     Unused, please remove with the next incompatible ABI change.
00057   */
00058   unsigned char *unused;
00059   unsigned int last_errno;
00060   unsigned char error;
00062   char last_error[LIBDRIZZLE_ERRMSG_SIZE];
00064   char sqlstate[LIBDRIZZLE_SQLSTATE_LENGTH+1];
00065   void *extension;
00066 } NET;
00067 
00068 bool drizzleclient_net_init(NET *net, Vio* vio, uint32_t buffer_length);
00069 void drizzleclient_net_end(NET *net);
00070 void drizzleclient_net_clear(NET *net, bool clear_buffer);
00071 bool drizzleclient_net_flush(NET *net);
00072 bool drizzleclient_net_write(NET *net,const unsigned char *packet, size_t len);
00073 bool drizzleclient_net_write_command(NET *net,unsigned char command,
00074                                      const unsigned char *header, size_t head_len,
00075                                      const unsigned char *packet, size_t len);
00076 uint32_t drizzleclient_net_read(NET *net);
00077 void drizzleclient_net_close(NET *net);
00078 bool drizzleclient_net_init_sock(NET * net, int sock, uint32_t buffer_length);
00079 bool drizzleclient_net_peer_addr(NET *net, char *buf, uint16_t *port, size_t buflen);
00080 void drizzleclient_net_keepalive(NET *net, bool flag);
00081 int drizzleclient_net_get_sd(NET *net);
00082 bool drizzleclient_net_more_data(NET *net);
00083 
00084 void drizzleclient_net_set_write_timeout(NET *net, uint32_t timeout);
00085 void drizzleclient_net_set_read_timeout(NET *net, uint32_t timeout);
00086 void drizzleclient_drizzleclient_net_clear_error(NET *net);
00087 
00088 } /* namespace drizzle_plugin */
00089