home *** CD-ROM | disk | FTP | other *** search
- /************************************************************
-
- Rotate13.c
-
- Preditor 3.0 extension.
-
- Perform the Rot-13 operation on the selected text.
-
- © Copyright Evatac Software 1988-1995
- All rights reserved
-
- ************************************************************/
-
- #include "PreditorExtension.h"
-
- #include <SetupA4.h>
- #ifndef THINKC
- #include <A4Stuff.h>
- #else
- #define SetCurrentA4() 0; RememberA4()
- #define SetA4(x) SetUpA4()
- #endif
-
- #ifdef powerc
- ProcInfoType __procinfo = ExtensionUPPInfo;
- #endif
-
- void main(
- ExternalCallbackBlock *callbacks,
- WindowRef window
- )
- {
- long saved_a4;
- Handle hdl;
- unsigned char *ptr;
- long length;
-
- saved_a4 = SetCurrentA4();
-
- if ((hdl = extCopy(callbacks)) != nil) {
-
- length = GetHandleSize(hdl);
-
- ptr = (unsigned char *) *hdl;
-
- while (length-- > 0) {
-
- if (*ptr >= 'A' && *ptr <= 'Z')
- *ptr = ((*ptr - 'A' + 13) % 26) + 'A';
- else if (*ptr >= 'a' && *ptr <= 'z')
- *ptr = ((*ptr - 'a' + 13) % 26) + 'a';
-
- ptr++;
- }
- }
-
- extPaste(callbacks, hdl);
-
- DisposeHandle(hdl);
-
- SetA4(saved_a4);
- }
-