1 | #include <config.h> |
2 | #include <odbcinstext.h> |
3 | |
4 | BOOL _SQLDriverConnectPrompt( |
5 | HWND hwnd, |
6 | SQLCHAR *dsn, |
7 | SQLSMALLINT len_dsn ) |
8 | { |
9 | HODBCINSTWND hODBCInstWnd = (HODBCINSTWND)hwnd; |
10 | char szName[FILENAME_MAX]; |
11 | char szNameAndExtension[FILENAME_MAX]; |
12 | char szPathAndName[FILENAME_MAX]; |
13 | void * hDLL; |
14 | BOOL (*pODBCDriverConnectPrompt)(HWND, SQLCHAR *, SQLSMALLINT ); |
15 | |
16 | /* initialize libtool */ |
17 | if ( lt_dlinit() ) |
18 | { |
19 | return FALSE; |
20 | } |
21 | |
22 | /* get plugin name */ |
23 | |
24 | if ( hODBCInstWnd ) |
25 | { |
26 | _appendUIPluginExtension( szNameAndExtension, _getUIPluginName( szName, hODBCInstWnd->szUI ) ); |
27 | } |
28 | else |
29 | { |
30 | _appendUIPluginExtension( szNameAndExtension, _getUIPluginName( szName, NULL ) ); |
31 | } |
32 | |
33 | /* lets try loading the plugin using an implicit path */ |
34 | hDLL = lt_dlopen( szNameAndExtension ); |
35 | if ( hDLL ) |
36 | { |
37 | /* change the name, as it avoids it finding it in the calling lib */ |
38 | pODBCDriverConnectPrompt = (BOOL (*)( HWND, SQLCHAR *, SQLSMALLINT ))lt_dlsym( hDLL, "ODBCDriverConnectPrompt" ); |
39 | if ( pODBCDriverConnectPrompt ) |
40 | { |
41 | if ( hODBCInstWnd ) |
42 | { |
43 | return pODBCDriverConnectPrompt(( *(hODBCInstWnd->szUI) ? hODBCInstWnd->hWnd : NULL ), dsn, len_dsn ); |
44 | } |
45 | else |
46 | { |
47 | return pODBCDriverConnectPrompt( NULL, dsn, len_dsn ); |
48 | } |
49 | } |
50 | else |
51 | { |
52 | return FALSE; |
53 | } |
54 | } |
55 | else |
56 | { |
57 | /* try with explicit path */ |
58 | _prependUIPluginPath( szPathAndName, szNameAndExtension ); |
59 | hDLL = lt_dlopen( szPathAndName ); |
60 | if ( hDLL ) |
61 | { |
62 | /* change the name, as it avoids linker finding it in the calling lib */ |
63 | pODBCDriverConnectPrompt = (BOOL (*)(HWND, SQLCHAR *, SQLSMALLINT ))lt_dlsym( hDLL, "ODBCDriverConnectPrompt" ); |
64 | if ( pODBCDriverConnectPrompt ) |
65 | { |
66 | if ( hODBCInstWnd ) |
67 | { |
68 | return pODBCDriverConnectPrompt(( *(hODBCInstWnd->szUI) ? hODBCInstWnd->hWnd : NULL ), dsn, len_dsn ); |
69 | } |
70 | else |
71 | { |
72 | return pODBCDriverConnectPrompt( NULL, dsn, len_dsn ); |
73 | } |
74 | } |
75 | else |
76 | { |
77 | return FALSE; |
78 | } |
79 | } |
80 | } |
81 | |
82 | return FALSE; |
83 | } |
84 | |