=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2014-06-25 12:53:11 +0000
+++ CMakeLists.txt	2014-08-08 15:16:52 +0000
@@ -67,9 +67,11 @@
   INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/win)
   SET(ODBC_LIBS odbc32)
   SET(ODBC_INSTLIBS odbccp32)
+  SET (MARIADB_ODBC_SOURCES ${MARIADB_ODBC_SOURCES} ma_platform_win32.c)
 ELSE()
-
+  SET (MARIADB_ODBC_SOURCES ${MARIADB_ODBC_SOURCES} ma_platform_posix.c)
 ENDIF()
+
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 
 IF(NOT CMAKE_BUILD_TYPE)

=== modified file 'dsn/odbc_dsn.c'
--- dsn/odbc_dsn.c	2014-06-30 22:24:51 +0000
+++ dsn/odbc_dsn.c	2014-08-08 14:23:23 +0000
@@ -31,20 +31,36 @@
 #pragma comment(lib, "ComCtl32.lib")
 
 #define LASTPAGE 4
+
 HINSTANCE hInstance;
 unsigned int CurrentPage= 0;
 SQLHANDLE Environment= NULL;
 my_bool DBFilled= FALSE;
 my_bool CSFilled= FALSE;
 my_bool ConnectionOK= FALSE;
-//MADB_Dsn Dsn;
+my_bool       notCanceled=  TRUE;
+
 char DSNStr[2048];
 HWND hwndTab[7], hwndMain;
+const int    *EffectiveDisabledPages=    NULL,
+             *EffectiveDisabledControls= NULL;
+
+const int DisabledPages[MAODBC_PROMPT_REQUIRED + 1][LASTPAGE + 1]= {
+                                                                    { 0, 0, 0, 0, 0},
+                                                                    { 0, 0, 0, 0, 0},
+                                                                    { 1, 0, 1, 1, 1}
+                                                                   };
+const int   PromptDisabledControls[]= { txtDsnName, 0 },
+            EmptyDisabledControls[]=  { 0 };
+const int*  DisabledControls[]=       {
+                                        EmptyDisabledControls,
+                                        PromptDisabledControls,
+                                        EmptyDisabledControls
+                                      };
 
 MADB_DsnMap DsnMap[] = {
   {&DsnKeys[0], 0, txtDsnName, 64, 1},
   {&DsnKeys[1], 0, txtDSNDescription, 64, 0},
-  {&DsnKeys[2], 0, txtDriver, 64, 0},
   {&DsnKeys[3], 1, rbPipe, 0, 0},
   {&DsnKeys[4], 1, rbTCP, 0, 0},
   {&DsnKeys[5], 1, txtServerName, 128, 0},
@@ -118,12 +134,12 @@
     i++;
   }
   i= 0;
