home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Tools / Preditor 2.0 / Preditor Folder / PCMD Source / Think C / Rotate13.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-04  |  865 b   |  40 lines  |  [TEXT/TCEd]

  1. /************************************************************
  2.  
  3.     Rotate13.c
  4.     Last Modified: Friday, May 31, 1991 at 9:46 PM
  5.     
  6.     Shift characters 13 positions
  7.  
  8.     © Copyright Evatac Software  1988-1990
  9.     All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13. #include "PCMD.h"
  14.  
  15. main(
  16.     unsigned char        *sourceText,
  17.     long                sourceLength,
  18.     unsigned char        *destText,
  19.     long                *destSpace,
  20.     PCMDInfo            *info
  21.     )
  22. {
  23.     if (sourceLength > *destSpace)
  24.         return(kPCMDMoreSpace);
  25.         
  26.     *destSpace = sourceLength;
  27.     
  28.     while (sourceLength-- > 0) {
  29.         if (*sourceText >= 'A' && *sourceText <= 'Z')
  30.             *destText = ((*sourceText - 'A' + 13) % 26) + 'A';
  31.         else if (*sourceText >= 'a' && *sourceText <= 'z')
  32.             *destText = ((*sourceText - 'a' + 13) % 26) + 'a';
  33.         else
  34.             *destText = *sourceText;
  35.         sourceText++;
  36.         destText++;
  37.     }
  38.     return(kPCMDSuccess);
  39. }
  40.