Plan 9 from Bell Labs’s /usr/web/sources/contrib/anothy/src/cmd/notify/biff.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include <plumb.h>

void
main(int argc, char *argv[])
{
	int seefd, notefd;
	Plumbmsg *m;
	char *from, *date, *note, *subj;

	USED(argc);
	USED(argv);

	if((seefd = plumbopen("seemail", OREAD)) < 0)
		exits(smprint("can't read seemail port: %r"));

	for(;;){
		m = plumbrecv(seefd);
		if(m == nil)
			exits("error on seemail plumb port");
		if(strcmp(plumblookup(m->attr, "mailtype"), "new") != 0){
			plumbfree(m);
			continue;
		}
		from = plumblookup(m->attr, "sender");
		date = plumblookup(m->attr, "date");
		if(date == nil)
			date = "<no date>";
		USED(*subj); /* not yet */

		note = smprint("Mail: %s\t%s\n\t%s\n", from, m->data, date);
		if((notefd = open(smprint("/srv/notify.%s", getuser()), OWRITE)) < 0)
			exits(smprint("notefd: %r"));
		if(fprint(notefd, note) < 0)
			print("fprint: %r\n");
		plumbfree(m);
		close(notefd);
	}
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.