Browse Source

Plan 9 from Bell Labs 2008-05-07

David du Colombier 16 years ago
parent
commit
4e41db9215

+ 8 - 7
dist/replica/_plan9.db

@@ -6654,9 +6654,9 @@ sys/lib/lp/perm - 20000000775 sys sys 1020895848 0
 sys/lib/lp/process - 20000000775 sys sys 1077670465 0
 sys/lib/lp/process/dpost - 775 sys sys 1015012079 2412
 sys/lib/lp/process/dvipost - 775 sys sys 954037459 3123
-sys/lib/lp/process/g3post - 775 sys sys 954037459 2348
-sys/lib/lp/process/generic - 775 sys sys 1209583971 4395
-sys/lib/lp/process/gifpost - 775 sys sys 1015012079 2317
+sys/lib/lp/process/g3post - 775 sys sys 1210119087 2350
+sys/lib/lp/process/generic - 775 sys sys 1210119239 4568
+sys/lib/lp/process/gifpost - 775 sys sys 1210119055 2309
 sys/lib/lp/process/gspipe - 775 sys sys 1015012079 434
 sys/lib/lp/process/gspipeijs - 775 sys sys 1077670465 949
 sys/lib/lp/process/hpost - 775 sys sys 1187741307 3386
@@ -6666,11 +6666,12 @@ sys/lib/lp/process/p9bitpost - 775 sys sys 954037459 2436
 sys/lib/lp/process/pdfgs - 775 sys sys 1204761083 1631
 sys/lib/lp/process/pdfgsijs - 775 sys sys 1077634892 1687
 sys/lib/lp/process/pdfpost - 775 sys sys 1015012079 2100
+sys/lib/lp/process/pngpost - 775 sys sys 1210119033 2310
 sys/lib/lp/process/post - 775 sys sys 1045164703 1955
-sys/lib/lp/process/ppost - 775 sys sys 969500538 2874
+sys/lib/lp/process/ppost - 775 sys sys 1210119088 2873
 sys/lib/lp/process/psextract - 775 sys sys 1045164704 777
 sys/lib/lp/process/testpost - 775 sys sys 954037459 1940
-sys/lib/lp/process/tiffpost - 775 sys sys 1015012080 2343
+sys/lib/lp/process/tiffpost - 775 sys sys 1210119088 2333
 sys/lib/lp/process/tr2post - 775 sys sys 954037459 2478
 sys/lib/lp/sched - 20000000775 sys sys 1039727406 0
 sys/lib/lp/sched/FIFO - 775 sys sys 954037459 65
@@ -10035,7 +10036,7 @@ sys/src/cmd/cdfs/dat.h - 664 sys sys 1208632592 4636
 sys/src/cmd/cdfs/fns.h - 664 sys sys 969542122 297
 sys/src/cmd/cdfs/main.c - 664 sys sys 1208195235 12480
 sys/src/cmd/cdfs/mkfile - 664 sys sys 1204937991 153
-sys/src/cmd/cdfs/mmc.c - 664 sys sys 1208649283 31548
+sys/src/cmd/cdfs/mmc.c - 664 sys sys 1210046871 31599
 sys/src/cmd/cec - 20000000775 sys sys 1193683647 0
 sys/src/cmd/cec/LICENSE - 664 sys sys 1186248056 1554
 sys/src/cmd/cec/Protocol - 664 sys sys 1186248056 2881
@@ -10407,7 +10408,7 @@ sys/src/cmd/fax/receiverc - 775 sys sys 944960990 581
 sys/src/cmd/fax/send.c - 664 sys sys 944960990 923
 sys/src/cmd/fax/subr.c - 664 sys sys 1015090401 1245
 sys/src/cmd/fcp.c - 664 sys sys 1136651872 3799
-sys/src/cmd/file.c - 664 sys sys 1198189467 28953
+sys/src/cmd/file.c - 664 sys sys 1210118716 28919
 sys/src/cmd/fmt.c - 664 sys sys 1137603598 4078
 sys/src/cmd/fortune.c - 664 sys sys 1072729222 1779
 sys/src/cmd/fossil - 20000000775 sys sys 1087005595 0

+ 8 - 7
dist/replica/plan9.db

@@ -6654,9 +6654,9 @@ sys/lib/lp/perm - 20000000775 sys sys 1020895848 0
 sys/lib/lp/process - 20000000775 sys sys 1077670465 0
 sys/lib/lp/process/dpost - 775 sys sys 1015012079 2412
 sys/lib/lp/process/dvipost - 775 sys sys 954037459 3123
