* [9fans] acme history
@ 2003-03-06 15:02 Russ Cox
0 siblings, 0 replies; only message in thread
From: Russ Cox @ 2003-03-06 15:02 UTC (permalink / raw)
To: 9fans
#include <u.h>
#include <libc.h>
#include <plumb.h>
void showmail(void);
void showedit(void);
void
usage(void)
{
fprint(2, "usage: ahist\n");
exits("usage");
}
void
main(int argc, char**)
{
int fd;
if(argc != 1)
usage();
if(chdir("/mnt/acme/new") < 0)
sysfatal("chdir /mnt/acme/new: %r");
if((fd = open("body", OWRITE)) < 0)
sysfatal("open body: %r");
dup(fd, 1);
close(fd);
if((fd = open("ctl", OWRITE)) < 0)
sysfatal("open ctl: %r");
fprint(fd, "name /history\n");
close(fd);
switch(fork()){
case -1:
sysfatal("fork: %r");
case 0:
showmail();
_exits(nil);
default:
showedit();
_exits(nil);
}
}
void
showmail(void)
{
int fd;
Plumbmsg *m;
fd = plumbopen("showmail", OREAD);
while((m = plumbrecv(fd)) != nil){
print("%s\n", m->data);
plumbfree(m);
}
}
void
showedit(void)
{
int fd;
Plumbmsg *m;
char *addr, *filename;
fd = plumbopen("edit", OREAD);
while((m = plumbrecv(fd)) != nil){
addr = plumblookup(m->attr, "addr");
filename = plumblookup(m->attr, "filename");
if(filename == nil)
filename = m->data;
if(addr && addr[0])
print("%s:%s\n", filename, addr);
else
print("%s\n", filename);
plumbfree(m);
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-03-06 15:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-06 15:02 [9fans] acme history Russ Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).