Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.     SDL - Simple DirectMedia Layer
  3.     Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public
  16.     License along with this library; if not, write to the Free
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  
  19.     Sam Lantinga
  20.     slouken@devolution.com
  21. */
  22.  
  23. /* Functions for dynamically reading and writing endian-specific values */
  24.  
  25. #include "SDL_endian.h"
  26.  
  27. Uint16 SDL_ReadLE16 (SDL_RWops *src)
  28. {
  29.         Uint16 value;
  30.  
  31.         SDL_RWread(src, &value, (sizeof value), 1);
  32.         return(SDL_SwapLE16(value));
  33. }
  34.  
  35. Uint16 SDL_ReadBE16 (SDL_RWops *src)
  36. {
  37.         Uint16 value;
  38.  
  39.         SDL_RWread(src, &value, (sizeof value), 1);
  40.         return(SDL_SwapBE16(value));
  41. }
  42. Uint32 SDL_ReadLE32 (SDL_RWops *src)
  43. {
  44.         Uint32 value;
  45.  
  46.         SDL_RWread(src, &value, (sizeof value), 1);
  47.         return(SDL_SwapLE32(value));
  48. }
  49. Uint32 SDL_ReadBE32 (SDL_RWops *src)
  50. {
  51.         Uint32 value;
  52.  
  53.         SDL_RWread(src, &value, (sizeof value), 1);
  54.         return(SDL_SwapBE32(value));
  55. }
  56. Uint64 SDL_ReadLE64 (SDL_RWops *src)
  57. {
  58.         Uint64 value;
  59.  
  60.         SDL_RWread(src, &value, (sizeof value), 1);
  61.         return(SDL_SwapLE64(value));
  62. }
  63. Uint64 SDL_ReadBE64 (SDL_RWops *src)
  64. {
  65.         Uint64 value;
  66.  
  67.         SDL_RWread(src, &value, (sizeof value), 1);
  68.         return(SDL_SwapBE64(value));
  69. }
  70.  
  71. int SDL_WriteLE16 (SDL_RWops *dst, Uint16 value)
  72. {
  73.         value = SDL_SwapLE16(value);
  74.         return(SDL_RWwrite(dst, &value, (sizeof value), 1));
  75. }
  76.  
  77. int SDL_WriteBE16 (SDL_RWops *dst, Uint16 value)
  78. {
  79.         value = SDL_SwapBE16(value);
  80.         return(SDL_RWwrite(dst, &value, (sizeof value), 1));
  81. }
  82.  
  83. int SDL_WriteLE32 (SDL_RWops *dst, Uint32 value)
  84. {
  85.         value = SDL_SwapLE32(value);
  86.         return(SDL_RWwrite(dst, &value, (sizeof value), 1));
  87. }
  88.  
  89. int SDL_WriteBE32 (SDL_RWops *dst, Uint32 value)
  90. {
  91.         value = SDL_SwapBE32(value);
  92.         return(SDL_RWwrite(dst, &value, (sizeof value), 1));
  93. }
  94.  
  95. int SDL_WriteLE64 (SDL_RWops *dst, Uint64 value)
  96. {
  97.         value = SDL_SwapLE64(value);
  98.         return(SDL_RWwrite(dst, &value, (sizeof value), 1));
  99. }
  100.  
  101. int SDL_WriteBE64 (SDL_RWops *dst, Uint64 value)
  102. {
  103.         value = SDL_SwapBE64(value);
  104.         return(SDL_RWwrite(dst, &value, (sizeof value), 1));
  105. }
  106.