From ce27ade7d565951ef66a6520f0cf966226937a74 Mon Sep 17 00:00:00 2001 From: Abscissa Date: Sat, 23 Jul 2011 21:35:26 -0400 Subject: [PATCH 1/2] Adjusted mysql.d to work on Windows. --- mysql.d | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/mysql.d b/mysql.d index ae50ffc..9933ef3 100644 --- a/mysql.d +++ b/mysql.d @@ -1,5 +1,10 @@ module arsd.mysql; -pragma(lib, "mysqlclient"); +version(Windows) { + pragma(lib, "libmysql"); +} +else { + pragma(lib, "mysqlclient"); +} public import arsd.database; @@ -8,6 +13,18 @@ import std.exception; import std.string; import std.conv; import std.typecons; +import core.stdc.config; + +version(Windows) { + extern(Windows) { + mixin(mySqlDecl); + } +} +else { + extern(C) { + mixin(mySqlDecl); + } +} class MySqlResult : ResultSet { private int[string] mapping; @@ -564,7 +581,7 @@ struct ResultByDataObject { MySql mysql; } -extern(C) { +enum mySqlDecl = q{ typedef void MYSQL; typedef void MYSQL_RES; typedef const(ubyte)* cstring; @@ -600,7 +617,7 @@ extern(C) { uint mysql_errno(MYSQL*); cstring mysql_error(MYSQL*); - MYSQL* mysql_real_connect(MYSQL*, cstring, cstring, cstring, cstring, uint, cstring, ulong); + MYSQL* mysql_real_connect(MYSQL*, cstring, cstring, cstring, cstring, uint, cstring, c_ulong); int mysql_query(MYSQL*, cstring); @@ -625,7 +642,7 @@ extern(C) { void mysql_free_result(MYSQL_RES*); -} +}; import std.string; cstring toCstring(string c) { From 1fd6272210d27d6aa54b5f680aaaf21af7225bb6 Mon Sep 17 00:00:00 2001 From: Abscissa Date: Tue, 26 Jul 2011 02:22:13 -0400 Subject: [PATCH 2/2] Fixed MYSQL_FIELD for MySQL client >= v5.1 --- mysql.d | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql.d b/mysql.d index 14d68b7..8027c95 100644 --- a/mysql.d +++ b/mysql.d @@ -1,3 +1,5 @@ +/// NOTE: If you're using MySQL client library v5.1 or greater, +/// you must pass this to dmd: -version=MySQL_51 module arsd.mysql; version(Windows) { pragma(lib, "libmysql"); @@ -597,6 +599,10 @@ extern(System) { uint charsetnr; /* Character set */ uint type; /* Type of field. See mysql_com.h for types */ // type is actually an enum btw + + version(MySQL_51) { + void* extension; + } } typedef cstring* MYSQL_ROW;