-  while (OptionsMap[i].DialogOption != 0)
+  while (OptionsMap[i].Item != 0)
   {
     my_bool Val= (Dsn->Options & OptionsMap[i].value) ? 1 : 0;
-    SendDlgItemMessage(hwndTab[OptionsMap[i].Page], OptionsMap[i].DialogOption, BM_SETCHECK,
+    SendDlgItemMessage(hwndTab[OptionsMap[i].Page], OptionsMap[i].Item, BM_SETCHECK,
                            Val ? BST_CHECKED : BST_UNCHECKED, 0);
-    if (Val && OptionsMap[i].DialogOption == rbPipe)
+    if (Val && OptionsMap[i].Item == rbPipe)
     {
       SendMessage(GetDlgItem(hwndTab[OptionsMap[i].Page], lblServerName), WM_SETTEXT, 0, (LPARAM)"Named pipe:");
 		  ShowWindow(GetDlgItem(hwndTab[OptionsMap[i].Page], lblPort), SW_HIDE);
@@ -135,13 +151,21 @@
 
 }
 
-char *GetFieldStrVal(int Dialog, int Field)
+char *GetFieldStrVal(int Dialog, int Field, char* (*allocator)(size_t))
 {
   int rc;
   size_t len= Edit_GetTextLength(GetDlgItem(hwndTab[Dialog],Field));
   char *p;
 
+  if (allocator)
+  {
+    p= allocator(len * sizeof(char) + 2);
+  }
+  else
+  {
   p= (char *)MADB_CALLOC(len * sizeof(char) + 2);
+  }
+
   if (p)
     rc= Edit_GetText(GetDlgItem(hwndTab[Dialog], Field),p , len+1);
   return p;      
@@ -150,7 +174,7 @@
 int GetFieldIntVal(int Dialog, int Field)
 {
   int rc= 0;
-  char *p= GetFieldStrVal(Dialog, Field);
+  char *p= GetFieldStrVal(Dialog, Field, NULL);
   if (p)
   {
     rc= atoi(p);
@@ -172,11 +196,66 @@
   return FALSE;
 }
 
-void SetPage(HWND hDlg, unsigned int value)
+
+unsigned int GetNextActiveTab(int current_page, int offset)
+{
+  unsigned int result= current_page + offset;
+
+  for (; result >= 0 && result <= LASTPAGE && EffectiveDisabledPages[result] != 0; result+= offset)
+  {
+    if (offset > 1)
+    {
+      offset= 1;
+    }
+    else if (offset < -1)
+    {
+      offset= -1;
+    }
+  }
+
+  if (result <  0 || result > LASTPAGE)
+  {
+    result= current_page;
+  }
+
+  return result;
+}
+
+
+#define DISABLE_CONTROLS(page_map) i= 0;\
+  /* Assuming that controls in the #page_map are sorted by tab page */\
+  while (page_map[i].Item && page_map[i].Page != CurrentPage && ++i);\
+\
+  while (page_map[i].Item && page_map[i].Page == CurrentPage)\
+  {\
+    int j= 0;\
+    while (EffectiveDisabledControls[j])\
+    {\
+      if (EffectiveDisabledControls[j] == page_map[i].Item)\
+      {\
+        EnableWindow(GetDlgItem(hwndTab[CurrentPage], EffectiveDisabledControls[j]), FALSE);\
+      }\
+      ++j;\
+    }\
+    ++i;\
+  } 1
+
+void DisableControls(MADB_Dsn *Dsn)
+{
+  int i;
+
+  DISABLE_CONTROLS(DsnMap);
+  DISABLE_CONTROLS(OptionsMap);
+}
+
+
+void SetPage(HWND hDlg, int value)
 {
   MADB_Dsn *Dsn= (MADB_Dsn *)GetWindowLongPtr(GetParent(hwndTab[0]), DWLP_USER);
-  /* Save */
-  if (value == 1 && CurrentPage == LASTPAGE)
+  unsigned int new_page=  GetNextActiveTab(CurrentPage, value);
+
+  /* Save if last page or all following pages are disabled */
+  if (value > 0 && (CurrentPage == LASTPAGE || new_page== CurrentPage))
   {
     GetDialogFields();
     if (Dsn->isPrompt || SaveDSN(hDlg, Dsn))
@@ -185,16 +264,32 @@
     }
     return;
   }
-	ShowWindow(hwndTab[CurrentPage], SW_HIDE);
-	CurrentPage+= value;
+
+	ShowWindow(hwndTab[CurrentPage != (unsigned int)(-1) ? CurrentPage : 0], SW_HIDE);
+
+	CurrentPage= new_page;
+
 	ShowWindow(hwndTab[CurrentPage], SW_SHOW);
-	EnableWindow(GetDlgItem(hwndTab[CurrentPage], PB_PREV), (CurrentPage > 0) ? TRUE : FALSE);
-	SendMessage(GetDlgItem(hwndTab[CurrentPage], PB_NEXT), WM_SETTEXT, 0, (CurrentPage == LASTPAGE) ? (LPARAM)"Finish" : (LPARAM)"Next >");
+
+  DisableControls(Dsn);
+
+  /* Disabling prev button if needed*/
+  new_page= GetNextActiveTab(CurrentPage, -1);
+  EnableWindow(GetDlgItem(hwndTab[CurrentPage], PB_PREV), (CurrentPage != new_page) ? TRUE : FALSE);
+
+  /* Switching caption of the Next/Finish button if needed*/
+  new_page= GetNextActiveTab(CurrentPage, 1);
+	SendMessage(GetDlgItem(hwndTab[CurrentPage], PB_NEXT), WM_SETTEXT, 0, (CurrentPage == new_page) ? (LPARAM)"Finish" : (LPARAM)"Next >");
 	SetFocus(hwndTab[CurrentPage]);
-	if (CurrentPage == LASTPAGE)
+
+  /* If not a prompt - disable finish button in case of empty DS name(for prompt it may be empty/invalid)
+     TODO: I think it rather has to check if the name is valid DS name */
+	if (Dsn->isPrompt ==  MAODBC_CONFIG && CurrentPage == new_page)
+  {
 	  EnableWindow(GetDlgItem(hwndTab[CurrentPage], PB_NEXT), 
 	               Edit_GetTextLength(GetDlgItem(hwndTab[0], txtDsnName)) ? TRUE : FALSE);
 }
+}
 
 void GetDialogFields()
 {
@@ -208,8 +303,12 @@
     case DSN_TYPE_COMBO:
       {
         char **p= (char **)((char *)Dsn + DsnMap[i].Key->DsnOffset);
-        MADB_FREE(*p);
-        *p= GetFieldStrVal(DsnMap[i].Page, DsnMap[i].Item);
+
+        if (Dsn->isPrompt != 0 && Dsn->free != NULL)
+        {
+          Dsn->free(*p);
+        }
+        *p= GetFieldStrVal(DsnMap[i].Page, DsnMap[i].Item, Dsn->allocator && Dsn->isPrompt ? Dsn->allocator : NULL);
       }
       break;
     case DSN_TYPE_INT:
@@ -218,13 +317,13 @@
     case DSN_TYPE_BOOL:
       *(my_bool *)((char *)Dsn + DsnMap[i].Key->DsnOffset)=  GetButtonState(DsnMap[i].Page, DsnMap[i].Item);
     }
-    i++;
+    ++i;
   }
   i= 0;
   Dsn->Options= 0;
-  while (OptionsMap[i].DialogOption != 0)
+  while (OptionsMap[i].Item != 0)
   {
-    if (GetButtonState(OptionsMap[i].Page, OptionsMap[i].DialogOption))
+    if (GetButtonState(OptionsMap[i].Page, OptionsMap[i].Item))
       Dsn->Options|= OptionsMap[i].value; 
     i++;
   }
@@ -364,6 +463,7 @@
     {
     case IDCANCEL:
       SendMessage(GetParent(hDlg), WM_CLOSE, 0, 0);
+      notCanceled= FALSE;
       return TRUE;
     case PB_PREV:
 	  SetPage(hDlg, -1);
@@ -416,6 +516,7 @@
     if(MessageBox(hDlg, TEXT("Close the program?"), TEXT("Close"),
       MB_ICONQUESTION | MB_YESNO) == IDYES)
     {
+      notCanceled= FALSE;
       DestroyWindow(hDlg);
     } return TRUE;
 
@@ -430,18 +531,18 @@
   	RECT rc;
   	GetWindowRect(hDlg, &rc);
 
-  	for (i=0; i <= LASTPAGE; i++)
+  	for (i= 0; i <= LASTPAGE; ++i)
   	{
       hwndTab[i]= CreateDialog(hInstance, MAKEINTRESOURCE(Dialogs[i]), hDlg, DialogDSNProc);
 	    SetWindowPos(hwndTab[i], 0, 120, 5, (rc.right-rc.left)-120, (rc.bottom-rc.top), SWP_NOZORDER | SWP_NOACTIVATE);
-	    ShowWindow(hwndTab[i], (!i) ? SW_SHOW : SW_HIDE);
+	    ShowWindow(hwndTab[i], (i == 0) ? SW_SHOW : SW_HIDE);
   	}
     i=0;
     while (DsnMap[i].Key)
     {
       if (DsnMap[i].MaxLength)
         MA_WIN_SET_MAXLEN(DsnMap[i].Page, DsnMap[i].Item, DsnMap[i].MaxLength);
-      i++;
+      ++i;
     }
     
     return TRUE; 
@@ -488,6 +589,14 @@
   char *DsnName= NULL;
   my_bool DsnExists= FALSE;
 
+  if (Dsn->isPrompt < 0 || Dsn->isPrompt > MAODBC_PROMPT_REQUIRED)
+  {
+    Dsn->isPrompt= MAODBC_CONFIG;
+  }
+
+  EffectiveDisabledPages=     DisabledPages[Dsn->isPrompt];
+  EffectiveDisabledControls=  DisabledControls[Dsn->isPrompt];
+
   if (lpszAttributes)
     DsnName= strchr((char *)lpszAttributes, '=');
   
@@ -496,8 +605,9 @@
 
   if (DsnName)
   {
-    DsnName++;
-    if (!SQLValidDSN(DsnName))
+    ++DsnName;
+    /* In case of prompting we are supposed to show dialog even DSN name is incorrect */
+    if (!Dsn->isPrompt && !SQLValidDSN(DsnName))
     {
       if (hwndParent)
         MessageBox(hwndParent, "Validation of data source name failed", "Error", MB_ICONERROR | MB_OK);
@@ -506,16 +616,22 @@
   }
 
   if (!DsnName && Dsn && Dsn->DSNName)
+  {
     DsnName= Dsn->DSNName;
+  }
+  else if (DsnName && Dsn)
+  {
+    /* Need to free current value in Dsn->DSNName */
+    MADB_SUBSTITUTE(Dsn->DSNName, _strdup(DsnName));
+  }
 
+  /* Even if DsnName invalid(in case of prompt) - we should not have problem */
   DsnExists= MADB_DSN_Exists(DsnName);
  
   InitCommonControls();
 
   if (lpszDriver)
     Dsn->Driver= _strdup(lpszDriver);
-  if (DsnName)
-    Dsn->DSNName= _strdup(DsnName);
 
   SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &Environment);
   SQLSetEnvAttr(Environment, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0);
@@ -532,19 +648,30 @@
   }
   else
   {
+    /* i.e. not a prompt */
+    if (Dsn->isPrompt == MAODBC_CONFIG)
+    {
     if (!DsnExists)
     {
       MessageBox(0, "Data source name not found", "Error", MB_ICONERROR | MB_OK);
       return FALSE;
     }
-    if (!MADB_ReadDSN(Dsn, (char *)lpszAttributes, TRUE))
+      else if (!MADB_ReadDSN(Dsn, (char *)lpszAttributes, TRUE))
     {
       SQLPostInstallerError(ODBC_ERROR_INVALID_DSN, Dsn->ErrorMsg);
       return FALSE;
     }
   }
+  }
+
+  notCanceled= TRUE;
   hwndMain= CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), 0, DialogProc, 0);
   SetWindowLongPtr(hwndMain, DWLP_USER, (LONG)Dsn);
