Browse Source

Plan 9 from Bell Labs 2007-04-22

David du Colombier 14 years ago
parent
commit
b4b1dc3546

+ 5 - 5
dist/replica/_plan9.db

@@ -5492,7 +5492,7 @@ rc/bin/ipconf/lra - 775 sys sys 1058791152 1558
 rc/bin/ipconf/outside - 775 sys sys 1058790951 550
 rc/bin/ipconf/theworld - 775 sys sys 1058790940 1212
 rc/bin/ipso - 775 sys sys 1079377794 2838
-rc/bin/ipv6on - 775 sys sys 1177099714 1872
+rc/bin/ipv6on - 775 sys sys 1177128625 1899
 rc/bin/iwhois - 775 sys sys 1143979502 1637
 rc/bin/juke - 775 sys sys 1105565140 1131
 rc/bin/kill - 775 sys sys 1143389260 142
@@ -6062,7 +6062,7 @@ sys/include/flate.h - 664 sys sys 1014929063 1245
 sys/include/frame.h - 664 sys sys 1147706379 2682
 sys/include/geometry.h - 664 sys sys 1014929063 2632
 sys/include/html.h - 664 sys sys 1128662123 15232
-sys/include/httpd.h - 664 sys sys 1091904418 5771
+sys/include/httpd.h - 664 sys sys 1177187803 5794
 sys/include/ip.h - 664 sys sys 1176499323 2978
 sys/include/keyboard.h - 664 sys sys 1131637696 865
 sys/include/libc.h - 664 sys sys 1168306860 19851
@@ -7101,7 +7101,7 @@ sys/lib/tmac/mmt - 664 sys sys 964454718 40915
 sys/lib/tmac/name.sed - 664 sys sys 944956202 62
 sys/lib/tmac/sendcover - 775 sys sys 944956202 50
 sys/lib/tmac/strings.mm - 664 sys sys 964455723 2146
-sys/lib/tmac/tmac.an - 664 sys sys 1175141775 8441
+sys/lib/tmac/tmac.an - 664 sys sys 1177190095 8342
 sys/lib/tmac/tmac.anhtml - 664 sys sys 984696197 105
 sys/lib/tmac/tmac.antimes - 664 sys sys 964454718 7809
 sys/lib/tmac/tmac.bits - 664 sys sys 944956202 1089
@@ -15338,14 +15338,14 @@ sys/src/libhttpd/date.c - 664 sys sys 1045502928 3507
 sys/src/libhttpd/escape.h - 664 sys sys 1014930784 2728
 sys/src/libhttpd/fail.c - 664 sys sys 1014930784 2794
 sys/src/libhttpd/gethead.c - 664 sys sys 1127766499 737
-sys/src/libhttpd/hio.c - 664 sys sys 1079372798 7482
+sys/src/libhttpd/hio.c - 664 sys sys 1177184789 7540
 sys/src/libhttpd/httpfmt.c - 664 sys sys 1014930784 472
 sys/src/libhttpd/httpunesc.c - 664 sys sys 1014930784 888
 sys/src/libhttpd/lower.c - 664 sys sys 1014930784 226
 sys/src/libhttpd/mkfile - 664 sys sys 1035389778 421
 sys/src/libhttpd/okheaders.c - 664 sys sys 1014930784 433
 sys/src/libhttpd/parse.c - 664 sys sys 1143695434 18934
-sys/src/libhttpd/parsereq.c - 664 sys sys 1152982850 5041
+sys/src/libhttpd/parsereq.c - 664 sys sys 1177187800 5112
 sys/src/libhttpd/query.c - 664 sys sys 1014930785 712
 sys/src/libhttpd/redirected.c - 664 sys sys 1014930785 1555
 sys/src/libhttpd/unallowed.c - 664 sys sys 1014930785 980

+ 5 - 5
dist/replica/plan9.db

