home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1988 by Sam Leffler.
- * All rights reserved.
- *
- * This file is provided for unrestricted use provided that this
- * legend is included on all tape media and as a part of the
- * software program in whole or part. Users may copy, modify or
- * distribute this file at will.
- */
-
- /*
- TIFF Library Byte Swapping Routines.
- We assume int, short and unsigned = 16-bits and long = 32-bits
- */
-
- void TIFFSwabShort(unsigned *wp)
- {
- register unsigned char *cp = (unsigned char *)wp;
- register unsigned t;
-
- t = cp[1];
- cp[1] = cp[0];
- cp[0] = t;
- }
-
-
- void TIFFSwabLong(unsigned long *lp)
- {
- register unsigned char *cp = (unsigned char *)lp;
- unsigned t;
-
- t = cp[3];
- cp[3] = cp[0];
- cp[0] = t;
- t = cp[2];
- cp[2] = cp[1];
- cp[1] = t;
- }
-
-
- void TIFFSwabArrayOfShort(unsigned *wp, unsigned n)
- {
- register unsigned char *cp;
- register unsigned t;
-
- while (n-- > 0)
- {
- cp = (unsigned char *)wp;
- t = cp[1];
- cp[1] = cp[0];
- cp[0] = t;
- wp++;
- }
- }
-
-
- void TIFFSwabArrayOfLong(unsigned long *lp, unsigned n)
- {
- register unsigned char *cp;
- register unsigned t;
-
- while (n-- > 0)
- {
- cp = (unsigned char *)lp;
- t = cp[3];
- cp[3] = cp[0];
- cp[0] = t;
- t = cp[2];
- cp[2] = cp[1];
- cp[1] = t;
- lp++;
- }
- }