home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume7
/
nsubj
/
subjc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-03
|
743b
|
37 lines
#include <stdio.h>
#define SZ 512 /*line lengths*/
main(argc,argv)
char *argv[];
{
FILE *fn, *fp;
char *line, *file, *fgets(), *malloc();
int i,k;
line = malloc(SZ+1);
if(line==(char *)0)exit(1);
file = malloc(SZ+1);
if(file==(char *)0)exit(2);
if(argc>=2)fn=fopen(argv[1],"r");
else exit(3);
if(fn==(FILE *)0)exit(1);
while( fgets(file,SZ,fn)==file){
for(i=0;file[i]&&i<SZ;i++)if(file[i]=='\n')file[i]=0;
fp=fopen(file,"r");
if(fp==NULL){
printf("cannot open: %s\n",file);
exit(2);
}
for(i=0;i<40;i++){
if( fgets(line,SZ,fp)!=line)break;
if(*line)
if( (k=jimsindex(line,"ubject:"))>0)
{
printf("%s\t%s",file+15,line+k+7);
break;
}
}
if(fp!=NULL){i=fclose(fp);if(i<0)exit(4);}
}
}