From: "Russ Cox" <rsc@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: [9fans] acme history
Date: Thu, 6 Mar 2003 10:02:50 -0500 [thread overview]
Message-ID: <3085e9cd8dd12b1b65bb3756ef516be1@plan9.bell-labs.com> (raw)
#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);
}
}
reply other threads:[~2003-03-06 15:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3085e9cd8dd12b1b65bb3756ef516be1@plan9.bell-labs.com \
--to=rsc@plan9.bell-labs.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).