-sys/lib/lp/process/g3post - 775 sys sys 954037459 2348
-sys/lib/lp/process/generic - 775 sys sys 1209583971 4395
-sys/lib/lp/process/gifpost - 775 sys sys 1015012079 2317
+sys/lib/lp/process/g3post - 775 sys sys 1210119087 2350
+sys/lib/lp/process/generic - 775 sys sys 1210119239 4568
+sys/lib/lp/process/gifpost - 775 sys sys 1210119055 2309
 sys/lib/lp/process/gspipe - 775 sys sys 1015012079 434
 sys/lib/lp/process/gspipeijs - 775 sys sys 1077670465 949
 sys/lib/lp/process/hpost - 775 sys sys 1187741307 3386
@@ -6666,11 +6666,12 @@ sys/lib/lp/process/p9bitpost - 775 sys sys 954037459 2436
 sys/lib/lp/process/pdfgs - 775 sys sys 1204761083 1631
 sys/lib/lp/process/pdfgsijs - 775 sys sys 1077634892 1687
 sys/lib/lp/process/pdfpost - 775 sys sys 1015012079 2100
+sys/lib/lp/process/pngpost - 775 sys sys 1210119033 2310
 sys/lib/lp/process/post - 775 sys sys 1045164703 1955
-sys/lib/lp/process/ppost - 775 sys sys 969500538 2874
+sys/lib/lp/process/ppost - 775 sys sys 1210119088 2873
 sys/lib/lp/process/psextract - 775 sys sys 1045164704 777
 sys/lib/lp/process/testpost - 775 sys sys 954037459 1940
-sys/lib/lp/process/tiffpost - 775 sys sys 1015012080 2343
+sys/lib/lp/process/tiffpost - 775 sys sys 1210119088 2333
 sys/lib/lp/process/tr2post - 775 sys sys 954037459 2478
 sys/lib/lp/sched - 20000000775 sys sys 1039727406 0
 sys/lib/lp/sched/FIFO - 775 sys sys 954037459 65
@@ -10035,7 +10036,7 @@ sys/src/cmd/cdfs/dat.h - 664 sys sys 1208632592 4636
 sys/src/cmd/cdfs/fns.h - 664 sys sys 969542122 297
 sys/src/cmd/cdfs/main.c - 664 sys sys 1208195235 12480
 sys/src/cmd/cdfs/mkfile - 664 sys sys 1204937991 153
-sys/src/cmd/cdfs/mmc.c - 664 sys sys 1208649283 31548
+sys/src/cmd/cdfs/mmc.c - 664 sys sys 1210046871 31599
 sys/src/cmd/cec - 20000000775 sys sys 1193683647 0
 sys/src/cmd/cec/LICENSE - 664 sys sys 1186248056 1554
 sys/src/cmd/cec/Protocol - 664 sys sys 1186248056 2881
@@ -10407,7 +10408,7 @@ sys/src/cmd/fax/receiverc - 775 sys sys 944960990 581
 sys/src/cmd/fax/send.c - 664 sys sys 944960990 923
 sys/src/cmd/fax/subr.c - 664 sys sys 1015090401 1245
 sys/src/cmd/fcp.c - 664 sys sys 1136651872 3799
-sys/src/cmd/file.c - 664 sys sys 1198189467 28953
+sys/src/cmd/file.c - 664 sys sys 1210118716 28919
 sys/src/cmd/fmt.c - 664 sys sys 1137603598 4078
 sys/src/cmd/fortune.c - 664 sys sys 1072729222 1779
 sys/src/cmd/fossil - 20000000775 sys sys 1087005595 0

+ 8 - 0
dist/replica/plan9.log

@@ -19336,3 +19336,11 @@
 1209616216 101 c acme/bin/386/News - 775 sys sys 1209614878 129316
 1209616216 102 c acme/bin/386/Wiki - 775 sys sys 1209614880 127893
 1209616216 103 c acme/bin/386/spout - 775 sys sys 1209614882 61782
+1210048213 0 c sys/src/cmd/cdfs/mmc.c - 664 sys sys 1210046871 31599
+1210120210 0 c sys/lib/lp/process/g3post - 775 sys sys 1210119087 2350
+1210120210 1 c sys/lib/lp/process/generic - 775 sys sys 1210119239 4568
+1210120210 2 c sys/lib/lp/process/gifpost - 775 sys sys 1210119055 2309
+1210120210 3 a sys/lib/lp/process/pngpost - 775 sys sys 1210119033 2310
+1210120210 4 c sys/lib/lp/process/ppost - 775 sys sys 1210119088 2873
+1210120210 5 c sys/lib/lp/process/tiffpost - 775 sys sys 1210119088 2333
+1210120210 6 c sys/src/cmd/file.c - 664 sys sys 1210118716 28919