+
+  /* Setting first not disabled page */
+  CurrentPage= -1;
+  SetPage(hwndMain, 1);
+
   Edit_SetReadOnly(GetDlgItem(hwndTab[0], txtDsnName), 
                    (hwndParent && DsnName && fRequest == ODBC_ADD_DSN) ? TRUE : FALSE);
 
@@ -552,8 +679,6 @@
   CenterWindow(hwndMain);
   ShowWindow(hwndMain, SW_SHOW);
 
-  
-
   while((ret = GetMessage(&msg, 0, 0, 0)) != 0) {
     if(ret == -1)
       break;
@@ -563,9 +688,10 @@
       DispatchMessage(&msg);
     }
   }
+
   SQLFreeHandle(SQL_HANDLE_ENV, Environment);
 
-  return TRUE;
+  return notCanceled;
 }
 
 BOOL INSTAPI ConfigDSN(
@@ -592,7 +718,7 @@
     char *Val= strchr((char *)lpszAttributes, '=');
     if (Val)
     {
-      Val++;
+      ++Val;
       return SQLRemoveDSNFromIni(Val);
     }
   }
@@ -603,7 +729,5 @@
 
 BOOL __stdcall DSNPrompt(HWND hwnd, MADB_Dsn *Dsn)
 {
-  if (!DSNDialog(hwnd, ODBC_CONFIG_DSN, NULL, NULL, Dsn))
-    return FALSE;
-  return TRUE;
+  return DSNDialog(hwnd, ODBC_CONFIG_DSN, NULL, NULL, Dsn);
 }

