shithub: mongrel

Download patch

ref: fe88b23b4cd4aa642b657dc2e0bd036980086ee7
parent: 66e9098dcd2eae1d65cd336164f2b6d7e5ea9b82
author: phil9 <telephil9@gmail.com>
date: Wed Feb 9 13:03:43 EST 2022

add option to display the raw message in a separate window

	the message menu now have a "raw" option that will open a new window
	with the raw message. This is useful to view all message headers.

--- a/index.c
+++ b/index.c
@@ -29,6 +29,7 @@
 
 enum
 {
+	Mraw,
 	Mplumb,
 	Mdelete,
 };
@@ -35,6 +36,7 @@
 
 char *menustr[] =
 {
+	"raw",
 	"plumb",
 	"delete",
 	nil
@@ -310,7 +312,21 @@
 	close(fd);	
 }
 
+static
 void
+rawmsg(Message *m)
+{
+	char buf[1024] = {0};
+
+	if(rfork(RFPROC|RFNOWAIT|RFFDG|RFREND) == 0){
+		snprint(buf, sizeof buf, "window -noscroll -dx 800 -dy 1000 'cat %s/rawunix; read'", m->path);
+		execl("/bin/rc", "rc", "-c", buf, 0);
+		fprint(2, "execl failed: %r");
+		threadexitsall("execl");
+	}
+}
+
+void
 mesgmenuhit(int but, Mouse m)
 {
 	int n;
@@ -317,6 +333,10 @@
 
 	n = menuhit(but, mctl, &menu, nil);
 	switch(n){
+	case Mraw:
+		select(indexat(m.xy), selc);
+		rawmsg(messageat(sel));
+		break;
 	case Mplumb:
 		select(indexat(m.xy), selc);
 		plumbmsg(messageat(sel));