[pan2: 16/68] Add console suport for windows.
- From: Petr Kovář <pmkovar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2: 16/68] Add console suport for windows.
- Date: Tue, 8 Feb 2011 22:59:22 +0000 (UTC)
commit 10b116ca1f73234817ff4fc33fd50c21769341d3
Author: K. Haley <haleykd users sf net>
Date: Thu Jan 7 17:42:35 2010 -0700
Add console suport for windows.
Change build so that test programs are built as console app.
Attach to console of parent for --help & --debug options. Only
works if started from a console.
configure.in | 2 +-
pan/gui/Makefile.am | 4 ++++
pan/gui/pan.cc | 39 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 43 insertions(+), 2 deletions(-)
---
diff --git a/configure.in b/configure.in
index 8f806f2..958b037 100644
--- a/configure.in
+++ b/configure.in
@@ -91,7 +91,7 @@ case $host_os in
;;
*cygwin|*mingw32*)
- CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
+ CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32"
CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN"
LIBS="$LIBS -lshell32 -lws2_32"
panlocaledir="locale"
diff --git a/pan/gui/Makefile.am b/pan/gui/Makefile.am
index 6a87d3f..ffbb094 100644
--- a/pan/gui/Makefile.am
+++ b/pan/gui/Makefile.am
@@ -93,3 +93,7 @@ endif
pan_SOURCES = gui.cc pan.cc $(WINRC)
pan_LDADD = ./libpangui.a $(WINRCOBJ) ../data-impl/libpandata.a ../tasks/libtasks.a ../data/libdata.a ../usenet-utils/libusenetutils.a ../general/libgeneralutils.a ../../uulib/libuu.a @GTKSPELL_LIBS@ @GTK_LIBS@ @GMIME_LIBS@ @GLIB_LIBS@
+
+if HAVE_WIN32
+pan_LDFLAGS = -mwindows
+endif
diff --git a/pan/gui/pan.cc b/pan/gui/pan.cc
index 1ca3d49..71af6b4 100644
--- a/pan/gui/pan.cc
+++ b/pan/gui/pan.cc
@@ -16,7 +16,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <memory>
+#include <memory>
+#include <fstream>
#include <config.h>
#include <signal.h>
extern "C" {
@@ -185,8 +186,43 @@ namespace
Queue & q;
};
+#ifdef G_OS_WIN32
+ void console()
+ {
+ using namespace std;
+ static bool done = false;
+ if ( done ) return;
+ done = true;
+
+ //AllocConsole();
+ if ( !AttachConsole( -1 ) ) return;
+ static ofstream out("CONOUT$");
+ static ofstream err("CONOUT$");
+ streambuf *tmp, *t2;
+
+ tmp = cout.rdbuf();
+ t2 = out.rdbuf();
+ cout.ios::rdbuf( t2 );
+ out.ios::rdbuf( tmp );
+
+ tmp = cerr.rdbuf();
+ t2 = err.rdbuf();
+ cerr.ios::rdbuf( t2 );
+ err.ios::rdbuf( tmp );
+
+ freopen( "CONOUT$", "w", stdout );
+ freopen( "CONOUT$", "w", stderr );
+ }
+#else
+ void console()
+ {
+ return;
+ }
+#endif
+
void usage ()
{
+ console();
std::cerr << "Pan " << VERSION << "\n\n" <<
_("General Options\n"
" -h, --help Show this usage page.\n"
@@ -231,6 +267,7 @@ main (int argc, char *argv[])
else if (!strcmp(tok,"--no-gui") || !strcmp(tok,"--nogui"))
gui = false;
else if (!strcmp (tok, "--debug")) { // do --debug --debug for verbose debug
+ console();
if (_debug_flag) _debug_verbose_flag = true;
else _debug_flag = true;
} else if (!strcmp (tok, "--nzb"))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]