physfs_byteorder.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 10 Jul 2002 07:21:48 +0000
changeset 321 50986060bee8
parent 214 19846c18071b
child 497 40cc2b2f3a09
permissions -rw-r--r--
Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
177
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/**
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * PhysicsFS; a portable, flexible file i/o abstraction.
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 * Documentation is in physfs.h. It's verbose, honest.  :)
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 *
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 * Please see the file LICENSE in the source's root directory.
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 *
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
 *  This file written by Ryan C. Gordon.
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
 */
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
214
19846c18071b Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents: 201
diff changeset
    11
#if HAVE_CONFIG_H
19846c18071b Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents: 201
diff changeset
    12
#  include <config.h>
19846c18071b Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents: 201
diff changeset
    13
#endif
19846c18071b Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents: 201
diff changeset
    14
177
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
#include <stdio.h>
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
#include <stdlib.h>
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
#include <assert.h>
321
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
    18
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
    19
#define __PHYSICSFS_INTERNAL__
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
    20
#include "physfs_internal.h"
177
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
/* This byteorder stuff was lifted from SDL. http://www.libsdl.org/ */
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
#define PHYSFS_LIL_ENDIAN  1234
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
#define PHYSFS_BIG_ENDIAN  4321
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
#if  defined(__i386__) || defined(__ia64__) || defined(WIN32) || \
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
    (defined(__alpha__) || defined(__alpha)) || \
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
     defined(__arm__) || \
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
    (defined(__mips__) && defined(__MIPSEL__)) || \
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
     defined(__SYMBIAN32__) || \
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
     defined(__LITTLE_ENDIAN__)
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
#define PHYSFS_BYTEORDER    PHYSFS_LIL_ENDIAN
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
#else
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
#define PHYSFS_BYTEORDER    PHYSFS_BIG_ENDIAN
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
#endif
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
/* The macros used to swap values */
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
/* Try to use superfast macros on systems that support them */
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
#ifdef linux
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
#include <asm/byteorder.h>
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
#ifdef __arch__swab16
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
#define PHYSFS_Swap16  __arch__swab16
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
#endif
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
#ifdef __arch__swab32
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
#define PHYSFS_Swap32  __arch__swab32
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
#endif
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
#endif /* linux */
201
7ea2ae5d1a6c Patched to stop -ansi bitching.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
    49
7ea2ae5d1a6c Patched to stop -ansi bitching.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
    50
#if (defined _MSC_VER)
7ea2ae5d1a6c Patched to stop -ansi bitching.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
    51
#define __inline__ __inline
7ea2ae5d1a6c Patched to stop -ansi bitching.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
    52
#endif
7ea2ae5d1a6c Patched to stop -ansi bitching.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
    53
177
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
#ifndef PHYSFS_Swap16
201
7ea2ae5d1a6c Patched to stop -ansi bitching.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
    55
static __inline__ PHYSFS_uint16 PHYSFS_Swap16(PHYSFS_uint16 D)
177
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
{
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
	return((D<<8)|(D>>8));
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
}
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
#endif
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
#ifndef PHYSFS_Swap32
201
7ea2ae5d1a6c Patched to stop -ansi bitching.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
    61
static __inline__ PHYSFS_uint32 PHYSFS_Swap32(PHYSFS_uint32 D)
177
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
{
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
	return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
}
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
#endif
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
#ifndef PHYSFS_NO_64BIT_SUPPORT
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
#ifndef PHYSFS_Swap64
201
7ea2ae5d1a6c Patched to stop -ansi bitching.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
    68
