Browse Source

Plan 9 from Bell Labs 2002-12-12

David du Colombier 17 years ago
commit
c0f3d9569e
100 changed files with 10412 additions and 0 deletions
  1. 38 0
      29000/include/u.h
  2. 58 0
      29000/include/ureg.h
  3. 6 0
      29000/mkfile
  4. 9 0
      386/bin/ape/psh
  5. 5 0
      386/bin/auth/disable
  6. 5 0
      386/bin/auth/enable
  7. 36 0
      386/bin/auth/status
  8. 74 0
      386/bin/aux/cropmarks
  9. 64 0
      386/bin/aux/grabit
  10. 70 0
      386/bin/aux/hardcopy
  11. 14 0
      386/bin/aux/vmware
  12. 14 0
      386/bin/bitsy/light
  13. 20 0
      386/bin/disk/ksync
  14. 5 0
      386/bin/disk/mk9660
  15. 2 0
      386/bin/replica/changes
  16. 2 0
      386/bin/replica/pull
  17. 2 0
      386/bin/replica/push
  18. 2 0
      386/bin/replica/scan
  19. 2 0
      386/bin/replica/setupdirs
  20. 73 0
      386/include/ape/float.h
  21. 66 0
      386/include/ape/math.h
  22. 11 0
      386/include/ape/stdarg.h
  23. 33 0
      386/include/ape/ureg.h
  24. 60 0
      386/include/u.h
  25. 25 0
      386/include/ureg.h
  26. 6 0
      386/mkfile
  27. 60 0
      68000/include/u.h
  28. 28 0
      68000/include/ureg.h
  29. 7 0
      68000/mkfile
  30. 74 0
      68020/include/ape/float.h
  31. 65 0
      68020/include/ape/math.h
  32. 11 0
      68020/include/ape/stdarg.h
  33. 36 0
      68020/include/ape/ureg.h
  34. 14 0
      68020/include/dac.h
  35. 3 0
      68020/include/lbp.h
  36. 60 0
      68020/include/u.h
  37. 28 0
      68020/include/ureg.h
  38. 7 0
      68020/mkfile
  39. 38 0
      960/include/u.h
  40. 7 0
      960/mkfile
  41. 658 0
      LICENSE
  42. 2 0
      NOTICE
  43. 6 0
      acme/acid/Acid
  44. 3 0
      acme/acid/guide
  45. 30 0
      acme/bin/Battery
  46. 7 0
      acme/bin/Perl
  47. 3 0
      acme/bin/README
  48. 24 0
      acme/bin/adiff
  49. 3 0
      acme/bin/agrep
  50. 12 0
      acme/bin/ap
  51. 43 0
      acme/bin/aspell
  52. 4 0
      acme/bin/guide
  53. 3 0
      acme/bin/ind
  54. 10 0
      acme/bin/new
  55. 3 0
      acme/bin/quote
  56. 33 0
      acme/bin/source/acd/README
  57. 243 0
      acme/bin/source/acd/access
  58. 171 0
      acme/bin/source/acd/acd.h
  59. 347 0
      acme/bin/source/acd/acme.c
  60. 206 0
      acme/bin/source/acd/cddb
  61. 170 0
      acme/bin/source/acd/cddb.c
  62. 894 0
      acme/bin/source/acd/cddbproto
  63. 159 0
      acme/bin/source/acd/discid
  64. 220 0
      acme/bin/source/acd/mailinglist
  65. 135 0
      acme/bin/source/acd/main.c
  66. 22 0
      acme/bin/source/acd/mkfile
  67. 303 0
      acme/bin/source/acd/mmc.c
  68. 32 0
      acme/bin/source/acd/outline
  69. 220 0
      acme/bin/source/acd/submit
  70. 59 0
      acme/bin/source/acd/toc.c
  71. 89 0
      acme/bin/source/acd/util.c
  72. 320 0
      acme/bin/source/acd/win.c
  73. 584 0
      acme/bin/source/adict/adict.c
  74. 10 0
      acme/bin/source/adict/adict.h
  75. 26 0
      acme/bin/source/adict/man
  76. 11 0
      acme/bin/source/adict/mkfile
  77. 315 0
      acme/bin/source/adict/win.c
  78. 59 0
      acme/bin/source/adict/win.h
  79. 27 0
      acme/bin/source/mkfile
  80. 45 0
      acme/bin/source/mkwnew.c
  81. 123 0
      acme/bin/source/spout.c
  82. 95 0
      acme/bin/source/win/dat.h
  83. 146 0
      acme/bin/source/win/fs.c
  84. 654 0
      acme/bin/source/win/main.c
  85. 24 0
      acme/bin/source/win/mkfile
  86. 175 0
      acme/bin/source/win/pipe.c
  87. 90 0
      acme/bin/source/win/util.c
  88. 264 0
      acme/bin/source/win/win.c
  89. 3 0
      acme/bin/unind
  90. 9 0
      acme/mail/Mail
  91. 4 0
      acme/mail/guide
  92. 11 0
      acme/mail/mkbox
  93. 0 0
      acme/mail/old.iostats
  94. 55 0
      acme/mail/readme
  95. 164 0
      acme/mail/src/dat.h
  96. 75 0
      acme/mail/src/html.c
  97. 532 0
      acme/mail/src/mail.c
  98. 1306 0
      acme/mail/src/mesg.c
  99. 31 0
      acme/mail/src/mkfile
  100. 0 0
      acme/mail/src/reply.c

+ 38 - 0
29000/include/u.h

@@ -0,0 +1,38 @@
+#define nil		((void*)0)
+typedef	unsigned short	ushort;
+typedef	unsigned char	uchar;
+typedef	unsigned long	ulong;
+typedef	unsigned int	uint;
+typedef	signed char	schar;
+typedef	long long	vlong;
+typedef	unsigned long long uvlong;
+typedef	ushort		Rune;
+typedef 	union FPdbleword FPdbleword;
+typedef long	jmp_buf[2];
+#define	JMPBUFSP	0
+#define	JMPBUFPC	1
+#define	JMPBUFDPC	0
+typedef unsigned int	mpdigit;	/* for /sys/include/mp.h */
+typedef unsigned int	u32int;
+union FPdbleword
+{
+	double	x;
+	struct {	/* big endian */
+		ulong hi;
+		ulong lo;
+	};
+};
+
+typedef	char*	va_list;
+#define va_start(list, start) list =\
+	(sizeof(start) < 4?\
+		(char*)((int*)&(start)+1):\
+		(char*)(&(start)+1))
+#define va_end(list)\
+	USED(list)
+#define va_arg(list, mode)\
+	((sizeof(mode) == 1)?\
+		((mode*)(list += 4))[-1]:\
+	(sizeof(mode) == 2)?\
+		((mode*)(list += 4))[-1]:\
+		((mode*)(list += sizeof(mode)))[-1])

+ 58 - 0
29000/include/ureg.h

@@ -0,0 +1,58 @@
+struct Ureg
+{
+	ulong	cause;			/* trap number */
+	ulong	status;			/* old status */
+	ulong	cha;			/* channel address */
+	ulong	chd;			/* channel data */
+	ulong	chc;			/* channel control */
+	union{
+		ulong	pc0;
+		ulong	pc;
+	};
+	ulong	pc1;
+	ulong	pc2;
+	ulong	ipc;
+	ulong	ipa;
+	ulong	ipb;
+	ulong	q;
+	ulong	alustat;
+	ulong	cr;
+	ulong	r64;
+	ulong	sp;			/* r65 */
+	ulong	r66;
+	ulong	r67;
+	ulong	r68;
+	ulong	r69;
+	ulong	r70;
+	ulong	r71;
+	ulong	r72;
+	ulong	r73;
+	ulong	r74;
+	ulong	r75;
+	ulong	r76;
+	ulong	r77;
+	ulong	r78;
+	ulong	r79;
+	ulong	r80;
+	ulong	r81;
+	ulong	r82;
+	ulong	r83;
+	ulong	r84;
+	ulong	r85;
+	ulong	r86;
+	ulong	r87;
+	ulong	r88;
+	ulong	r89;
+	ulong	r90;
+	ulong	r91;
+	ulong	r92;
+	ulong	r93;
+	ulong	r94;
+	ulong	r95;
+	ulong	r96;
+	ulong	r97;
+	ulong	r98;
+	ulong	r99;
+	ulong	r100;
+	ulong	r101;
+};

+ 6 - 0
29000/mkfile

@@ -0,0 +1,6 @@
+</sys/src/mkfile.proto
+
+CC=9c
+LD=9l
+O=9
+AS=9a

+ 9 - 0
386/bin/ape/psh

@@ -0,0 +1,9 @@
+#!/bin/rc
+# set up a shell running in an approximate POSIX 1003.2 environment
+rfork en
+fn sigterm{}
+HOME=$home
+bind -b /rc/bin/ape /bin
+bind -b /$cputype/bin/ape /bin
+bind -a /$cputype/bin/pub /bin
+/bin/sh $*

+ 5 - 0
386/bin/auth/disable

@@ -0,0 +1,5 @@
+#!/bin/rc
+if(test -e /mnt/keys/$1)
+	echo -n disabled > /mnt/keys/$1/status
+if(test -e /mnt/netkeys/$1)
+	echo -n disabled > /mnt/netkeys/$1/status

+ 5 - 0
386/bin/auth/enable

@@ -0,0 +1,5 @@
+#!/bin/rc
+if(test -e /mnt/keys/$1)
+	echo -n ok > /mnt/keys/$1/status
+if(test -e /mnt/netkeys/$1)
+	echo -n ok > /mnt/netkeys/$1/status

+ 36 - 0
386/bin/auth/status

@@ -0,0 +1,36 @@
+#!/bin/rc
+cd /mnt/keys/$1 > /dev/null >[2=1] && {
+	stat=`{cat status}
+	exp=`{cat expire}
+	switch($exp){
+	case never 0
+		exp='never expires'
+	case *
+		exp=(expires on `{date $exp})
+	}
+	switch($stat){
+	case expired
+		echo user $1: plan 9 key has expired
+	case *
+		echo user $1: plan 9 key status is $stat and $exp
+	}
+	grep '^'$1'[ 	]' /adm/keys.who | tail -1
+}
+cd /mnt/netkeys/$1 > /dev/null >[2=1] && {
+	stat=`{cat status}
+	exp=`{cat expire}
+	switch($exp){
+	case never 0
+		exp='never expires'
+	case *
+		exp=(expires on `{date $exp})
+	}
+	switch($stat){
+	case expired
+		echo user $1: network key has expired
+	case *
+		echo user $1: network key status is $stat and $exp
+		auth/printnetkey $1
+	}
+	grep '^'$1'[ 	]' /adm/netkeys.who | tail -1
+}

+ 74 - 0
386/bin/aux/cropmarks

