[Scummvm-cvs-logs] SF.net SVN: scummvm: [24252] scummvm/trunk/backends/platform/wince/ wince-sdl.cpp

knakos at users.sourceforge.net knakos at users.sourceforge.net
Mon Oct 9 13:42:16 CEST 2006


Revision: 24252
          http://svn.sourceforge.net/scummvm/?rev=24252&view=rev
Author:   knakos
Date:     2006-10-09 04:42:12 -0700 (Mon, 09 Oct 2006)

Log Message:
-----------
Implement stdout/stderr redirection

Modified Paths:
--------------
    scummvm/trunk/backends/platform/wince/wince-sdl.cpp

Modified: scummvm/trunk/backends/platform/wince/wince-sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/wince/wince-sdl.cpp	2006-10-09 11:06:56 UTC (rev 24251)
+++ scummvm/trunk/backends/platform/wince/wince-sdl.cpp	2006-10-09 11:42:12 UTC (rev 24252)
@@ -56,6 +56,10 @@
 #endif
 #endif
 
+#ifdef __GNUC__
+extern "C" _CRTIMP FILE* __cdecl   _wfreopen (const wchar_t*, const wchar_t*, FILE*);
+#endif
+
 using namespace CEGUI;
 
 // ********************************************************************************************
@@ -67,7 +71,7 @@
 #define NAME_ITEM_OPTIONS		"Options"
 #define NAME_ITEM_SKIP			"Skip"
 #define NAME_ITEM_SOUND			"Sound"
-#define NAME_ITEM_ORIENTATION	"Orientation"
+#define NAME_ITEM_ORIENTATION		"Orientation"
 #define NAME_ITEM_BINDKEYS		"Bindkeys"
 
 // Given to the true main, needed for backend adaptation
@@ -111,6 +115,8 @@
 	{0, 0, 0}
 };
 
+#define STDOUT_FNAME "\\scummvm_stdout.txt"
+#define STDERR_FNAME "\\scummvm_stderr.txt"
 
 // ********************************************************************************************
 
@@ -156,8 +162,38 @@
 	OSystem_WINCE3::initScreenInfos();
 	
 	/* Avoid print problems - this file will be put in RAM anyway */
-	stdout_file = fopen("\\scummvm_stdout.txt", "w");
-	stderr_file = fopen("\\scummvm_stderr.txt", "w");
+#ifndef __GNUC__
+	stdout_file = fopen(STDOUT_FNAME, "w");
+	stderr_file = fopen(STDERR_FNAME, "w");
+#else
+	/* Redirect standard input and standard output */
+	FILE *newfp = _wfreopen(TEXT(STDOUT_FNAME), TEXT("w"), stdout);
+	if (newfp == NULL) {
+#if !defined(stdout)
+		stdout = fopen(STDOUT_FNAME, "w");
+		stdout_file = stdout;
+#else
+		newfp = fopen(STDOUT_FNAME, "w");
+		if (newfp) {
+			*stdout = *newfp;
+			stdout_file = stdout;
+		}
+#endif
+	}
+	newfp = _wfreopen(TEXT(STDERR_FNAME), TEXT("w"), stderr);
+	if (newfp == NULL) {
+#if !defined(stderr)
+		stderr = fopen(STDERR_FNAME, "w");
+		stderr_file = stderr;
+#else
+		newfp = fopen(STDERR_FNAME, "w");
+		if (newfp) {
+			*stderr = *newfp;
+			stderr_file = stderr;
+		}
+#endif
+	}
+#endif
 
 	int res = 0;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list