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-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -286,14 +245,23 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
-
+
-
+
diff --git a/include/SDL/SDL.h b/include/SDL/SDL.h
index 6087b7c..5a51d09 100644
--- a/include/SDL/SDL.h
+++ b/include/SDL/SDL.h
@@ -87,6 +87,8 @@ extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
*/
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
+extern DECLSPEC void SDLCALL cSDL_LogToFile(const char *fmt, ... );
+
/** This function cleans up all initialized subsystems and unloads the
* dynamically linked library. You should call it upon all exit conditions.
*/
diff --git a/include/SDL/SDL_rwops.h b/include/SDL/SDL_rwops.h
index 98361d7..6c3793f 100644
--- a/include/SDL/SDL_rwops.h
+++ b/include/SDL/SDL_rwops.h
@@ -74,7 +74,7 @@ typedef struct SDL_RWops {
} buffer;
} win32io;
#endif
-#ifdef HAVE_STDIO_H
+#ifdef HAVE_STDIO_H
struct {
int autoclose;
FILE *fp;
@@ -120,10 +120,10 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
/** @name Macros to easily read and write from an SDL_RWops structure */
/*@{*/
#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
-#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
+#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
-#define SDL_RWclose(ctx) (ctx)->close(ctx)
+#define SDL_RWclose(ctx) (ctx)->close(ctx)
/*@}*/
/** @name Read an item of the specified endianness and return in native format */
diff --git a/include/SDL_config.h b/include/SDL_config.h
index 0d9a007..389bd22 100644
--- a/include/SDL_config.h
+++ b/include/SDL_config.h
@@ -25,7 +25,7 @@
#define FXCG50 1
-#include "SDL_platform.h"
+#include "SDL/SDL_platform.h"
@@ -45,7 +45,7 @@
/// Added a config_file for Casio fx-CG10/20/50/PRIZM/Graph 90+E
#elif defined(__CASIOPRIZM__)
-#include "SDL_config_prizm.h"
+#include "SDL/SDL_config_prizm.h"
#else
#include "SDL_config_minimal.h"
diff --git a/src/SDL.c b/src/SDL.c
index 87f1b1a..8e42ccc 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -23,7 +23,7 @@
/* Initialization code for SDL */
-#include "SDL.h"
+#include "SDL/SDL.h"
#include "SDL_fatal.h"
#if !SDL_VIDEO_DISABLED
#include "video/SDL_leaks.h"
@@ -33,6 +33,27 @@
#include
#endif
+#include
+#include
+#include
+
+
+void cSDL_LogToFile(const char *fmt, ... )
+{
+ FILE * fp = fopen( "OutLog.txt", "a" );
+ if (fp==NULL) return;
+
+ va_list args;
+ va_start( args, fmt );
+
+ vfprintf( fp, fmt, args );
+ fprintf( fp, "\n");
+
+ va_end( args );
+ fclose( fp );
+}
+
+
/* Initialization/Cleanup routines */
#if !SDL_JOYSTICK_DISABLED
extern int SDL_JoystickInit(void);
@@ -49,7 +70,7 @@ extern void SDL_TimerQuit(void);
#endif
/* The current SDL version */
-static SDL_version version =
+static SDL_version version =
{ SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL };
/* The initialized subsystems */
@@ -228,7 +249,7 @@ void SDL_Quit(void)
/* Print the number of surfaces not freed */
if ( surfaces_allocated != 0 ) {
- fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n",
+ fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n",
surfaces_allocated);
}
#endif
@@ -332,8 +353,8 @@ unsigned _System LibMain(unsigned hmod, unsigned termination)
#define WIN32_LEAN_AND_MEAN
#include
-BOOL APIENTRY _DllMainCRTStartup( HANDLE hModule,
- DWORD ul_reason_for_call,
+BOOL APIENTRY _DllMainCRTStartup( HANDLE hModule,
+ DWORD ul_reason_for_call,
LPVOID lpReserved )
{
switch (ul_reason_for_call) {
diff --git a/src/SDL_error.c b/src/SDL_error.c
index 0f06bd5..6e2dc01 100644
--- a/src/SDL_error.c
+++ b/src/SDL_error.c
@@ -23,7 +23,7 @@
/* Simple error handling in SDL */
-#include "SDL_error.h"
+#include "SDL/SDL_error.h"
#include "SDL_error_c.h"
/* Routine to get the thread-specific error variable */
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index 1593e97..aabdfbc 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -27,13 +27,13 @@
#include "SDL_endian.h"
#include "SDL_rwops.h"
-
+#include "SDL/SDL.h"
#if defined(__WIN32__) && !defined(__SYMBIAN32__)
/* Functions to read/write Win32 API file pointers */
/* Will not use it on WinCE because stdio is buffered, it means
- faster, and all stdio functions anyway are embedded in coredll.dll -
+ faster, and all stdio functions anyway are embedded in coredll.dll -
the main wince dll*/
#define WINDOWS_LEAN_AND_MEAN
@@ -57,7 +57,7 @@ static int SDLCALL win32_file_open(SDL_RWops *context, const char *filename, con
if (!context)
return -1; /* failed (invalid call) */
-
+
context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* mark this as unusable */
context->hidden.win32io.buffer.data = NULL;
context->hidden.win32io.buffer.size = 0;
@@ -69,7 +69,7 @@ static int SDLCALL win32_file_open(SDL_RWops *context, const char *filename, con
/* "a" = writing, append file may not exist */
/* "a+"= append + read, file may not exist */
/* "w+" = read, write, truncate. file may not exist */
-
+
must_exist = ( SDL_strchr(mode,'r') != NULL ) ? OPEN_EXISTING : 0;
truncate = ( SDL_strchr(mode,'w') != NULL ) ? CREATE_ALWAYS : 0;
r_right = ( SDL_strchr(mode,'+') != NULL || must_exist ) ? GENERIC_READ : 0;
@@ -97,7 +97,7 @@ static int SDLCALL win32_file_open(SDL_RWops *context, const char *filename, con
SDL_SetError("Unable to convert filename to Unicode");
return -1;
}
- h = CreateFile(filenameW, (w_right|r_right), (w_right)? 0 : FILE_SHARE_READ,
+ h = CreateFile(filenameW, (w_right|r_right), (w_right)? 0 : FILE_SHARE_READ,
NULL, (must_exist|truncate|a_mode), FILE_ATTRIBUTE_NORMAL,NULL);
SDL_stack_free(filenameW);
}
@@ -187,7 +187,7 @@ static int SDLCALL win32_file_seek(SDL_RWops *context, int offset, int whence)
{
DWORD win32whence;
int file_pos;
-
+
if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE) {
SDL_SetError("win32_file_seek: invalid context/file not opened");
return -1;
@@ -200,14 +200,14 @@ static int SDLCALL win32_file_seek(SDL_RWops *context, int offset, int whence)
context->hidden.win32io.buffer.left = 0;
switch (whence) {
- case RW_SEEK_SET:
+ case RW_SEEK_SET:
win32whence = FILE_BEGIN; break;
case RW_SEEK_CUR:
win32whence = FILE_CURRENT; break;
case RW_SEEK_END:
win32whence = FILE_END; break;
default:
- SDL_SetError("win32_file_seek: Unknown value for 'whence'");
+ SDL_SetError("win32_file_seek: Unknown value for 'whence'");
return -1;
}
@@ -215,27 +215,27 @@ static int SDLCALL win32_file_seek(SDL_RWops *context, int offset, int whence)
if ( file_pos != INVALID_SET_FILE_POINTER )
return file_pos; /* success */
-
+
SDL_Error(SDL_EFSEEK);
return -1; /* error */
}
static int SDLCALL win32_file_read(SDL_RWops *context, void *ptr, int size, int maxnum)
{
- int total_need;
- int total_read = 0;
+ int total_need;
+ int total_read = 0;
int read_ahead;
DWORD byte_read;
-
+
total_need = size*maxnum;
-
- if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE || total_need<=0 || !size)
+
+ if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE || total_need<=0 || !size)
return 0;
if (context->hidden.win32io.buffer.left > 0) {
void *data = (char *)context->hidden.win32io.buffer.data +
context->hidden.win32io.buffer.size -
context->hidden.win32io.buffer.left;
- read_ahead = SDL_min(total_need, context->hidden.win32io.buffer.left);
+ read_ahead = SDL_min(total_need, context->hidden.win32io.buffer.left);
SDL_memcpy(ptr, data, read_ahead);
context->hidden.win32io.buffer.left -= read_ahead;
@@ -243,7 +243,7 @@ static int SDLCALL win32_file_read(SDL_RWops *context, void *ptr, int size, int
return maxnum;
}
ptr = (char *)ptr + read_ahead;
- total_need -= read_ahead;
+ total_need -= read_ahead;
total_read += read_ahead;
}
@@ -268,13 +268,13 @@ static int SDLCALL win32_file_read(SDL_RWops *context, void *ptr, int size, int
}
static int SDLCALL win32_file_write(SDL_RWops *context, const void *ptr, int size, int num)
{
-
- int total_bytes;
+
+ int total_bytes;
DWORD byte_written,nwritten;
-
+
total_bytes = size*num;
- if (!context || context->hidden.win32io.h==INVALID_HANDLE_VALUE || total_bytes<=0 || !size)
+ if (!context || context->hidden.win32io.h==INVALID_HANDLE_VALUE || total_bytes<=0 || !size)
return 0;
if (context->hidden.win32io.buffer.left) {
@@ -289,19 +289,19 @@ static int SDLCALL win32_file_write(SDL_RWops *context, const void *ptr, int siz
return 0;
}
}
-
+
if (!WriteFile(context->hidden.win32io.h,ptr,total_bytes,&byte_written,NULL)) {
SDL_Error(SDL_EFWRITE);
return 0;
}
-
+
nwritten = byte_written/size;
return nwritten;
}
static int SDLCALL win32_file_close(SDL_RWops *context)
{
-
- if ( context ) {
+
+ if ( context ) {
if (context->hidden.win32io.h != INVALID_HANDLE_VALUE) {
CloseHandle(context->hidden.win32io.h);
context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* to be sure */
@@ -322,6 +322,8 @@ static int SDLCALL win32_file_close(SDL_RWops *context)
static int SDLCALL stdio_seek(SDL_RWops *context, int offset, int whence)
{
+ ///cSDL_LogToFile( "je suis dans stdio_seek" );
+
if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) {
return(ftell(context->hidden.stdio.fp));
} else {
@@ -331,26 +333,36 @@ static int SDLCALL stdio_seek(SDL_RWops *context, int offset, int whence)
}
static int SDLCALL stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum)
{
+ cSDL_LogToFile( "je suis dans stdio_read" );
+
size_t nread;
- nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
+ nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
if ( nread == 0 && ferror(context->hidden.stdio.fp) ) {
+ cSDL_LogToFile( "error SDL_EFREAD" );
SDL_Error(SDL_EFREAD);
}
+ cSDL_LogToFile( "nread is equal to %d", (int) nread );
return(nread);
}
static int SDLCALL stdio_write(SDL_RWops *context, const void *ptr, int size, int num)
{
size_t nwrote;
+ ///cSDL_LogToFile( "je suis dans stdio_write" );
+
nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp);
if ( nwrote == 0 && ferror(context->hidden.stdio.fp) ) {
SDL_Error(SDL_EFWRITE);
}
return(nwrote);
}
+
static int SDLCALL stdio_close(SDL_RWops *context)
{
+
+ ///cSDL_LogToFile( "je suis dans stdio_close" );
+
if ( context ) {
if ( context->hidden.stdio.autoclose ) {
/* WARNING: Check the return value here! */
@@ -499,7 +511,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
if (win32_file_open(rwops,file,mode) < 0) {
SDL_FreeRW(rwops);
return NULL;
- }
+ }
rwops->seek = win32_file_seek;
rwops->read = win32_file_read;
rwops->write = win32_file_write;