src/physfs_byteorder.c
changeset 1402 c5a5dadb901d
parent 1240 22d4d1bd4e21
equal deleted inserted replaced
1401:ea83e65d4a35 1402:c5a5dadb901d
    86 } /* readAll */
    86 } /* readAll */
    87 
    87 
    88 #define PHYSFS_BYTEORDER_READ(datatype, swaptype) \
    88 #define PHYSFS_BYTEORDER_READ(datatype, swaptype) \
    89     int PHYSFS_read##swaptype(PHYSFS_File *file, PHYSFS_##datatype *val) { \
    89     int PHYSFS_read##swaptype(PHYSFS_File *file, PHYSFS_##datatype *val) { \
    90         PHYSFS_##datatype in; \
    90         PHYSFS_##datatype in; \
    91         BAIL_IF_MACRO(val == NULL, PHYSFS_ERR_INVALID_ARGUMENT, 0); \
    91         BAIL_IF(val == NULL, PHYSFS_ERR_INVALID_ARGUMENT, 0); \
    92         BAIL_IF_MACRO(!readAll(file, &in, sizeof (in)), ERRPASS, 0); \
    92         BAIL_IF_ERRPASS(!readAll(file, &in, sizeof (in)), 0); \
    93         *val = PHYSFS_swap##swaptype(in); \
    93         *val = PHYSFS_swap##swaptype(in); \
    94         return 1; \
    94         return 1; \
    95     }
    95     }
    96 
    96 
    97 PHYSFS_BYTEORDER_READ(sint16, SLE16)
    97 PHYSFS_BYTEORDER_READ(sint16, SLE16)
   114 } /* writeAll */
   114 } /* writeAll */
   115 
   115 
   116 #define PHYSFS_BYTEORDER_WRITE(datatype, swaptype) \
   116 #define PHYSFS_BYTEORDER_WRITE(datatype, swaptype) \
   117     int PHYSFS_write##swaptype(PHYSFS_File *file, PHYSFS_##datatype val) { \
   117     int PHYSFS_write##swaptype(PHYSFS_File *file, PHYSFS_##datatype val) { \
   118         const PHYSFS_##datatype out = PHYSFS_swap##swaptype(val); \
   118         const PHYSFS_##datatype out = PHYSFS_swap##swaptype(val); \
   119         BAIL_IF_MACRO(!writeAll(file, &out, sizeof (out)), ERRPASS, 0); \
   119         BAIL_IF_ERRPASS(!writeAll(file, &out, sizeof (out)), 0); \
   120         return 1; \
   120         return 1; \
   121     }
   121     }
   122 
   122 
   123 PHYSFS_BYTEORDER_WRITE(sint16, SLE16)
   123 PHYSFS_BYTEORDER_WRITE(sint16, SLE16)
   124 PHYSFS_BYTEORDER_WRITE(uint16, ULE16)
   124 PHYSFS_BYTEORDER_WRITE(uint16, ULE16)