diff src/file/SDL_rwops.c @ 1354:22f39393668a

Fixed build problem with SDL_string.c Officially deprecated SDL_byteorder.h, SDL_getenv.h and SDL_types.h Moved endian-related SDL_rwops code into SDL_rwops.c
author Sam Lantinga <slouken@libsdl.org>
date Thu, 09 Feb 2006 09:38:05 +0000
parents 604d73db6802
children c71e05b4dc2e
line wrap: on
line diff
--- a/src/file/SDL_rwops.c	Thu Feb 09 09:07:13 2006 +0000
+++ b/src/file/SDL_rwops.c	Thu Feb 09 09:38:05 2006 +0000
@@ -24,11 +24,11 @@
    data sources.  It can easily be extended to files, memory, etc.
 */
 
-#include "SDL_stdlib.h"
-#include "SDL_string.h"
 #include "SDL_error.h"
+#include "SDL_endian.h"
 #include "SDL_rwops.h"
 
+
 #ifdef HAVE_STDIO_H
 
 /* Functions to read/write stdio file pointers */
@@ -303,3 +303,79 @@
 {
 	SDL_free(area);
 }
+
+/* Functions for dynamically reading and writing endian-specific values */
+
+Uint16 SDL_ReadLE16 (SDL_RWops *src)
+{
+	Uint16 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapLE16(value));
+}
+Uint16 SDL_ReadBE16 (SDL_RWops *src)
+{
+	Uint16 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapBE16(value));
+}
+Uint32 SDL_ReadLE32 (SDL_RWops *src)
+{
+	Uint32 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapLE32(value));
+}
+Uint32 SDL_ReadBE32 (SDL_RWops *src)
+{
+	Uint32 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapBE32(value));
+}
+Uint64 SDL_ReadLE64 (SDL_RWops *src)
+{
+	Uint64 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapLE64(value));
+}
+Uint64 SDL_ReadBE64 (SDL_RWops *src)
+{
+	Uint64 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapBE64(value));
+}
+
+int SDL_WriteLE16 (SDL_RWops *dst, Uint16 value)
+{
+	value = SDL_SwapLE16(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteBE16 (SDL_RWops *dst, Uint16 value)
+{
+	value = SDL_SwapBE16(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteLE32 (SDL_RWops *dst, Uint32 value)
+{
+	value = SDL_SwapLE32(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteBE32 (SDL_RWops *dst, Uint32 value)
+{
+	value = SDL_SwapBE32(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteLE64 (SDL_RWops *dst, Uint64 value)
+{
+	value = SDL_SwapLE64(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteBE64 (SDL_RWops *dst, Uint64 value)
+{
+	value = SDL_SwapBE64(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}