+ 3 - 1
sys/lib/lp/process/g3post

@@ -78,5 +78,7 @@ if (~ $MAG [.0-9]*) MAG=-m^$MAG^,^`{echo $MAG '*' 2 | hoc}
 if (! ~ $LAND '') LAND=-L
 if not LAND=()
 
-/$cputype/bin/aux/g3p9bit | /$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH | $LPLIB/process/hpost
+/$cputype/bin/aux/g3p9bit |
+	/$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH |
+	$LPLIB/process/hpost
 exit

+ 10 - 2
sys/lib/lp/process/generic

@@ -31,7 +31,6 @@ case troff
 		case Latin1 post
 			tcs -s -f utf -t latin1 <$temp | $proc/dpost |
 				$proc/gspipe
-
 		case UTF
 			$proc/tr2post <$temp | $proc/gspipe
 		}
@@ -81,7 +80,16 @@ case GIF
 	case *gsijs!*
 		$proc/gifpost <$temp | $proc/gspipeijs
 	}
-case ccitt-g31;
+case PNG
+	switch ($LPCLASS) {
+	case *post*
+		$proc/pngpost <$temp
+	case *gs!*
+		$proc/pngpost <$temp | $proc/gspipe
+	case *gsijs!*
+		$proc/pngpost <$temp | $proc/gspipeijs
+	}
+case ccitt-g31
 	switch ($LPCLASS) {
 	case *post*
 		$proc/g3post <$temp

+ 4 - 3
sys/lib/lp/process/gifpost

@@ -1,5 +1,5 @@
 #!/bin/rc
-# convert CCITT G3 Fax format to PostScript
+# convert GIF format to PostScript
 if (! ~ $DEBUG '') flag x +
 PATCH='%%Patch from lp'
 switch ($LPCLASS) {
@@ -78,6 +78,7 @@ if (~ $MAG [.0-9]*) MAG=-m^$MAG
 if (! ~ $LAND '') LAND=-L
 if not LAND=()
 
-/$cputype/bin/gif -t | /$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH | $LPLIB/process/hpost
+/$cputype/bin/gif -t |
+	/$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH |
+	$LPLIB/process/hpost
 exit
-

+ 84 - 0
sys/lib/lp/process/pngpost

@@ -0,0 +1,84 @@
+#!/bin/rc
+# convert PNG format to PostScript
+if (! ~ $DEBUG '') flag x +
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+	PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+	statusdict begin defaultpapertray end 1 ne {
+		statusdict begin
+			1 setdefaultpapertray
+		end
+	} if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+	switch ($i) {
+	case -P*;
+	case man manual manualfeed;
+		PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+    << /ManualFeed true >> setpagedevice
+   } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+	case simplex;
+		DUPLEX=0
+	case [0-9];
+		PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+	<< '$i' << /MediaType (tray'$i') >> >>
+    << /MediaType (tray'$i') >> setpagedevice
+   } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+	case 11x17 [Ll]edger;
+		PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+    << /PageSize [792 1224] >> setpagedevice
+   } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+	case transparency vg viewgraph;
+		PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+	case *;
+		echo illegal option ''''-i $i'''' >[1=2]
+	}
+}
+if (! ~ $#DUPLEX 0) {
+	switch ($DUPLEX) {
+	case 0;
+		DUPLEX=false
+	case 1;
+		DUPLEX=true
+	}
+	PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+    << /Duplex '$DUPLEX'  >> setpagedevice
+  } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp'
+if (! ~ $PATCH '' -P*)
+	PATCH=-P$PATCH;
+
+if (~ $MAG '') MAG=1
+if (~ $MAG [.0-9]*) MAG=-m^$MAG
+
+if (! ~ $LAND '') LAND=-L
+if not LAND=()
+
+/$cputype/bin/png -9t |
+	/$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH |
+	$LPLIB/process/hpost
+exit

+ 1 - 1
sys/lib/lp/process/ppost

@@ -1,5 +1,5 @@
 #!/bin/rc
-# converts a regular ascii file to PostScript
+# converts a regular text file to PostScript
 if (! ~ $DEBUG '') flag x +
 PATCH='%%Patch from lp'
 switch ($LPCLASS) {

+ 6 - 3
sys/lib/lp/process/tiffpost

@@ -1,5 +1,5 @@
 #!/bin/rc
-# convert CCITT G3 Fax format to PostScript
+# convert TIFF format to PostScript
 if (! ~ $DEBUG '') flag x +
 PATCH='%%Patch from lp'
 switch ($LPCLASS) {
@@ -78,5 +78,8 @@ if (~ $MAG [.0-9]*) MAG=-m^$MAG
 if (! ~ $LAND '') LAND=-L
 if not LAND=()
 
-fb/tiff2pic $1 | fb/3to1 rgbv | fb/pcp -tplan9 |  /$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH | $LPLIB/process/hpost
-exit
+fb/tiff2pic $1 |
+	fb/3to1 rgbv |
+	fb/pcp -tplan9 |
+	/$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH |
+	$LPLIB/process/hpost

+ 11 - 10
sys/src/cmd/cdfs/mmc.c

@@ -40,23 +40,24 @@ struct Mmcaux {
 	long	ntotbk;
 };
 
+/* these will be printed as user ids, so no spaces please */
 static char *dvdtype[] = {
 	"dvd-rom",
 	"dvd-ram",
 	"dvd-r",
 	"dvd-rw",
-	"hd dvd-rom",
-	"hd dvd-ram",
-	"hd dvd-r",
-	"type 7 (unknown)",
-	"type 8 (unknown)",
+	"hd-dvd-rom",
+	"hd-dvd-ram",
+	"hd-dvd-r",
+	"type-7-unknown",
+	"type-8-unknown",
 	"dvd+rw",
 	"dvd+r",
-	"type 11 (unknown)",
-	"type 12 (unknown)",
-	"dvd+rw dl",
-	"dvd+r dl",
-	"type 15 (unknown)",
+	"type-11-unknown",
+	"type-12-unknown",
+	"dvd+rw-dl",
+	"dvd+r-dl",
+	"type-15-unknown",
 };
 
 static ulong

+ 12 - 16
sys/src/cmd/file.c

@@ -341,8 +341,8 @@ filetype(int fd)
 			mbuf->type, mbuf->name);
 		return;
 	}
-	nbuf = read(fd, buf, sizeof(buf)-1);
-
+	/* may be reading a pipe on standard input */
+	nbuf = readn(fd, buf, sizeof(buf)-1);
 	if(nbuf < 0) {
 		print("cannot read\n");
 		return;
@@ -650,7 +650,7 @@ fileoffmagic(Fileoffmag *tab, int ntab)
 	for(i=0; i<ntab; i++) {
 		tp = tab + i;
 		seek(fd, tp->off, 0);
-		if (read(fd, buf, sizeof buf) != sizeof buf)
+		if (readn(fd, buf, sizeof buf) != sizeof buf)
 			continue;
 		x = LENDIAN(buf);
 		if((x&tp->mask) == tp->x){
@@ -865,7 +865,7 @@ isoffstr(void)
 		n = p->length;
 		if (n > sizeof buf)
 			n = sizeof buf;
-		if (read(fd, buf, n) != n)
+		if (readn(fd, buf, n) != n)
 			continue;
 		if(memcmp(buf, p->key, n) == 0) {
 			if(mime)
@@ -1292,8 +1292,8 @@ isp9bit(void)
 
 	/*
 	 * for compressed images, don't look any further. otherwise:
-	 * for image file, length is non-zero and must match calculation above
-	 * for /dev/window and /dev/screen the length is always zero
+	 * for image file, length is non-zero and must match calculation above.
+	 * for /dev/window and /dev/screen the length is always zero.
 	 * for subfont, the subfont header should follow immediately.
 	 */
 	if (cmpr) {
@@ -1301,16 +1301,12 @@ isp9bit(void)
 			newlabel, dep);
 		return 1;
 	}
-	if (len != 0 && mbuf->length == 0) {
-		print(mime ? OCTET : "%splan 9 image, depth %d\n", newlabel, dep);
-		return 1;
-	}
-	if (mbuf->length == len) {
-		print(mime ? OCTET : "%splan 9 image, depth %d\n", newlabel, dep);
-		return 1;
-	}
-	/* Ghostscript sometimes produces a little extra on the end */
-	if (mbuf->length < len+P9BITLEN) {
+	/*
+	 * mbuf->length == 0 probably indicates reading a pipe.
+	 * Ghostscript sometimes produces a little extra on the end.
+	 */
+	if (len != 0 && (mbuf->length == 0 || mbuf->length == len ||
+	    mbuf->length > len && mbuf->length < len+P9BITLEN)) {
 		print(mime ? OCTET : "%splan 9 image, depth %d\n", newlabel, dep);
 		return 1;
 	}