home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume7 / nsubj / subjc.c < prev    next >
C/C++ Source or Header  |  1989-06-03  |  743b  |  37 lines

  1. #include <stdio.h>
  2. #define SZ 512 /*line lengths*/
  3. main(argc,argv)
  4. char *argv[];
  5. {
  6.     FILE *fn, *fp;
  7.     char *line, *file, *fgets(), *malloc();
  8.     int i,k;
  9.  
  10.     line = malloc(SZ+1);
  11.     if(line==(char *)0)exit(1);
  12.     file = malloc(SZ+1);
  13.     if(file==(char *)0)exit(2);
  14.  
  15.     if(argc>=2)fn=fopen(argv[1],"r");
  16.     else exit(3);
  17.     if(fn==(FILE *)0)exit(1);
  18.     while( fgets(file,SZ,fn)==file){
  19.         for(i=0;file[i]&&i<SZ;i++)if(file[i]=='\n')file[i]=0;
  20.         fp=fopen(file,"r");
  21.         if(fp==NULL){
  22.             printf("cannot open: %s\n",file);
  23.             exit(2);
  24.         }
  25.         for(i=0;i<40;i++){
  26.             if( fgets(line,SZ,fp)!=line)break;
  27.             if(*line)
  28.                 if( (k=jimsindex(line,"ubject:"))>0)
  29.                 {
  30.                     printf("%s\t%s",file+15,line+k+7);
  31.                     break;
  32.                 }
  33.         }
  34.         if(fp!=NULL){i=fclose(fp);if(i<0)exit(4);}
  35.     }
  36. }
  37.