Drizzled Public API Documentation

structs.h

Go to the documentation of this file.
00001 /*
00002  * Drizzle Client & Protocol Library
00003  *
00004  * Copyright (C) 2008 Eric Day (eday@oddments.org)
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are
00009  * met:
00010  *
00011  *     * Redistributions of source code must retain the above copyright
00012  * notice, this list of conditions and the following disclaimer.
00013  *
00014  *     * Redistributions in binary form must reproduce the above
00015  * copyright notice, this list of conditions and the following disclaimer
00016  * in the documentation and/or other materials provided with the
00017  * distribution.
00018  *
00019  *     * The names of its contributors may not be used to endorse or
00020  * promote products derived from this software without specific prior
00021  * written permission.
00022  *
00023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00027  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00028  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00029  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00030  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00031  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  *
00035  */
00036 
00042 #ifndef __DRIZZLE_STRUCTS_H
00043 #define __DRIZZLE_STRUCTS_H
00044 
00045 #include <sys/types.h>
00046 
00047 #ifndef NI_MAXHOST
00048 # define NI_MAXHOST 1025
00049 #endif
00050 
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054 
00058 struct drizzle_st
00059 {
00060   uint16_t error_code;
00061   drizzle_options_t options;
00062   drizzle_verbose_t verbose;
00063   uint32_t con_count;
00064   uint32_t pfds_size;
00065   uint32_t query_count;
00066   uint32_t query_new;
00067   uint32_t query_running;
00068   int last_errno;
00069   int timeout;
00070   drizzle_con_st *con_list;
00071   void *context;
00072   drizzle_context_free_fn *context_free_fn;
00073   drizzle_event_watch_fn *event_watch_fn;
00074   void *event_watch_context;
00075   drizzle_log_fn *log_fn;
00076   void *log_context;
00077   struct pollfd *pfds;
00078   drizzle_query_st *query_list;
00079   char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
00080   char last_error[DRIZZLE_MAX_ERROR_SIZE];
00081 };
00082 
00086 struct drizzle_con_tcp_st
00087 {
00088   in_port_t port;
00089   struct addrinfo *addrinfo;
00090   char *host;
00091   char host_buffer[NI_MAXHOST];
00092 };
00093 
00097 struct drizzle_con_uds_st
00098 {
00099   struct addrinfo addrinfo;
00100   struct sockaddr_un sockaddr;
00101 };
00102 
00106 struct drizzle_con_st
00107 {
00108   uint8_t packet_number;
00109   uint8_t protocol_version;
00110   uint8_t state_current;
00111   short events;
00112   short revents;
00113   drizzle_capabilities_t capabilities;
00114   drizzle_charset_t charset;
00115   drizzle_command_t command;
00116   drizzle_con_options_t options;
00117   drizzle_con_socket_t socket_type;
00118   drizzle_con_status_t status;
00119   uint32_t max_packet_size;
00120   uint32_t result_count;
00121   uint32_t thread_id;
00122   int backlog;
00123   int fd;
00124   size_t buffer_size;
00125   size_t command_offset;
00126   size_t command_size;
00127   size_t command_total;
00128   size_t packet_size;
00129   struct addrinfo *addrinfo_next;
00130   uint8_t *buffer_ptr;
00131   uint8_t *command_buffer;
00132   uint8_t *command_data;
00133   void *context;
00134   drizzle_con_context_free_fn *context_free_fn;
00135   drizzle_st *drizzle;
00136   drizzle_con_st *next;
00137   drizzle_con_st *prev;
00138   drizzle_query_st *query;
00139   drizzle_result_st *result;
00140   drizzle_result_st *result_list;
00141   uint8_t *scramble;
00142   union
00143   {
00144     drizzle_con_tcp_st tcp;
00145     drizzle_con_uds_st uds;
00146   } socket;
00147   uint8_t buffer[DRIZZLE_MAX_BUFFER_SIZE];
00148   char db[DRIZZLE_MAX_DB_SIZE];
00149   char password[DRIZZLE_MAX_PASSWORD_SIZE];
00150   uint8_t scramble_buffer[DRIZZLE_MAX_SCRAMBLE_SIZE];
00151   char server_version[DRIZZLE_MAX_SERVER_VERSION_SIZE];
00152   char server_extra[DRIZZLE_MAX_SERVER_EXTRA_SIZE];
00153   drizzle_state_fn *state_stack[DRIZZLE_STATE_STACK_SIZE];
00154   char user[DRIZZLE_MAX_USER_SIZE];
00155 };
00156 
00160 struct drizzle_query_st
00161 {
00162   drizzle_st *drizzle;
00163   drizzle_query_st *next;
00164   drizzle_query_st *prev;
00165   drizzle_query_options_t options;
00166   drizzle_query_state_t state;
00167   drizzle_con_st *con;
00168   drizzle_result_st *result;
00169   const char *string;
00170   size_t size;
00171   void *context;
00172   drizzle_query_context_free_fn *context_free_fn;
00173 };
00174 
00178 struct drizzle_result_st
00179 {
00180   drizzle_con_st *con;
00181   drizzle_result_st *next;
00182   drizzle_result_st *prev;
00183   drizzle_result_options_t options;
00184 
00185   char info[DRIZZLE_MAX_INFO_SIZE];
00186   uint16_t error_code;
00187   char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
00188   uint64_t insert_id;
00189   uint16_t warning_count;
00190   uint64_t affected_rows;
00191 
00192   uint16_t column_count;
00193   uint16_t column_current;
00194   drizzle_column_st *column_list;
00195   drizzle_column_st *column;
00196   drizzle_column_st *column_buffer;
00197 
00198   uint64_t row_count;
00199   uint64_t row_current;
00200 
00201   uint16_t field_current;
00202   size_t field_total;
00203   size_t field_offset;
00204   size_t field_size;
00205   drizzle_field_t field;
00206   drizzle_field_t field_buffer;
00207 
00208   uint64_t row_list_size;
00209   drizzle_row_t row;
00210   drizzle_row_t *row_list;
00211   size_t *field_sizes;
00212   size_t **field_sizes_list;
00213 };
00214 
00218 struct drizzle_column_st
00219 {
00220   drizzle_result_st *result;
00221   drizzle_column_st *next;
00222   drizzle_column_st *prev;
00223   drizzle_column_options_t options;
00224   char catalog[DRIZZLE_MAX_CATALOG_SIZE];
00225   char db[DRIZZLE_MAX_DB_SIZE];
00226   char table[DRIZZLE_MAX_TABLE_SIZE];
00227   char orig_table[DRIZZLE_MAX_TABLE_SIZE];
00228   char name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
00229   char orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
00230   drizzle_charset_t charset;
00231   uint32_t size;
00232   size_t max_size;
00233   drizzle_column_type_t type;
00234   drizzle_column_flags_t flags;
00235   uint8_t decimals;
00236   uint8_t default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE];
00237   size_t default_value_size;
00238 };
00239 
00240 #ifdef __cplusplus
00241 }
00242 #endif
00243 
00244 #endif /* __DRIZZLE_STRUCTS_H */