=== modified file 'dsn/odbc_dsn.rc'
--- dsn/odbc_dsn.rc	2014-06-30 22:24:51 +0000
+++ dsn/odbc_dsn.rc	2014-08-08 12:53:05 +0000
@@ -126,7 +126,7 @@
 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
-    LTEXT           "How do you want to connect to MariaDB",IDC_STATIC,9,7,187,14,0,WS_EX_TRANSPARENT
+    LTEXT           "How do you want to connect to MariaDB",IDC_STATIC,9,7,130,10,0,WS_EX_TRANSPARENT
     LTEXT           "Server Name:",lblServerName,86,21,49,11,0,WS_EX_TRANSPARENT | WS_EX_RIGHT
     LTEXT           "Please specify a user name and password to connect to MariaDB",IDC_STATIC,9,54,207,8,0,WS_EX_TRANSPARENT
     LTEXT           "Please specify a user name and password to connect to MariaDB",IDC_STATIC,9,105,207,8,0,WS_EX_TRANSPARENT

=== modified file 'dsn/resource.h'
Binary files c:\users\c2ea~1\appdata\local\temp\bzr-diff-old-jm60fv and c:\users\c2ea~1\appdata\local\temp\bzr-diff-new-rjtgul differ

=== modified file 'ma_connection.c'
--- ma_connection.c	2014-06-30 22:24:51 +0000
+++ ma_connection.c	2014-08-08 16:17:57 +0000
@@ -1461,6 +1461,23 @@
 }
 /* }}} */
 
