Mercurial > pidgin
comparison src/win_gaim.c @ 11060:52d6b10025ca
[gaim-migrate @ 13014]
On Windows XP or newer, try to use the existing console, if one is present.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 05 Jul 2005 03:54:46 +0000 |
parents | cfacc0de0d94 |
children | e865bdbbf91d |
comparison
equal
deleted
inserted
replaced
11059:c86d423df757 | 11060:52d6b10025ca |
---|---|
22 * You should have received a copy of the GNU General Public License | 22 * You should have received a copy of the GNU General Public License |
23 * along with this program; if not, write to the Free Software | 23 * along with this program; if not, write to the Free Software |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
25 * | 25 * |
26 */ | 26 */ |
27 | |
28 #ifndef _WIN32_WINNT | |
29 # define _WIN32_WINNT 0x0501 | |
30 #endif | |
27 #include <windows.h> | 31 #include <windows.h> |
28 #include <fcntl.h> | 32 #include <fcntl.h> |
29 #include <stdlib.h> | 33 #include <stdlib.h> |
30 #include <string.h> | 34 #include <string.h> |
31 #include <stdio.h> | 35 #include <stdio.h> |
32 | 36 |
37 /** Currently missing from win32-api */ | |
38 #ifndef ATTACH_PARENT_PROCESS | |
39 # define ATTACH_PARENT_PROCESS -1 | |
40 #endif | |
41 | |
33 typedef int (CALLBACK* LPFNGAIMMAIN)(HINSTANCE, int, char**); | 42 typedef int (CALLBACK* LPFNGAIMMAIN)(HINSTANCE, int, char**); |
34 typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCTSTR); | 43 typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCTSTR); |
44 typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD); | |
35 | 45 |
36 /* | 46 /* |
37 * PROTOTYPES | 47 * PROTOTYPES |
38 */ | 48 */ |
39 static LPFNGAIMMAIN gaim_main = NULL; | 49 static LPFNGAIMMAIN gaim_main = NULL; |
287 { | 297 { |
288 char errbuf[512]; | 298 char errbuf[512]; |
289 char gaimdir[MAX_PATH]; | 299 char gaimdir[MAX_PATH]; |
290 HMODULE hmod; | 300 HMODULE hmod; |
291 | 301 |
292 /* If debug flag used, create console for output */ | 302 /* If debug or help flag used, create console for output */ |
293 if(strstr(lpszCmdLine, "-d")) { | 303 if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h")) { |
294 if(AllocConsole()) | 304 LPFNATTACHCONSOLE MyAttachConsole = NULL; |
295 freopen ("CONOUT$", "w", stdout); | 305 if ((hmod = GetModuleHandle("kernel32.dll"))) { |
296 } | 306 MyAttachConsole = |
307 (LPFNATTACHCONSOLE) | |
308 GetProcAddress(hmod, "AttachConsole"); | |
309 } | |
310 if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) | |
311 || AllocConsole()) | |
312 freopen("CONOUT$", "w", stdout); | |
313 } | |
297 | 314 |
298 /* Load exception handler if we have it */ | 315 /* Load exception handler if we have it */ |
299 if(GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) { | 316 if(GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) { |
300 char *tmp = gaimdir; | 317 char *tmp = gaimdir; |
301 char *prev = NULL; | 318 char *prev = NULL; |