home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / DIGFLIP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  1.1 KB  |  50 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-DIG 1.2
  9.     Copyright (c) 1988, by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14.      3/28/90 jmd    ansi-fied
  15.      6/22/90 ted    added "void"s to no-parameter function per ansii.
  16. */
  17.  
  18. #include "oakhead.h"
  19. #include "disppriv.h"
  20. #include "digutil.h"
  21.  
  22. typedef struct { byte lo, hi; } split;
  23.  
  24. /* -------------------------------------------------------------------------- */
  25.  
  26. void dig_flipshort(unsigned short *usp)
  27. {
  28.     byte tmp;
  29.  
  30.     tmp = ((split *) usp)->lo;
  31.     ((split *) usp)->lo = ((split *) usp)->hi;
  32.     ((split *) usp)->hi = tmp;
  33. }
  34. /* -------------------------------------------------------------------------- */
  35.  
  36. byte DIGPRIV dig_testbyteorder(void)
  37. /*
  38.     Determines which kind of byte order the current processor uses.
  39. */
  40. {
  41.     unsigned short test;
  42.     byte low;
  43.  
  44.     test = 1;
  45.     low = ((split *)(&test))->lo;
  46.     return((low == 1) ? BO_LSBYTFIRST : BO_MSBYTFIRST);
  47. }
  48. /* -------------------------------------------------------------------------- */
  49.  
  50.