+
+/* {{{ MADB_DriverSideMemalocate */
+char * MADB_DriverSideAllocate(size_t size)
+{
+  return (char *)MADB_CALLOC(size);
+}
+/* }}} */
+
+
+/* {{{ MADB_DriverSideFree */
+void MADB_DriverSideFree(void *ptr)
+{
+  MADB_FREE(ptr);
+}
+/* }}} */
+
+
 /* {{{ MADB_DriverConnect */
 SQLRETURN MADB_DriverConnect(MADB_Dbc *Dbc, SQLHWND WindowHandle, SQLCHAR *InConnectionString,
                              SQLSMALLINT StringLength1, SQLCHAR *OutConnectionString,
@@ -1470,8 +1487,7 @@
   MADB_Dsn *Dsn;
   MADB_Drv *Drv= NULL;
   SQLRETURN ret= SQL_SUCCESS;
-  HMODULE hMod= NULL;
-  PromptDSN DSNPrompt= NULL;
+  MADB_Prompt DSNPrompt= { NULL, NULL };
   SQLSMALLINT Length;
 
   if (!Dbc)
@@ -1508,6 +1524,7 @@
     }
     break;
   case SQL_DRIVER_PROMPT:
+    Dsn->isPrompt= MAODBC_PROMPT/*_REQUIRED*/;
     break;
   default:
     MADB_SetError(&Dbc->Error, MADB_ERR_HY110, NULL, 0);
@@ -1541,18 +1558,23 @@
     goto error;
   }
  
-  if (!(hMod= LoadLibrary(Drv->SetupLibrary)))
+  if (!SQL_SUCCEEDED(DSNPrompt_Lookup(&DSNPrompt, Drv->SetupLibrary, Dbc)))
   {
-    MADB_SetError(&Dbc->Error, MADB_ERR_HY000, "Couldn't load setup library", 0);
     goto error;
   }
