1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23 /* All Rights Reserved */ 24 25 26 /* 27 * University Copyright- Copyright (c) 1982, 1986, 1988 28 * The Regents of the University of California 29 * All Rights Reserved 30 * 31 * University Acknowledgment- Portions of this document are derived from 32 * software developed by the University of California, Berkeley, and its 33 * contributors. 34 */ 35 36 #include "rcv.h" 37 38 struct name * 39 translate(struct name *np) 40 { 41 struct name *n, *t, *x; 42 void (*sigint)(int), (*sigquit)(int); 43 char *xl = value("translate"); 44 char line[LINESIZE]; 45 char postmark[256]; 46 char *cmd; 47 FILE *pp; 48 int i; 49 50 if (!xl) 51 return np; 52 askme = 0; 53 postmark[0] = 0; 54 i = strlen(xl) + 1; 55 for (n = np; n; n = n->n_flink) 56 if (! (n->n_type & GDEL)) 57 i += strlen(n->n_name) + 3; 58 cmd = (char *)salloc((unsigned)i); 59 strcpy(cmd, xl); 60 for (n = np; n; n = n->n_flink) 61 if (! (n->n_type & GDEL)) { 62 strcat(cmd, " \""); 63 strcat(cmd, n->n_name); 64 strcat(cmd, "\""); 65 } 66 if ((pp = npopen(cmd, "r")) == NULL) { 67 perror(xl); 68 senderr++; 69 return np; 70 } 71 sigint = sigset(SIGINT, SIG_IGN); 72 sigquit = sigset(SIGQUIT, SIG_IGN); 73 fgets(postmark, sizeof postmark, pp); 74 if (postmark[0]) 75 { 76 postmark[strlen(postmark)-1] = 0; 77 assign("postmark", postmark); 78 } 79 for (n = np; n; n = n->n_flink) { 80 if (n->n_type & GDEL) 81 continue; 82 if (fgets(line, sizeof line, pp) == NULL) 83 break; 84 line[strlen(line)-1] = 0; 85 if (!strcmp(line, n->n_name)) 86 continue; 87 x = extract(line, n->n_type); 88 n->n_type |= GDEL; 89 n->n_name = ""; 90 if (x && !x->n_flink && strpbrk(n->n_full, "(<")) 91 x->n_full = splice(x->n_name, n->n_full); 92 if (x) { 93 t = tailof(x); 94 cat(t, n->n_flink); 95 n->n_flink = NULL; 96 cat(n, x); 97 n = t; 98 } 99 } 100 if (getc(pp) == 'y') 101 askme++; 102 if (npclose(pp) != 0 || n) 103 senderr++; 104 sigset(SIGINT, sigint); 105 sigset(SIGQUIT, sigquit); 106 return np; 107 } 108