home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / util / flip_bits.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  823 b   |  44 lines

  1. /* flip_bits: reverse bits in char */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/util/RCS/flip_bits.c,v 6.0 1991/12/18 20:25:18 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/util/RCS/flip_bits.c,v 6.0 1991/12/18 20:25:18 jpo Rel $
  9.  *
  10.  * $Log: flip_bits.c,v $
  11.  * Revision 6.0  1991/12/18  20:25:18  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17. static unsigned char    table[] = {
  18. /* 0x00 */    0x00,
  19. /* 0x01 */    0x08,
  20. /* 0x02 */    0x04,
  21. /* 0x03 */    0x0c,
  22. /* 0x04 */     0x02,
  23. /* 0x05 */    0x0a,
  24. /* 0x06 */    0x06,
  25. /* 0x07 */    0x0e,
  26. /* 0x08 */    0x01,
  27. /* 0x09 */    0x09,
  28. /* 0x0a */    0x05,
  29. /* 0x0b */    0x0d,
  30. /* 0x0c */    0x03,
  31. /* 0x0d */    0x0b,
  32. /* 0x0e */    0x07,
  33. /* 0x0f */    0x0f,
  34.     };
  35.  
  36. unsigned char flip_bits(ch)
  37. unsigned char    ch;
  38. {
  39.     unsigned char    ret;
  40.     ret = table[(ch >> 4) & 0x0f];
  41.     ret |= table[ch & 0x0f] << 4;
  42.     return ret;
  43. }
  44.