-  if (!(DSNPrompt= (PromptDSN)GetProcAddress(hMod, "DSNPrompt")))
+
+  Dsn->allocator= MADB_DriverSideAllocate;
+  Dsn->free=      MADB_DriverSideFree;
+
+  if (DSNPrompt.Call((HWND)WindowHandle, Dsn) == FALSE)
   {
-    MADB_SetError(&Dbc->Error, MADB_ERR_HY000, "Couldn't find DSNPrompt function in setup library", 0);
+    /* If user cancels prompt, SQLDriverConnect should return SQL_NO_DATA */
+    Dbc->Error.ReturnValue= SQL_NO_DATA;
     goto error;
   }
-  if (DSNPrompt((HWND)WindowHandle, Dsn) == TRUE);
-  FreeLibrary(hMod);
+
+  DSNPrompt_Free(&DSNPrompt);
+
   ret= MADB_DbcConnectDB(Dbc, (void *)Dsn);
   if (!SUCCEEDED(ret))
     goto error;
@@ -1569,8 +1591,7 @@
     *StringLength2Ptr= Length;
   return ret;
 error:
-  if (hMod)   
-    FreeLibrary(hMod);
+  DSNPrompt_Free(&DSNPrompt);
   MADB_DSN_Free(Dsn);
   MADB_DriverFree(Drv);
   return Dbc->Error.ReturnValue;

=== modified file 'ma_connection.h'
--- ma_connection.h	2014-03-11 18:29:16 +0000
+++ ma_connection.h	2014-08-08 15:35:14 +0000
@@ -46,11 +46,6 @@
                              SQLUSMALLINT DriverCompletion);
 };
 
-#ifdef WIN32
-/* Show configuration dialog for SQLDriverConnect */
-typedef BOOL (__stdcall *PromptDSN)(HWND hwnd, MADB_Dsn *Dsn);
-#endif
-
 my_bool CheckConnection(MADB_Dbc *Dbc);
 
 SQLRETURN MADB_DbcFree(MADB_Dbc *Connection);

=== modified file 'ma_dsn.c'
--- ma_dsn.c	2014-03-10 19:00:15 +0000
+++ ma_dsn.c	2014-08-06 14:12:21 +0000
@@ -81,6 +81,7 @@
 }
 /* }}} */
 
+
 /* {{{ MADB_DsnStoreValue */
 my_bool MADB_DsnStoreValue(MADB_Dsn *Dsn, size_t Offset, char *Value, int Type, my_bool OverWrite)
 {
@@ -92,10 +93,14 @@
   case DSN_TYPE_COMBO:
     {
       char **p= (char **)((char *)Dsn +Offset);
-      if (*p && OverWrite == FALSE)
+      char *current= *p;
+
+      if (current && OverWrite == FALSE)
         break;
-      MADB_FREE(*p);
+
       *p= _strdup(Value);
+      /* For the case of making copy of currently stored values */
+      MADB_FREE(current);
     }
     break;
   case DSN_TYPE_BOOL:
@@ -114,6 +119,7 @@
 }
 /* }}} */
 
+
 /* {{{ MADB_ReadDSN */
 my_bool MADB_ReadDSN(MADB_Dsn *Dsn, char *KeyValue, my_bool OverWrite)
 {
@@ -129,7 +135,7 @@
   else 
   {
     if (Value= strchr(KeyValue, '='))
-      Value++;
+      ++Value;
   }
   
   if (Value)
@@ -144,7 +150,7 @@
         if (!MADB_DsnStoreValue(Dsn, DsnKeys[i].DsnOffset, KeyVal, DsnKeys[i].Type, OverWrite))
           return FALSE;
       }
-      i++;
+      ++i;
     }
     return TRUE;
   }
@@ -264,7 +270,7 @@
         Value= trim(Value);
         if (Value[0] == '{')
         {
-          Value++;
+          ++Value;
           if ((p = strchr(Value, '}')))
           {
             *p= 0;
@@ -281,10 +287,10 @@
           *p= (special) ? ' ' : ';';
         break;
       }
-      i++;
+      ++i;
     }
     if ((Key= strchr(Value, ';')))
