home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 194_01 / concat1.c < prev    next >
Text File  |  1985-11-14  |  1KB  |  52 lines

  1. /* [CONCAT1.C of JUGPDS Vol.17]
  2. *****************************************************************
  3. *                                *
  4. *    Written by  Hakuo Katayose (JUG-CP/M No.179)        *
  5. *            49-114 Kawauchi-Sanjuunin-machi        *
  6. *            Sendai, Miyagi 980                          *
  7. *            Phone: 0222-61-3219                *
  8. *                                *
  9. *    Edited & tested by Y. Monma (JUG-C/M Disk Editor)       * 
  10. *                                *
  11. *****************************************************************
  12. */
  13.  
  14. #include "stdio.h"
  15. #include <dio.h>
  16.  
  17. #define cout(s,limit)    while (*s != CPMEOF && limit--) putchar(*s++)
  18.  
  19. char tbuf[(1024*38)];
  20.  
  21. main(argc, argv)
  22. char **argv;
  23. {
  24.     int fp;
  25.     char *p;
  26.     int n;
  27.  
  28.  
  29.     if (wildexp(&argc, &argv) == ERROR)
  30.         error("WILDEXP  error!");
  31.     dioinit(&argc, argv);
  32.     if (argc < 2) {
  33.         error("Usage: cat1 file1 file2 ... >outfile");
  34.         exit();
  35.         }
  36.     p = tbuf;
  37.     while (--argc > 0) {
  38.         if ( (fp = open( *++argv, 0)) == ERROR) {
  39.             fprintf(STDERR, "cat: can't open %s\n", *argv);
  40.             exit();
  41.             }
  42.         else
  43.             fprintf(STDERR, "file:%s\n", *argv);
  44.             while ((n=read(fp, p, 304)*128 ) > 0) {
  45.                 cout(p, n);
  46.                 p = tbuf;
  47.             }
  48.         close(fp);
  49.         }
  50.     dioflush();
  51. }
  52.