Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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