-      Key++;
+      ++Key;
   }
   MADB_FREE(Buffer);
   return TRUE;
@@ -338,7 +344,7 @@
                              DsnKeys[i].DsnKey, isSpecial ? "{" : "", Value, isSpecial ? "}" : "");
       TotalLength+= CpyLength;
     }
-    i++;
+    ++i;
   }
 
   if (OutLength && OutString)

=== modified file 'ma_dsn.h'
--- ma_dsn.h	2014-03-11 18:29:16 +0000
+++ ma_dsn.h	2014-08-08 11:41:47 +0000
@@ -55,7 +55,7 @@
 typedef struct
 {
   unsigned int Page;
-  unsigned long DialogOption;
+  unsigned long Item;
   unsigned long value;
 } MADB_OptionsMap;
 
@@ -65,7 +65,6 @@
 MADB_DsnKey DsnKeys[];
 
 
-
 /*** Function prototypes ***/
 MADB_Dsn *MADB_DSN_Init(void);
 void MADB_DSN_Free(MADB_Dsn *Dsn);

=== modified file 'ma_helper.h'
--- ma_helper.h	2014-05-19 09:46:21 +0000
+++ ma_helper.h	2014-07-21 12:51:06 +0000
@@ -74,6 +74,11 @@
 #define MADB_CALLOC(a) my_malloc((a), MYF(MY_ZEROFILL))
 #define MADB_REALLOC(a,b) my_realloc((a),(b),MYF(MY_ZEROFILL))
 
+/* If required to free old memory pointed by current ptr, and set new value */
+#define MADB_SUBSTITUTE(ptr, newptr) \
+  my_free((gptr)(ptr), MYF(MY_ALLOW_ZERO_PTR));\
+  (ptr)= (newptr);
+
 #define MADB_UTF8_LEN(a) WideCharToMultiByte(CP_UTF8, 0, (a), -1, NULL, 0, NULL, NULL)
 
 

=== modified file 'ma_odbc.h'
--- ma_odbc.h	2014-03-11 18:29:16 +0000
+++ ma_odbc.h	2014-08-08 16:17:57 +0000
@@ -353,6 +353,11 @@
   bool IsAlias;
 } MADB_DsnKey;
 
+/* Definitions to tell setup library via isPrompt field what should it do */
+#define MAODBC_CONFIG           0
+#define MAODBC_PROMPT           1
+#define MAODBC_PROMPT_REQUIRED  2
+
 typedef struct st_madb_dsn
 {
   /*** General ***/
@@ -375,12 +380,17 @@
   unsigned int ConnectionTimeout;
   my_bool Reconnect;
   my_bool MultiStatements;
+  /* TRUE means "no prompt" */
   my_bool ConnectPrompt;
   /* --- Internal --- */
-  my_bool isPrompt;
+  int isPrompt;
   MADB_DsnKey *Keys;
   char ErrorMsg[SQL_MAX_MESSAGE_LENGTH];
   my_bool FreeMe;
+  /* Callbacke required for prompt to keep all memory de/allocation operations
+     on same side of libraries */
+  char * (*allocator)(size_t);
+  void (*free)(void*);
 } MADB_Dsn;
 
 struct st_ma_odbc_connection
@@ -419,6 +429,17 @@
   SQLINTEGER TxnIsolation;
   SQLINTEGER CursorCount;
 };
+
+typedef BOOL (__stdcall *PromptDSN)(HWND hwnd, MADB_Dsn *Dsn);
+
+typedef struct
+{
+  void     *LibraryHandle;
+  PromptDSN Call;
+} MADB_Prompt;
+
+SQLRETURN DSNPrompt_Lookup(MADB_Prompt *prompt, const char *SetupLibName, MADB_Dbc *Dbc);
+int       DSNPrompt_Free  (MADB_Prompt *prompt);
 
 #include <ma_error.h>
 #include <ma_compatibility.h>

