home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / assist11.zip / TOGGLE.C < prev    next >
Text File  |  1999-04-25  |  1KB  |  57 lines

  1. /******************************************************************/
  2. /* Assistant/2 copyright (c) 1998 Hinnerk Becker                  */
  3. /* Macro Example Code                                             */
  4. /******************************************************************/
  5. /******************************************************************/
  6. /* NOTE:  Read the text from STDIN.                   */
  7. /*                                                    */
  8. /*        Write your results to STDOUT.                           */
  9. /*        The macro will wait until this process terminates       */
  10. /******************************************************************/
  11.  
  12. #include <stdio.h>
  13. #include <fcntl.h>
  14. #include <io.h>
  15.  
  16. int main(int argc, void * arg[]) {
  17.  
  18. char ch, mode;
  19. int count;
  20.  
  21. if(argc!=2) return 1;
  22.  
  23. mode =  * ( (char *) arg[1]);
  24.  
  25. setmode(fileno(stdin), O_BINARY);
  26. setmode(fileno(stdout), O_BINARY);
  27.  
  28. do { 
  29. count = fread(&ch,1,1,stdin);
  30. if(count) {
  31.  if(mode=='D'&&ch>='A'&&ch<='Z')
  32.   putchar(ch-'A'+'a');
  33.  else
  34.  if(mode=='U'&&ch>='a'&&ch<='z')
  35.   putchar(ch-'a'+'A');
  36.  
  37. /* needed if you use EXEC_I instead of EXEC_IC */
  38.  
  39. /* else
  40.  if(ch==10) 
  41.   printf("<CR>");
  42.  else
  43.  if(ch=='<')
  44.   printf("<<>");
  45. */
  46.  else
  47.   putchar(ch);
  48.  }
  49. }
  50.  while(count);
  51.  
  52. setmode(fileno(stdout), O_TEXT);
  53. setmode(fileno(stdin), O_TEXT);
  54.  
  55. return 0;
  56. }
  57.