mysql4_com.pp 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. unit mysql4_com;
  2. interface
  3. {
  4. Automatically converted by H2Pas 0.99.15 from mysql_com.ph
  5. The following command line parameters were used:
  6. -p
  7. -D
  8. -l
  9. mysqlclient
  10. mysql_com.ph
  11. }
  12. const
  13. External_library='mysqlclient'; {Setup as you need}
  14. { Pointers to basic pascal types, inserted by h2pas conversion program.}
  15. Type
  16. PLongint = ^Longint;
  17. PSmallInt = ^SmallInt;
  18. PByte = ^Byte;
  19. PWord = ^Word;
  20. PDWord = ^DWord;
  21. PDouble = ^Double;
  22. { Extra manually added types }
  23. PVIO = Pointer;
  24. My_socket = longint;
  25. my_bool = byte;
  26. pppchar = ^PPChar;
  27. gptr = Pointer;
  28. {$PACKRECORDS C}
  29. { Copyright (C) 2000 MySQL AB
  30. This program is free software; you can redistribute it and/or modify
  31. it under the terms of the GNU General Public License as published by
  32. the Free Software Foundation; either version 2 of the License, or
  33. (at your option) any later version.
  34. This program is distributed in the hope that it will be useful,
  35. but WITHOUT ANY WARRANTY; without even the implied warranty of
  36. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  37. GNU General Public License for more details.
  38. You should have received a copy of the GNU General Public License
  39. along with this program; if not, write to the Free Software
  40. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA }
  41. {
  42. Common definition between mysql server & client
  43. }
  44. { Field/table name length }
  45. const
  46. NAME_LEN = 64;
  47. HOSTNAME_LENGTH = 60;
  48. USERNAME_LENGTH = 16;
  49. SERVER_VERSION_LENGTH = 60;
  50. LOCAL_HOST = 'localhost';
  51. LOCAL_HOST_NAMEDPIPE = '.';
  52. type
  53. enum_server_command = (COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
  54. COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,
  55. COM_REFRESH,COM_SHUTDOWN,COM_STATISTICS,
  56. COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
  57. COM_DEBUG,COM_PING,COM_TIME,COM_DELAYED_INSERT,
  58. COM_CHANGE_USER,COM_BINLOG_DUMP,COM_TABLE_DUMP,
  59. COM_CONNECT_OUT,COM_REGISTER_SLAVE);
  60. { Field can't be NULL }
  61. const
  62. NOT_NULL_FLAG = 1;
  63. PRI_KEY_FLAG = 2;
  64. UNIQUE_KEY_FLAG = 4;
  65. MULTIPLE_KEY_FLAG = 8;
  66. BLOB_FLAG = 16;
  67. UNSIGNED_FLAG = 32;
  68. ZEROFILL_FLAG = 64;
  69. BINARY_FLAG = 128;
  70. ENUM_FLAG = 256;
  71. AUTO_INCREMENT_FLAG = 512;
  72. TIMESTAMP_FLAG = 1024;
  73. SET_FLAG = 2048;
  74. NUM_FLAG = 32768;
  75. PART_KEY_FLAG = 16384;
  76. GROUP_FLAG = 32768;
  77. UNIQUE_FLAG = 65536;
  78. REFRESH_GRANT = 1;
  79. REFRESH_LOG = 2;
  80. REFRESH_TABLES = 4;
  81. REFRESH_HOSTS = 8;
  82. REFRESH_STATUS = 16;
  83. REFRESH_THREADS = 32;
  84. REFRESH_SLAVE = 64;
  85. REFRESH_MASTER = 128;
  86. REFRESH_READ_LOCK = 16384;
  87. REFRESH_FAST = 32768;
  88. REFRESH_QUERY_CACHE = 65536;
  89. REFRESH_QUERY_CACHE_FREE = $20000;
  90. REFRESH_DES_KEY_FILE = $40000;
  91. CLIENT_LONG_PASSWORD = 1;
  92. CLIENT_FOUND_ROWS = 2;
  93. CLIENT_LONG_FLAG = 4;
  94. CLIENT_CONNECT_WITH_DB = 8;
  95. CLIENT_NO_SCHEMA = 16;
  96. CLIENT_COMPRESS = 32;
  97. CLIENT_ODBC = 64;
  98. CLIENT_LOCAL_FILES = 128;
  99. CLIENT_IGNORE_SPACE = 256;
  100. CLIENT_CHANGE_USER = 512;
  101. CLIENT_INTERACTIVE = 1024;
  102. CLIENT_SSL = 2048;
  103. CLIENT_IGNORE_SIGPIPE = 4096;
  104. CLIENT_TRANSACTIONS = 8192;
  105. SERVER_STATUS_IN_TRANS = 1;
  106. SERVER_STATUS_AUTOCOMMIT = 2;
  107. MYSQL_ERRMSG_SIZE = 200;
  108. NET_READ_TIMEOUT = 30;
  109. NET_WRITE_TIMEOUT = 60;
  110. MAX_BLOB_WIDTH = 8192;
  111. {
  112. #define NET_WAIT_TIMEOUT (8 60 60)
  113. }
  114. {
  115. struct st_vio; // Only C
  116. typedef struct st_vio Vio;
  117. }
  118. type
  119. Pst_net = ^st_net;
  120. st_net = record
  121. vio : PVio;
  122. buff : Pbyte;
  123. buff_end : Pbyte;
  124. write_pos : Pbyte;
  125. read_pos : Pbyte;
  126. fd : my_socket;
  127. max_packet : dword;
  128. max_packet_size : dword;
  129. last_errno : dword;
  130. pkt_nr : dword;
  131. compress_pkt_nr : dword;
  132. write_timeout : dword;
  133. read_timeout : dword;
  134. retry_count : dword;
  135. fcntl : longint;
  136. last_error : array[0..(MYSQL_ERRMSG_SIZE)-1] of char;
  137. error : byte;
  138. return_errno : my_bool;
  139. compress : my_bool;
  140. remain_in_buf : dword;
  141. length : dword;
  142. buf_length : dword;
  143. where_b : dword;
  144. return_status : Pdword;
  145. reading_or_writing : byte;
  146. save_char : char;
  147. no_send_ok : my_bool;
  148. query_cache_query : gptr;
  149. end;
  150. NET = st_net;
  151. TNET = NET;
  152. PNET = ^NET;
  153. function packet_error : longint;
  154. type
  155. enum_field_types = (FIELD_TYPE_DECIMAL,FIELD_TYPE_TINY,FIELD_TYPE_SHORT,
  156. FIELD_TYPE_LONG,FIELD_TYPE_FLOAT,FIELD_TYPE_DOUBLE,
  157. FIELD_TYPE_NULL,FIELD_TYPE_TIMESTAMP,
  158. FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
  159. FIELD_TYPE_DATE,FIELD_TYPE_TIME,FIELD_TYPE_DATETIME,
  160. FIELD_TYPE_YEAR,FIELD_TYPE_NEWDATE,FIELD_TYPE_ENUM := 247,
  161. FIELD_TYPE_SET := 248,FIELD_TYPE_TINY_BLOB := 249,
  162. FIELD_TYPE_MEDIUM_BLOB := 250,FIELD_TYPE_LONG_BLOB := 251,
  163. FIELD_TYPE_BLOB := 252,FIELD_TYPE_VAR_STRING := 253,
  164. FIELD_TYPE_STRING := 254);
  165. { For compability }
  166. const
  167. FIELD_TYPE_CHAR = FIELD_TYPE_TINY;
  168. { For compability }
  169. FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM;
  170. {
  171. #define net_new_transaction(net) ((net)->pkt_nr=0)
  172. }
  173. var
  174. max_allowed_packet : dword;cvar;external;
  175. net_buffer_length : dword;cvar;external;
  176. function my_net_init(net:PNET; vio:PVio):longint;cdecl;external External_library name 'my_net_init';
  177. procedure net_end(net:PNET);cdecl;external External_library name 'net_end';
  178. procedure net_clear(net:PNET);cdecl;external External_library name 'net_clear';
  179. function net_flush(net:PNET):longint;cdecl;external External_library name 'net_flush';
  180. (* Const before type ignored *)
  181. function my_net_write(net:PNET; packet:Pchar; len:dword):longint;cdecl;external External_library name 'my_net_write';
  182. (* Const before type ignored *)
  183. function net_write_command(net:PNET; command:byte; packet:Pchar; len:dword):longint;cdecl;external External_library name 'net_write_command';
  184. (* Const before type ignored *)
  185. function net_real_write(net:PNET; packet:Pchar; len:dword):longint;cdecl;external External_library name 'net_real_write';
  186. function my_net_read(net:PNET):dword;cdecl;external External_library name 'my_net_read';
  187. { The following function is not meant for normal usage }
  188. {
  189. struct sockaddr;
  190. int my_connect(my_socket s, const struct sockaddr name, unsigned int namelen,
  191. unsigned int timeout);
  192. }
  193. type
  194. Prand_struct = ^rand_struct;
  195. rand_struct = record
  196. seed1 : dword;
  197. seed2 : dword;
  198. max_value : dword;
  199. max_value_dbl : double;
  200. end;
  201. { The following is for user defined functions }
  202. Item_result = (STRING_RESULT,REAL_RESULT,INT_RESULT
  203. );
  204. pitem_result = ^item_result;
  205. { Number of arguments }
  206. { Pointer to item_results }
  207. { Pointer to argument }
  208. { Length of string arguments }
  209. { Set to 1 for all maybe_null args }
  210. Pst_udf_args = ^st_udf_args;
  211. st_udf_args = record
  212. arg_count : dword;
  213. arg_type : PItem_result;
  214. args : ^Pchar;
  215. lengths : Pdword;
  216. maybe_null : Pchar;
  217. end;
  218. UDF_ARGS = st_udf_args;
  219. PUDF_ARGS = ^UDF_ARGS;
  220. { This holds information about the result }
  221. { 1 if function can return NULL }
  222. { for real functions }
  223. { For string functions }
  224. { free pointer for function data }
  225. { 0 if result is independent of arguments }
  226. Pst_udf_init = ^st_udf_init;
  227. st_udf_init = record
  228. maybe_null : my_bool;
  229. decimals : dword;
  230. max_length : dword;
  231. ptr : Pchar;
  232. const_item : my_bool;
  233. end;
  234. UDF_INIT = st_udf_init;
  235. PUDF_INIT = ^UDF_INIT;
  236. { Constants when using compression }
  237. { standard header size }
  238. const
  239. NET_HEADER_SIZE = 4;
  240. { compression header extra size }
  241. COMP_HEADER_SIZE = 3;
  242. { Prototypes to password functions }
  243. procedure randominit(_para1:Prand_struct; seed1:dword; seed2:dword);cdecl;external External_library name 'randominit';
  244. function rnd(_para1:Prand_struct):double;cdecl;external External_library name 'rnd';
  245. (* Const before type ignored *)
  246. procedure make_scrambled_password(_to:Pchar; password:Pchar);cdecl;external External_library name 'make_scrambled_password';
  247. (* Const before type ignored *)
  248. procedure get_salt_from_password(res:Pdword; password:Pchar);cdecl;external External_library name 'get_salt_from_password';
  249. procedure make_password_from_salt(_to:Pchar; hash_res:Pdword);cdecl;external External_library name 'make_password_from_salt';
  250. (* Const before type ignored *)
  251. (* Const before type ignored *)
  252. function scramble(_to:Pchar; message:Pchar; password:Pchar; old_ver:my_bool):Pchar;cdecl;external External_library name 'scramble';
  253. (* Const before type ignored *)
  254. (* Const before type ignored *)
  255. function check_scramble(_para1:Pchar; message:Pchar; salt:Pdword; old_ver:my_bool):my_bool;cdecl;external External_library name 'check_scramble';
  256. function get_tty_password(opt_message:Pchar):Pchar;cdecl;external External_library name 'get_tty_password';
  257. (* Const before type ignored *)
  258. procedure hash_password(result:Pdword; password:Pchar);cdecl;external External_library name 'hash_password';
  259. { Some other useful functions }
  260. procedure my_init;cdecl;external External_library name 'my_init';
  261. (* Const before type ignored *)
  262. (* Const before type ignored *)
  263. procedure load_defaults(conf_file:Pchar; groups:PPchar; argc:Plongint; argv:PPPchar);cdecl;external External_library name 'load_defaults';
  264. function my_thread_init:my_bool;cdecl;external External_library name 'my_thread_init';
  265. procedure my_thread_end;cdecl;external External_library name 'my_thread_end';
  266. { For net_store_length }
  267. { was #define dname def_expr }
  268. function NULL_LENGTH : dword;
  269. implementation
  270. { was #define dname def_expr }
  271. function packet_error : longint;
  272. { return type might be wrong }
  273. begin
  274. packet_error:= not (dword(0));
  275. end;
  276. { was #define dname def_expr }
  277. function NULL_LENGTH : dword;
  278. begin
  279. NULL_LENGTH:=dword( not (0));
  280. end;
  281. end.