@@ -5492,7 +5492,7 @@ rc/bin/ipconf/lra - 775 sys sys 1058791152 1558
 rc/bin/ipconf/outside - 775 sys sys 1058790951 550
 rc/bin/ipconf/theworld - 775 sys sys 1058790940 1212
 rc/bin/ipso - 775 sys sys 1079377794 2838
-rc/bin/ipv6on - 775 sys sys 1177099714 1872
+rc/bin/ipv6on - 775 sys sys 1177128625 1899
 rc/bin/iwhois - 775 sys sys 1143979502 1637
 rc/bin/juke - 775 sys sys 1105565140 1131
 rc/bin/kill - 775 sys sys 1143389260 142
@@ -6062,7 +6062,7 @@ sys/include/flate.h - 664 sys sys 1014929063 1245
 sys/include/frame.h - 664 sys sys 1147706379 2682
 sys/include/geometry.h - 664 sys sys 1014929063 2632
 sys/include/html.h - 664 sys sys 1128662123 15232
-sys/include/httpd.h - 664 sys sys 1091904418 5771
+sys/include/httpd.h - 664 sys sys 1177187803 5794
 sys/include/ip.h - 664 sys sys 1176499323 2978
 sys/include/keyboard.h - 664 sys sys 1131637696 865
 sys/include/libc.h - 664 sys sys 1168306860 19851
@@ -7101,7 +7101,7 @@ sys/lib/tmac/mmt - 664 sys sys 964454718 40915
 sys/lib/tmac/name.sed - 664 sys sys 944956202 62
 sys/lib/tmac/sendcover - 775 sys sys 944956202 50
 sys/lib/tmac/strings.mm - 664 sys sys 964455723 2146
-sys/lib/tmac/tmac.an - 664 sys sys 1175141775 8441
+sys/lib/tmac/tmac.an - 664 sys sys 1177190095 8342
 sys/lib/tmac/tmac.anhtml - 664 sys sys 984696197 105
 sys/lib/tmac/tmac.antimes - 664 sys sys 964454718 7809
 sys/lib/tmac/tmac.bits - 664 sys sys 944956202 1089
@@ -15338,14 +15338,14 @@ sys/src/libhttpd/date.c - 664 sys sys 1045502928 3507
 sys/src/libhttpd/escape.h - 664 sys sys 1014930784 2728
 sys/src/libhttpd/fail.c - 664 sys sys 1014930784 2794
 sys/src/libhttpd/gethead.c - 664 sys sys 1127766499 737
-sys/src/libhttpd/hio.c - 664 sys sys 1079372798 7482
+sys/src/libhttpd/hio.c - 664 sys sys 1177184789 7540
 sys/src/libhttpd/httpfmt.c - 664 sys sys 1014930784 472
 sys/src/libhttpd/httpunesc.c - 664 sys sys 1014930784 888
 sys/src/libhttpd/lower.c - 664 sys sys 1014930784 226
 sys/src/libhttpd/mkfile - 664 sys sys 1035389778 421
 sys/src/libhttpd/okheaders.c - 664 sys sys 1014930784 433
 sys/src/libhttpd/parse.c - 664 sys sys 1143695434 18934
-sys/src/libhttpd/parsereq.c - 664 sys sys 1152982850 5041
+sys/src/libhttpd/parsereq.c - 664 sys sys 1177187800 5112
 sys/src/libhttpd/query.c - 664 sys sys 1014930785 712
 sys/src/libhttpd/redirected.c - 664 sys sys 1014930785 1555
 sys/src/libhttpd/unallowed.c - 664 sys sys 1014930785 980

+ 5 - 0
dist/replica/plan9.log

@@ -48444,3 +48444,8 @@
 1177101006 4 a sys/src/cmd/ip/linklocal.c - 664 sys sys 1177099730 867
 1177101006 5 c sys/src/cmd/ip/mkfile - 664 sys sys 1177099797 1271
 1177101006 6 d 386/bin/ip/gizzard - 775 sys sys 1081480408 0
