/* $Header: kfile.c,v 4.3.1.3 85/05/29 09:11:52 lwall Exp $
* Revision 4.3.1.3 85/05/29 09:11:52 lwall
* Suppressed some killing messages on -t.
* Revision 4.3.1.2 85/05/10 14:21:29 lwall
* Prevented THRU from setting art < absfirst.
* Revision 4.3.1.1 85/05/10 11:34:33 lwall
* Revision 4.3 85/05/01 11:41:53 lwall
* Baseline for release with 4.3bsd.
static bool exitcmds
= FALSE
;
char killglobal
[] = KILLGLOBAL
;
char killlocal
[] = KILLLOCAL
;
fseek(kfp
,0L,0); /* rewind file */
while (fgets(buf
,LBUFLEN
,kfp
) != Nullch
) {
buf
[strlen(buf
)-1] = '\0';
if (strnEQ(buf
,"THRU",4)) {
if (*buf
== 'X') { /* exit command? */
else if (*buf
== '/' && firstart
<= lastart
) {
switch (art_search(buf
, (sizeof buf
), FALSE
)) {
printf("\n(Interrupted at article %ld)\n",(long)art
)
printf("\n(Intr at %ld)\n",(long)art
) FLUSH
;
fputs("\tsubject not found (???)\n",stdout
) FLUSH
;
fputs("\tnot found\n",stdout
) FLUSH
;
fputs("\tfound\n",stdout
) FLUSH
;
kill_unwanted(starting
,message
,entering
)
bool intr
= FALSE
; /* did we get an interrupt? */
bool anytokill
= (toread
[ng
] > 0);
if (localkfp
|| globkfp
) {
if (!entering
&& !exitcmds
)
fputs(message
,stdout
) FLUSH
;
intr
= do_kfile(localkfp
,entering
);
intr
= do_kfile(globkfp
,entering
);
if (entering
&& localkfp
&& !intr
)
if (anytokill
) /* if there was anything to kill */
forcelast
= FALSE
; /* allow for having killed it all */
fseek(localkfp
,0L,0); /* rewind current file */
strcpy(buf
,filexp(getval("KILLLOCAL",killlocal
)));
UNLINK(buf
); /* to prevent file reuse */
if (newkfp
= fopen(buf
,"w")) {
fprintf(newkfp
,"THRU %ld\n",(long)thru
);
while (fgets(buf
,LBUFLEN
,localkfp
) != Nullch
) {
if (strnEQ(buf
,"THRU",4))
open_kfile(KF_LOCAL
); /* and reopen local file */
printf(cantcreate
,buf
) FLUSH
;
/* edit KILL file for newsgroup */
strcpy(buf
,filexp(getval("KILLLOCAL",killlocal
)));
strcpy(buf
,filexp(getval("KILLGLOBAL",killglobal
)));
if ((r
= makedir(buf
,MD_FILE
)) >= 0) {
filexp(getval("VISUAL",getval("EDITOR",defeditor
))),buf
);
printf("\nEditing %s KILL file:\n%s\n",
(in_ng
?"local":"global"),cmd_buf
) FLUSH
;
resetty(); /* make sure tty is friendly */
r
= doshell(sh
,cmd_buf
);/* invoke the shell */
noecho(); /* and make terminal */
crmode(); /* unfriendly again */
printf("Can't make %s\n",buf
) FLUSH
;
char *kname
= filexp(local
?
getval("KILLLOCAL",killlocal
) :
getval("KILLGLOBAL",killglobal
)
if (!filestat
.st_size
) /* nothing in the file? */
UNLINK(kname
); /* delete the file */
localkfp
= fopen(kname
,"r");
globkfp
= fopen(kname
,"r");
strcpy(cmd_buf
,filexp(getval("KILLLOCAL",killlocal
)));
if (makedir(cmd_buf
,MD_FILE
) >= 0) {
printf("\nDepositing command in %s...",cmd_buf
);
printf("\n--> %s...",cmd_buf
);
if ((tmpfp
= fopen(cmd_buf
,"a")) != Nullfp
) {
fseek(tmpfp
,0L,2); /* get to EOF for sure */
fprintf(tmpfp
,"%s\n",cmd
);
fputs("done\n",stdout
) FLUSH
;
printf(cantopen
,cmd_buf
) FLUSH
;