shithub: gopher

Download patch

ref: 1e49f254eccffe21591dbd9785d8a3595694de9b
parent: 0ce20bd09df8ea923078920978339a42d2e98092
author: telephil9 <[email protected]>
date: Sat Nov 28 01:34:59 EST 2020

Add gopher:// url plumbing

gopher now listens on the gopher plumb port and will open plumbed urls.

--- a/gopher.c
+++ b/gopher.c
@@ -757,9 +757,11 @@
 void
 main(int argc, char *argv[])
 {
+	enum { Eplumb = 128 };
 	Event e;
 	Link *l;
 	char *url;
+	Plumbmsg *pm;
 
 	if(argc == 2)
 		url = argv[1];
@@ -778,8 +780,18 @@
 	else
 		visit(l, 1);
 	eresized(0);
+	eplumb(Eplumb, "gopher");
 	for(;;){
 		switch(event(&e)){
+		case Eplumb:
+			pm = e.v;
+			if(pm->ndata > 0){
+				l = urltolink(pm->data);
+				if(l!=nil)
+					visit(l, 1);
+			}
+			plumbfree(pm);
+			break;
 		case Ekeyboard:
 			switch(e.kbdc){
 			default: