home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3996 / pspeak.c next >
Encoding:
C/C++ Source or Header  |  1991-09-09  |  1010 b   |  56 lines

  1. /* Propaganda Speak -- MY VERSION! */
  2. #include<stdio.h>
  3.  
  4. #define    BOLD_ON        "\033\041"    /* This is the string that precedes "bold" letters */
  5. #define    BOLD_OFF    "\033\042"
  6.  
  7.  
  8.  
  9.  
  10. int main() {
  11.     char *string;
  12.     int counter;
  13.     char *buffer;
  14.  
  15.     /* Now we read in the 'string' line */
  16.     /* We are allowed 20,000 characters */
  17.  
  18.     string = (char *) malloc(20000);
  19.  
  20.  
  21.     /* Initialize them all */
  22.  
  23.  
  24.     /* Read them in from stdin--preceded by a '*' */
  25.     gets(string);
  26.  
  27.     if(string[0] == '*')
  28.         string += 2;  /* Get rid of the * and space */
  29.     else {
  30.         puts("Error, not a pspeak-usable file");
  31.         exit(1);
  32.     }
  33.     
  34.     /* Now begin */
  35.  
  36.     counter = 0;
  37.     while(1) {
  38.         if(string[counter] == ' ') /* Avoid spaces */
  39.             counter++;
  40.         char outchar;
  41.         outchar = getchar();
  42.         if(outchar == EOF)
  43.             break;    /* End of file */
  44.         if((outchar & ~0x20) == string[counter]) {    /* Turn off the #5 bit */
  45.             printf(BOLD_ON);
  46.             putchar(outchar);
  47.             printf(BOLD_OFF);
  48.             counter++;
  49.             if(counter > strlen(string))
  50.                 counter = 0;
  51.         } else {
  52.             putchar(outchar);
  53.         }
  54.     }
  55. }
  56.