home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / utils.zip / ripplec.c < prev    next >
C/C++ Source or Header  |  1999-04-15  |  1KB  |  44 lines

  1. /*
  2.   New, improved, efficient, flexible ripple program.
  3.   Usage: ripple [ w [ l ] ]
  4.   w = screen line width, default 80, must be > 0.
  5.   l = how many lines to display, default 1000, must be > 0.
  6. */
  7.  
  8. char *p =
  9. " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]\
  10. ^_`abcdefghijklmnopqrstuvwxyz{|}~ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGH\
  11. IJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
  12.  
  13. char *crlf = "\015\012";
  14.  
  15. main(argc,argv) int argc; char *argv[]; {
  16.     int i, j, k, x;
  17.     int w = 80;
  18.     int l = 1000;
  19.  
  20.     if (argc > 1)            /* User-specified width */
  21.       w = atoi(argv[1]);
  22.     if (argc > 2)            /* User-specified number of lines */
  23.       l = atoi(argv[2]);
  24.     if (w < 1 || l < 1)            /* Quit upon conversion error */
  25.       exit(1);
  26.  
  27.     for (j = i = 0; i < l; i++) {    /* Ripple loop */
  28. /*
  29.     write(1, p+j, w);
  30.     write(1, crlf, 2);
  31. */
  32.     for (k = 0; k < w; k++) {
  33.         x = *(p+j+k);
  34.         printf("%c[3%c;4%cm%c",27,
  35.            (char)((8 - (x % 8)) + '0'),
  36.            (char)((x % 8) + '0'),
  37.            x);
  38.     }
  39.     printf("\n");
  40.     if (++j > 94) j = 0;
  41.     }
  42.     printf("%c[0m",27);
  43. }
  44.