|
|
1.1 ! root 1: #ident "@(#)translate.c 1.4 'attmail mail(1) command'" ! 2: #ident "@(#)mailx:translate.c 1.1" ! 3: #include "rcv.h" ! 4: ! 5: struct name * ! 6: translate(np) ! 7: struct name *np; ! 8: { ! 9: struct name *n, *t, *x; ! 10: void (*sigint)(), (*sigquit)(); ! 11: char *xl = value("translate"); ! 12: char line[LINESIZE]; ! 13: char postmark[256]; ! 14: char *cmd; ! 15: FILE *pp; ! 16: int i; ! 17: ! 18: if (!xl) ! 19: return np; ! 20: askme = 0; ! 21: postmark[0] = 0; ! 22: i = strlen(xl) + 1; ! 23: for (n = np; n; n = n->n_flink) ! 24: if (! (n->n_type & GDEL)) ! 25: i += strlen(n->n_name) + 3; ! 26: cmd = salloc((unsigned)i); ! 27: strcpy(cmd, xl); ! 28: for (n = np; n; n = n->n_flink) ! 29: if (! (n->n_type & GDEL)) { ! 30: strcat(cmd, " \""); ! 31: strcat(cmd, n->n_name); ! 32: strcat(cmd, "\""); ! 33: } ! 34: if ((pp = npopen(cmd, "r")) == NULL) { ! 35: perror(xl); ! 36: senderr++; ! 37: return np; ! 38: } ! 39: sigint = sigset(SIGINT, SIG_IGN); ! 40: sigquit = sigset(SIGQUIT, SIG_IGN); ! 41: fgets(postmark, sizeof postmark, pp); ! 42: if (postmark[0]) ! 43: { ! 44: postmark[strlen(postmark)-1] = 0; ! 45: assign("postmark", postmark); ! 46: } ! 47: for (n = np; n; n = n->n_flink) { ! 48: if (n->n_type & GDEL) ! 49: continue; ! 50: if (fgets(line, sizeof line, pp) == NULL) ! 51: break; ! 52: line[strlen(line)-1] = 0; ! 53: if (!strcmp(line, n->n_name)) ! 54: continue; ! 55: x = extract(line, n->n_type); ! 56: n->n_type |= GDEL; ! 57: n->n_name = ""; ! 58: if (x && !x->n_flink && strpbrk(n->n_full, "(<")) ! 59: x->n_full = splice(x->n_name, n->n_full); ! 60: if (x) { ! 61: t = tailof(x); ! 62: cat(t, n->n_flink); ! 63: n->n_flink = NULL; ! 64: cat(n, x); ! 65: n = t; ! 66: } ! 67: } ! 68: if (getc(pp) == 'y') ! 69: askme++; ! 70: if (npclose(pp) != 0 || n) ! 71: senderr++; ! 72: sigset(SIGINT, sigint); ! 73: sigset(SIGQUIT, sigquit); ! 74: return np; ! 75: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.