home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 154_01 / darken.c < prev    next >
Text File  |  1979-12-31  |  1KB  |  75 lines

  1. /* darken.c:  overstrike text lines for darker output -
  2.  
  3. -----
  4.     (c) Chuck Allison, 1985
  5. -----
  6. */
  7.  
  8. #include <stdio.h>
  9.  
  10. #define MAXLINE 256
  11. #define MAXFILES 150
  12.  
  13. int strikes = 3;            /* ..default line-print count.. */
  14.  
  15. main(argc,argv)
  16. int argc;
  17. char *argv[];
  18. {
  19.     FILE *f;
  20.     int i,
  21.         xargc,                /* ..expanded arg count (after options).. */
  22.         maxarg = MAXFILES;    /* ..max allowable args after expanding.. */
  23.     char *xargv[MAXFILES];    /* ..arg vector after expanding.. */
  24.  
  25.     /* ..process switches.. */
  26.     if (argv[1][0] == '-')
  27.     {
  28.         strikes = atoi(argv[1]+1);
  29.         ++argv;
  30.         --argc;
  31.     }
  32.  
  33.     /* ..process files.. */
  34.     if (argc == 1)
  35.         dk(stdin,"");
  36.     else
  37.     {
  38.         /* ..expand filespecs.. (Mark Williams only!) */
  39.         xargc = exargs("",argc,argv,xargv,maxarg);
  40.  
  41.         /* ..print each file.. */
  42.         for (i = 0; i < xargc; ++i)
  43.             if ((f = fopen(xargv[i],"r")) != NULL)
  44.             {
  45.                 dk(f,xargv[i]);
  46.                 fclose(f);
  47.             }
  48.             else
  49.                 fprintf(stderr,"can't open: %s\n",xargv[i]);
  50.     }
  51. }
  52.  
  53. dk(f)
  54. FILE *f;
  55. {
  56.     int i;
  57.     char *line;
  58.  
  59.     line = (char *) malloc(MAXLINE);
  60.  
  61.     while (fgets(line,MAXLINE-1,f) != NULL)
  62.     {
  63.         /* ..check for form-feed at line start.. */
  64.         if (*line == '\f')
  65.         {
  66.             putchar('\f');
  67.             line++;
  68.         }
  69.         line[strlen(line)-1] = '\0';    /* zap \n */
  70.         for (i = 0; i < strikes; ++i)
  71.             printf("%s\r",line);
  72.         putchar('\n');
  73.     }
  74. }
  75.