Added MOJODDS_isDDS().
authorRyan C. Gordon <icculus@icculus.org>
Sun, 08 May 2011 21:28:28 -0400
changeset 5 ab7382a45d11
parent 4 f7af15116713
child 6 b693c592d4ab
Added MOJODDS_isDDS().
mojodds.c
mojodds.h
--- a/mojodds.c	Sat May 07 23:12:10 2011 -0400
+++ b/mojodds.c	Sun May 08 21:28:28 2011 -0400
@@ -173,6 +173,13 @@
 
 
 // !!! FIXME: improve the crap out of this API later.
+int MOJODDS_isDDS(const void *_ptr, const unsigned long _len)
+{
+    size_t len = (size_t) _len;
+    const uint8 *ptr = (const uint8 *) _ptr;
+    return (readui32(&ptr, &len) == DDS_MAGIC);
+}
+
 int MOJODDS_getTexture(const void *_ptr, const unsigned long _len,
                        const void **_tex, unsigned long *_texlen, int *_dxtver,
                        unsigned int *_w, unsigned int *_h)
--- a/mojodds.h	Sat May 07 23:12:10 2011 -0400
+++ b/mojodds.h	Sun May 08 21:28:28 2011 -0400
@@ -3,6 +3,7 @@
 
 /* !!! FIXME: flesh this file out. */
 
+int MOJODDS_isDDS(const void *_ptr, const unsigned long _len);
 int MOJODDS_getTexture(const void *_ptr, const unsigned long _len,
                        const void **_tex, unsigned long *_texlen, int *_dxtver,
                        unsigned int *_w, unsigned int *_h);