*** HTInit.c.orig Thu Sep 17 12:43:48 1998 --- HTInit.c Sun Dec 13 15:04:40 1998 *************** *** 472,477 **** --- 472,522 ---- *to = '\0'; } + #define RTR_forget 0 + #define RTR_lookup 1 + #define RTR_add 2 + + PRIVATE int RememberTestResult ARGS3( + int, mode, + char *, cmd, + int, result) + { + struct cmdlist_s { + char *cmd; + int result; + struct cmdlist_s *next; + }; + static struct cmdlist_s *cmdlist = NULL; + struct cmdlist_s *cur; + + switch(mode) { + case RTR_forget: + while(cmdlist) { + cur = cmdlist->next; + FREE(cmdlist->cmd); + FREE(cmdlist); + cmdlist = cur; + } + return 0; + case RTR_lookup: + for(cur = cmdlist; cur; cur = cur->next) + if(!strcmp(cmd, cur->cmd)) + return cur->result; + return -1; + case RTR_add: + cur = calloc(1, sizeof(struct cmdlist_s)); + cur->next = cmdlist; + cur->cmd = (char *)malloc(strlen(cmd) + 1); + if(cur->cmd) + strcpy(cur->cmd, cmd); + else + ExitWithError("Out of memory"); + cur->result = result; + cmdlist = cur; + } + return 0; + } + PRIVATE int PassesTest ARGS1( struct MailcapEntry *, mc) { *************** *** 529,534 **** --- 574,581 ---- return(-1 == 0); } + result = RememberTestResult(RTR_lookup, mc->testcommand, 0); + if(result == -1) { /* * Build the command and execute it. */ *************** *** 546,551 **** --- 593,600 ---- result = LYSystem(cmd); FREE(cmd); LYRemoveTemp(TmpFileName); + RememberTestResult(RTR_add, mc->testcommand, result ? 1 : 0); + } /* * Free the test command as well since *************** *** 580,585 **** --- 629,635 ---- ProcessMailcapEntry(fp, &mc); } fclose(fp); + RememberTestResult(RTR_forget, NULL, 0); return(0 == 0); }