static __inline__ PHYSFS_uint64 PHYSFS_Swap64(PHYSFS_uint64 val) {
177
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
	PHYSFS_uint32 hi, lo;
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
	/* Separate into high and low 32-bit values and swap them */
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
	lo = (PHYSFS_uint32)(val&0xFFFFFFFF);
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
	val >>= 32;
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
	hi = (PHYSFS_uint32)(val&0xFFFFFFFF);
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
	val = PHYSFS_Swap32(lo);
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
	val <<= 32;
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
	val |= PHYSFS_Swap32(hi);
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
	return(val);
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
}
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
#endif
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
#else
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
#ifndef PHYSFS_Swap64
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
/* This is mainly to keep compilers from complaining in PHYSFS code.
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
   If there is no real 64-bit datatype, then compilers will complain about
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
   the fake 64-bit datatype that PHYSFS provides when it compiles user code.
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
*/
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
#define PHYSFS_Swap64(X)	(X)
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
#endif
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
#endif /* PHYSFS_NO_64BIT_SUPPORT */
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
/* Byteswap item from the specified endianness to the native endianness */
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
#if PHYSFS_BYTEORDER == PHYSFS_LIL_ENDIAN
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 x) { return(PHYSFS_Swap16(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 x) { return(PHYSFS_Swap16(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 x) { return(PHYSFS_Swap32(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 x) { return(PHYSFS_Swap32(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 x) { return(PHYSFS_Swap64(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 x) { return(PHYSFS_Swap64(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
#else
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 x) { return(PHYSFS_Swap16(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 x) { return(PHYSFS_Swap16(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 x) { return(PHYSFS_Swap32(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 x) { return(PHYSFS_Swap32(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 x) { return(PHYSFS_Swap64(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 x) { return(PHYSFS_Swap64(x)); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 x) { return(x); }
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
#endif
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
321
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   123
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   124
int PHYSFS_readSLE16(PHYSFS_file *file, PHYSFS_sint16 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   125
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   126
    PHYSFS_sint16 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   127
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   128
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   129
    *val = PHYSFS_swapSLE16(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   130
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   131
} /* PHYSFS_readSLE16 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   132
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   133
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   134
int PHYSFS_readULE16(PHYSFS_file *file, PHYSFS_uint16 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   135
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   136
    PHYSFS_uint16 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   137
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   138
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   139
    *val = PHYSFS_swapULE16(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   140
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   141
} /* PHYSFS_readULE16 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   142
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   143
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   144
int PHYSFS_readSBE16(PHYSFS_file *file, PHYSFS_sint16 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   145
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   146
    PHYSFS_sint16 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   147
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   148
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   149
    *val = PHYSFS_swapSBE16(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   150
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   151
} /* PHYSFS_readSBE16 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   152
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   153
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   154
int PHYSFS_readUBE16(PHYSFS_file *file, PHYSFS_uint16 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   155
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   156
    PHYSFS_uint16 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   157
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   158
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   159
    *val = PHYSFS_swapUBE16(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   160
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   161
} /* PHYSFS_readUBE16 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   162
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   163
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   164
int PHYSFS_readSLE32(PHYSFS_file *file, PHYSFS_sint32 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   165
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   166
    PHYSFS_sint32 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   167
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   168
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   169
    *val = PHYSFS_swapSLE32(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   170
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   171
} /* PHYSFS_readSLE32 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   172
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   173
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   174
int PHYSFS_readULE32(PHYSFS_file *file, PHYSFS_uint32 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   175
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   176
    PHYSFS_uint32 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   177
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   178
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   179
    *val = PHYSFS_swapULE32(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   180
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   181
} /* PHYSFS_readULE32 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   182
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   183
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   184
int PHYSFS_readSBE32(PHYSFS_file *file, PHYSFS_sint32 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   185
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   186
    PHYSFS_sint32 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   187
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   188
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   189
    *val = PHYSFS_swapSBE32(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   190
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   191
} /* PHYSFS_readSBE32 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   192
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   193
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   194
int PHYSFS_readUBE32(PHYSFS_file *file, PHYSFS_uint32 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   195
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   196
    PHYSFS_uint32 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   197
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   198
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   199
    *val = PHYSFS_swapUBE32(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   200
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   201
} /* PHYSFS_readUBE32 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   202
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   203
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   204
int PHYSFS_readSLE64(PHYSFS_file *file, PHYSFS_sint64 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   205
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   206
    PHYSFS_sint64 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   207
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   208
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   209
    *val = PHYSFS_swapSLE64(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   210
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   211
} /* PHYSFS_readSLE64 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   212
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   213
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   214
int PHYSFS_readULE64(PHYSFS_file *file, PHYSFS_uint64 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   215
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   216
    PHYSFS_uint64 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   217
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   218
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   219
    *val = PHYSFS_swapULE64(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   220
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   221
} /* PHYSFS_readULE64 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   222
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   223
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   224
int PHYSFS_readSBE64(PHYSFS_file *file, PHYSFS_sint64 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   225
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   226
    PHYSFS_sint64 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   227
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   228
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   229
    *val = PHYSFS_swapSBE64(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   230
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   231
} /* PHYSFS_readSBE64 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   232
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   233
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   234
int PHYSFS_readUBE64(PHYSFS_file *file, PHYSFS_uint64 *val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   235
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   236
    PHYSFS_uint64 in;
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   237
    BAIL_IF_MACRO(val == NULL, ERR_INVALID_ARGUMENT, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   238
    BAIL_IF_MACRO(PHYSFS_read(file, &in, sizeof (in), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   239
    *val = PHYSFS_swapUBE64(in);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   240
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   241
} /* PHYSFS_readUBE64 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   242
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   243
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   244
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   245
int PHYSFS_writeSLE16(PHYSFS_file *file, PHYSFS_sint16 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   246
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   247
    PHYSFS_sint16 out = PHYSFS_swapSLE16(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   248
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   249
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   250
} /* PHYSFS_writeSLE16 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   251
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   252
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   253
int PHYSFS_writeULE16(PHYSFS_file *file, PHYSFS_uint16 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   254
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   255
    PHYSFS_uint16 out = PHYSFS_swapULE16(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   256
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   257
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   258
} /* PHYSFS_writeULE16 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   259
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   260
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   261
int PHYSFS_writeSBE16(PHYSFS_file *file, PHYSFS_sint16 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   262
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   263
    PHYSFS_sint16 out = PHYSFS_swapSBE16(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   264
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   265
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   266
} /* PHYSFS_writeSBE16 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   267
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   268
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   269
int PHYSFS_writeUBE16(PHYSFS_file *file, PHYSFS_uint16 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   270
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   271
    PHYSFS_uint16 out = PHYSFS_swapUBE16(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   272
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   273
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   274
} /* PHYSFS_writeUBE16 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   275
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   276
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   277
int PHYSFS_writeSLE32(PHYSFS_file *file, PHYSFS_sint32 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   278
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   279
    PHYSFS_sint32 out = PHYSFS_swapSLE32(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   280
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   281
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   282
} /* PHYSFS_writeSLE32 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   283
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   284
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   285
int PHYSFS_writeULE32(PHYSFS_file *file, PHYSFS_uint32 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   286
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   287
    PHYSFS_uint32 out = PHYSFS_swapULE32(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   288
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   289
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   290
} /* PHYSFS_writeULE32 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   291
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   292
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   293
int PHYSFS_writeSBE32(PHYSFS_file *file, PHYSFS_sint32 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   294
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   295
    PHYSFS_sint32 out = PHYSFS_swapSBE32(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   296
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   297
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   298
} /* PHYSFS_writeSBE32 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   299
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   300
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   301
int PHYSFS_writeUBE32(PHYSFS_file *file, PHYSFS_uint32 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   302
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   303
    PHYSFS_uint32 out = PHYSFS_swapUBE32(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   304
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   305
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   306
} /* PHYSFS_writeUBE32 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   307
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   308
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   309
int PHYSFS_writeSLE64(PHYSFS_file *file, PHYSFS_sint64 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   310
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   311
    PHYSFS_sint64 out = PHYSFS_swapSLE64(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   312
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   313
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   314
} /* PHYSFS_writeSLE64 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   315
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   316
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   317
int PHYSFS_writeULE64(PHYSFS_file *file, PHYSFS_uint64 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   318
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   319
    PHYSFS_uint64 out = PHYSFS_swapULE64(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   320
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   321
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   322
} /* PHYSFS_writeULE64 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   323
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   324
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   325
int PHYSFS_writeSBE64(PHYSFS_file *file, PHYSFS_sint64 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   326
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   327
    PHYSFS_sint64 out = PHYSFS_swapSBE64(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   328
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   329
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   330
} /* PHYSFS_writeSBE64 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   331
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   332
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   333
int PHYSFS_writeUBE64(PHYSFS_file *file, PHYSFS_uint64 val)
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   334
{
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   335
    PHYSFS_uint64 out = PHYSFS_swapUBE64(val);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   336
    BAIL_IF_MACRO(PHYSFS_write(file, &out, sizeof (out), 1) != 1, NULL, 0);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   337
    return(1);
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   338
} /* PHYSFS_writeUBE64 */
50986060bee8 Added PHYSFS_(read|write)[SU][BL]E(16|32|64).
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   339
177
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   340
/* end of physfs_byteorder.c ... */
9aaf01f4b8ec Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   341