git: 9front

Download patch

ref: c72e9aa46b74b986867b1ce32f3cca254f0d7794
parent: 38ae7b4136f0fb2d2ea981ed18b7173c55927cfd
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Tue Oct 4 20:05:51 EDT 2011

mothra: animated gifs, page: cleanup

--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -954,6 +954,10 @@
 			fd=pipeline("/bin/gunzip", fd);
 			typ = snooptype(fd);
 		}
+		if(typ == COMPRESS){
+			fd=pipeline("/bin/uncompress", fd);
+			typ = snooptype(fd);
+		}
 		switch(typ){
 		default:
 			message("Bad type %x in geturl", typ);
@@ -991,6 +995,17 @@
 			setcurrent(i, selection->tag);
 			break;
 		case GIF:
+			if(rfork(RFFDG|RFPROC|RFNAMEG|RFNOWAIT) == 0){
+				snprint(cmd, sizeof(cmd), "-pid %d", getpid());
+				if(newwindow(cmd) != -1){
+					close(1); open("/dev/cons", OWRITE);
+					print("reading gif...\n");
+					filter("gif", fd);
+				}
+				exits(nil);
+			}
+			close(fd);
+			break;
 		case JPEG:
 		case PNG:
 		case BMP:
--- a/sys/src/cmd/page.c
+++ b/sys/src/cmd/page.c
@@ -625,7 +625,7 @@
 {
 	static struct {
 		char	*typ;
-		void	*popen;
+		void	*open;
 		void	*data;
 	} tab[] = {
 	"application/pdf",		popengs,	nil,
@@ -709,7 +709,7 @@
 	}
 	p->fd = fd;
 	p->data = tab[i].data;
-	p->open = tab[i].popen;
+	p->open = tab[i].open;
 	if(seek(fd, 0, 0) < 0)
 		goto Noseek;
 	if((i = read(fd, buf+n, n)) < 0)
--