G:/ScriptBasic/source/extensions/mysql/mysql.h

Go to the documentation of this file.
00001 /* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
00002    This file is public domain and comes with NO WARRANTY of any kind */
00003 
00004 /* defines for libmysql */
00005 
00006 #ifndef _mysql_h
00007 #define _mysql_h
00008 #ifdef  __cplusplus
00009 extern "C" {
00010 #endif
00011 
00012 #ifndef _global_h                               /* If not standard header */
00013 #include <sys/types.h>
00014 typedef char my_bool;
00015 #if !defined(__WIN32__) && !defined(WIN32)
00016 #define STDCALL
00017 #else
00018 #define STDCALL __stdcall
00019 #endif
00020 typedef char * gptr;
00021 
00022 #ifndef ST_USED_MEM_DEFINED
00023 #define ST_USED_MEM_DEFINED
00024 typedef struct st_used_mem {                    /* struct for once_alloc */
00025   struct st_used_mem *next;                     /* Next block in use */
00026   unsigned int  left;                           /* memory left in block  */
00027   unsigned int  size;                           /* size of block */
00028 } USED_MEM;
00029 typedef struct st_mem_root {
00030   USED_MEM *free;
00031   USED_MEM *used;
00032   unsigned int  min_malloc;
00033   unsigned int  block_size;
00034   void (*error_handler)(void);
00035 } MEM_ROOT;
00036 #endif
00037 
00038 #ifndef Socket_defined
00039 #ifdef __WIN32__
00040 #define Socket SOCKET
00041 #else
00042 typedef int Socket;
00043 #endif
00044 #endif
00045 #endif
00046 #include "mysql_com.h"
00047 #include "mysql_version.h"
00048 
00049 extern unsigned int mysql_port;
00050 extern char *mysql_unix_port;
00051 
00052 #define IS_PRI_KEY(n)   ((n) & PRI_KEY_FLAG)
00053 #define IS_NOT_NULL(n)  ((n) & NOT_NULL_FLAG)
00054 #define IS_BLOB(n)      ((n) & BLOB_FLAG)
00055 #define IS_NUM(t)       ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR)
00056 
00057 typedef struct st_mysql_field {
00058   char *name;                   /* Name of column */
00059   char *table;                  /* Table of column if column was a field */
00060   char *def;                    /* Default value (set by mysql_list_fields) */
00061   enum enum_field_types type;   /* Type of field. Se mysql_com.h for types */
00062   unsigned int length;          /* Width of column */
00063   unsigned int max_length;      /* Max width of selected set */
00064   unsigned int flags;           /* Div flags */
00065   unsigned int decimals;        /* Number of decimals in field */
00066 } MYSQL_FIELD;
00067 
00068 typedef char **MYSQL_ROW;               /* return data as array of strings */
00069 typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
00070 
00071 typedef struct st_mysql_rows {
00072   struct st_mysql_rows *next;           /* list of rows */
00073   MYSQL_ROW data;
00074 } MYSQL_ROWS;
00075 
00076 typedef MYSQL_ROWS *MYSQL_ROW_OFFSET;   /* offset to current row */
00077 
00078 typedef struct st_mysql_data {
00079   unsigned int rows;
00080   unsigned int fields;
00081   MYSQL_ROWS *data;
00082   MEM_ROOT alloc;
00083 } MYSQL_DATA;
00084 
00085 struct st_mysql_options {
00086   unsigned int connect_timeout;
00087   my_bool compress;
00088 };
00089 
00090 enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS };
00091 
00092 enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
00093                     MYSQL_STATUS_USE_RESULT};
00094 
00095 typedef struct st_mysql {
00096   NET           net;                    /* Communication parameters */
00097   char          *host,*user,*passwd,*unix_socket,*server_version,*host_info,
00098                 *info,*db;
00099   unsigned int  port,client_flag,server_capabilities;
00100   unsigned int  protocol_version;
00101   unsigned int  field_count;
00102   unsigned long thread_id;              /* Id for connection in server */
00103   unsigned long affected_rows;
00104   unsigned long insert_id;              /* id if insert on table with NEXTNR */
00105   unsigned long extra_info;             /* Used by mysqlshow */
00106   enum mysql_status status;
00107   MYSQL_FIELD   *fields;
00108   MEM_ROOT      field_alloc;
00109   my_bool       free_me;                /* If free in mysql_close */
00110   my_bool       reconnect;              /* set to 1 if automatic reconnect */
00111   struct st_mysql_options options;
00112 } MYSQL;
00113 
00114 
00115 typedef struct st_mysql_res {
00116   unsigned long row_count;
00117   unsigned int  field_count, current_field;
00118   MYSQL_FIELD   *fields;
00119   MYSQL_DATA    *data;
00120   MYSQL_ROWS    *data_cursor;
00121   MEM_ROOT      field_alloc;
00122   MYSQL_ROW     row;                    /* If unbuffered read */
00123   MYSQL_ROW     current_row;            /* buffer to current row */
00124   unsigned int  *lengths;               /* column lengths of current row */
00125   MYSQL         *handle;                /* for unbuffered reads */
00126   my_bool       eof;                    /* Used my mysql_fetch_row */
00127 } MYSQL_RES;
00128 
00129 
00130 #define mysql_num_rows(res) (res)->row_count
00131 #define mysql_num_fields(res) (res)->field_count
00132 #define mysql_eof(res) (res)->eof
00133 #define mysql_fetch_field_direct(res,fieldnr) ((res)->fields[fieldnr])
00134 #define mysql_fetch_fields(res) (res)->fields
00135 #define mysql_row_tell(res) (res)->data_cursor
00136 #define mysql_field_tell(res) (res)->current_field
00137 
00138 #define mysql_affected_rows(mysql) (mysql)->affected_rows
00139 #define mysql_insert_id(mysql) (mysql)->insert_id
00140 #define mysql_error(mysql) (mysql)->net.last_error
00141 #define mysql_errno(mysql) (mysql)->net.last_errno
00142 #define mysql_info(mysql) (mysql)->info
00143 #define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
00144 #define mysql_thread_id(mysql) (mysql)->thread_id
00145 
00146 MYSQL *         STDCALL mysql_init(MYSQL *mysql);
00147 MYSQL *         STDCALL mysql_connect(MYSQL *mysql, const char *host,
00148                                       const char *user, const char *passwd);
00149 #if MYSQL_VERSION_ID >= 32200
00150 MYSQL *         STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
00151                                            const char *user,
00152                                            const char *passwd,
00153                                            const char *db,
00154                                            unsigned int port,
00155                                            const char *unix_socket,
00156                                            unsigned int clientflag);
00157 #else
00158 MYSQL *         STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
00159                                            const char *user,
00160                                            const char *passwd,
00161                                            unsigned int port,
00162                                            const char *unix_socket,
00163                                            unsigned int clientflag);
00164 #endif
00165 void            STDCALL mysql_close(MYSQL *sock);
00166 int             STDCALL mysql_select_db(MYSQL *mysql, const char *db);
00167 int             STDCALL mysql_query(MYSQL *mysql, const char *q);
00168 int             STDCALL mysql_real_query(MYSQL *mysql, const char *q,
00169                                         unsigned int length);
00170 int             STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
00171 int             STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
00172 int             STDCALL mysql_shutdown(MYSQL *mysql);
00173 int             STDCALL mysql_dump_debug_info(MYSQL *mysql);
00174 int             STDCALL mysql_refresh(MYSQL *mysql,
00175                                      unsigned int refresh_options);
00176 int             STDCALL mysql_kill(MYSQL *mysql,unsigned long pid);
00177 int             STDCALL mysql_ping(MYSQL *mysql);
00178 char *          STDCALL mysql_stat(MYSQL *mysql);
00179 char *          STDCALL mysql_get_server_info(MYSQL *mysql);
00180 char *          STDCALL mysql_get_client_info(void);
00181 char *          STDCALL mysql_get_host_info(MYSQL *mysql);
00182 unsigned int    STDCALL mysql_get_proto_info(MYSQL *mysql);
00183 MYSQL_RES *     STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
00184 MYSQL_RES *     STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
00185 MYSQL_RES *     STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
00186                                          const char *wild);
00187 MYSQL_RES *     STDCALL mysql_list_processes(MYSQL *mysql);
00188 MYSQL_RES *     STDCALL mysql_store_result(MYSQL *mysql);
00189 MYSQL_RES *     STDCALL mysql_use_result(MYSQL *mysql);
00190 int             STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
00191                                       const char *arg);
00192 void            STDCALL mysql_free_result(MYSQL_RES *result);
00193 void            STDCALL mysql_data_seek(MYSQL_RES *mysql,unsigned int offset);
00194 MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *mysql, MYSQL_ROW_OFFSET);
00195 MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *mysql,
00196                                            MYSQL_FIELD_OFFSET offset);
00197 MYSQL_ROW       STDCALL mysql_fetch_row(MYSQL_RES *mysql);
00198 unsigned int *  STDCALL mysql_fetch_lengths(MYSQL_RES *mysql);
00199 MYSQL_FIELD *   STDCALL mysql_fetch_field(MYSQL_RES *handle);
00200 unsigned int    STDCALL mysql_escape_string(char *to,const char *from,
00201                                             unsigned int from_length);
00202 void            STDCALL mysql_debug(char *debug);
00203 
00204 /* new api functions */
00205 
00206 #define HAVE_MYSQL_REAL_CONNECT
00207 
00208 #ifdef  __cplusplus
00209 }
00210 #endif
00211 #endif

Generated on Sun Mar 12 23:56:30 2006 for ScriptBasic by  doxygen 1.4.6-NO