SQLRETURN SQL_API _iodbcdm_loginbox ( HWND hwnd, LPSTR szInOutConnStr, DWORD cbInOutConnStr, int * sqlStat) { RETCODE retcode = SQL_ERROR; char *szUID = NULL, *szPWD = NULL, *szDSN = NULL, *curr; TLOGIN log_t; /* Check input parameters */ if (!hwnd || !szInOutConnStr || cbInOutConnStr < 1) goto quit; /* Check if the user and password are put */ for (curr = szInOutConnStr; *curr; curr += (STRLEN (curr) + 1)) { if (!strncasecmp (curr, "DSN=", STRLEN ("DSN="))) szDSN = curr + STRLEN ("DSN="); if (!strncasecmp (curr, "UID=", STRLEN ("UID="))) szUID = curr + STRLEN ("UID="); if (!strncasecmp (curr, "PWD=", STRLEN ("PWD="))) szPWD = curr + STRLEN ("PWD="); } if (!szUID || !szPWD) { create_login (hwnd, szUID, szPWD, szDSN, &log_t); if (log_t.user && !szUID) { sprintf (curr, "UID=%s\0", log_t.user); curr += (STRLEN (curr) + 1); free (log_t.user); *curr = 0; } if (log_t.pwd) { sprintf (curr, "PWD=%s\0", log_t.pwd); curr += (STRLEN (curr) + 1); free (log_t.pwd); *curr = 0; } } retcode = SQL_SUCCESS; quit: return retcode; }
int main(int argc, char **argv) { if (!g_thread_supported()) g_thread_init(NULL); gdk_threads_init(); gtk_init(&argc, &argv); window_login = create_login(); gtk_widget_show_all(window_login); //window_adduser=create_adduser(); //window_list=create_list(); //gtk_widget_show_all(window_list); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); return FALSE; }
SQLRETURN SQL_API _iodbcdm_drvconn_dialbox ( HWND hwnd, LPSTR szInOutConnStr, DWORD cbInOutConnStr, int * sqlStat, SQLUSMALLINT fDriverCompletion, UWORD * config) { RETCODE retcode = SQL_ERROR; char *szDSN = NULL, *szDriver = NULL, *szUID = NULL, *szPWD = NULL, *curr; TLOGIN log_t; /* Check input parameters */ if (!hwnd || !szInOutConnStr || cbInOutConnStr < 1) goto quit; /* Check if the DSN is already set or DRIVER */ for (curr = szInOutConnStr; *curr; curr += (STRLEN (curr) + 1)) { if (!strncasecmp (curr, "DSN=", STRLEN ("DSN="))) { szDSN = curr + STRLEN ("DSN="); continue; } if (!strncasecmp (curr, "DRIVER=", STRLEN ("DRIVER="))) { szDriver = curr + STRLEN ("DRIVER="); continue; } if (!strncasecmp (curr, "UID=", STRLEN ("UID="))) { szUID = curr + STRLEN ("UID="); continue; } if (!strncasecmp (curr, "UserName="******"UserName="******"UserName="******"LastUser="******"LastUser="******"LastUser="******"PWD=", STRLEN ("PWD="))) { szPWD = curr + STRLEN ("PWD="); continue; } if (!strncasecmp (curr, "Password="******"Password="******"Password="******"(File DSN)", &log_t); if (log_t.user && !szUID) { sprintf (curr, "UID=%s", log_t.user); curr += STRLEN (curr); *curr++ = '\0'; free (log_t.user); } if (log_t.pwd && !szPWD) { sprintf (curr, "PWD=%s", log_t.pwd); curr += STRLEN (curr); *curr++ = '\0'; free (log_t.pwd); } /* add list-terminating '\0' */ *curr = '\0'; } retcode = log_t.ok ? SQL_SUCCESS : SQL_NO_DATA_FOUND; quit: for (curr = szInOutConnStr; *curr; curr = szDSN + 1) { szDSN = curr + STRLEN (curr); if (szDSN[1]) szDSN[0] = ';'; } return retcode; }