2
Contains the MySQL_com functions calls
4
Call InitialiseMysql3_com before using any of the calls, and call ReleaseMysql3_com
10
Adapted from mysql4_comdyn by Bram Kuijvenhoven (Hexis BV, The Netherlands)
18
uses dynlibs, sysutils;
21
{$DEFINE extdecl:=cdecl}
23
Mysqllib = 'libmysqlclient.'+sharedsuffix;
26
{$DEFINE extdecl:=stdcall}
28
Mysqllib = 'libmysql.dll';
33
{$i mysql3_comtypes.inc}
36
sql_free : procedure(root : PMEM_ROOT);extdecl;
37
init_alloc_root : procedure(root: PMEM_ROOT;block_size : Cardinal);extdecl;
38
sql_alloc_first_block : function(root : PMEM_ROOT) : my_bool;extdecl;
39
sql_alloc_root : function(mem_root : PMEM_ROOT;len : Cardinal) : longint;extdecl;
40
sql_strdup_root : function(root : PMEM_ROOT;st : pchar) : pchar;extdecl;
41
sql_memdup_root : function(root: PMEM_ROOT;st : pchar; len : Cardinal) : longint;extdecl;
42
my_net_init : function(net :PNET; fd : Socket) : Longint;extdecl;
43
net_end : procedure(net : PNET);extdecl;
44
net_clear : procedure(net : PNET);extdecl;
45
net_flush : function(net : PNET) : longint;extdecl;
46
my_net_write : function(net : PNET;packet : pbyte;len : cardinal) : longint;extdecl;
47
net_write_command : function(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;extdecl;
48
net_real_write : function(net : PNET;packet : pbyte; len : Cardinal) : longint;extdecl;
49
my_net_read : function(net : PNET) : Cardinal;extdecl;
50
randominit : procedure(rand : Prand_struct; seed1,seed2 : Cardinal);extdecl;
51
rnd : function(rand : Prand_struct) : double;extdecl;
52
make_scrambled_password : procedure(toarg, passwd : Pchar);extdecl;
53
get_salt_from_password : procedure(res : pcardinal; password : pchar);extdecl;
54
scramble : procedure(toarg,message,password : pchar; old_ver : my_bool);extdecl;
55
check_scramble : function(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;extdecl;
56
get_tty_password : function(opt_message: pchar) : pchar;extdecl;
58
Procedure InitialiseMysql3_com;
59
Procedure ReleaseMysql3_com;
61
var Mysql3_comLibraryHandle : TLibHandle;
65
var RefCount : integer;
67
Procedure InitialiseMysql3_com;
73
Mysql3_comLibraryHandle := loadlibrary(Mysqllib);
74
if Mysql3_comLibraryHandle = nilhandle then
77
Raise EInOutError.Create('Can not load MySQL client. Is it installed? ('+Mysqllib+')');
80
pointer(sql_free) := GetProcedureAddress(Mysql3_comLibraryHandle,'sql_free');
81
pointer(init_alloc_root) := GetProcedureAddress(Mysql3_comLibraryHandle,'init_alloc_root');
82
pointer(sql_alloc_first_block) := GetProcedureAddress(Mysql3_comLibraryHandle,'sql_alloc_first_block');
83
pointer(sql_alloc_root) := GetProcedureAddress(Mysql3_comLibraryHandle,'sql_alloc_root');
84
pointer(sql_strdup_root) := GetProcedureAddress(Mysql3_comLibraryHandle,'sql_strdup_root');
85
pointer(sql_memdup_root) := GetProcedureAddress(Mysql3_comLibraryHandle,'sql_memdup_root');
86
pointer(my_net_init) := GetProcedureAddress(Mysql3_comLibraryHandle,'my_net_init');
87
pointer(net_end) := GetProcedureAddress(Mysql3_comLibraryHandle,'net_end');
88
pointer(net_clear) := GetProcedureAddress(Mysql3_comLibraryHandle,'net_clear');
89
pointer(net_flush) := GetProcedureAddress(Mysql3_comLibraryHandle,'net_flush');
90
pointer(my_net_write) := GetProcedureAddress(Mysql3_comLibraryHandle,'my_net_write');
91
pointer(net_write_command) := GetProcedureAddress(Mysql3_comLibraryHandle,'net_write_command');
92
pointer(net_real_write) := GetProcedureAddress(Mysql3_comLibraryHandle,'net_real_write');
93
pointer(my_net_read) := GetProcedureAddress(Mysql3_comLibraryHandle,'my_net_read');
94
pointer(randominit) := GetProcedureAddress(Mysql3_comLibraryHandle,'randominit');
95
pointer(rnd) := GetProcedureAddress(Mysql3_comLibraryHandle,'rnd');
96
pointer(make_scrambled_password) := GetProcedureAddress(Mysql3_comLibraryHandle,'make_scrambled_password');
97
pointer(get_salt_from_password) := GetProcedureAddress(Mysql3_comLibraryHandle,'get_salt_from_password');
98
pointer(scramble) := GetProcedureAddress(Mysql3_comLibraryHandle,'scramble');
99
pointer(check_scramble) := GetProcedureAddress(Mysql3_comLibraryHandle,'check_scramble');
100
pointer(get_tty_password) := GetProcedureAddress(Mysql3_comLibraryHandle,'get_tty_password');
104
Procedure ReleaseMysql3_com;
107
if RefCount > 0 then dec(RefCount);
110
if not UnloadLibrary(Mysql3_comLibraryHandle) then inc(RefCount);