home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / binsrclib / ktar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-18  |  1.0 KB  |  53 lines

  1. /* %W%    %G% /
  2. /*
  3. Pack a set of files to a single file with keys and path-names at the biginning 
  4. It reads from standard input a list of UNIX pathnames.
  5. Either a full or partial path-name can be given 
  6. It does not complain about the file not found; it just ignores 
  7. eg. each line should contain strings of proper pathnames, no filename expansion done
  8.     tmp
  9.     Makefile
  10.     /usr/kim/PACKAGE2/kaos.c
  11.     /usr/include/stdio.h
  12.     ...            */
  13.  
  14. #include <stdio.h>
  15. #define   YES   1
  16. #define   NO    0
  17. #define   LINELEN 240
  18.  
  19. main()
  20. {
  21.     int c,cc,inword,argc,nc;
  22.     char s[80];
  23.     FILE *fp,*fopen();
  24.     
  25.     inword = NO;
  26.     argc=0;
  27.     while  ( (c  = getchar()) != EOF) {
  28.         if (c == ' ' || c == '\n' || c == '\t'){
  29.             if( inword == YES ){
  30.                 s[argc]='\0';
  31.                 printf("\n");
  32.                 if( ( fp=fopen(s,"r") ) != NULL ){
  33.  
  34.                     printf("/*KTAR NEWFILE=%s */\n",s);
  35.                     while ( ( cc = getc( fp ) ) != EOF){
  36.                         putchar(cc);
  37.                     }
  38.                     fclose(fp);
  39.                     printf("/*KTAR ENDFILE=%s */\n",s);
  40.                 }
  41.             }
  42.             inword = NO;
  43.             argc=0;
  44.         }
  45.         else {
  46.             s[argc]=c;
  47.             argc++;
  48.             if (inword == NO)
  49.                 inword = YES;
  50.         }
  51.     }
  52. }
  53.