=== added file 'ma_platform_posix.c'
--- ma_platform_posix.c	1970-01-01 00:00:00 +0000
+++ ma_platform_posix.c	2014-08-08 17:25:57 +0000
@@ -0,0 +1,41 @@
+/************************************************************************************
+   Copyright (C) 2014 SkySQL AB
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not see <http://www.gnu.org/licenses>
+   or write to the Free Software Foundation, Inc., 
+   51 Franklin St., Fifth Floor, Boston, MA 02110, USA
+*************************************************************************************/
+
+
+/* MariaDB ODBC driver helper functions for platforms other than windows(so far) */
+
+/* NOTE If you change something in this program, please consider if other platform's version 
+        of the function you are changing, needs to be changed accordingly */
+
+#include <ma_odbc.h>
+
+
+SQLRETURN DSNPrompt_Lookup(MADB_Prompt *prompt, const char * SetupLibName, MADB_Dbc *Dbc)
+{
+  MADB_SetError(&Dbc->Error, MADB_ERR_HY000, "Prompting is not supported on this platform", 0);
+  return Dbc->Error.ReturnValue;
+}
+
+
+int DSNPrompt_Free  (MADB_Prompt *prompt)
+{
+  prompt->LibraryHandle= NULL;
+
+  return 0;
+}

=== added file 'ma_platform_win32.c'
--- ma_platform_win32.c	1970-01-01 00:00:00 +0000
+++ ma_platform_win32.c	2014-08-08 17:26:36 +0000
@@ -0,0 +1,55 @@
+/************************************************************************************
+   Copyright (C) 2014 SkySQL AB
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not see <http://www.gnu.org/licenses>
+   or write to the Free Software Foundation, Inc., 
+   51 Franklin St., Fifth Floor, Boston, MA 02110, USA
+*************************************************************************************/
+
+
+/* MariaDB ODBC driver Win32 specific helper functions */
+
+/* NOTE If you change something in this program, please consider if other platform's version 
+        of the function you are changing, needs to be changed accordingly */
+
+#include <ma_odbc.h>
+
+
+/* Connection is needed to set custom error */
+SQLRETURN DSNPrompt_Lookup(MADB_Prompt *prompt, const char * SetupLibName, MADB_Dbc *Dbc)
+{
+  if (!(prompt->LibraryHandle=(void*) LoadLibrary(SetupLibName)))
+  {
+    MADB_SetError(&Dbc->Error, MADB_ERR_HY000, "Couldn't load setup library", 0);
+  }
+  if (!(prompt->Call= (PromptDSN)GetProcAddress((HMODULE)prompt->LibraryHandle, "DSNPrompt")))
+  {
+    MADB_SetError(&Dbc->Error, MADB_ERR_HY000, "Couldn't find DSNPrompt function in setup library", 0);
+  }
+
+  return Dbc->Error.ReturnValue;
+}
+
+
+int DSNPrompt_Free(MADB_Prompt *prompt)
+{
+  if (prompt->LibraryHandle != NULL)
+  {
+    FreeLibrary(prompt->LibraryHandle);
+  }
+  prompt->LibraryHandle= NULL;
+  prompt->Call= NULL;
+
+  return 0;
+}

=== modified file 'test/basic.c'
--- test/basic.c	2014-06-30 22:24:51 +0000
+++ test/basic.c	2014-08-08 14:30:29 +0000
@@ -1222,6 +1222,7 @@
   return OK;
 }
 
+
 MA_ODBC_TESTS my_tests[]=
 {
 /*  {t_disconnect, "t_disconnect"},

=== modified file 'win/ma_odbc_setup.h'
--- win/ma_odbc_setup.h	2014-03-10 19:00:15 +0000
+++ win/ma_odbc_setup.h	2014-07-30 10:04:37 +0000
@@ -18,7 +18,7 @@
   int Page;
   int Item;
   int MaxLength;
-  my_bool Manadatory;
+  my_bool Mandatory;
 } MADB_DsnMap;
 
 #endif /* _ma_odbc_setup_h_ */

