diff options
author | rsc <devnull@localhost> | 2005-10-29 16:26:44 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-10-29 16:26:44 +0000 |
commit | 5cdb17983ae6e6367ad7a940cb219eab247a9304 (patch) | |
tree | 8ca1ef49af2a96e7daebe624d91fdf679814a057 /src/cmd/upas/send/translate.c | |
parent | cd3745196389579fb78b9b01ef1daefb5a57aa71 (diff) | |
download | plan9port-5cdb17983ae6e6367ad7a940cb219eab247a9304.tar.gz plan9port-5cdb17983ae6e6367ad7a940cb219eab247a9304.tar.bz2 plan9port-5cdb17983ae6e6367ad7a940cb219eab247a9304.zip |
Thanks to John Cummings.
Diffstat (limited to 'src/cmd/upas/send/translate.c')
-rw-r--r-- | src/cmd/upas/send/translate.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/cmd/upas/send/translate.c b/src/cmd/upas/send/translate.c new file mode 100644 index 00000000..0332659c --- /dev/null +++ b/src/cmd/upas/send/translate.c @@ -0,0 +1,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; +} |