home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / DIGFLIP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  1.0 KB  |  49 lines

  1. /*
  2.     digflip.c
  3.  
  4.     % Functions for flipping bytes in loaded words to match machine byte order.
  5.  
  6.     5/02/88  by Ted.
  7.  
  8.     OWL 1.1
  9.     Copyright (c) 1988, by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14. */
  15.  
  16. #include "oakhead.h"
  17. #include "disppriv.h"
  18. #include "digutil.h"
  19.  
  20. typedef struct { byte lo, hi; } split;
  21.  
  22. /* -------------------------------------------------------------------------- */
  23.  
  24. void dig_flipshort(usp)
  25.     unsigned short *usp;
  26. {
  27.     byte tmp;
  28.  
  29.     tmp = ((split *) usp)->lo;
  30.     ((split *) usp)->lo = ((split *) usp)->hi;
  31.     ((split *) usp)->hi = tmp;
  32. }
  33. /* -------------------------------------------------------------------------- */
  34.  
  35. byte DIGPRIV dig_testbyteorder()
  36. /*
  37.     Determines which kind of byte order the current processor uses.
  38. */
  39. {
  40.     unsigned short test;
  41.     byte low;
  42.  
  43.     test = 1;
  44.     low = ((split *)(&test))->lo;
  45.     return((low == 1) ? BO_LSBYTFIRST : BO_MSBYTFIRST);
  46. }
  47. /* -------------------------------------------------------------------------- */
  48.  
  49.