G:/ScriptBasic/source/extensions/mysql/mysql_com.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 /*
00005 ** Common definition between mysql server & client
00006 */
00007 
00008 #ifndef _mysql_com_h
00009 #define _mysql_com_h
00010 #ifdef  __cplusplus
00011 extern "C" {
00012 #endif
00013 
00014 #define NAME_LEN        64              /* Field/table name length */
00015 #define LOCAL_HOST      "localhost"
00016 
00017 #define MYSQL_PORT      3306            /* Alloced by ISI for MySQL */
00018 #define MYSQL_UNIX_ADDR "/tmp/mysql.sock"
00019 
00020 enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
00021                           COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
00022                           COM_SHUTDOWN,COM_STATISTICS,
00023                           COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
00024                           COM_DEBUG,COM_PING};
00025 
00026 #define NOT_NULL_FLAG   1               /* Field can't be NULL */
00027 #define PRI_KEY_FLAG    2               /* Field is part of a primary key */
00028 #define UNIQUE_KEY_FLAG 4               /* Field is part of a unique key */
00029 #define MULTIPLE_KEY_FLAG 8             /* Field is part of a key */
00030 #define BLOB_FLAG       16              /* Field is a blob */
00031 #define UNSIGNED_FLAG   32              /* Field is unsigned */
00032 #define ZEROFILL_FLAG   64              /* Field is zerofill */
00033 #define BINARY_FLAG     128
00034 /* The following are only sent to new clients */
00035 #define ENUM_FLAG       256             /* field is an enum */
00036 #define AUTO_INCREMENT_FLAG 512         /* field is a autoincrement field */
00037 #define TIMESTAMP_FLAG  1024            /* Field is a timestamp */
00038 #define PART_KEY_FLAG   16384           /* Intern; Part of some key */
00039 #define GROUP_FLAG      32768           /* Intern group field */
00040 
00041 #define REFRESH_GRANT           1       /* Refresh grant tables */
00042 #define REFRESH_LOG             2       /* Start on new log file */
00043 #define REFRESH_TABLES          4       /* close all tables */
00044 #define REFRESH_HOSTS           8       /* Flush host cache */
00045 #define REFRESH_FAST            32768   /* Intern flag */
00046 
00047 #define CLIENT_LONG_PASSWORD    1       /* new more secure passwords */
00048 #define CLIENT_FOUND_ROWS       2       /* Found instead of affected rows */
00049 #define CLIENT_LONG_FLAG        4       /* Get all column flags */
00050 #define CLIENT_CONNECT_WITH_DB  8       /* One can specify db on connect */
00051 #define CLIENT_NO_SCHEMA        16      /* Don't allow database.table.column */
00052 #define CLIENT_COMPRESS         32      /* Can use compression protcol */
00053 #define CLIENT_ODBC             64      /* Odbc client */
00054 
00055 #define MYSQL_ERRMSG_SIZE 200
00056 #define NET_READ_TIMEOUT 30                     /* Timeout on read */
00057 #define NET_WRITE_TIMEOUT 60                    /* Timeout on write */
00058 #define NET_WAIT_TIMEOUT 8*60*60                /* Wait for new query */
00059 
00060 typedef struct st_net {
00061   Socket fd;
00062   int fcntl;
00063   unsigned char *buff,*buff_end,*write_pos;
00064   char last_error[MYSQL_ERRMSG_SIZE];
00065   unsigned int last_errno,max_packet,timeout,pkt_nr;
00066   my_bool error,return_errno,compress;
00067 } NET;
00068 
00069 #define packet_error ((unsigned int) -1)
00070 
00071 enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
00072                         FIELD_TYPE_SHORT,  FIELD_TYPE_LONG,
00073                         FIELD_TYPE_FLOAT,  FIELD_TYPE_DOUBLE,
00074                         FIELD_TYPE_NULL,   FIELD_TYPE_TIMESTAMP,
00075                         FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
00076                         FIELD_TYPE_DATE,   FIELD_TYPE_TIME,
00077                         FIELD_TYPE_DATETIME, FIELD_TYPE_YEAR,
00078                         FIELD_TYPE_NEWDATE,
00079                         FIELD_TYPE_ENUM=247,
00080                         FIELD_TYPE_SET=248,
00081                         FIELD_TYPE_TINY_BLOB=249,
00082                         FIELD_TYPE_MEDIUM_BLOB=250,
00083                         FIELD_TYPE_LONG_BLOB=251,
00084                         FIELD_TYPE_BLOB=252,
00085                         FIELD_TYPE_VAR_STRING=253,
00086                         FIELD_TYPE_STRING=254
00087 };
00088 
00089 #define FIELD_TYPE_CHAR FIELD_TYPE_TINY         /* For compability */
00090 #define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM     /* For compability */
00091 
00092 extern unsigned long max_allowed_packet;
00093 extern unsigned long net_buffer_length;
00094 
00095 #define net_new_transaction(net) ((net)->pkt_nr=0)
00096 int     my_net_init(NET *net,Socket fd);
00097 void    net_end(NET *net);
00098 void    net_clear(NET *net);
00099 int     net_flush(NET *net);
00100 int     my_net_write(NET *net,char *packet,unsigned long len);
00101 int     net_write_command(NET *net,unsigned char command,const char *packet,
00102                           unsigned long len);
00103 int     net_real_write(NET *net,const char *packet,unsigned long len);
00104 unsigned int    my_net_read(NET *net);
00105 
00106 struct rand_struct {
00107   unsigned long seed,seed2,max_value;
00108   double max_value_dbl;
00109 };
00110 
00111   /* The following is for user defined functions */
00112 
00113 enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT};
00114 
00115 typedef struct st_udf_args
00116 {
00117   unsigned int arg_count;               /* Number of arguments */
00118   enum Item_result *arg_type;           /* Pointer to item_results */
00119   char **args;                          /* Pointer to argument */
00120   unsigned long *lengths;               /* Length of string arguments */
00121 } UDF_ARGS;
00122 
00123   /* This holds information about the result */
00124 
00125 typedef struct st_udf_init
00126 {
00127   my_bool maybe_null;                   /* 1 if function can return NULL */
00128   unsigned int decimals;                /* for real functions */
00129   unsigned int max_length;              /* For string functions */
00130   char    *ptr;                         /* free pointer for function data */
00131 } UDF_INIT;
00132 
00133   /* Constants when using compression */
00134 #define NET_HEADER_SIZE 4               /* standard header size */
00135 #define COMP_HEADER_SIZE 3              /* compression header extra size */
00136 
00137   /* Prototypes to password functions */
00138 
00139 void randominit(struct rand_struct *rand,unsigned long seed1,
00140                 unsigned long seed2);
00141 double rnd(struct rand_struct *rand);
00142 void make_scrambled_password(char *to,const char *password);
00143 void get_salt_from_password(unsigned long *res,const char *password);
00144 char *scramble(char *to,const char *message,const char *password,
00145                my_bool old_ver);
00146 my_bool check_scramble(const char *scramble,const char *message,
00147                        unsigned long *salt,my_bool old_ver);
00148 char *get_tty_password(char *opt_message);
00149 
00150 #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
00151 
00152 #ifdef __WIN32__
00153 #define socket_errno WSAGetLastError()
00154 #else
00155 #define socket_errno errno
00156 #endif
00157 
00158 #ifdef  __cplusplus
00159 }
00160 #endif
00161 #endif

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