blob: 0332659c0af00c7444c87c53e6318b6492b0ba6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include "common.h"
#include "send.h"
/* pipe an address through a command to translate it */
extern dest *
translate(dest *dp)
{
process *pp;
String *line;
dest *rv;
char *cp;
int n;
pp = proc_start(s_to_c(dp->repl1), (stream *)0, outstream(), outstream(), 1, 0);
if (pp == 0) {
dp->status = d_resource;
return 0;
}
line = s_new();
for(;;) {
cp = Brdline(pp->std[1]->fp, '\n');
if(cp == 0)
break;
if(strncmp(cp, "_nosummary_", 11) == 0){
nosummary = 1;
continue;
}
n = Blinelen(pp->std[1]->fp);
cp[n-1] = ' ';
s_nappend(line, cp, n);
}
rv = s_to_dest(s_restart(line), dp);
s_restart(line);
while(s_read_line(pp->std[2]->fp, line))
;
if ((dp->pstat = proc_wait(pp)) != 0) {
dp->repl2 = line;
rv = 0;
} else
s_free(line);
proc_free(pp);
return rv;
}
|