@@ -0,0 +1,74 @@
+#!/bin/rc
+# Center pages and put cropmarks at each corner. Physical page size
+# is set with -w and -h. The default is 8.5 by 11.0 inches. Device
+# dependent code to change paper size (e.g. with setpageparams) goes
+# in the prologue. You may need to customize the device dependent
+# code that we distribute. By default it only supports variable page
+# sizes on Linotronic typesetters, and assumes those typesetters are
+# using 12 inch wide paper. Use -d to disable execution of device
+# dependent PostScript code.
+#
+# What's here was written quickly and will likely be very different
+# in our next release. It should be part of a more general program!!
+# 
+
+POSTLIB=/sys/lib/postscript/prologues
+PROLOGUE=$POSTLIB/cropmarks.ps
+
+EXPANDPAGE=true
+PAGEWIDTH=8.5
+PAGEHEIGHT=11.0
+SCALETOFIT=false
+XOFFSET=0.0
+YOFFSET=0.0
+
+NONCONFORMING=%!PS
+ENDPROLOG=%%EndProlog
+BEGINSETUP=%%BeginSetup
+ENDSETUP=%%EndSetup
+
+while (! ~ $#* 0 && ~ $1 -*) {
+	switch ($1) {
+	case -d;  EXPANDPAGE=false
+
+	case -h;  shift; PAGEHEIGHT=$1
+	case -h*; PAGEHEIGHT=`{echo $1 | sed s/-h//}
+
+	case -s;  SCALETOFIT=true
+
+	case -w;  shift; PAGEWIDTH=$1
+	case -w*; PAGEWIDTH=`{echo $1 | sed s/-w//}
+
+	case -x;  shift; XOFFSET=$1
+	case -x*; XOFFSET=`{echo $1 | sed s/-x//}
+
+	case -y;  shift; YOFFSET=$1
+	case -y*; YOFFSET=`{echo $1 | sed s/-y//}
+
+	case -L;  shift; PROLOGUE=$1
+	case -L*; PROLOGUE=`{echo $1 | sed s/-L//}
+
+	case --;
+
+	case -*;  echo '$0: illegal option $1' >[1=2]; exit 1
+
+	}
+	shift
+}
+
+echo $NONCONFORMING
+cat $PROLOGUE
+echo $ENDPROLOG
+echo $BEGINSETUP
+echo 'CropmarkDict begin'
+echo '/pageheight '$PAGEHEIGHT' def'
+echo '/pagewidth '$PAGEWIDTH' def'
+echo '/expandpage '$EXPANDPAGE' def'
+echo '/scaletofit '$SCALETOFIT' def'
+echo '/xoffset '$XOFFSET' def'
+echo '/yoffset '$YOFFSET' def'
+echo 'setup'
+echo 'end'
+echo $ENDSETUP
+
+cat $*

+ 64 - 0
386/bin/aux/grabit

@@ -0,0 +1,64 @@
+#!/bin/rc
+# Print a listing of an object, often a dictionary or an array. Something
+# like ==, but the output is often easier to read and closer to PostScript
+# that can be sent back through the interpreter.
+#
+
+POSTLIB=/sys/lib/postscript/prologues
+PROLOGUE=$POSTLIB/grabit.ps
+
+COPYFILE=
+RECURSIVE=true
+OMITNAMES='/Grabit /GrabitDict'
+
+NONCONFORMING='%!PS'
+ENDPROLOG='%%EndProlog'
+BEGINSETUP='%%BeginSetup'
+ENDSETUP='%%EndSetup'
+TRAILER='%%Trailer'
+
+SETUP=GrabitSetup
+
+while (! ~ $#* 0 && ~ $1 -*) {
+	switch ($1) {
+	case -d;  RECURSIVE=false
+
+	case -o;  shift; OMITNAMES=$OMITNAMES' '$1
+	case -o*; OMITNAMES=$OMITNAMES' '`{echo $1 | sed s/-o//}
+
+	case -C;  shift; COPYFILE=$COPYFILE' '$1
+	case -C*; COPYFILE=$COPYFILE' '`{echo $1 | sed s/-C//}
+
+	case -L;  shift; PROLOGUE=$1
+	case -L*; PROLOGUE=`{echo $1 | sed s/-L//}
+
+	case --;
+
+	case -*;  echo $0: illegal option $1 >[1=2]; exit 1
+    }
+    shift
+done
+
+echo $NONCONFORMING
+cat $PROLOGUE
+echo $ENDPROLOG
+echo $BEGINSETUP
+if (~ $COPYFILE '') COPYFILE=/dev/null
+cat $COPYFILE
+echo 'GrabitDict begin'
+echo '/recursive '$RECURSIVE' def'
+
+echo mark
+for (i in $OMITNAMES) {
+	switch ($i) {
+	case /*; echo $i
+	case ?*; echo /$i
+	}
+}
+echo GrabitSetup
+
+echo end
+echo $ENDSETUP
+
+for (i) echo $i Grabit
+

+ 70 - 0
386/bin/aux/hardcopy

@@ -0,0 +1,70 @@
+#!/bin/rc
+# Generate paper output from the data that a PostScript program normally
+# sends back to a host computer using file output operators.
+#
+
+POSTLIB=/sys/lib/postscript/prologues
+PROLOGUE=$POSTLIB/hardcopy.ps
+
+OPTIONS=
+MODE=portrait
+
+NONCONFORMING='%!PS'
+ENDPROLOG='%%EndProlog'
+BEGINSETUP='%%BeginSetup'
+ENDSETUP='%%EndSetup'
+TRAILER='%%Trailer'
+
+SETUP=HardcopySetup
+DONE='(%stdout)(w) file -1 write'
+
+while (! ~ $#* 0 && ~ $1 -*) {
+	switch ($1) {
+	case -c;  shift; OPTIONS=$OPTIONS' /#copies '$1' store'
+	case -c*; OPTIONS=$OPTIONS' /#copies `{echo $1 | sed s/-c//}' store'
+
+	case -f;  shift; OPTIONS=$OPTIONS' /font '/$1' def'
+	case -f*; OPTIONS=$OPTIONS' /font '/`{echo $1 | sed s/-f//}' def'
+
+	case -p;  shift; MODE=$1
+	case -p*; MODE=`{echo $1 | sed s/-p//}
+
+	case -m;  shift; OPTIONS=$OPTIONS' /magnification '$1' def'
+	case -m*; OPTIONS=$OPTIONS' /magnification '`{echo $1 | sed s/-m//}' def'
+
+	case -s;  shift; OPTIONS=$OPTIONS' /pointsize '$1' def'
+	case -s*; OPTIONS=$OPTIONS' /pointsize '`{echo $1 | sed s/-s//}' def'
+
+	case -x;  shift; OPTIONS=$OPTIONS' /xoffset '$1' def'
+	case -x*; OPTIONS=$OPTIONS' /xoffset '`{echo $1 | sed s/-x//}' def'
+
+	case -y;  shift; OPTIONS=$OPTIONS' /yoffset '$1' def'
+	case -y*; OPTIONS=$OPTIONS' /yoffset '`{echo $1 | sed s/-y//}' def'
+
+	case -L;  shift; PROLOGUE=$1
+	case -L*; PROLOGUE=`{echo $1 | sed s/-L//}
+
+	case --;
+
+	case -*;  echo '$0: illegal option $1' >&2; exit 1
+	}
+	shift
+}
+
+switch ($MODE) {
+	case l*; OPTIONS=$OPTIONS' /landscape true def'
+	case *;  OPTIONS=$OPTIONS' /landscape false def'
+}
+
+echo $NONCONFORMING
+cat $PROLOGUE
+echo $ENDPROLOG
+echo $BEGINSETUP
+echo $OPTIONS
+echo $SETUP
+echo $ENDSETUP
+
+cat $*
+
+echo $TRAILER
+echo $DONE

+ 14 - 0
386/bin/aux/vmware

@@ -0,0 +1,14 @@
+#!/bin/rc
+
+if(aux/isvmware -s){
+	echo -n off >'#P/i8253timerset'
+	for(i in '#S'/sd??)
+		if(test -f $i/ctl)
+			echo dma on >$i/ctl
+	aux/vmwarefs
+	if(! test -f /dev/snarf)
+		aux/stub /dev/snarf
+	bind /mnt/vmware/snarf /dev/snarf
+	aux/vmmousepoll &
+}
+

+ 14 - 0
386/bin/bitsy/light

@@ -0,0 +1,14 @@
+#!/bin/rc
+
+#master file is /sys/src/cmd/bitsy/light.rc
+
+switch($1){
+case on
+	echo -n 2 1 0x80 > /dev/backlight
+case off
+	echo -n 2 0 0x80 > /dev/backlight
+case auto
+	echo -n 1 1 0x80 > /dev/backlight
+case *
+	echo -n 2 1 $1 > /dev/backlight
+}

+ 20 - 0
386/bin/disk/ksync

@@ -0,0 +1,20 @@
+#!/bin/rc
+
+fn dosync {
+	echo disk/kfscmd $* sync
+	if(disk/kfscmd $* sync)
+		echo synced
+	if not
+		echo sync failed
+}
+
+kfs = `{ls /srv/kfs.*.cmd >[2]/dev/null}
+switch($#kfs){
+case 0
+	dosync
+case *
+	if(test -r /srv/kfs.cmd)
+		dosync
+	for(i in $kfs)
+		dosync -n `{echo $i|sed 's%/srv/kfs.(.*).cmd%\1%'}
+}

+ 5 - 0
386/bin/disk/mk9660

@@ -0,0 +1,5 @@
+#!/bin/rc
+
+# the master copy of this file is /sys/src/cmd/disk/9660/mk9660.rc
+# do NOT edit the copies in /*/bin/disk.
+exec disk/dump9660 -M $*

+ 2 - 0
386/bin/replica/changes

@@ -0,0 +1,2 @@
+#!/bin/rc
+exec /rc/bin/replica/changes $*

+ 2 - 0
386/bin/replica/pull

@@ -0,0 +1,2 @@
+#!/bin/rc
+exec /rc/bin/replica/pull $*

+ 2 - 0
386/bin/replica/push

@@ -0,0 +1,2 @@
+#!/bin/rc
+exec /rc/bin/replica/push $*

+ 2 - 0
386/bin/replica/scan

@@ -0,0 +1,2 @@
+#!/bin/rc
+exec /rc/bin/replica/scan $*

+ 2 - 0
386/bin/replica/setupdirs

@@ -0,0 +1,2 @@
+#!/bin/rc
+exec /rc/bin/replica/setupdirs $*

+ 73 - 0
386/include/ape/float.h

@@ -0,0 +1,73 @@
+#ifndef __FLOAT
+#define __FLOAT
+/* IEEE, default rounding */
+
+#define FLT_ROUNDS	1
+#define FLT_RADIX	2
+
+#define FLT_DIG		6
+#define FLT_EPSILON	1.19209290e-07
+#define FLT_MANT_DIG	24
+#define FLT_MAX		3.40282347e+38
+#define FLT_MAX_10_EXP	38
+#define FLT_MAX_EXP	128
+#define FLT_MIN		1.17549435e-38
+#define FLT_MIN_10_EXP	-37
+#define FLT_MIN_EXP	-125
+
+#define DBL_DIG		15
+#define DBL_EPSILON	2.2204460492503131e-16
+#define DBL_MANT_DIG	53
+#define DBL_MAX		1.797693134862315708145e+308
+#define DBL_MAX_10_EXP	308
+#define DBL_MAX_EXP	1024
+#define DBL_MIN		2.225073858507201383090233e-308
+#define DBL_MIN_10_EXP	-307
+#define DBL_MIN_EXP	-1021
+#define LDBL_MANT_DIG	DBL_MANT_DIG
+#define LDBL_EPSILON	DBL_EPSILON
+#define LDBL_DIG	DBL_DIG
+#define LDBL_MIN_EXP	DBL_MIN_EXP
+#define LDBL_MIN	DBL_MIN
+#define LDBL_MIN_10_EXP	DBL_MIN_10_EXP
+#define LDBL_MAX_EXP	DBL_MAX_EXP
+#define LDBL_MAX	DBL_MAX
+#define LDBL_MAX_10_EXP	DBL_MAX_10_EXP
+
+typedef 	union FPdbleword FPdbleword;
+union FPdbleword
+{
+	double	x;
+	struct {	/* little endian */
+		long lo;
+		long hi;
+	};
+};
+
+#ifdef _RESEARCH_SOURCE
+/* define stuff needed for floating conversion */
+#define IEEE_8087	1
+#define Sudden_Underflow 1
+#endif
+#ifdef _PLAN9_SOURCE
+/* FCR */
+#define	FPINEX	(1<<5)
+#define	FPOVFL	(1<<3)
+#define	FPUNFL	((1<<4)|(1<<1))
+#define	FPZDIV	(1<<2)
+#define	FPRNR	(0<<10)
+#define	FPRZ	(3<<10)
+#define	FPRPINF	(2<<10)
+#define	FPRNINF	(1<<10)
+#define	FPRMASK	(3<<10)
+#define	FPPEXT	(3<<8)
+#define	FPPSGL	(0<<8)
+#define	FPPDBL	(2<<8)
+#define	FPPMASK	(3<<8)
+/* FSR */
+#define	FPAINEX	FPINEX
+#define	FPAOVFL	FPOVFL
+#define	FPAUNFL	FPUNFL
+#define	FPAZDIV	FPZDIV
+#endif
+#endif /* __FLOAT */

+ 66 - 0
386/include/ape/math.h

@@ -0,0 +1,66 @@
+#ifndef __MATH
+#define __MATH
+#pragma lib "/$M/lib/ape/libap.a"
+
+/* a HUGE_VAL appropriate for IEEE double-precision */
+/* the correct value, 1.797693134862316e+308, causes a ken overflow */
+#define HUGE_VAL 1.79769313486231e+308
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern double acos(double);
+extern double asin(double);
+extern double atan(double);
+extern double atan2(double, double);
+extern double cos(double);
+extern double sin(double);
+extern double tan(double);
+extern double cosh(double);
+extern double sinh(double);
+extern double tanh(double);
+extern double exp(double);
+extern double frexp(double, int *);
+extern double ldexp(double, int);
+extern double log(double);
+extern double log10(double);
+extern double modf(double, double *);
+extern double pow(double, double);
+extern double sqrt(double);
+extern double ceil(double);
+extern double fabs(double);
+extern double floor(double);
+extern double fmod(double, double);
+extern double NaN(void);
+extern int isNaN(double);
+extern double Inf(int);
+extern int isInf(double, int);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#ifdef _RESEARCH_SOURCE
+/* does >> treat left operand as unsigned ? */
+#define Unsigned_Shifts 1
+#define	M_E		2.7182818284590452354	/* e */
+#define	M_LOG2E		1.4426950408889634074	/* log 2e */
+#define	M_LOG10E	0.43429448190325182765	/* log 10e */
+#define	M_LN2		0.69314718055994530942	/* log e2 */
+#define	M_LN10		2.30258509299404568402	/* log e10 */
+#define	M_PI		3.14159265358979323846	/* pi */
+#define	M_PI_2		1.57079632679489661923	/* pi/2 */
+#define	M_PI_4		0.78539816339744830962	/* pi/4 */
+#define	M_1_PI		0.31830988618379067154	/* 1/pi */
+#define	M_2_PI		0.63661977236758134308	/* 2/pi */
+#define	M_2_SQRTPI	1.12837916709551257390	/* 2/sqrt(pi) */
+#define	M_SQRT2		1.41421356237309504880	/* sqrt(2) */
+#define	M_SQRT1_2	0.70710678118654752440	/* 1/sqrt(2) */
+
+
+extern double hypot(double, double);
+#endif
+#endif /* __MATH */

+ 11 - 0
386/include/ape/stdarg.h

@@ -0,0 +1,11 @@
+#ifndef __STDARG
+#define __STDARG
+
+typedef char *va_list;
+
+#define va_start(list, start) list = (sizeof(start)<4 ? (char *)((int *)&(start)+1) : \
+(char *)(&(start)+1))
+#define va_end(list)
+#define va_arg(list, mode) ((mode*)(list += sizeof(mode)))[-1]
+
+#endif /* __STDARG */

+ 33 - 0
386/include/ape/ureg.h

@@ -0,0 +1,33 @@
+#ifndef __UREG_H
+#define __UREG_H
+#if !defined(_PLAN9_SOURCE)
+    This header file is an extension to ANSI/POSIX
+#endif
+
+struct Ureg
+{
+	unsigned long	di;		/* general registers */
+	unsigned long	si;		/* ... */
+	unsigned long	bp;		/* ... */
+	unsigned long	nsp;
+	unsigned long	bx;		/* ... */
+	unsigned long	dx;		/* ... */
+	unsigned long	cx;		/* ... */
+	unsigned long	ax;		/* ... */
+	unsigned long	gs;		/* data segments */
+	unsigned long	fs;		/* ... */
+	unsigned long	es;		/* ... */
+	unsigned long	ds;		/* ... */
+	unsigned long	trap;		/* trap type */
+	unsigned long	ecode;		/* error code (or zero) */
+	unsigned long	pc;		/* pc */
+	unsigned long	cs;		/* old context */
+	unsigned long	flags;		/* old flags */
+	union {
+		unsigned long	usp;
+		unsigned long	sp;
+	};
+	unsigned long	ss;		/* old stack segment */
+};
+
+#endif

+ 60 - 0
386/include/u.h

@@ -0,0 +1,60 @@
+#define nil		((void*)0)
+typedef	unsigned short	ushort;
+typedef	unsigned char	uchar;
+typedef unsigned long	ulong;
+typedef unsigned int	uint;
+typedef   signed char	schar;
+typedef	long long	vlong;
+typedef	unsigned long long uvlong;
+typedef	ushort		Rune;
+typedef 	union FPdbleword FPdbleword;
+typedef long	jmp_buf[2];
+#define	JMPBUFSP	0
+#define	JMPBUFPC	1
+#define	JMPBUFDPC	0
+typedef unsigned int	mpdigit;	/* for /sys/include/mp.h */
+typedef unsigned int	u32int;
+
+/* FCR */
+#define	FPINEX	(1<<5)
+#define	FPUNFL	((1<<4)|(1<<1))
+#define	FPOVFL	(1<<3)
+#define	FPZDIV	(1<<2)
+#define	FPINVAL	(1<<0)
+#define	FPRNR	(0<<10)
+#define	FPRZ	(3<<10)
+#define	FPRPINF	(2<<10)
+#define	FPRNINF	(1<<10)
+#define	FPRMASK	(3<<10)
+#define	FPPEXT	(3<<8)
+#define	FPPSGL	(0<<8)
+#define	FPPDBL	(2<<8)
+#define	FPPMASK	(3<<8)
+/* FSR */
+#define	FPAINEX	FPINEX
+#define	FPAOVFL	FPOVFL
+#define	FPAUNFL	FPUNFL
+#define	FPAZDIV	FPZDIV
+#define	FPAINVAL	FPINVAL
+union FPdbleword
+{
+	double	x;
+	struct {	/* little endian */
+		ulong lo;
+		ulong hi;
+	};
+};
+
+typedef	char*	va_list;
+#define va_start(list, start) list =\
+	(sizeof(start) < 4?\
+		(char*)((int*)&(start)+1):\
+		(char*)(&(start)+1))
+#define va_end(list)\
+	USED(list)
+#define va_arg(list, mode)\
+	((sizeof(mode) == 1)?\
+		((mode*)(list += 4))[-4]:\
+	(sizeof(mode) == 2)?\
+		((mode*)(list += 4))[-2]:\
+		((mode*)(list += sizeof(mode)))[-1])

+ 25 - 0
386/include/ureg.h

@@ -0,0 +1,25 @@
+struct Ureg
+{
+	ulong	di;		/* general registers */
+	ulong	si;		/* ... */
+	ulong	bp;		/* ... */
+	ulong	nsp;
+	ulong	bx;		/* ... */
+	ulong	dx;		/* ... */
+	ulong	cx;		/* ... */
+	ulong	ax;		/* ... */
+	ulong	gs;		/* data segments */
+	ulong	fs;		/* ... */
+	ulong	es;		/* ... */
+	ulong	ds;		/* ... */
+	ulong	trap;		/* trap type */
+	ulong	ecode;		/* error code (or zero) */
+	ulong	pc;		/* pc */
+	ulong	cs;		/* old context */
+	ulong	flags;		/* old flags */
+	union {
+		ulong	usp;
+		ulong	sp;
+	};
+	ulong	ss;		/* old stack segment */
+};

+ 6 - 0
386/mkfile

@@ -0,0 +1,6 @@
+</sys/src/mkfile.proto
+
+CC=8c
+LD=8l
+O=8
+AS=8a

+ 60 - 0
68000/include/u.h

@@ -0,0 +1,60 @@
+#define nil		((void*)0)
+typedef	unsigned short	ushort;
+typedef	unsigned char	uchar;
+typedef	unsigned long	ulong;
+typedef	unsigned int	uint;
+typedef	signed char	schar;
+typedef	long long	vlong;
+typedef	unsigned long long uvlong;
+typedef	ushort		Rune;
+typedef 	union FPdbleword FPdbleword;
+typedef long	jmp_buf[2];
+#define	JMPBUFSP	0
+#define	JMPBUFPC	1
+#define	JMPBUFDPC	0
+typedef unsigned int	mpdigit;	/* for /sys/include/mp.h */
+typedef unsigned int	u32int;
+
+/* FCR */
+#define	FPINEX	(3<<8)
+#define	FPOVFL	(1<<12)
+#define	FPUNFL	(1<<11)
+#define	FPZDIV	(1<<10)
+#define	FPRNR	(0<<4)
+#define	FPRZ	(1<<4)
+#define	FPINVAL	(3<<13)
+#define	FPRPINF	(3<<4)
+#define	FPRNINF	(2<<4)
+#define	FPRMASK	(3<<4)
+#define	FPPEXT	(0<<6)
+#define	FPPSGL	(1<<6)
+#define	FPPDBL	(2<<6)
+#define	FPPMASK	(3<<6)
+/* FSR */
+#define	FPAINEX	FPINEX
+#define	FPAOVFL	FPOVFL
+#define	FPAUNFL	FPUNFL
+#define	FPAZDIV	FPZDIV
+#define	FPAINVAL	FPINVAL
+union FPdbleword
+{
+	double	x;
+	struct {	/* big endian */
+		ulong hi;
+		ulong lo;
+	};
+};
+
+typedef	char*	va_list;
+#define va_start(list, start) list =\
+	(sizeof(start) < 4?\
+		(char*)((int*)&(start)+1):\
+		(char*)(&(start)+1))
+#define va_end(list)\
+	USED(list)
+#define va_arg(list, mode)\
+	((sizeof(mode) == 1)?\
+		((mode*)(list += 4))[-1]:\
+	(sizeof(mode) == 2)?\
+		((mode*)(list += 4))[-1]:\
+		((mode*)(list += sizeof(mode)))[-1])

+ 28 - 0
68000/include/ureg.h

@@ -0,0 +1,28 @@
+struct Ureg
+{
+	ulong	r0;
+	ulong	r1;
+	ulong	r2;
+	ulong	r3;
+	ulong	r4;
+	ulong	r5;
+	ulong	r6;
+	ulong	r7;
+	ulong	a0;
+	ulong	a1;
+	ulong	a2;
+	ulong	a3;
+	ulong	a4;
+	ulong	a5;
+	ulong	a6;
+	ulong	sp;
+	ulong	usp;
+	ulong	magic;		/* for db to find bottom of ureg */
+	ushort	sr;
+	ulong	pc;
+	ushort	vo;
+#ifndef	UREGVARSZ
+#define	UREGVARSZ 23		/* for 68040; 15 is enough on 68020 */
+#endif
+	uchar	microstate[UREGVARSZ];	/* variable-sized portion */
+};

+ 7 - 0
68000/mkfile

@@ -0,0 +1,7 @@
+</sys/src/mkfile.proto
+
+CC=1c
+LD=1l
+O=1
+RL=rl
+AS=1a

+ 74 - 0
68020/include/ape/float.h

@@ -0,0 +1,74 @@
+#ifndef __FLOAT
+#define __FLOAT
+/* IEEE, default rounding */
+
+#define FLT_ROUNDS	1
+#define FLT_RADIX	2
+
+#define FLT_DIG		6
+#define FLT_EPSILON	1.19209290e-07
+#define FLT_MANT_DIG	24
+#define FLT_MAX		3.40282347e+38
+#define FLT_MAX_10_EXP	38
+#define FLT_MAX_EXP	128
+#define FLT_MIN		1.17549435e-38
+#define FLT_MIN_10_EXP	-37
+#define FLT_MIN_EXP	-125
+
+#define DBL_DIG		15
+#define DBL_EPSILON	2.2204460492503131e-16
+#define DBL_MANT_DIG	53
+#define DBL_MAX		1.797693134862315708145e+308
+#define DBL_MAX_10_EXP	308
+#define DBL_MAX_EXP	1024
+#define DBL_MIN		2.225073858507201383090233e-308
+#define DBL_MIN_10_EXP	-307
+#define DBL_MIN_EXP	-1021
+#define LDBL_MANT_DIG	DBL_MANT_DIG
+#define LDBL_EPSILON	DBL_EPSILON
+#define LDBL_DIG	DBL_DIG
+#define LDBL_MIN_EXP	DBL_MIN_EXP
+#define LDBL_MIN	DBL_MIN
+#define LDBL_MIN_10_EXP	DBL_MIN_10_EXP
+#define LDBL_MAX_EXP	DBL_MAX_EXP
+#define LDBL_MAX	DBL_MAX
+#define LDBL_MAX_10_EXP	DBL_MAX_10_EXP
+
+
+typedef 	union FPdbleword FPdbleword;
+union FPdbleword
+{
+	double	x;
+	struct {	/* big endian */
+		long hi;
+		long lo;
+	};
+};
+
+#ifdef _RESEARCH_SOURCE
+/* define order of longs in IEEE double: little endian */
+#define IEEE_MC68k	1
+#define Sudden_Underflow 1
+#endif
+#ifdef _PLAN9_SOURCE
+/* FCR */
+#define	FPINEX	(3<<8)
+#define	FPOVFL	(1<<12)
+#define	FPUNFL	(1<<11)
+#define	FPZDIV	(1<<10)
+#define	FPRNR	(0<<4)
+#define	FPRZ	(1<<4)
+#define	FPRPINF	(3<<4)
+#define	FPRNINF	(2<<4)
+#define	FPRMASK	(3<<4)
+#define	FPPEXT	(0<<6)
+#define	FPPSGL	(1<<6)
+#define	FPPDBL	(2<<6)
+#define	FPPMASK	(3<<6)
+/* FSR */
+#define	FPAINEX	FPINEX
+#define	FPAOVFL	FPOVFL
+#define	FPAUNFL	FPUNFL
+#define	FPAZDIV	FPZDIV
+#endif
+#endif /* __FLOAT */

+ 65 - 0
68020/include/ape/math.h

@@ -0,0 +1,65 @@
+#ifndef __MATH
+#define __MATH
+#pragma lib "/$M/lib/ape/libap.a"
+
+/* a HUGE_VAL appropriate for IEEE double-precision */
+/* the correct value, 1.797693134862316e+308, causes a ken overflow */
+#define HUGE_VAL 1.79769313486231e+308
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern double acos(double);
+extern double asin(double);
+extern double atan(double);
+extern double atan2(double, double);
+extern double cos(double);
+extern double sin(double);
+extern double tan(double);
+extern double cosh(double);
+extern double sinh(double);
+extern double tanh(double);
+extern double exp(double);
+extern double frexp(double, int *);
+extern double ldexp(double, int);
+extern double log(double);
+extern double log10(double);
+extern double modf(double, double *);
+extern double pow(double, double);
+extern double sqrt(double);
+extern double ceil(double);
+extern double fabs(double);
+extern double floor(double);
+extern double fmod(double, double);
+extern double NaN(void);
+extern int isNaN(double);
+extern double Inf(int);
+extern int isInf(double, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#ifdef _RESEARCH_SOURCE
+/* does >> treat left operand as unsigned ? */
+#define Unsigned_Shifts 1
+#define	M_E		2.7182818284590452354	/* e */
+#define	M_LOG2E		1.4426950408889634074	/* log 2e */
+#define	M_LOG10E	0.43429448190325182765	/* log 10e */
+#define	M_LN2		0.69314718055994530942	/* log e2 */
+#define	M_LN10		2.30258509299404568402	/* log e10 */
+#define	M_PI		3.14159265358979323846	/* pi */
+#define	M_PI_2		1.57079632679489661923	/* pi/2 */
+#define	M_PI_4		0.78539816339744830962	/* pi/4 */
+#define	M_1_PI		0.31830988618379067154	/* 1/pi */
+#define	M_2_PI		0.63661977236758134308	/* 2/pi */
+#define	M_2_SQRTPI	1.12837916709551257390	/* 2/sqrt(pi) */
+#define	M_SQRT2		1.41421356237309504880	/* sqrt(2) */
+#define	M_SQRT1_2	0.70710678118654752440	/* 1/sqrt(2) */
+
+
+extern double hypot(double, double);
+#endif
+#endif /* __MATH */

+ 11 - 0
68020/include/ape/stdarg.h

@@ -0,0 +1,11 @@
+#ifndef __STDARG
+#define __STDARG
+
+typedef char *va_list;
+
+#define va_start(list, start) list = (char *)(&(start)+1)
+#define va_end(list)
+#define va_arg(list, mode) (sizeof(mode)==1 ? ((mode *) (list += 4))[-4] : \
+sizeof(mode)==2 ? ((mode *) (list += 4))[-2] : ((mode *) (list += sizeof(mode)))[-1])
+
+#endif /* __STDARG */

+ 36 - 0
68020/include/ape/ureg.h

@@ -0,0 +1,36 @@
+#ifndef __UREG_H
+#define __UREG_H
+#if !defined(_PLAN9_SOURCE)
+    This header file is an extension to ANSI/POSIX
+#endif
+
+struct Ureg
+{
+	unsigned long	r0;
+	unsigned long	r1;
+	unsigned long	r2;
+	unsigned long	r3;
+	unsigned long	r4;
+	unsigned long	r5;
+	unsigned long	r6;
+	unsigned long	r7;
+	unsigned long	a0;
+	unsigned long	a1;
+	unsigned long	a2;
+	unsigned long	a3;
+	unsigned long	a4;
+	unsigned long	a5;
+	unsigned long	a6;
+	unsigned long	sp;
+	unsigned long	usp;
+	unsigned long	magic;		/* for db to find bottom of ureg */
+	unsigned short	sr;
+	unsigned long	pc;
+	unsigned short	vo;
+#ifndef	UREGVARSZ
+#define	UREGVARSZ 23		/* for 68040; 15 is enough on 68020 */
+#endif
+	unsigned char	microstate[UREGVARSZ];	/* variable-sized portion */
+};
+
+#endif

+ 14 - 0
68020/include/dac.h

@@ -0,0 +1,14 @@
+/*
+ * Inmos G17x d/a converter
+ */
+
+typedef
+struct	G170
+{
+	uchar	waddr;
+	uchar	value;
+	uchar	mask;
+	uchar	raddr;
+} G170;
+
+#define DAC	((G170*)0xc0100000)

+ 3 - 0
68020/include/lbp.h

@@ -0,0 +1,3 @@
+typedef struct Lbpconf {
+	int nhblank, nvblank, xmax, ymax, res;
+} Lbpconf;

+ 60 - 0
68020/include/u.h

@@ -0,0 +1,60 @@
+#define nil		((void*)0)
+typedef	unsigned short	ushort;
+typedef	unsigned char	uchar;
+typedef	unsigned long	ulong;
+typedef	unsigned int	uint;
+typedef	signed char	schar;
+typedef	long long	vlong;
+typedef	unsigned long long uvlong;
+typedef	ushort		Rune;
+typedef 	union FPdbleword FPdbleword;
+typedef long	jmp_buf[2];
+#define	JMPBUFSP	0
+#define	JMPBUFPC	1
+#define	JMPBUFDPC	0
+typedef unsigned int	mpdigit;	/* for /sys/include/mp.h */
+typedef unsigned int	u32int;
+
+/* FCR */
+#define	FPINEX	(3<<8)
+#define	FPOVFL	(1<<12)
+#define	FPUNFL	(1<<11)
+#define	FPZDIV	(1<<10)
+#define	FPRNR	(0<<4)
+#define	FPRZ	(1<<4)
+#define	FPINVAL	(3<<13)
+#define	FPRPINF	(3<<4)
+#define	FPRNINF	(2<<4)
+#define	FPRMASK	(3<<4)
+#define	FPPEXT	(0<<6)
+#define	FPPSGL	(1<<6)
+#define	FPPDBL	(2<<6)
+#define	FPPMASK	(3<<6)
+/* FSR */
+#define	FPAINEX	FPINEX
+#define	FPAOVFL	FPOVFL
+#define	FPAUNFL	FPUNFL
+#define	FPAZDIV	FPZDIV
+#define	FPAINVAL	FPINVAL
+union FPdbleword
+{
+	double	x;
+	struct {	/* big endian */
+		ulong hi;
+		ulong lo;
+	};
+};
+
+typedef	char*	va_list;
+#define va_start(list, start) list =\
+	(sizeof(start) < 4?\
+		(char*)((int*)&(start)+1):\
+		(char*)(&(start)+1))
+#define va_end(list)\
+	USED(list)
+#define va_arg(list, mode)\
+	((sizeof(mode) == 1)?\
+		((mode*)(list += 4))[-1]:\
+	(sizeof(mode) == 2)?\
+		((mode*)(list += 4))[-1]:\
+		((mode*)(list += sizeof(mode)))[-1])

+ 28 - 0
68020/include/ureg.h

@@ -0,0 +1,28 @@
+struct Ureg
+{
+	ulong	r0;
+	ulong	r1;
+	ulong	r2;
+	ulong	r3;
+	ulong	r4;
+	ulong	r5;
+	ulong	r6;
+	ulong	r7;
+	ulong	a0;
+	ulong	a1;
+	ulong	a2;
+	ulong	a3;
+	ulong	a4;
+	ulong	a5;
+	ulong	a6;
+	ulong	sp;
+	ulong	usp;
+	ulong	magic;		/* for db to find bottom of ureg */
+	ushort	sr;
+	ulong	pc;
+	ushort	vo;
+#ifndef	UREGVARSZ
+#define	UREGVARSZ 23		/* for 68040; 15 is enough on 68020 */
+#endif
+	uchar	microstate[UREGVARSZ];	/* variable-sized portion */
+};

+ 7 - 0
68020/mkfile

@@ -0,0 +1,7 @@
+</sys/src/mkfile.proto
+
+CC=2c
+LD=2l
+O=2
+RL=rl
+AS=2a

+ 38 - 0
960/include/u.h

@@ -0,0 +1,38 @@
+#define nil		((void*)0)
+#define	float	long
+#define	double	long
+typedef	unsigned short	ushort;
+typedef	unsigned char	uchar;
+typedef	unsigned long	ulong;
+typedef	unsigned int	uint;
+typedef	signed char	schar;
+typedef	long		vlong;
+typedef	unsigned long	uvlong;
+typedef	ushort		Rune;
+typedef 	union FPdbleword FPdbleword;
+typedef long	jmp_buf[2];
+typedef unsigned int	mpdigit;	/* for /sys/include/mp.h */
+typedef unsigned int	u32int;
+
+union FPdbleword
+{
+	double	x;
+	struct {	/* little endian */
+		ulong lo;
+		ulong hi;
+	};
+};
+
+typedef	char*	va_list;
+#define va_start(list, start) list =\
+	(sizeof(start) < 4?\
+		(char*)((int*)&(start)+1):\
+		(char*)(&(start)+1))
+#define va_end(list)\
+	USED(list)
+#define va_arg(list, mode)\
+	((sizeof(mode) == 1)?\
+		((mode*)(list += 4))[-4]:\
+	(sizeof(mode) == 2)?\
+		((mode*)(list += 4))[-2]:\
+		((mode*)(list += sizeof(mode)))[-1])

+ 7 - 0
960/mkfile

@@ -0,0 +1,7 @@
+</sys/src/mkfile.proto
+
+CC=6c
+LD=6l
+O=6
+RL=rl
+AS=6a

+ 658 - 0
LICENSE

@@ -0,0 +1,658 @@
+
+LUCENT TECHNOLOGIES INC.
+PLAN 9 OPEN SOURCE LICENSE AGREEMENT
+
+PLEASE READ THIS AGREEMENT (INCLUDING THE EXHIBITS) CAREFULLY BEFORE
+PROCEEDING.  BY CLICKING ON THE "ACCEPT" BUTTON, OR BY DOWNLOADING,
+INSTALLING, USING, COPYING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR
+DERIVATIVE WORKS THEREOF, YOU ARE CONSENTING TO BE BOUND BY THIS
+AGREEMENT.  IF YOU DO NOT AGREE TO ALL OF THE TERMS OF THIS AGREEMENT,
+CLICK ON THE "DO NOT ACCEPT" BUTTON AND THE INSTALLATION/DOWNLOAD
+PROCESS WILL NOT CONTINUE.
+
+1.	DEFINITIONS
+
+1.1 "Agreement" means this Lucent Technologies Inc. Plan 9 Open Source
+License Agreement (including Exhibits).
+1.2 "Contributor(s)" means any individual or legal entity that creates
+or contributes to a Modification of the Original Software.
+1.3 "Licensee" means an individual or a legal entity entering into and
+exercising rights under this Agreement.  For the purposes hereunder,
+Licensee includes any entity that controls, is controlled by, or is
+under common control with Licensee.  For purposes of this definition,
+"control" means (i) the power, direct or indirect, to cause the
+direction or management of such entity, whether by contract or
+otherwise; or (ii) ownership of fifty percent (50%) or more of the
+controlling shares or beneficial ownership of such entity.  Licensee
+is also referred to herein as "You" with "Your" as the possessive.
+1.4 "Licensed Software" means the Original Software, Modifications, or
+any combination of the Original Software and Modifications.
+1.5 "Lucent" means Lucent Technologies Inc., a Delaware corporation
+having an office at 600 Mountain Ave., Murray Hill, NJ 07974, its
+related companies and/or affiliates.
+1.6 "Modification(s)" means any addition, deletion, change, or
+improvement to the Original Software or prior Modifications thereto.
+Modifications do not include additions to the Original Software or
+prior Modifications which (i) are separate modules of software which
+may be distributed in conjunction with Licensed Software; or (ii) are
+not derivative works of the Licensed Software itself.
+1.7 "Object Code" means machine executable software code.
+1.8 "Original Contributor" means Lucent and its Licensors, collectively.
+1.9 "Original Software" means the Plan 9 Software, in both Source Code
+form and Object Code form, and any associated documentation, as
+furnished under this Agreement.
+1.10 "Plan 9 Software" means a network operating system designed for
+research into distributed services, applications and software
+development.
+1.11 "Plan 9 Trademark" means the trademark PLAN 9 (for which Lucent
+has acquired common law rights and for which Lucent owns U.S.
+Trademark Registration Number 2,065,577).
+1.12 "Recipient" means any individual or legal entity receiving the
+Licensed Software under this Agreement, including all Contributors, or
+receiving the Licensed Software under another license agreement as
+authorized herein.
+1.13 "Source Code" means human readable software code.
+2.0	GRANT OF RIGHTS
+2.1 Subject to the terms of this Agreement and to third party
+intellectual property claims, Lucent grants to Licensee, a
+royalty-free, nonexclusive, non-transferable, worldwide license to
+use, reproduce, modify, execute, display, perform, distribute and
+sublicense, the Original Software (with or without Modifications) in
+Source Code form and/or Object Code form for commercial and/or
+non-commercial purposes.  This grant includes a nonexclusive and
+non-transferable license under any patents which Lucent has a right to
+license and which, but for this license, are unavoidably and
+necessarily infringed by the execution of the inherent functionality
+of the Original Software in the form furnished under this Agreement.
+Nothing in this Agreement shall be construed as conferring in any way
+(by implication, estoppel or otherwise) any license or right under any
+existing or future patent claim which is directed to a combination of
+the functionality of the Original Software with the functionality of
+any other software programs, or a combination of hardware systems
+other than the combination of the Original Software and the hardware
+or firmware into which the Original Software is loaded.  Distribution
+of Licensed Software to third parties pursuant to this grant shall be
+subject to the same terms and conditions as set forth in this
+Agreement, and may, at Your option, include a reasonable charge for
+the cost of any media.  You may also, at Your option, charge for any
+other software, product or service that includes or incorporates the
+Original Software as a part thereof.
+
+2.2 No right is granted to Licensee to create derivative works of or
+to redistribute (other than with the Original Software or a derivative
+thereof) the screen imprinter fonts identified in subdirectory
+/lib/font/bit/lucida and printer fonts (Lucida Sans Unicode, Lucida
+Sans Italic, Lucida Sans Demibold, Lucida Typewriter, Lucida Sans
+Typewriter83), identified in subdirectory /sys/lib/postscript/font.
+
+2.3 Exhibit A contains additional terms and conditions relating to the
+printer fonts identified in subdirectory /sys/lib/ghostscript/font.
+In the case of any conflict between the provisions of the body of this
+Agreement and Exhibit A regarding such printer fonts, the provisions
+of Exhibit A shall control.
+
+2.4 The Original Software licensed herein contains material copyrights
+by the Original Contributor, including but not limited to Lucent, B&H
+Inc., and Y&Y Inc. No rights are granted with respect to Original
+Software except as expressly provided herein.
+
+2.5 Lucent grants to Licensee a nonexclusive, royalty free, worldwide
+license to use the Plan 9 Trademark solely in connection with the Plan
+9 operating system source code and documentation.  Such use by
+Licensee of the Plan 9 Trademark shall be in accordance with the
+following quality standards and controls:
+
+* Any use of the Plan 9 Trademark must be made under the terms of this
+Agreement;
+
+* The Plan 9 Trademark may not be combined with any other mark or logo
+to form a composite mark or logo or suggest that the Parties are part
+of one company;
+
+* The Plan 9 Trademark font must be smaller than the font used for
+Licensee's own trademarks and/or logos.
+
+Upon Lucent's written request and at Licensee's expense, Licensee will
+provide Lucent with a representative sample of Licensee's promotional
+materials bearing the Plan 9 Trademark.  If, for any reason, Lucent
+determines that the quality standards or controls applied by Licensee
+to the Plan 9 system source code and documentation fall below those
+that are consistent with Lucent's standards, upon written notice of
+the deficiency to Licensee, Lucent may, at its sole option and
+discretion, terminate Licensee's right to use the Plan 9 Trademark
+upon written notice to Licensee.
+
+Licensee acknowledges that Lucent is the owner of the Plan 9 Trademark
+and all goodwill attached thereto.  This Agreement does not give
+Licensee any interest in the Plan 9 Trademark except the right to use
+the mark in accordance with the provisions of this Agreement.
+Licensee agrees not to attempt to register the Plan 9 Trademark nor to
+adopt, attempt to register or register anywhere in the world a mark
+the same as or confusingly similar to the Plan 9 Trademark.
+
+
+3.0 	DISTRIBUTION OBLIGATIONS
+
+3.1 Modifications which You create or to which You contribute are
+governed by the terms of this Agreement and must be made available
+under the terms of this Agreement in at least the same form as the Source
+Code version of Original Software furnished hereunder.  Any
+distribution by You of the Source Code version of Licensed Software
+must be made under the terms of this Agreement or any future version
+of this Agreement under Section 11.0, and You must include a copy of
+this Agreement with each and every copy of such Source Code version of
+Licensed Software which You distribute.  You may not offer or impose
+any terms on any such Source Code version of Licensed Software that
+alters or restricts the terms of the applicable version of this
+Agreement or the Recipients' rights and obligations hereunder.
+3.2 You must cause all Licensed Software to which You contribute, i.e.
+Your Modifications, to contain a clear identification, e.g., a
+separate file, documenting the changes made by You and identifying You
+as the Contributor that reasonably allows subsequent Recipients to
+identify the originator of the Modification.  To the extent You create
+at least one Modification, You may add Your name as a Contributor to
+the requisite notice described in Section 3.3.
+3.3 With respect to Your distribution of Licensed Software (or any
+portion thereof), You must include the following information in a
+conspicuous location governing such distribution (e.g., a separate
+file) and on all copies of any Source Code version of Licensed
+Software You distribute:
+	"The contents herein includes software initially developed by
+	Lucent Technologies Inc. and others, and is subject to the terms
+	of the Lucent Technologies Inc. Plan 9 Open Source License
+	Agreement.  A copy of the Plan 9 Open Source License Agreement is
+	available at: http://plan9.bell-labs.com/plan9dist/download.html
+	or by contacting Lucent Technologies at http: //www.lucent.com.
+	All software distributed under such Agreement is distributed on
+	an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+	implied.  See the Lucent Technologies Inc. Plan 9 Open Source
+	License Agreement for the specific language governing all rights,
+	obligations and limitations under such Agreement.  Portions of
+	the software developed by Lucent Technologies Inc. and others are
+	Copyright (c) 2002.  All rights reserved.
+	Contributor(s):___________________________"
+3.4 You may distribute Licensed Software in Object Code form using
+this Agreement, or under a license of Your choice provided that You
+are in compliance with this Agreement and Your license: (a) complies
+with the terms and conditions of this Agreement; (b) does not limit or
+alter the Recipient's rights and obligations in the Source Code
+version of the Licensed Software set forth in this Agreement; (c)
+states that the Source Code version of the Licensed Software is
+available from You, and describes how it may be obtained by
+Recipient; (d) effectively disclaims on behalf of Original Contributor
+and all Contributors all warranties and conditions, express or
+implied, including warranties or conditions of title or
+non-infringement, and implied warranties or conditions of
+merchantability and fitness for a particular purpose; (e) effectively
+excludes on behalf of Original Contributor and all Contributors all
+liability for damages, including direct, indirect, special,
+incidental, and consequential damages; and (f) clearly states that any
+terms which differ from this Agreement are offered by You alone, not
+by Original Contributor or any other Contributor.  You hereby agree to
+indemnify Original Contributor or any other Contributor for any
+liability incurred by Original Contributor or any other Contributor as
+result of any such differing terms You offer in Your license.
+3.5 You may not use the names "Lucent Technologies", "Bell Labs" or
+any other name associated with Lucent or any Lucent trademark for any
+purposes other than as specifically provided in this Agreement.
+3.6 You must include all of the original copyright, labels or other
+notices on the Licensed Software on any copies of the Licensed
+Software which You make; and include with the distribution of any
+Modifications You create a copy (or an offer to provide such a copy at
+no charge) of the Licensed Software, on the same terms as set forth in
+this Agreement.
+3.7 While this Agreement contemplates the commercial use and
+distribution of Licensed Software, commercial distributors of software
+may, for a variety of reasons, accept certain responsibilities with
+respect to customers, licensees, business partners and the like.  As
+such, if You or any Contributor include Licensed Software in a
+commercial offering ("Commercial Contributor"), such Commercial
+Contributor agrees to defend and indemnify Original Contributor and
+all other Contributors (collectively "Indemnified Contributors")
+against any liability, losses, damages and costs arising from claims,
+lawsuits and other legal actions brought by any third party against
+the Indemnified Contributors to the extent caused by the acts or
+omissions of such Commercial Contributor in connection with its use or
+distribution of Licensed Software in a commercial offering of any
+kind.
+
+4.0 	MODIFICATIONS
+You agree to provide the Original Contributor, at its request, with a
+copy of the complete Source Code version, Object Code version and
+related documentation for Modifications created or contributed to by
+You if distributed in any form, e.g., binary or source.  Original
+Contributor and/or other Contributors shall have unrestricted,
+nonexclusive, worldwide, perpetual, royalty-free rights, to use,
+reproduce, modify, display, perform, sublicense and distribute such
+Modifications, and to grant third parties the right to do so,
+including without limitation as a part of or with the Licensed
+Software; and Original Contributor and/or other Contributors shall
+have the right to license or to otherwise transfer to third parties
+such Modifications without notice, obligation or recourse to You. You
+grant to Original Contributor, Contributors and their respective
+licensees all rights and licenses (including patents) as are necessary
+to incorporate the Modifications created or contributed and so
+distributed by You into the Licensed Software and to use, distribute
+or otherwise exploit such Licensed Software without payment or
+accounting to You.
+
+5.0 TITLE
+Title, ownership rights, and intellectual property rights in the
+Original Software and the Plan 9 Trademark shall remain in the
+Original Contributor.  Original Contributor and/or the other
+Contributors reserve all rights not expressly granted to You, and no
+other licenses are granted or implied.  The Licensed Software is
+protected by copyright laws and treaties.
+
+6.0  	TERMINATION
+6.1 The licenses and rights granted under this Agreement shall
+terminate automatically if (i) You fail to comply with all of the
+terms and conditions herein; or (ii) You initiate or participate in
+any intellectual property action against Original Contributor.
+
+6.2 The rights and obligations of the parties hereto which by their
+nature would continue beyond termination of this Agreement shall
+survive and continue after any such termination of this Agreement.
+
+6.3 Upon termination for any reason, You must destroy all copies of
+the Licensed Software in Your possession.  All sublicenses of Licensed
+Software which were validly granted by You to third parties under this
+Agreement shall survive such termination.
+
+7.0  DISCLAIMER OF WARRANTY
+
+YOU UNDERSTAND AND ACKNOWLEDGE THAT, TO THE FULLEST EXTENT PERMITTED
+BY LAW, THE LICENSED SOFTWARE IS LICENSED UNDER THIS AGREEMENT FREE OF
+CHARGE ON AN "AS IS" BASIS WITH ALL FAULTS, LATENT AND PATENT AND
+WITHOUT ANY WARRANTY OF ANY TYPE.  ORIGINAL CONTRIBUTOR AND THE OTHER
+CONTRIBUTORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESSED OR
+IMPLIED.  BY WAY OF EXAMPLE, BUT NOT OF LIMITATION, ORIGINAL
+CONTRIBUTOR AND THE OTHER CONTRIBUTORS MAKE NO REPRESENTATIONS OF
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR THAT THE USE OF
+THE LICENSED SOFTWARE WILL NOT INFRINGE ANY PATENT OR OTHER
+INTELLECTUAL PROPERTY RIGHT OF ANY THIRD PARTY AND IT SHALL BE THE
+SOLE RESPONSIBILITY OF YOU TO MAKE SUCH DETERMINATION AS IS NECESSARY
+WITH RESPECT TO THE ACQUISITION OF LICENSES UNDER PATENTS OR OTHER
+INTELLECTUAL PROPERTY RIGHTS OF THIRD PARTIES.  ORIGINAL CONTRIBUTOR
+AND THE OTHER CONTRIBUTORS DO NOT WARRANT THAT THE FUNCTIONS OF THE
+LICENSED SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT LICENSED
+SOFTWARE OPERATION WILL BE ERROR-FREE OR UNINTERRUPTED.  YOU ASSUME
+THE RISK OF ANY AND ALL DAMAGE OR LOSS FROM USE, OR INABILITY TO USE,
+THE LICENSED SOFTWARE.  ORIGINAL CONTRIBUTOR AND THE OTHER
+CONTRIBUTORS BEAR NO RESPONSIBILITY FOR CORRECTING THE LICENSED
+SOFTWARE, SUPPLYING ASSISTANCE FOR FIXING, OR FOR COMMUNICATING KNOWN
+ERRORS TO YOU PERTAINING TO THE LICENSED SOFTWARE FURNISHED HEREUNDER.
+
+ORIGINAL CONTRIBUTOR AND THE OTHER CONTRIBUTORS SHALL NOT BE HELD TO
+ANY LIABILITY WITH RESPECT TO ANY PATENT INFRINGEMENT OR ANY OTHER
+CLAIM MADE BY YOU OR ANY THIRD PARTY ON ACCOUNT OF, OR ARISING FROM
+THE USE OF, THE LICENSED SOFTWARE PROVIDED HEREUNDER.
+
+SOME STATES DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE
+ABOVE EXCLUSION MAY NOT APPLY TO YOU. YOU MAY ALSO HAVE OTHER RIGHTS
+THAT VARY FROM JURISDICTION TO JURISDICTION.
+
+8.0  	LIMITATION OF LIABILITY
+UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, OR
+OTHERWISE, SHALL ORIGINAL CONTRIBUTOR AND/OR THE OTHER CONTRIBUTORS BE
+LIABLE TO YOU OR ANY OTHER THIRD PARTY FOR DAMAGES OF ANY KIND
+INCLUDING, BUT NOT LIMITED TO, ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER WHATSOEVER
+INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK
+STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+COMMERCIAL DAMAGES OR LOSSES, EVEN IF THE ORIGINAL CONTRIBUTOR AND/OR
+ANY OTHER CONTRIBUTORS SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
+SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.  FURTHERMORE, SOME
+JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL
+OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION AND EXCLUSION MAY NOT
+APPLY TO YOU. TO THE EXTENT THAT ANY EXCLUSION OF DAMAGES ABOVE IS NOT
+VALID, YOU AGREE THAT IN NO EVENT WILL ORIGINAL CONTRIBUTOR'S AND ALL
+OTHER CONTRIBUTORS' TOTAL LIABILITY UNDER OR RELATED TO THIS AGREEMENT
+EXCEED ONE THOUSAND DOLLARS ($1000.00 US).
+
+9.0  	EXPORT CONTROL
+You acknowledge that the Licensed Software hereunder is "unrestricted
+encryption source code" as the term is defined under the United States
+Export Administration Regulations and is subject to export control
+under such laws and regulations.  You agree that, if you export or
+re-export the Licensed Software or any modifications to it, You are
+responsible for compliance with the United States Export
+Administration Regulations and hereby indemnify the Original
+Contributor and all other Contributors for any liability incurred as a
+result.
+
+10.0  	U.S. GOVERNMENT RIGHTS
+
+You may only acquire the Licensed Software on behalf of, or for
+delivery to, any part of the United States Government, if the Licensed
+Software is treated as commercial computer software and licensed to
+the Government under the terms and conditions of this Agreement,
+pursuant to the policies stated in 48 C.F.R.  Section 12.212 (October
+1995) or 48 C.F.R.  Section 227.7202 (June 1995), as applicable.
+
+11.0 	LICENSE VERSIONS
+
+LUCENT, at its sole discretion, may from time to time publish a
+revised and/or new version of this Agreement (each such revised or new
+version shall carry a distinguishing version number) which shall
+govern all copies of Licensed Software downloaded after the posting of
+such revised or new version of this Agreement.
+
+12.0  	MISCELLANEOUS
+This Agreement sets forth the entire agreement and understanding
+between the parties as to the subject matter hereof and merges all
+prior discussions between them.  This Agreement shall be governed by
+the laws of the State of New York, USA, excluding its conflict of law
+provisions.  The application of the United Nations Convention of
+Contracts for the International Sale of Goods is expressly excluded.
+YOUR DOWNLOAD, INSTALLATION AND USE, MODIFICATION OR DISTRIBUTION OF
+THE LICENSED SOFTWARE IS EXPRESSLY MADE CONDITIONAL ON YOUR ASSENT TO
+THE TERMS SET FORTH HEREIN.  You further agree and acknowledge that by
+clicking on the "ACCEPT" button below, You shall have manifested
+acceptance to enter into this Agreement and shall be deemed to have
+manually signed and executed this Agreement making this an enforceable
+Agreement between the parties.  If any provision of this Agreement is
+held to be unenforceable, such provision shall be reformed only to the
+extent necessary to make it enforceable.
+ 
+
+
+ 
+
+EXHIBIT A - GNU GENERAL PUBLIC LICENSE
+
+
+GNU GENERAL PUBLIC LICENSE
+
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
+Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
+verbatim copies of this license document, but changing it is not
+allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom
+to share and change it.  By contrast, the GNU General Public License
+is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on,
+we want its recipients to know that what they have is not the
+original, so that any problems introduced by others will not reflect
+on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at
+all.
+
+The precise terms and conditions for copying, distribution and
+modification follow.
+
+GNU GENERAL PUBLIC LICENSE
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0.  This License applies to any program or other work which contains a
+notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the Program
+(independent of having been made by running the Program).  Whether
+that is true depends on what the Program does.
+
+1.  You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a
+fee.
+
+2.  You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+a) You must cause the modified files to carry prominent notices
+stating that you changed the files and the date of any change.
+
+b) You must cause any work that you distribute or publish, that in
+whole or in part contains or is derived from the Program or any part
+thereof, to be licensed as a whole at no charge to all third parties
+under the terms of this License.
+
+c) If the modified program normally reads commands interactively when
+run, you must cause it, when started running for such interactive use
+in the most ordinary way, to print or display an announcement
+including an appropriate copyright notice and a notice that there is
+no warranty (or else, saying that you provide a warranty) and that
+users may redistribute the program under these conditions, and telling
+the user how to view a copy of this License.  (Exception: if the
+Program itself is interactive but does not normally print such an
+announcement, your work based on the Program is not required to print
+an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+3.  You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+a) Accompany it with the complete corresponding machine-readable
+source code, which must be distributed under the terms of Sections 1
+and 2 above on a medium customarily used for software interchange; or,
+
+b) Accompany it with a written offer, valid for at least three years,
+to give any third party, for a charge no more than your cost of
+physically performing source distribution, a complete machine-readable
+copy of the corresponding source code, to be distributed under the
+terms of Sections 1 and 2 above on a medium customarily used for
+software interchange; or,
+
+c) Accompany it with the information you received as to the offer to
+distribute corresponding source code.  (This alternative is allowed
+only for noncommercial distribution and only if you received the
+program in object code or executable form with such an offer, in
+accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+4.  You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+5.  You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+6.  Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+7.  If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+8.  If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+9.  The Free Software Foundation may publish revised and/or new
+versions of the General Public License from time to time.  Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Program does not specify a
+version number of this License, you may choose any version ever
+published by the Free Software Foundation.
+
+10.  If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the
+author to ask for permission.  For software which is copyrighted by
+the Free Software Foundation, write to the Free Software Foundation;
+we sometimes make exceptions for this.  Our decision will be guided by
+the two goals of preserving the free status of all derivatives of our
+free software and of promoting the sharing and reuse of software
+generally.
+
+NO WARRANTY
+
+11.  BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12.  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+
+
+YOU ACKNOWLEDGE THAT YOU HAVE READ THIS AGREEMENT (INCLUDING THE
+EXHIBITS) AND UNDERSTAND IT, AND THAT BY CLICKING ON THE "ACCEPT"
+BUTTON BELOW AND INSTALLING/DOWNLOADING THE SOFTWARE YOU ACCEPT AND
+AGREE TO BE BOUND BY THE TERMS AND CONDITIONS OF THIS AGREEMENT.
+Plan 9 Open Source License - Version 1.4 - 09/10/02 1

+ 2 - 0
NOTICE

@@ -0,0 +1,2 @@
+Copyright © 2002 Lucent Technologies Inc.
+All Rights Reserved

+ 6 - 0
acme/acid/Acid

@@ -0,0 +1,6 @@
+#!/bin/rc
+if(~ $#* 0){
+	echo usage: Acid pid >[2=1]
+	exit usage
+}
+win acid -l acme $*

+ 3 - 0
acme/acid/guide

@@ -0,0 +1,3 @@
+broke|rc    kill program|rc
+Acid pid
+Acid -l thread -l acidfile pid

+ 30 - 0
acme/bin/Battery

@@ -0,0 +1,30 @@
+#!/bin/rc
+
+if(! test -f /mnt/apm/battery){
+	echo no apm >[1=2]
+	exit 'no apm'
+}
+
+cd /mnt/acme/new
+echo name /dev/apm >ctl
+echo dump Battery >ctl
+
+awkscript='
+NR==1 {
+	if($3 != -1)
+		printf("%d%% %d:%02d %s", $2, $3/3600, ($3/60)%60, $1);
+	else
+		printf("%d%% %s", $2, $1);
+}
+'
+
+fn chk {
+	what=`{awk $awkscript /mnt/apm/battery}
+	echo cleartag >ctl || exit die
+	echo clean >ctl || exit die
+	echo ' '^$"what >tag || exit die
+}
+
+chk
+while(sleep 60)
+	chk

+ 7 - 0
acme/bin/Perl

@@ -0,0 +1,7 @@
+#!/bin/rc
+
+# aperl:   
+# Executes perl command and alters stderr to produce Acme-friendly error messages
+# Created 02-JUL-1996, Luther Huffman,  lutherh@stratcom.com
+
+/bin/perl $* |[2]  /bin/perl -pe 's/ line (\d+)/:$1 /'  >[1=2]

+ 3 - 0
acme/bin/README

@@ -0,0 +1,3 @@
+The source directory should be called ./src instead of ./source,
+but this directory is bound into /bin and there is a command called
+src that the local directory would hide.

+ 24 - 0
acme/bin/adiff

@@ -0,0 +1,24 @@
+#!/bin/rc
+
+if(~ $#* 0 1){
+	echo >[1=2] usage: adiff file1 file2
+	echo >[1=2] or adiff file1 file2... dir
+	exit usage
+}
+
+dir = /mnt/wsys
+if(! test -f $dir/cons)
+	dir = /mnt/term/$dir
+id=`{cat $dir/new/ctl}
+id=$id(1)
+
+l=$1
+r=$2
+if (test -d $1) l=$1/`{basename $2}
+if not if (test -d $2) r=$2/`{basename $1}
+
+echo 'name '^`{pwd}^/-diff-^`{basename $l} > $dir/$id/ctl
+
+diff $* | awk -v 'l='$l -v 'r='^$r '/^diff/ {l=$2; r=$3; next} /^[1-9]/ {sub("[acd]", " & " r ":"); sub("^", l ":", $0)}
+	{print $0}' > $dir/$id/body
+echo clean > $dir/$id/ctl

+ 3 - 0
acme/bin/agrep

@@ -0,0 +1,3 @@
+#!/bin/rc
+
+exec grep -n $* /dev/null

+ 12 - 0
acme/bin/ap

@@ -0,0 +1,12 @@
+#!/bin/rc
+args=''
+while(~ $1 -*) {
+	args=$args^' '^$1
+	shift 1
+}
+if (~ $#1 0)
+	sysname=alice
+if not
+	sysname=$1
+if (! test -f /n/$sysname/usr/spool/ap ) { 9fs $sysname }
+eval exec /acme/bin/$cputype/apread $args $sysname

+ 43 - 0
acme/bin/aspell

@@ -0,0 +1,43 @@
+#!/bin/rc
+
+spellflags=()
+fflag=''
+for(x){
+	switch($x){
+	case -[bcvx]
+		spellflags=($spellflags $x)
+	case -f
+		fflag=$x
+	case *
+		if(~ $fflag -f)	{
+			spellflags=($spellflags -f $x)
+			fflag=''
+		}
+		if not args = ($args $x)
+	}
+}
+
+dir = /mnt/wsys
+if(! test -f $dir/cons)
+	dir = /mnt/term/$dir
+id=`{cat $dir/new/ctl}
+id=$id(1)
+
+if(~ $#args 1 && ~ $args /*){
+	adir = `{basename -d $args}
+	args = `{basename $args}
+	echo 'name '^$adir^/-spell > $dir/$id/ctl
+	cd $adir
+}
+if not {
+	echo 'name '^`{pwd}^/-spell > $dir/$id/ctl
+}
+
+{
+	echo noscroll
+	if(~ $#args 0)
+		/acme/bin/$cputype/spout | sort  -t: -u +2 | sort  -t: +1.1n | aux/sprog -a $spellflags > $dir/$id/body
+	if not for(i in $args)
+		/acme/bin/$cputype/spout $i | sort  -t: -u +2 | sort  -t: +1.1n | aux/sprog -a $spellflags > $dir/$id/body
+	echo clean
+}> $dir/$id/ctl

+ 4 - 0
acme/bin/guide

@@ -0,0 +1,4 @@
+win
+aspell file
+adiff file1 file2
+adict -d oed

+ 3 - 0
acme/bin/ind

@@ -0,0 +1,3 @@
+#!/bin/rc
+
+sed 's/^/	/' $*

+ 10 - 0
acme/bin/new

@@ -0,0 +1,10 @@
+#!/bin/rc
+
+id=`{cat /mnt/acme/new/ctl}
+id=$id(1)
+cmd = $*
+if(~ $#cmd 0) cmd = cat
+
+echo 'name '^`{pwd}^/-^`{basename $cmd(1)} > /mnt/acme/$id/ctl
+$cmd > /mnt/acme/$id/body
+echo clean > /mnt/acme/$id/ctl

+ 3 - 0
acme/bin/quote

@@ -0,0 +1,3 @@
+#!/bin/rc
+
+sed 's/^/> /' $*

+ 33 - 0
acme/bin/source/acd/README

@@ -0,0 +1,33 @@
+This is a CD player for use under Acme.
+
+It is derived from my earlier cdplay, which
+was in turn derived from a 2nd edition player
+called vcd.  I think hardly any of the code from
+vcd is left anymore, but it's what got me started.
+Vcd was originally by David Hogan with additions
+by Alberto Nava.  David Hogan claims the only
+code left is the definition of struct Msf.
+
+Run it by executing "acd /dev/sdD0", where
+/dev/sdD0 is your CD reader.
+
+A window with a track list will appear, with
+tracks named Track 1, Track 2, etc.
+If it can be found in the freedb.org CD database,
+real track names will replace the boring
+ones before long.
+
+To start playing a track, right click the number.
+A "> " marks the currently playing track.
+When that track finishes, acd plays the track
+on the next line.  This means you can edit
+the window as thought it were a play list.
+
+If the next line is "repeat", acd will start again
+at the first song listed in the window.
+
+CD changes are handled gracefully.
+
+Russ Cox
+9 August 2000
+rsc@plan9.bell-labs.com

+ 243 - 0
acme/bin/source/acd/access

@@ -0,0 +1,243 @@
+TWO FORMS OF ACCESS TO THE FREEDB
+---------------------------------
+
+In the following document we will refer to CDDB instead of freedb, since 
+from a technical point of view, freedb is a CDDB-Server as it uses the 
+CDDB-protocol.
+
+If you are interested in incorporating the use of freedb in your
+software, there are two forms of access that you may consider.
+
+1. <a href="#local">Local access</a>
+
+   In this mode your software simply attempts to open local files on
+   the computer to access the CDDB.
+
+2. <a href="#remote">Remote access</a>
+
+   In this mode the software must connect to a freedb server on the
+   network to access the CDDB.  There is a CDDB server protocol that
+   the software (also known as the "client") must use to converse with
+   the server.
+
+You may choose to support either one, or both of these modes.
+
+
+CDDB DISCID
+-----------
+
+Both forms of CDDB access requires that the software computes a "disc
+ID" which is an identifier that is used to access the CDDB.  The disc
+ID is a 8-digit hexadecimal (base-16) number, computed using data from
+a CD's Table-of-Contents (TOC) in MSF (Minute Second Frame) form.  The
+algorithm is listed below in the <a href="http://freedb.freedb.org/sections.php?op=viewarticle&artid=6">DISCID Howto</a>.
+
+It is crucial that your software compute the disc ID correctly.  If it
+does not generate the disc ID, it will not be compatible with the
+CDDB.  Moreover, if your software submits CDDB entries with bad disc
+IDs to the freedb archives, it could compromise the integrity of the
+freedb.
+
+If you have access to a UNIX platform that xmcd supports, we suggest 
+installing xmcd, and then test the disc ID code in your software by
+comparing the disc ID generated by xmcd with that of your software,
+for as large a number of CDs as possible.
+
+
+<a name="local"></a>LOCAL CDDB ACCESS
+-----------------
+
+There are two forms of the CDDB archive available, the standard form
+and the alternate form.  Both forms are available for download from 
+various servers. You can always find an actual list of mirrors on the 
+freedb-homepage at <a href="http://freedb.freedb.org">http://freedb.freedb.org</a>.
+The standard form of the CDDB archive is released to the public as 
+a UNIX tar(1)-format archive, compressed with gzip.  The alternate 
+form  archive is in the .zip format that is popular on the Windows 
+platform.
+
+Standard Form:
+--------------
+
+Each CD entry is a separate file in the xmcd CDDB.  These files are
+organized in several directories, each directory is a category of
+music.  Currently the "official" categories are listed as follows:
+
+	blues
+	classical
+	country
+	data
+	folk
+	jazz
+	misc
+	newage
+	reggae
+	rock
+	soundtrack
+
+The individual CDDB files have a file name that is the 8-digit disc
+ID. For example, under the blues directory there may be the following
+files:
+
+	0511c012
+	060e7314
+	0c01e902
+	0f0c3112
+	...
+	fa0f6f10
+	fb0f8814
+	fd0e6013
+
+To access the CDDB entry associated with a CD, your software simply
+opens the appropriate file and reads the information.
+
+The content of each of these files is in a format described in the 
+<a href="http://freedb.freedb.org/software/old/DBFORMAT">database-format specification</a>.
+
+Different pressings of a particular CD title may contain differences
+in timings that can cause the computed disc ID to be different.
+The CDDB allows this by having multiple file names be links to
+the same file.  The links are implemented as actual filesystem links
+(see the ln(1) command) on UNIX systems.  For example, the following
+files in the rock directory are all links to the same file, and
+refer to the CD "Pink Floyd / The Division Bell".:
+
+	850f740b
+	850f950b
+	850f970b
+	860f960b
+	890f970b
+
+Xmcd and the CD database server use this form of the CDDB archive.  The
+benefit of the standard form of the CDDB archive is very fast access,
+and ease of add/delete/edit operations on entries.
+
+Alternate Form:
+---------------
+
+Due to limitations in the FAT file system used on Windows 9x and 
+Windows ME, it is unfeasible to use the standard format CDDB archive 
+due to the large number of files.  This is because such a filesystem 
+operates on fixed-size clusters and even a small file (and most CDDB
+files are 1KB or less) would consume the space of a full cluster
+(Depending upon disk size, a cluster can range from 4KB to 32KB in 
+size).  Thus, a tremendous amount of disk space would be wasted on
+these systems if the CDDB archive is used in its standard form.
+
+An alternate form of the CDDB archives was created for use by software
+that must operate on a system with the FAT limitations.
+
+The alterate form still use the separate category directories as the
+standard form, but concatenates many files into a smaller number of
+files under each category.  The first two digits of the CDDB file names
+is used as a key for concatenation, each file is allowed to grow to
+approximately 64KB in size before a new file is started.  The file name
+indicates what range of the digits are included in that file.  For
+example, under the blues category we may have the following files:
+
+	01to36
+	37to55
+	56to71
+	...
+	b2tod7
+	d8toff
+
+The 01to36 file contains all CDDB entries with disc ID 01xxxxxx,
+02xxxxxx, 03xxxxxx and so on, up to 36xxxxxx.
+
+Each entry in the concatenated file begins with the keyword
+
+#FILENAME=xxxxxxxx
+
+where discid is the 8-digit hexadecimal disc ID of that entry.  Your
+software must search through the appropriate file to locate the desired
+entry.  The CDDB entry is in the format described in Appendix B below.
+
+The alternate form avoids the problem of inefficient disk space
+utilization on FAT-based filesystems, but is slower to access than the
+standard form, and it is much more cumbersome to perform add/delete/edit
+operations on a CDDB entry.
+
+
+<a name="remote"></a>REMOTE CDDB ACCESS
+------------------
+
+Your software must be able to communicate with a remote CD server
+system via TCP/IP or HTTP.  
+There are a number of public freedb servers operating
+on the Internet.  The <a href="http://freedb.freedb.org/sections.php?op=viewarticle&artid=9">current list of public servers</a> is listed on the
+freedb web page at:
+
+    http://freedb.freedb.org.
+	
+It may also be obtained programmatically via the CDDB protocol "sites" 
+command.
+
+TCP/IP access:
+
+All current freedb servers answer at TCP port 888.  There may be future
+sites that deviate from this convention, however.
+
+HTTP access:
+
+The freedb-servers can be accessed via the cddb.cgi. This is resides at the
+following path: /~cddb/cddb.cgi 
+Thus, the URL for accessing the server at freedb.freedb.org is:
+http://freedb.freedb.org/~cddb/cddb.cgi
+
+You should make the freedb server host (or hosts) and port numbers
+user-configurable in your software.  Do not hard-wire the list of
+CD database servers into your code.  The list of active servers changes
+over time.
+
+The CDDB server protocol is described in the <a href="http://freedb.freedb.org/sections.php?op=viewarticle&artid=28">CDDB-protocol documentation</a>.
+
+The CDDB entry returned from the server via a "cddb read" command is in
+the format described <a href="http://freedb.freedb.org/software/old/DBFORMAT">database-format specification</a>.
+
+You may experiment with the freedb server by connecting to port 888 of
+the server host via the "telnet" program, and then typing the cddb
+protocol commands by hand.  For example:
+
+	telnet freedb.freedb.org 888
+
+connects you to the freedb server at freedb.freedb.org.
+
+Some additional notes for accessing freedb over the Internet:
+
+Your application should always specify the highest documented protocol
+level. The highest level currently supported is "3". Lower protocol 
+levels will work, but are only provided for compatibility with older 
+CDDB applications. If you do not use the highest available protocol 
+level, certain important features will not be available to your 
+application.
+
+Make sure to use the proper arguments with the "hello" command. The user
+and hostname arguments should be that of the user's email address, not
+some fixed hard-coded value. The application name and version should be
+that of your application, not that of another existing application.
+
+We consider the use of the "cddb query" command mandatory for all CDDB
+clients. It is not valid to issue a "cddb read" command without issuing
+a prior "cddb query" and receiving a good response, as it may yield incorrect
+results. In addition, it is clients should support close matches
+(aka "fuzzy" matches, or response code 211).
+
+The proper way to handle multiple fuzzy matches is to present the
+entire list of matches to the user and to let the user choose between them.
+Matches are listed in the order of best fit for the user's disc, so they
+should be presented to the user in the order they are listed by the server.
+
+The suggested algorithm for obtaining the list of server sites is
+as follows.  The application should offer to get the list from
+freedb.freedb.org with the "sites" command the first time the user runs 
+the program. Additionally the application should provide the user with 
+some method of downloading the list on-demand.
+
+We do strongly suggest that you provide your users with the capability of
+choosing freedb server sites as described above. However, for some 
+applications this may not be feasible. If you do not wish to offer this 
+functionality, you may safely hard-code "freedb.freedb.org" in your 
+application as the sole freedb site to access. This will deprive your users
+of the option to choose a site near their locale for optimal response, but
+that is your choice.

+ 171 - 0
acme/bin/source/acd/acd.h

@@ -0,0 +1,171 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <disk.h>
+#include <auth.h>
+#include <fcall.h>
+#include <thread.h>
+#include <9p.h>
+
+/* acme */
+typedef struct Event Event;
+typedef struct Window Window;
+
+enum
+{
+	STACK		= 16384,
+	EVENTSIZE	= 256,
+	NEVENT		= 5,
+};
+
+struct Event
+{
+	int	c1;
+	int	c2;
+	int	q0;
+	int	q1;
+	int	flag;
+	int	nb;
+	int	nr;
+	char	b[EVENTSIZE*UTFmax+1];
+	Rune	r[EVENTSIZE+1];
+};
+
+struct Window
+{
+	/* file descriptors */
+	int		ctl;
+	int		event;
+	int		addr;
+	int		data;
+	Biobuf	*body;
+
+	/* event input */
+	char		buf[512];
+	char		*bufp;
+	int		nbuf;
+	Event	e[NEVENT];
+
+	int		id;
+	int		open;
+	Channel	*cevent;	/* chan(Event*) */
+};
+
+extern	Window*	newwindow(void);
+extern	int		winopenfile(Window*, char*);
+extern	void		winopenbody(Window*, int);
+extern	void		winclosebody(Window*);
+extern	void		wintagwrite(Window*, char*, int);
+extern	void		winname(Window*, char*);
+extern	void		winwriteevent(Window*, Event*);
+extern	void		winread(Window*, uint, uint, char*);
+extern	int		windel(Window*, int);
+extern	void		wingetevent(Window*, Event*);
+extern	void		wineventproc(void*);
+extern	void		winwritebody(Window*, char*, int);
+extern	void		winclean(Window*);
+extern	int		winselect(Window*, char*, int);
+extern	int		winsetaddr(Window*, char*, int);
+extern	char*	winreadbody(Window*, int*);
+extern	void		windormant(Window*);
+extern	void		winsetdump(Window*, char*, char*);
+
+extern	char*	readfile(char*, char*, int*);
+extern	void		ctlprint(int, char*, ...);
+extern	void*	emalloc(uint);
+extern	char*	estrdup(char*);
+extern	char*	estrstrdup(char*, char*);
+extern	char*	egrow(char*, char*, char*);
+extern	char*	eappend(char*, char*, char*);
+extern	void		error(char*, ...);
+extern	int		tokenizec(char*, char**, int, char*);
+
+/* cd stuff */
+typedef struct Msf Msf;	/* minute, second, frame */
+struct Msf {
+	int m;
+	int s;
+	int f;
+};
+
+typedef struct Track Track;
+struct Track {
+	Msf start;
+	Msf end;
+	ulong bstart;
+	ulong bend;
+	char *title;
+};
+
+enum {
+	MTRACK = 64,
+};
+typedef struct Toc Toc;
+struct Toc {
+	int ntrack;
+	int nchange;
+	int changetime;
+	int track0;
+	Track track[MTRACK];
+	char *title;
+};
+
+extern int msfconv(Fmt*);
+
+#pragma	varargck	argpos	error	1
+#pragma	varargck	argpos	ctlprint	2
+#pragma	varargck	type		"M"	Msf
+
+enum {	/* state */
+	Sunknown,
+	Splaying,
+	Spaused,
+	Scompleted,
+	Serror,
+};
+
+typedef struct Cdstatus Cdstatus;
+struct Cdstatus {
+	int state;
+	int track;
+	int index;
+	Msf abs;
+	Msf rel;
+};
+
+typedef struct Drive Drive;
+struct Drive {
+	Window *w;
+	Channel *cstatus;	/* chan(Cdstatus) */
+	Channel *ctocdisp;	/* chan(Toc) */
+	Channel *cdbreq;	/* chan(Toc) */
+	Channel *cdbreply; /* chan(Toc) */
+	Scsi *scsi;
+	Toc toc;
+	Cdstatus status;
+};
+
+int gettoc(Scsi*, Toc*);
+void drawtoc(Window*, Drive*, Toc*);
+void redrawtoc(Window*, Toc*);
+void tocproc(void*);	/* Drive* */
+void cddbproc(void*);	/* Drive* */
+void cdstatusproc(void*);	/* Drive* */
+
+extern int debug;
+
+#define DPRINT if(debug)fprint
+void acmeevent(Drive*, Window*, Event*);
+
+int playtrack(Drive*, int, int);
+int pause(Drive*);
+int resume(Drive*);
+int stop(Drive*);
+int eject(Drive*);
+int ingest(Drive*);
+
+int markplay(Window*, ulong);
+int setplaytime(Window*, char*);
+void advancetrack(Drive*, Window*);
+
+

+ 347 - 0
acme/bin/source/acd/acme.c

@@ -0,0 +1,347 @@
+#include "acd.h"
+
+static int
+iscmd(char *s, char *cmd)
+{
+	int len;
+
+	len = strlen(cmd);
+	return strncmp(s, cmd, len)==0 && (s[len]=='\0' || s[len]==' ' || s[len]=='\t' || s[len]=='\n');
+}
+
+static char*
+skip(char *s, char *cmd)
+{
+	s += strlen(cmd);
+	while(*s==' ' || *s=='\t' || *s=='\n')
+		s++;
+	return s;
+}
+
+//#define PLAYSTRING "/^[0-9:]+>"
+//#define PLAYSTRINGSPACE "/^[0-9:]+> ?"
+//#define INITSTRING "0:00> "
+
+#define INITSTRING "> "
+#define PLAYSTRING "/^>"
+#define PLAYSTRINGSPACE "/^> ?"
+
+/*
+ * find the playing string, leave in addr
+ * if q0, q1 are non-nil, set them to the addr of the string.
+ */
+int
+findplay(Window *w, char *s, ulong *q0, ulong *q1)
+{
+	char xbuf[25];
+	if(w->data < 0)
+		w->data = winopenfile(w, "data");
+
+	if(!winsetaddr(w, "#0", 1) || !winsetaddr(w, s, 1))
+		return 0;
+
+	seek(w->addr, 0, 0);
+	if(read(w->addr, xbuf, 24) != 24)
+		return 0;
+	
+	xbuf[24] = 0;
+	if(q0)
+		*q0 = atoi(xbuf);
+	if(q1)
+		*q1 = atoi(xbuf+12);
+
+	return 1;
+}
+
+/*
+ * find the playing string and replace the time
+ */
+int
+setplaytime(Window *w, char *new)
+{
+	char buf[40];
+	ulong q0, q1;
+
+return 1;
+	if(!findplay(w, PLAYSTRING, &q0, &q1))
+		return 0;
+
+	q1--;	/* > */
+	sprint(buf, "#%lud,#%lud", q0, q1);
+	DPRINT(2, "setaddr %s\n", buf);
+	if(!winsetaddr(w, buf, 1))
+		return 0;
+	
+	if(write(w->data, new, strlen(new)) != strlen(new))
+		return 0;
+
+	return 1;
+}
+
+/*
+ * find the playing string, and remove it.
+ * return the string at the beginning of hte next line in buf
+ * (presumably a track number).
+ */
+static int
+unmarkplay(Window *w, char *buf, int n, ulong *q0, ulong *q1, ulong *qbegin)
+{
+	char xbuf[24];
+
+	if(!findplay(w, PLAYSTRINGSPACE, q0, q1))
+		return 0;
+
+	if(write(w->data, "", 0) < 0 || !winsetaddr(w, "+1+#0", 1))
+		return 0;
+
+	if(qbegin) {
+		seek(w->addr, 0, 0);
+		if(read(w->addr, xbuf, 24) != 24)
+			return 0;
+		*qbegin = atoi(xbuf);
+	}
+
+	if(buf) {
+		if((n = read(w->data, buf, n-1)) < 0)
+			return 0;
+	
+		buf[n] = '\0';
+	}
+
+	return 1;
+}
+
+int
+markplay(Window *w, ulong q0)
+{
+	char buf[20];
+
+	if(w->data < 0)
+		w->data = winopenfile(w, "data");
+
+	sprint(buf, "#%lud", q0);
+	DPRINT(2, "addr %s\n", buf);
+	if(!winsetaddr(w, buf, 1) || !winsetaddr(w, "-0", 1))
+		return 0;
+	if(write(w->data, INITSTRING, strlen(INITSTRING)) != strlen(INITSTRING))
+		return 0;
+	return 1;
+}
+
+/* return 1 if handled, 0 otherwise */
+int
+cdcommand(Window *w, Drive *d, char *s)
+{
+	s = skip(s, "");
+
+	if(iscmd(s, "Del")){
+		if(windel(w, 0))
+			threadexitsall(nil);
+		return 1;
+	}
+	if(iscmd(s, "Stop")){
+		unmarkplay(w, nil, 0, nil, nil, nil);
+		stop(d);
+		return 1;
+	}
+	if(iscmd(s, "Eject")){
+		unmarkplay(w, nil, 0, nil, nil, nil);
+		eject(d);
+		return 1;
+	}
+	if(iscmd(s, "Ingest")){
+		unmarkplay(w, nil, 0, nil, nil, nil);
+		ingest(d);
+		return 1;
+	}
+	if(iscmd(s, "Pause")){
+		pause(d);
+		return 1;
+	}
+	if(iscmd(s, "Resume")){
+		resume(d);
+		return 1;
+	}
+	return 0;
+}
+
+void
+drawtoc(Window *w, Drive *d, Toc *t)
+{
+	int i, playing;
+
+	if(w->data < 0)
+		w->data = winopenfile(w, "data");
+	if(!winsetaddr(w, ",", 1))
+		return;
+
+	fprint(w->data, "Title\n\n");
+	playing = -1;
+	if(d->status.state == Splaying || d->status.state == Spaused)
+		playing = d->status.track-t->track0;
+
+	for(i=0; i<t->ntrack; i++)
+		fprint(w->data, "%s%d/ Track %d\n", i==playing ? "> " : "", i+1, i+1);
+	fprint(w->data, "");
+}
+
+void
+redrawtoc(Window *w, Toc *t)
+{
+	int i;
+	char old[50];
+
+	if(w->data < 0)
+		w->data = winopenfile(w, "data");
+	if(t->title) {
+		if(winsetaddr(w, "/Title", 1))
+			write(w->data, t->title, strlen(t->title));
+	}
+	for(i=0; i<t->ntrack; i++) {
+		if(t->track[i].title) {
+			sprint(old, "/Track %d", i+1);
+			if(winsetaddr(w, old, 1))
+				write(w->data, t->track[i].title, strlen(t->track[i].title));
+		}
+	}
+}
+
+void
+advancetrack(Drive *d, Window *w)
+{
+	int n;
+	ulong q0, q1, qnext;
+	char buf[20];
+
+	q0 = q1 = 0;
+	if(!unmarkplay(w, buf, sizeof(buf), &q0, &q1, &qnext)) {
+		DPRINT(2, "unmark: %r\n");
+		return;
+	}
+
+	DPRINT(2, "buf: %s\n", buf);
+	if(strncmp(buf, "repeat", 6) == 0) {
+		if(!winsetaddr(w, "#0", 1) || !findplay(w, "/^[0-9]+\\/", &qnext, nil)) {
+			DPRINT(2, "set/find: %r\n");
+			return;
+		}
+		if(w->data < 0)
+			w->data = winopenfile(w, "data");
+		if((n = read(w->data, buf, sizeof(buf)-1)) <= 0) {
+			DPRINT(2, "read %d: %r\n", n);
+			return;
+		}
+		buf[n] = 0;
+		DPRINT(2, "buf: %s\n", buf);
+	}
+
+	if((n = atoi(buf)) == 0)
+		return;
+
+	if(!markplay(w, qnext))
+		DPRINT(2, "err: %r");
+
+	playtrack(d, n-1, n-1);
+}
+
+void
+acmeevent(Drive *d, Window *w, Event *e)
+{
+	Event *ea, *e2, *eq;
+	char *s, *t, *buf;
+	int n, na;
+	ulong q0, q1;
+
+	switch(e->c1){	/* origin of action */
+	default:
+	Unknown: