| 58 (LPWSTR) &err_msg, sizeof(err_msg) / sizeof(wchar_t), NULL); |
58 (LPWSTR) &err_msg, sizeof(err_msg) / sizeof(wchar_t), NULL); |
| 59 |
59 |
| 60 return err_msg; |
60 return err_msg; |
| 61 } |
61 } |
| 62 |
62 |
| |
63 static BOOL reg_value_exists(HKEY key, wchar_t *sub_key, wchar_t *val_name) { |
| |
64 HKEY hkey; |
| |
65 LONG retv; |
| |
66 DWORD index; |
| |
67 wchar_t name_buffer[100]; |
| |
68 BOOL exists = FALSE; |
| |
69 |
| |
70 if (sub_key == NULL || val_name == NULL) |
| |
71 return FALSE; |
| |
72 |
| |
73 retv = RegOpenKeyExW(key, sub_key, 0, KEY_ENUMERATE_SUB_KEYS, &hkey); |
| |
74 if (retv != ERROR_SUCCESS) |
| |
75 return FALSE; |
| |
76 |
| |
77 index = 0; |
| |
78 while (TRUE) |
| |
79 { |
| |
80 DWORD name_size = sizeof(name_buffer); |
| |
81 retv = RegEnumValueW(hkey, index++, name_buffer, &name_size, |
| |
82 NULL, NULL, NULL, NULL); |
| |
83 if (retv != ERROR_SUCCESS) |
| |
84 break; |
| |
85 name_size /= sizeof(wchar_t); |
| |
86 if (wcsncmp(name_buffer, val_name, name_size) == 0) { |
| |
87 exists = TRUE; |
| |
88 break; |
| |
89 } |
| |
90 } |
| |
91 |
| |
92 RegCloseKey(hkey); |
| |
93 return exists; |
| |
94 } |
| |
95 |
| 63 static BOOL read_reg_string(HKEY key, wchar_t *sub_key, wchar_t *val_name, LPBYTE data, LPDWORD data_len) { |
96 static BOOL read_reg_string(HKEY key, wchar_t *sub_key, wchar_t *val_name, LPBYTE data, LPDWORD data_len) { |
| 64 HKEY hkey; |
97 HKEY hkey; |
| 65 BOOL ret = FALSE; |
98 BOOL ret = FALSE; |
| 66 LONG retv; |
99 LONG retv; |
| 67 |
100 |
| 90 } |
123 } |
| 91 |
124 |
| 92 return ret; |
125 return ret; |
| 93 } |
126 } |
| 94 |
127 |
| 95 static BOOL common_dll_prep(const wchar_t *path) { |
128 static BOOL check_for_gtk(const wchar_t *path) { |
| 96 HMODULE hmod; |
|
| 97 HKEY hkey; |
|
| 98 struct _stat stat_buf; |
129 struct _stat stat_buf; |
| 99 wchar_t test_path[MAX_PATH + 1]; |
130 wchar_t test_path[MAX_PATH + 1]; |
| 100 |
131 |
| 101 _snwprintf(test_path, sizeof(test_path) / sizeof(wchar_t), |
132 _snwprintf(test_path, sizeof(test_path) / sizeof(wchar_t), |
| 102 L"%s\\libgtk-win32-2.0-0.dll", path); |
133 L"%s\\libgtk-win32-2.0-0.dll", path); |
| 103 test_path[sizeof(test_path) / sizeof(wchar_t) - 1] = L'\0'; |
134 test_path[sizeof(test_path) / sizeof(wchar_t) - 1] = L'\0'; |
| 104 |
135 |
| 105 if (_wstat(test_path, &stat_buf) != 0) { |
136 return (_wstat(test_path, &stat_buf) == 0); |
| 106 printf("Unable to determine GTK+ path. \n" |
137 } |
| 107 "Assuming GTK+ is in the PATH.\n"); |
138 |
| 108 return FALSE; |
139 static void common_dll_prep(const wchar_t *path) { |
| 109 } |
140 HMODULE hmod; |
| 110 |
141 HKEY hkey; |
| |
142 wchar_t alt_path_buff[MAX_PATH + 1]; |
| |
143 wchar_t tmp_path[MAX_PATH + 1]; |
| |
144 /* Hold strlen("FS_PLUGIN_PATH=") + MAX_PATH + 1 */ |
| |
145 wchar_t farstream_path[MAX_PATH + 16]; |
| |
146 |
| |
147 if (!check_for_gtk(path)) { |
| |
148 const wchar_t *winpath = _wgetenv(L"PATH"); |
| |
149 wchar_t *delim; |
| |
150 |
| |
151 if (winpath == NULL) { |
| |
152 printf("Unable to determine GTK+ path (and PATH is not set).\n"); |
| |
153 exit(-1); |
| |
154 } |
| |
155 |
| |
156 path = NULL; |
| |
157 do |
| |
158 { |
| |
159 wcsncpy(alt_path_buff, winpath, MAX_PATH); |
| |
160 alt_path_buff[MAX_PATH] = L'\0'; |
| |
161 delim = wcschr(alt_path_buff, L';'); |
| |
162 if (delim != NULL) { |
| |
163 delim[0] = L'\0'; |
| |
164 winpath = wcschr(winpath, L';') + 1; |
| |
165 } |
| |
166 if (check_for_gtk(alt_path_buff)) { |
| |
167 path = alt_path_buff; |
| |
168 break; |
| |
169 } |
| |
170 } |
| |
171 while (delim != NULL); |
| |
172 |
| |
173 if (path == NULL) { |
| |
174 printf("Unable to determine GTK+ path.\n"); |
| |
175 exit(-1); |
| |
176 } |
| |
177 } |
| 111 |
178 |
| 112 wprintf(L"GTK+ path found: %s\n", path); |
179 wprintf(L"GTK+ path found: %s\n", path); |
| |
180 |
| |
181 wcsncpy(tmp_path, path, MAX_PATH); |
| |
182 tmp_path[MAX_PATH] = L'\0'; |
| |
183 wcsrchr(tmp_path, L'\\')[0] = L'\0'; |
| |
184 _snwprintf(farstream_path, sizeof(farstream_path) / sizeof(wchar_t), |
| |
185 L"FS_PLUGIN_PATH=%s\\lib\\farstream-0.1", tmp_path); |
| |
186 farstream_path[sizeof(farstream_path) / sizeof(wchar_t) - 1] = L'\0'; |
| |
187 _wputenv(farstream_path); |
| 113 |
188 |
| 114 if ((hmod = GetModuleHandleW(L"kernel32.dll"))) { |
189 if ((hmod = GetModuleHandleW(L"kernel32.dll"))) { |
| 115 MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress( |
190 MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress( |
| 116 hmod, "SetDllDirectoryW"); |
191 hmod, "SetDllDirectoryW"); |
| 117 if (!MySetDllDirectory) |
192 if (!MySetDllDirectory) |
| 119 } else |
194 } else |
| 120 printf("Error getting kernel32.dll module handle\n"); |
195 printf("Error getting kernel32.dll module handle\n"); |
| 121 |
196 |
| 122 /* For Windows XP SP1+ / Server 2003 we use SetDllDirectory to avoid dll hell */ |
197 /* For Windows XP SP1+ / Server 2003 we use SetDllDirectory to avoid dll hell */ |
| 123 if (MySetDllDirectory) { |
198 if (MySetDllDirectory) { |
| 124 printf("Using SetDllDirectory\n"); |
|
| 125 MySetDllDirectory(path); |
199 MySetDllDirectory(path); |
| 126 } |
200 } |
| 127 |
201 |
| 128 /* For the rest, we set the current directory and make sure |
202 /* For the rest, we set the current directory and make sure |
| 129 * SafeDllSearch is set to 0 where needed. */ |
203 * SafeDllSearch is set to 0 where needed. */ |
| 177 (UINT) GetLastError()); |
251 (UINT) GetLastError()); |
| 178 } else |
252 } else |
| 179 printf("SafeDllSearchMode is set to 0\n"); |
253 printf("SafeDllSearchMode is set to 0\n"); |
| 180 }/*end else*/ |
254 }/*end else*/ |
| 181 } |
255 } |
| 182 |
256 } |
| 183 return TRUE; |
257 |
| 184 } |
258 static void dll_prep(const wchar_t *pidgin_dir) { |
| 185 |
|
| 186 static BOOL dll_prep(const wchar_t *pidgin_dir) { |
|
| 187 wchar_t path[MAX_PATH + 1]; |
259 wchar_t path[MAX_PATH + 1]; |
| 188 path[0] = L'\0'; |
260 path[0] = L'\0'; |
| 189 |
261 |
| 190 if (*pidgin_dir) { |
262 if (*pidgin_dir) { |
| 191 _snwprintf(path, sizeof(path) / sizeof(wchar_t), L"%s\\Gtk\\bin", pidgin_dir); |
263 _snwprintf(path, sizeof(path) / sizeof(wchar_t), L"%s\\Gtk\\bin", pidgin_dir); |
| 192 path[sizeof(path) / sizeof(wchar_t) - 1] = L'\0'; |
264 path[sizeof(path) / sizeof(wchar_t) - 1] = L'\0'; |
| 193 } |
265 } |
| 194 |
266 |
| 195 return common_dll_prep(path); |
267 common_dll_prep(path); |
| 196 } |
268 } |
| 197 |
269 |
| 198 static void portable_mode_dll_prep(const wchar_t *pidgin_dir) { |
270 static void portable_mode_dll_prep(const wchar_t *pidgin_dir) { |
| 199 /* need to be able to fit MAX_PATH + "PURPLEHOME=" in path2 */ |
271 /* need to be able to fit MAX_PATH + "PURPLEHOME=" in path2 */ |
| 200 wchar_t path[MAX_PATH + 1]; |
272 wchar_t path[MAX_PATH + 1]; |
| 212 int cnt = (prev - pidgin_dir); |
284 int cnt = (prev - pidgin_dir); |
| 213 wcsncpy(path, pidgin_dir, cnt); |
285 wcsncpy(path, pidgin_dir, cnt); |
| 214 path[cnt] = L'\0'; |
286 path[cnt] = L'\0'; |
| 215 } else { |
287 } else { |
| 216 printf("Unable to determine current executable path. \n" |
288 printf("Unable to determine current executable path. \n" |
| 217 "This will prevent the settings dir from being set.\n" |
289 "This will prevent the settings dir from being set.\n"); |
| 218 "Assuming GTK+ is in the PATH.\n"); |
290 common_dll_prep(L'\0'); |
| 219 return; |
291 return; |
| 220 } |
292 } |
| 221 |
293 |
| 222 /* Set $HOME so that the GTK+ settings get stored in the right place */ |
294 /* Set $HOME so that the GTK+ settings get stored in the right place */ |
| 223 _snwprintf(path2, sizeof(path2) / sizeof(wchar_t), L"HOME=%s", path); |
295 _snwprintf(path2, sizeof(path2) / sizeof(wchar_t), L"HOME=%s", path); |
| 227 * The actual settings dir will be \\path\to\.purple */ |
299 * The actual settings dir will be \\path\to\.purple */ |
| 228 _snwprintf(path2, sizeof(path2) / sizeof(wchar_t), L"PURPLEHOME=%s", path); |
300 _snwprintf(path2, sizeof(path2) / sizeof(wchar_t), L"PURPLEHOME=%s", path); |
| 229 wprintf(L"Setting settings dir: %s\n", path2); |
301 wprintf(L"Setting settings dir: %s\n", path2); |
| 230 _wputenv(path2); |
302 _wputenv(path2); |
| 231 |
303 |
| 232 if (!dll_prep(pidgin_dir)) { |
304 _snwprintf(path2, sizeof(path2) / sizeof(wchar_t), L"%s\\Gtk\\bin", |
| |
305 pidgin_dir); |
| |
306 path2[sizeof(path2) / sizeof(wchar_t) - 1] = L'\0'; |
| |
307 if (check_for_gtk(path2)) |
| |
308 common_dll_prep(path2); |
| |
309 else { |
| 233 /* set the GTK+ path to be \\path\to\GTK\bin */ |
310 /* set the GTK+ path to be \\path\to\GTK\bin */ |
| 234 wcscat(path, L"\\GTK\\bin"); |
311 wcscat(path, L"\\GTK\\bin"); |
| 235 common_dll_prep(path); |
312 common_dll_prep(path); |
| 236 } |
313 } |
| 237 } |
314 } |
| 442 printf("%s", "not found.\n"); |
519 printf("%s", "not found.\n"); |
| 443 |
520 |
| 444 printf("%s", "Looking for MIT Kerberos... "); |
521 printf("%s", "Looking for MIT Kerberos... "); |
| 445 |
522 |
| 446 plen = sizeof(mit_kerberos_path) / sizeof(wchar_t); |
523 plen = sizeof(mit_kerberos_path) / sizeof(wchar_t); |
| 447 if (read_reg_string(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MIT\\Kerberos", L"InstallDir", |
524 if (reg_value_exists(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MIT\\Kerberos", L"InstallDir") && |
| |
525 read_reg_string(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MIT\\Kerberos", L"InstallDir", |
| 448 (LPBYTE) &mit_kerberos_path, &plen)) { |
526 (LPBYTE) &mit_kerberos_path, &plen)) { |
| 449 /* We *could* check for gssapi32.dll */ |
527 /* We *could* check for gssapi32.dll */ |
| 450 wprintf(L"found in '%s'.\n", mit_kerberos_path); |
528 wprintf(L"found in '%s'.\n", mit_kerberos_path); |
| 451 |
529 |
| 452 if (mit_kerberos_path[wcslen(mit_kerberos_path) - 1] != L'\\') |
530 if (mit_kerberos_path[wcslen(mit_kerberos_path) - 1] != L'\\') |