home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PILOT / PC / RC2BMP / SWAPPER.H < prev   
Encoding:
C/C++ Source or Header  |  1996-08-26  |  883 b   |  50 lines

  1. // Swapper.h
  2.  
  3. #if !defined(__SWAPPER_H__)
  4. #define __SWAPPER_H__
  5.  
  6. #ifdef SWAPPER
  7.  
  8. __inline ulong SwapWords(ulong ul)
  9. {
  10.     return (ul >> 16) | (ul << 16);
  11. }
  12.  
  13. __inline ushort SwapBytes(ushort us)
  14. {
  15.     return (us >> 8) | (us << 8);
  16. }
  17.  
  18. __inline ulong SwapLong(ulong ul)
  19. {
  20.     return SwapWords(ul);
  21. }
  22.  
  23. __inline ulong SwapShort(ushort us)
  24. {
  25.     return SwapBytes(us);
  26. }
  27.  
  28. __inline ulong ReverseLong(ulong ul)
  29. {
  30.     return (ul >> 24) | ( ul << 24) | ((ul & 0x00FF0000) >> 8) | ((ul & 0x0000FF00) << 8);
  31. }
  32.  
  33. #ifdef __cplusplus
  34. extern "C" char *SwapChars(char *pszSwapped, const char *psz68);
  35. #else
  36. char *SwapChars(char *pszSwapped, const char *psz68);
  37. #endif
  38.  
  39. #else // SWAPPER
  40.  
  41. #define SwapWords(ul) ul
  42. #define SwapBytes(us) us
  43. #define SwapLong(ul) ul
  44. #define SwapShort(us) us
  45. //#define Sz86(psz68) psz68
  46.  
  47. #endif // SWAPPER
  48.  
  49. #endif // !defined(__SWAPPER_H__)
  50.