Revision 1016

src/main.c (revision 1016)
89 89

  
90 90
#ifdef G_OS_WIN32
91 91
#  include <windows.h>
92
#  include <fcntl.h>
92 93
#endif
93 94

  
94 95
#include "version.h"
......
264 265
	return 0;
265 266
}
266 267

  
268
static void init_console(void)
269
{
270
#ifdef G_OS_WIN32
271
	gint fd;
272
	FILE *fp;
273

  
274
	if (!AllocConsole()) {
275
		g_warning("AllocConsole() failed\n");
276
		return;
277
	}
278

  
279
	fd = _open_osfhandle((glong)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
280
	_dup2(fd, 1);
281
	fp = _fdopen(fd, "w");
282
	*stdout = *fp;
283
	setvbuf(stdout, NULL, _IONBF, 0);
284
	fd = _open_osfhandle((glong)GetStdHandle(STD_ERROR_HANDLE), _O_TEXT);
285
	_dup2(fd, 2);
286
	fp = _fdopen(fd, "w");
287
	*stderr = *fp;
288
	setvbuf(stderr, NULL, _IONBF, 0);
289
#endif
290
}
291

  
292
static void cleanup_console(void)
293
{
294
#ifdef G_OS_WIN32
295
	FreeConsole();
296
#endif
297
}
298

  
267 299
static void parse_cmd_opt(int argc, char *argv[])
268 300
{
269 301
	gint i;
270 302

  
271 303
	for (i = 1; i < argc; i++) {
272
		if (!strncmp(argv[i], "--debug", 7))
304
		if (!strncmp(argv[i], "--debug", 7)) {
305
			init_console();
273 306
			set_debug_mode(TRUE);
274
		else if (!strncmp(argv[i], "--receive-all", 13))
307
		} else if (!strncmp(argv[i], "--receive-all", 13))
275 308
			cmd.receive_all = TRUE;
276 309
		else if (!strncmp(argv[i], "--receive", 9))
277 310
			cmd.receive = TRUE;
......
358 391
		} else if (!strncmp(argv[i], "--exit", 6)) {
359 392
			cmd.exit = TRUE;
360 393
		} else if (!strncmp(argv[i], "--help", 6)) {
394
			init_console();
395

  
361 396
			g_print(_("Usage: %s [OPTION]...\n"),
362 397
				g_basename(argv[0]));
363 398

  
......
377 412
			g_print("%s\n", _("  --help                 display this help and exit"));
378 413
			g_print("%s\n", _("  --version              output version information and exit"));
379 414

  
415
#ifdef G_OS_WIN32
416
			g_print("\n");
417
			g_print(_("Press any key..."));
418
			_getch();
419
#endif
420

  
421
			cleanup_console();
380 422
			exit(1);
381 423
		}
382 424
	}
......
632 674
	ssl_done();
633 675
#endif
634 676

  
677
	cleanup_console();
635 678
	sock_cleanup();
636 679

  
637 680
	if (gtk_main_level() > 0)
ChangeLog.ja (revision 1016)
1
2006-02-28
2

  
3
	* src/main.c: win32: ?ǥХå????إ??ץ??å??????򿷵??˺???????
4
	  ???󥽡????˽??Ϥ????褦?ˤ?????
5

  
1 6
2006-02-27
2 7

  
3 8
	* libsylph/utils.c: execute_async(), execute_sync(): win32:
ChangeLog (revision 1016)
1
2006-02-28
2

  
3
	* src/main.c: win32: output debug and help messages to newly created
4
	  console.
5

  
1 6
2006-02-27
2 7

  
3 8
	* libsylph/utils.c: execute_async(), execute_sync(): win32: fixed

Also available in: Unified diff