+1177129805 0 c rc/bin/ipv6on - 775 sys sys 1177128625 1899
+1177185605 0 c sys/src/libhttpd/hio.c - 664 sys sys 1177184789 7540
+1177189206 0 c sys/include/httpd.h - 664 sys sys 1177187803 5794
+1177189206 1 c sys/src/libhttpd/parsereq.c - 664 sys sys 1177187800 5112
+1177191006 0 c sys/lib/tmac/tmac.an - 664 sys sys 1177190095 8342

+ 1 - 1
rc/bin/ipv6on

@@ -41,7 +41,7 @@ fn nonnil {	# name ip
 #
 if (! ip/ipconfig -6 $xdir ether $netdir/ether?)
 	exit 'ipconfig -6 failed'
-ip/ipconfig ra6 recvra 1
+ip/ipconfig $xdir ether $netdir/ether? ra6 recvra 1
 
 mev6=`{ndb/query -f $ndbf sys $sysname ipv6}
 mev4=`{ndb/query -f $ndbf sys $sysname ip}

+ 1 - 0
sys/include/httpd.h

@@ -149,6 +149,7 @@ struct HttpReq
 	char		*search;
 	int		vermaj;
 	int		vermin;
+	HSPairs	*searchpairs;
 };
 
 /*

+ 1 - 4
sys/lib/tmac/tmac.an

@@ -468,10 +468,7 @@
 .dsS \s\n()S
 ..\}
 .ifn \{.ie \nL<=0 .nr )L 11i
-.el \{\c
-.nr )L \nLu
-.\" Changed the above from .nr )L 1000i
-.\" (doesn't work for invocation outside of man) [sape]
+.el \{.nr )L \nLu
 .nr V 0\}
 .nrLL 6.5i
 .nr)O .463i

+ 42 - 43
sys/src/libhttpd/hio.c

@@ -4,6 +4,7 @@
 
 static	char	hstates[] = "nrewE";
 static	char	hxfers[] = " x";
+static int _hflush(Hio*, int, int);
 
 int
 hinit(Hio *h, int fd, int mode)
@@ -157,10 +158,12 @@ hreadbuf(Hio *h, void *vsave)
 			memmove(h->start + cpy, hh->pos, in);
 			hh->pos += in;
 		}
-	}else if(in && (in = read(h->fd, h->start + cpy, in)) < 0){
-		h->state = Herr;
-		h->pos = h->stop;
-		return nil;
+	}else if(in){
+		if((in = read(h->fd, h->start + cpy, in)) < 0){
+			h->state = Herr;
+			h->pos = h->stop;
+			return nil;
+		}
 	}
 	if(in == 0)
 		h->state = Hend;
@@ -276,12 +279,12 @@ hload(Hio *h, char *buf)
 
 	s = strchr(hstates, buf[0]);
 	if(s == nil)
-		return 0;
+		return -1;
 	h->state = s - hstates;
 
 	s = strchr(hxfers, buf[1]);
 	if(s == nil)
-		return 0;
+		return -1;
 	h->xferenc = s - hxfers;
 
 	t = h->start;
@@ -295,13 +298,13 @@ hload(Hio *h, char *buf)
 		}
 		*t++ = c;
 		if(t >= stop)
-			return 0;
+			return -1;
 	}
 	*t = '\0';
 	h->pos = h->start;
 	h->stop = t;
 	h->seek = 0;
-	return 1;
+	return 0;
 }
 
 void
@@ -324,7 +327,7 @@ hxferenc(Hio *h, int on)
 {
 	if(h->xferenc && !on && h->pos != h->start)
 		hflush(h);
-	if(hflush(h) < 0)
+	if(_hflush(h, 1, 0) < 0)
 		return -1;
 	h->xferenc = !!on;
 	return 0;
@@ -373,8 +376,8 @@ hvprint(Hio *h, char *fmt, va_list args)
 	f.flush = fmthflush;
 	f.farg = h;
 	f.nfmt = 0;
-	f.args = args;
-	n = dofmt(&f, fmt);
+//	fmtlocaleinit(&f, nil, nil, nil);
+	n = fmtvprint(&f, fmt, args);
 	h->pos = f.to;
 	return n;
 }
@@ -392,7 +395,7 @@ hprint(Hio *h, char *fmt, ...)
 }
 
 static int
-_hflush(Hio* h, int dolength)
+_hflush(Hio *h, int force, int dolength)
 {
 	uchar *s;
 	int w;
@@ -404,6 +407,8 @@ _hflush(Hio* h, int dolength)
 	}
 	s = h->start;
 	w = h->pos - s;
+	if(w == 0 && !force)
+		return 0;
 	if(h->xferenc){
 		*--s = '\n';
 		*--s = '\r';
@@ -415,7 +420,7 @@ _hflush(Hio* h, int dolength)
 		h->pos[1] = '\n';
 		w = &h->pos[2] - s;
 	}
-	if (dolength)
+	if(dolength)
 		fprint(h->fd, "Content-Length: %d\r\n\r\n", w);
 	if(write(h->fd, s, w) != w){
 		h->state = Herr;
@@ -430,19 +435,19 @@ _hflush(Hio* h, int dolength)
 int
 hflush(Hio *h)
 {
-	return _hflush(h, 0);
+	return _hflush(h, 0, 0);
 }
 
 int
 hlflush(Hio* h)
 {
-	return _hflush(h, 1);
+	return _hflush(h, 0, 1);
 }
 
 int
 hwrite(Hio *h, void *vbuf, int len)
 {
-	uchar *pos, *buf;
+	uchar *buf;
 	int n, m;
 
 	buf = vbuf;
@@ -452,36 +457,30 @@ hwrite(Hio *h, void *vbuf, int len)
 		h->stop = h->pos;
 		return -1;
 	}
-	pos = h->pos;
-	if(pos + n >= h->stop){
-		m = pos - h->start;
-		if(m){
-			m = Hsize - m;
-			if(m){
-				memmove(pos, buf, m);
-				buf += m;
-				n -= m;
-			}
-			if(write(h->fd, h->start, Hsize) != Hsize){
-				h->state = Herr;
-				h->stop = h->pos;
+	if(h->pos + n >= h->stop){
+		if(h->start != h->pos)
+			if(hflush(h) < 0)
 				return -1;
+		while(h->pos + n >= h->stop){
+			m = h->stop - h->pos;
+			if(h->xferenc){
+				memmove(h->pos, buf, m);
+				h->pos += m;
+				if(hflush(h) < 0)
+					return -1;
+			}else{
+				if(write(h->fd, buf, m) != m){
+					h->state = Herr;
+					h->stop = h->pos;
+					return -1;
+				}
+				h->seek += m;
 			}
-			h->seek += Hsize;
-		}
-		m = n % Hsize;
-		n -= m;
-		if(n != 0 && write(h->fd, buf, n) != n){
-			h->state = Herr;
-			h->stop = h->pos;
-			return -1;
+			n -= m;
+			buf += m;
 		}
-		h->seek += n;
-		buf += n;
-		pos = h->pos = h->start;
-		n = m;
 	}
-	memmove(pos, buf, n);
-	h->pos = pos + n;
+	memmove(h->pos, buf, n);
+	h->pos += n;
 	return len;
 }

+ 2 - 0
sys/src/libhttpd/parsereq.c

@@ -130,6 +130,8 @@ hparsereq(HConnect *c, int timeout)
 
 	c->req.uri = uri;
 	c->req.search = search;
+	if(search)
+		c->req.searchpairs = hparsequery(c, hstrdup(c, search));
 
 	return 1;
 }