diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-02-28 06:14:01 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-02-28 06:14:01 +0000 |
commit | 5f21e1e3d051b7a7ed4fcde4201fd2fac2895eed (patch) | |
tree | 558eece2bee7749b9939732cd9804f6d0859f7a9 | |
parent | 7315db0829c3845da10ace14a4f6b032429d6ebe (diff) |
win32: output debug and help messages to newly created console.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1016 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ChangeLog.ja | 5 | ||||
-rw-r--r-- | src/main.c | 47 |
3 files changed, 55 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2006-02-28 + + * src/main.c: win32: output debug and help messages to newly created + console. + 2006-02-27 * libsylph/utils.c: execute_async(), execute_sync(): win32: fixed diff --git a/ChangeLog.ja b/ChangeLog.ja index de8abd76..983aed1e 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,8 @@ +2006-02-28 + + * src/main.c: win32: デバッグ、ヘルプメッセージを新規に作成した + コンソールに出力するようにした。 + 2006-02-27 * libsylph/utils.c: execute_async(), execute_sync(): win32: @@ -89,6 +89,7 @@ #ifdef G_OS_WIN32 # include <windows.h> +# include <fcntl.h> #endif #include "version.h" @@ -264,14 +265,46 @@ int main(int argc, char *argv[]) return 0; } +static void init_console(void) +{ +#ifdef G_OS_WIN32 + gint fd; + FILE *fp; + + if (!AllocConsole()) { + g_warning("AllocConsole() failed\n"); + return; + } + + fd = _open_osfhandle((glong)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); + _dup2(fd, 1); + fp = _fdopen(fd, "w"); + *stdout = *fp; + setvbuf(stdout, NULL, _IONBF, 0); + fd = _open_osfhandle((glong)GetStdHandle(STD_ERROR_HANDLE), _O_TEXT); + _dup2(fd, 2); + fp = _fdopen(fd, "w"); + *stderr = *fp; + setvbuf(stderr, NULL, _IONBF, 0); +#endif +} + +static void cleanup_console(void) +{ +#ifdef G_OS_WIN32 + FreeConsole(); +#endif +} + static void parse_cmd_opt(int argc, char *argv[]) { gint i; for (i = 1; i < argc; i++) { - if (!strncmp(argv[i], "--debug", 7)) + if (!strncmp(argv[i], "--debug", 7)) { + init_console(); set_debug_mode(TRUE); - else if (!strncmp(argv[i], "--receive-all", 13)) + } else if (!strncmp(argv[i], "--receive-all", 13)) cmd.receive_all = TRUE; else if (!strncmp(argv[i], "--receive", 9)) cmd.receive = TRUE; @@ -358,6 +391,8 @@ static void parse_cmd_opt(int argc, char *argv[]) } else if (!strncmp(argv[i], "--exit", 6)) { cmd.exit = TRUE; } else if (!strncmp(argv[i], "--help", 6)) { + init_console(); + g_print(_("Usage: %s [OPTION]...\n"), g_basename(argv[0])); @@ -377,6 +412,13 @@ static void parse_cmd_opt(int argc, char *argv[]) g_print("%s\n", _(" --help display this help and exit")); g_print("%s\n", _(" --version output version information and exit")); +#ifdef G_OS_WIN32 + g_print("\n"); + g_print(_("Press any key...")); + _getch(); +#endif + + cleanup_console(); exit(1); } } @@ -632,6 +674,7 @@ void app_will_exit(gboolean force) ssl_done(); #endif + cleanup_console(); sock_cleanup(); if (gtk_main_level() > 0) |