[comp.os.minix] V1.4a #6

ast@cs.vu.nl (Andy Tanenbaum) (01/23/89)

: This is a shar archive.  Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
: --------------------------- cut here --------------------------
PATH=/bin:/usr/bin:/usr/ucb
echo Extracting 'cc.c.cdif'
sed 's/^X//' > 'cc.c.cdif' << '+ END-OF-FILE ''cc.c.cdif'
X*** /local/ast/minix/tape3/commands/cc.c	Sun Sep 25 15:24:45 1988
X--- cc.c	Fri Jan 20 11:54:29 1989
X***************
X*** 161,169 ****
X  
X  	ProgCall = *argv++;
X  
X! 	signal(SIGHUP, trapcc);
X! 	signal(SIGINT, trapcc);
X! 	signal(SIGQUIT, trapcc);
X  	while (--argc > 0) {
X  		if (*(str = *argv++) != '-') {
X  			append(&SRCFILES, str);
X--- 161,169 ----
X  
X  	ProgCall = *argv++;
X  
X! 	if (signal(SIGHUP, SIG_IGN) != SIG_IGN) signal(SIGHUP, trapcc);
X! 	if (signal(SIGINT, SIG_IGN) != SIG_IGN) signal(SIGINT, trapcc);
X! 	if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) signal(SIGQUIT, trapcc);
X  	while (--argc > 0) {
X  		if (*(str = *argv++) != '-') {
X  			append(&SRCFILES, str);
+ END-OF-FILE cc.c.cdif
chmod 'u=rw,g=r,o=r' 'cc.c.cdif'
set `wc -c 'cc.c.cdif'`
count=$1
case $count in
669)	:;;
*)	echo 'Bad character count in ''cc.c.cdif' >&2
		echo 'Count should be 669' >&2
esac
echo Extracting 'crc.c.cdif'
sed 's/^X//' > 'crc.c.cdif' << '+ END-OF-FILE ''crc.c.cdif'
X*** /local/ast/minix/tape3/commands/crc.c	Wed Sep 28 11:16:52 1988
X--- crc.c	Fri Jan 20 11:54:33 1989
X***************
X*** 1,22 ****
X  /* crc - list length and checksum		Author: Johan W. Stevenson */
X  
X- 
X  #include <stdio.h>
X  
X  int	errs;
X  
X  main(argc,argv)
X  char **argv;
X  {
X  
X  	if (argc <= 1)
X! 		crc((char *)0);
X  	else
X  		do {
X! 			if (freopen(argv[1], "r", stdin) == NULL)
X! 				error("cannot open %s", argv[1]);
X! 			else
X! 				crc(argv[1]);
X  			argv++;
X  			argc--;
X  		} while (argc > 1);
X--- 1,25 ----
X  /* crc - list length and checksum		Author: Johan W. Stevenson */
X  
X  #include <stdio.h>
X+ #include <string.h>
X  
X  int	errs;
X+ char line[256];
X  
X  main(argc,argv)
X  char **argv;
X  {
X  
X  	if (argc <= 1)
X! 		while (fgets(line, sizeof line, stdin) != NULL)
X! 		{
X! 			if (index(line, '\n') != NULL)
X! 				*index(line, '\n') = 0;
X! 			crc(line);
X! 		}
X  	else
X  		do {
X! 			crc(argv[1]);
X  			argv++;
X  			argc--;
X  		} while (argc > 1);
X***************
X*** 76,102 ****
X  crc(fname)
X  char *fname;
X  {
X  	register int		c;
X- 	register int		i;
X  	register long		len = 0;
X  	register unsigned short	crc = 0;
X  
X! 	while ((c = getc(stdin)) != EOF) {
X  		len++;
X  		crc = updcrc(c, crc);
X  	}
X! 	printf("%05u %6ld", crc, len, fname);
X! 	if (fname)
X! 		printf(" %s", fname);
X! 	printf("\n");
X! }
X! 		
X! error(s, a1, a2, a3, a4)
X! char *s;
X! {
X! 
X! 	fprintf(stderr, "crc: ");
X! 	fprintf(stderr, s, a1, a2, a3, a4);
X! 	fprintf(stderr, "\n");
X! 	errs++;
X  }
X--- 79,97 ----
X  crc(fname)
X  char *fname;
X  {
X+ 	register FILE		*fp;
X  	register int		c;
X  	register long		len = 0;
X  	register unsigned short	crc = 0;
X  
X! 	if ((fp = fopen(fname, "r")) == NULL) {
X! 		fprintf(stderr, "crc: cannot open %s\n", fname);
X! 		errs++;
X! 	}
X! 	while ((c = getc(fp)) != EOF) {
X  		len++;
X  		crc = updcrc(c, crc);
X  	}
X! 	fclose(fp);
X! 	printf("%05u %6ld %s\n", crc, len, fname);
X  }
+ END-OF-FILE crc.c.cdif
chmod 'u=rw,g=r,o=r' 'crc.c.cdif'
set `wc -c 'crc.c.cdif'`
count=$1
case $count in
1881)	:;;
*)	echo 'Bad character count in ''crc.c.cdif' >&2
		echo 'Count should be 1881' >&2
esac
echo Extracting 'df.c.cdif'
sed 's/^X//' > 'df.c.cdif' << '+ END-OF-FILE ''df.c.cdif'
X*** /local/ast/minix/tape3/commands/df.c	Sun Sep 25 15:24:55 1988
X--- df.c	Fri Jan 20 11:54:34 1989
X***************
X*** 177,191 ****
X  getname(p)
X  char *p;
X  {
X!   char c;
X!   char ch;
X  
X    while (1) {
X! 	ch = getchar();
X! 	if (ch == EOF) exit(0);
X! 	c = (char) ch;
X  	if (c == ' ') c = 0;
X! 	*p++ = c;
X  	if (c == '\n') return;
X    }
X  }
X--- 177,189 ----
X  getname(p)
X  char *p;
X  {
X!   int c;
X  
X    while (1) {
X! 	c = getchar();
X! 	if (c == EOF) exit(0);
X  	if (c == ' ') c = 0;
X! 	*p++ = (char)c;
X  	if (c == '\n') return;
X    }
X  }
+ END-OF-FILE df.c.cdif
chmod 'u=rw,g=r,o=r' 'df.c.cdif'
set `wc -c 'df.c.cdif'`
count=$1
case $count in
540)	:;;
*)	echo 'Bad character count in ''df.c.cdif' >&2
		echo 'Count should be 540' >&2
esac
echo Extracting 'dosread.c.cdif'
sed 's/^X//' > 'dosread.c.cdif' << '+ END-OF-FILE ''dosread.c.cdif'
X*** /local/ast/minix/tape3/commands/dosread.c	Sun Sep 25 15:24:56 1988
X--- dosread.c	Fri Jan 20 11:54:35 1989
X***************
X*** 25,30 ****
X--- 25,38 ----
X   *			properly then all the rest should be okay.
X   *		If there are any problems there is debugging information
X   *		  in fdinit() -- please let me know of any problems
X+  *
X+  * 	Modified by Al Crew January 5, 1989
X+  *		allow 720K (and when the kernel does 1.44M) diskettes
X+  *			(for 1.44M the size of /dev/at[01] will have to
X+  *			 be changed or a new device name added)
X+  *		adjusted MAX_FAT_SIZE and MAX_CLUSTER_SIZE to better
X+  *			match my fixed disk (you may want to change them)
X+  *              fixed bug in read_cluster (sbrk failures were not reported)
X   */
X  
X  #include <sys/stat.h>
X***************
X*** 37,44 ****
X  #define DDHD	0xF9
X  #define DDFD	0xF8
X  
X! #define	MAX_CLUSTER_SIZE	4096
X! #define MAX_FAT_SIZE		23552	/* 46 sectoren */
X  #define HMASK		0xFF00
X  #define LMASK		0x00FF
X  
X--- 45,52 ----
X  #define DDHD	0xF9
X  #define DDFD	0xF8
X  
X! #define	MAX_CLUSTER_SIZE	2048
X! #define MAX_FAT_SIZE		25600	/* 50 sectoren */
X  #define HMASK		0xFF00
X  #define LMASK		0x00FF
X  
X***************
X*** 199,237 ****
X  		exit(1);
X  	}
X  
X! 	if (fdisk) {		/* fixed disk */
X! 		fdinit(dev_nr);
X! 		disk_read(f_start, &fat_type, sizeof(fat_type));
X! 		if (fat_type != DDFD) {
X! 			print_string(TRUE, "Fixed disk is not DOS\n");
X! 			leave(1);
X! 		}
X! 	}
X! 	else {		/* use standard start for floppies */
X! 		f_start = FAT_START;
X! 		disk_read(f_start, &fat_type, sizeof(fat_type));
X! 		if (fat_type == DDDD) {		/* Double-sided double-density 9 s/t */
X! 			total_clusters = 355;	/* 720 - 7 - 2 - 2 - 1 */
X! 			cluster_size = 1024;	/* 2 sectors per cluster */
X! 			fat_size = 1024;	/* 2 sectors */
X! 			data_start = 6144L;	/* Starts on sector #12 */
X! 			root_entries = 112;	
X! 			sub_entries = 32;	/* 1024 / 32 */
X! 		}
X! 		else if (fat_type == DDHD) {	/* Double-sided high-density 15 s/t */
X! 			total_clusters = 2372;	/* 2400 - 14 - 7 - 7 - 1 */
X! 			cluster_size = 512;	/* 1 sector per cluster */
X! 			fat_size = 3584;	/* 7 sectors */
X! 			data_start = 14848L;	/* Starts on sector #29 */
X! 			root_entries = 224;	
X! 			sub_entries = 16;	/* 512 / 32 */
X! 		}
X! 		else {
X!         		print_string(TRUE, "Diskette is not DOS 2.0 360K or 1.2M\n");
X! 			leave(1);
X! 		}
X! 	}
X! 
X  	disk_read(f_start + (long) fat_size, &fat_check, sizeof(fat_check));
X  	if (fat_check != fat_type) {
X  		print_string(TRUE, "Disk type in FAT copy differs from disk type in FAT original.\n");
X--- 207,214 ----
X  		exit(1);
X  	}
X  
X! 	fdinit(dev_nr);
X! 	disk_read(f_start, &fat_type, sizeof(fat_type));
X  	disk_read(f_start + (long) fat_size, &fat_check, sizeof(fat_check));
X  	if (fat_check != fat_type) {
X  		print_string(TRUE, "Disk type in FAT copy differs from disk type in FAT original.\n");
X***************
X*** 328,334 ****
X  	leave(0);
X  }
X  
X! fdinit(part_nr)		/* Fixed Disk Initializations */
X  char part_nr;
X  {
X  
X--- 305,311 ----
X  	leave(0);
X  }
X  
X! fdinit(part_nr)		/* Initializations */
X  char part_nr;
X  {
X  
X***************
X*** 379,384 ****
X--- 356,365 ----
X  	pe = (struct part_entry *)&secbuf[TABLEOFFSET];
X  		/* get the proper partition */
X  	switch(part_nr) {
X+ 		case '0':
X+ 		case 'a':
X+ 		case '1':
X+ 		case 'b': boot_loc=0; break;
X  		case 'f': pe++;
X  		case 'e': pe++;
X  		case 'd': pe++;
X***************
X*** 412,418 ****
X  		(boot.hidden_sectors[1]  << 8 & HMASK) + (boot.hidden_sectors[0] & LMASK));
X  	leave(1);
X  /**************/
X! 	if (boot.media_type != DDFD) {
X  		printf("DISK is not DOS Format.\n");
X  		leave(1);
X  	}
X--- 393,400 ----
X  		(boot.hidden_sectors[1]  << 8 & HMASK) + (boot.hidden_sectors[0] & LMASK));
X  	leave(1);
X  /**************/
X! 	if (((boot.media_type & 0xf0) != 0xf0)
X!             || (boot.jump[0] != 0xeb) || (boot.jump[2] != 0x90) ) {
X  		printf("DISK is not DOS Format.\n");
X  		leave(1);
X  	}
X***************
X*** 1050,1056 ****
X  	register DIRECTORY *sub_dir;
X  	extern char *sbrk();
X  
X! 	if ((sub_dir = (DIRECTORY *) sbrk(cluster_size)) < 0) {
X  		print_string(TRUE, "Cannot set break!\n");
X  		leave(1);
X  	}
X--- 1032,1039 ----
X  	register DIRECTORY *sub_dir;
X  	extern char *sbrk();
X  
X! 	if ((sub_dir = (DIRECTORY *) sbrk(cluster_size)) 
X!             == ((DIRECTORY *)-1)) {
X  		print_string(TRUE, "Cannot set break!\n");
X  		leave(1);
X  	}
+ END-OF-FILE dosread.c.cdif
chmod 'u=rw,g=r,o=r' 'dosread.c.cdif'
set `wc -c 'dosread.c.cdif'`
count=$1
case $count in
4357)	:;;
*)	echo 'Bad character count in ''dosread.c.cdif' >&2
		echo 'Count should be 4357' >&2
esac
echo Extracting 'fdisk.c.cdif'
sed 's/^X//' > 'fdisk.c.cdif' << '+ END-OF-FILE ''fdisk.c.cdif'
X*** /local/ast/minix/tape3/commands/fdisk.c	Sun Sep 25 15:24:59 1988
X--- fdisk.c	Sun Jan 22 12:32:17 1989
X***************
X*** 5,12 ****
X   * puts the boot code in sector 0.
X   * Then run fdisk
X   *
X!  *	fdisk /dev/hdx	(MINIX)
X!  *	fdisk x:		(DOS)
X   *
X   * Compiling
X   *
X--- 5,11 ----
X   * puts the boot code in sector 0.
X   * Then run fdisk
X   *
X!  *	fdisk [-heads] [/dev/hdx]	(MINIX)
X   *
X   * Compiling
X   *
X***************
X*** 55,61 ****
X--- 54,63 ----
X  char	secbuf[SECSIZE];
X  char	*devname;
X  char	*dosstr  = "  DOS  ";
X+ char	*dosstr4 = " DOS  4";
X  char	*ndosstr = "Non-DOS";
X+ char	*xenstr = " Xenix ";
X+ int heads;
X  
X  #ifdef DOS
X  union	REGS	regs;
X***************
X*** 75,86 ****
X  
X  	/* init */
X  
X! 	if (argc != 2) {
X! 		printf("Usage: fdisk /dev/hdx\n");
X  		exit(1);
X  	}
X  
X! 	devname = argv[1];
X  	getboot(secbuf);	/* get boot sector	*/
X  
X  	do {
X--- 77,98 ----
X  
X  	/* init */
X  
X! 	if (  argc > 1 && (*++argv)[0] == '-')		/*flag*/
X! 		{heads = atoi( & (*argv)[1]);
X! 		 printf("heads: %d	", heads);
X! 		 argv++;
X! 		 argc--;
X! 		}
X! 	else	heads = NHEAD;
X! 
X! 	if (argc > 2) {
X! 		printf("Usage: fdisk [-heads] [/dev/hdx]\n");
X  		exit(1);
X  	}
X  
X! 	if ( argc == 1)
X! 		devname = "/dev/hd0";
X! 	else	devname = *argv;
X  	getboot(secbuf);	/* get boot sector	*/
X  
X  	do {
X***************
X*** 339,346 ****
X  
X  	if (entry->sysind == 0x01)
X  		typestring = dosstr;
X! 	else
X! 		typestring = ndosstr;
X  	printf("%5d         %s  ",number,typestring);
X  	temp = entry->start_sec & 0xc0;
X  	low_cyl = (entry->start_cyl & 0xff) + (temp << 2);
X--- 351,362 ----
X  
X  	if (entry->sysind == 0x01)
X  		typestring = dosstr;
X! 	else	if (entry->sysind == 0x02)
X! 		typestring = xenstr;
X! 	else	if (entry->sysind == 0x04)
X! 		typestring = dosstr4;
X! 		else
X! 			typestring = ndosstr;
X  	printf("%5d         %s  ",number,typestring);
X  	temp = entry->start_sec & 0xc0;
X  	low_cyl = (entry->start_cyl & 0xff) + (temp << 2);
X***************
X*** 423,432 ****
X  {
X  	int	bigcyl;
X  
X! 	bigcyl = logsec / (NHEAD * NSEC);
X  	*sec = (logsec % NSEC) + 1 + ((bigcyl >> 2) & 0xc0);
X  	*cyl = bigcyl & 0xff;
X! 	*hd = (logsec % (NHEAD * NSEC)) / NSEC;
X  }
X  
X  /*
X--- 439,448 ----
X  {
X  	int	bigcyl;
X  
X! 	bigcyl = logsec / (heads * NSEC);
X  	*sec = (logsec % NSEC) + 1 + ((bigcyl >> 2) & 0xc0);
X  	*cyl = bigcyl & 0xff;
X! 	*hd = (logsec % (heads * NSEC)) / NSEC;
X  }
X  
X  /*
X***************
X*** 487,497 ****
X  		return;
X  	}
X  	low = first & 0xffff;
X! 	low = low * NSEC * NHEAD;
X  	if (low == 0)
X  		low = 1; /* sec0 is master boot record */
X  	high = last & 0xffff;
X! 	high = (high + 1)*NSEC*NHEAD - 1;
X  	entry->lowsec = low;
X  	entry->size = high - low + 1;
X  	sec_to_hst(low,
X--- 503,513 ----
X  		return;
X  	}
X  	low = first & 0xffff;
X! 	low = low * NSEC * heads;
X  	if (low == 0)
X  		low = 1; /* sec0 is master boot record */
X  	high = last & 0xffff;
X! 	high = (high + 1)*NSEC*heads - 1;
X  	entry->lowsec = low;
X  	entry->size = high - low + 1;
X  	sec_to_hst(low,
+ END-OF-FILE fdisk.c.cdif
chmod 'u=rw,g=r,o=r' 'fdisk.c.cdif'
set `wc -c 'fdisk.c.cdif'`
count=$1
case $count in
2961)	:;;
*)	echo 'Bad character count in ''fdisk.c.cdif' >&2
		echo 'Count should be 2961' >&2
esac
echo Extracting 'lorder.c.cdif'
sed 's/^X//' > 'lorder.c.cdif' << '+ END-OF-FILE ''lorder.c.cdif'
X*** /local/ast/minix/tape3/commands/lorder.c	Sun Sep 25 15:25:04 1988
X--- lorder.c	Fri Jan 20 11:54:41 1989
X***************
X*** 237,243 ****
X  
X  	if (n = finddef(s)) {
X  		if (n->file != NULL) 
X! 			fprintf(stderr,"Error %s - %s defined twice in %s and %s", progname, s, n->file, yyfile);
X  		else
X  			n->file = yyfile;
X  	}
X--- 237,245 ----
X  
X  	if (n = finddef(s)) {
X  		if (n->file != NULL) 
X! 			fprintf(stderr,
X! 				"Error %s - %s defined twice in %s and %s\n",
X! 				 progname, s, n->file, yyfile);
X  		else
X  			n->file = yyfile;
X  	}
+ END-OF-FILE lorder.c.cdif
chmod 'u=rw,g=r,o=r' 'lorder.c.cdif'
set `wc -c 'lorder.c.cdif'`
count=$1
case $count in
546)	:;;
*)	echo 'Bad character count in ''lorder.c.cdif' >&2
		echo 'Count should be 546' >&2
esac
echo Extracting 'ls.c.cdif'
sed 's/^X//' > 'ls.c.cdif' << '+ END-OF-FILE ''ls.c.cdif'
X*** /local/ast/minix/tape3/commands/ls.c	Sun Sep 25 15:25:05 1988
X--- ls.c	Fri Jan 20 11:54:42 1989
X***************
X*** 402,408 ****
X    }
X    buf = getuidgid(xid);
X    if (buf != 0)
X! 	fprintf(stdout, "%6s ",buf);
X    else
X  	fprintf(stdout, "%6d ",xid);
X  }
X--- 402,409 ----
X    }
X    buf = getuidgid(xid);
X    if (buf != 0)
X! 	/* Assuming the number 8 is not a good idea. */
X! 	fprintf(stdout, "%-8.8s ",buf);
X    else
X  	fprintf(stdout, "%6d ",xid);
X  }
+ END-OF-FILE ls.c.cdif
chmod 'u=rw,g=r,o=r' 'ls.c.cdif'
set `wc -c 'ls.c.cdif'`
count=$1
case $count in
458)	:;;
*)	echo 'Bad character count in ''ls.c.cdif' >&2
		echo 'Count should be 458' >&2
esac
echo Extracting 'pr.c.cdif'
sed 's/^X//' > 'pr.c.cdif' << '+ END-OF-FILE ''pr.c.cdif'
X*** /local/ast/minix/tape3/commands/pr.c	Sun Sep 25 15:25:10 1988
X--- pr.c	Fri Jan 20 12:18:36 1989
X***************
X*** 86,91 ****
X--- 86,92 ----
X    FILE *file;
X    char *ptr;
X    int index = 1;	/* index is one ahead of argc */
X+   int line, col;
X  
X    setbuf(stdout, output);
X    do { 
X***************
X*** 146,151 ****
X--- 147,153 ----
X    		}
X  	continue;	/* Scan for next flags */
X  
X+ 
X  	/* ==============  flags are read. Print the file(s) ========= */
X  
X  pr_files:
X***************
X*** 153,158 ****
X--- 155,163 ----
X  	if (!no_header)
X  		length -= 10;
X  
X+ 		for(line=0; line < length; line++)
X+ 			for(col=0; col < columns; col++)
X+ 				L_BUF(line, col) = NIL_PTR; 
X  	if (length <= 0 ) {
X  		fprintf(stderr,"Minimal length shuold be %d\n",no_header ?
X  							1: 11);
+ END-OF-FILE pr.c.cdif
chmod 'u=rw,g=r,o=r' 'pr.c.cdif'
set `wc -c 'pr.c.cdif'`
count=$1
case $count in
781)	:;;
*)	echo 'Bad character count in ''pr.c.cdif' >&2
		echo 'Count should be 781' >&2
esac
echo Extracting 'tar.c.cdif'
sed 's/^X//' > 'tar.c.cdif' << '+ END-OF-FILE ''tar.c.cdif'
X*** /local/ast/minix/tape3/commands/tar.c	Mon Sep 26 15:01:28 1988
X--- tar.c	Fri Jan 20 12:18:21 1989
X***************
X*** 39,44 ****
X--- 39,53 ----
X  
X  HEADER header;
X  
X+ #define MAXLINKS 512
X+ 
X+ struct {
X+         unsigned short ino;
X+         unsigned short dev;
X+         char *path;
X+ } links[MAXLINKS];
X+ int nlinks = 0;
X+ 
X  #define INT_TYPE	(sizeof(header.member.m_uid))
X  #define LONG_TYPE	(sizeof(header.member.m_size))
X  
X***************
X*** 185,190 ****
X--- 194,200 ----
X  register char *file;
X  {
X    register int fd;
X+   struct stat st;
X  
X    if (header.member.m_linked == '1') {
X  	if (link(header.member.m_link, file) < 0)
X***************
X*** 205,210 ****
X--- 215,224 ----
X    (void) close(fd);
X  
X    chmod(file, (int)convert(header.member.m_mode, INT_TYPE));
X+   st.st_mtime = convert(header.member.m_time, LONG_TYPE);
X+   st.st_atime = st.st_mtime;
X+   utime(file, &st.st_atime);
X+   chown(file, (int)convert(header.member.m_uid, INT_TYPE),(int)convert(header.member.m_gid, INT_TYPE));
X    flush();
X  }
X  
X***************
X*** 329,334 ****
X--- 343,349 ----
X    struct stat st;
X    struct direct dir;
X    register int fd;
X+   char *islink(), *link=NIL_PTR;
X  
X    if (stat(file, &st) < 0) {
X  	string_print(NIL_PTR, "Cannot find %s\n", file);
X***************
X*** 339,349 ****
X  	return;
X    }
X  
X!   make_header(path_name(file), &st);
X    mwrite(tar_fd, &header, sizeof(header));
X!   if (st.st_mode & S_IFREG)
X! 	copy(path_name(file), fd, tar_fd, st.st_size);
X!   else if (st.st_mode & S_IFDIR) {
X  	if (chdir(file) < 0)
X  		string_print(NIL_PTR, "Cannot chdir to %s\n", file);
X  	else {
X--- 354,371 ----
X  	return;
X    }
X  
X! 
X!   /* check for link */
X!   if ((st.st_mode & S_IFMT)!=S_IFDIR && st.st_nlink>1)
X! 	 link = islink (path_name(file), &st, header.member.m_link);
X! 
X!   make_header(path_name(file), &st ,link);
X    mwrite(tar_fd, &header, sizeof(header));
X!   if ((st.st_mode & S_IFMT) == S_IFREG)
X! 	{if (link == 0)
X! 		copy(path_name(file), fd, tar_fd, st.st_size);
X! 	}
X!   else if ((st.st_mode & S_IFMT) == S_IFDIR) {
X  	if (chdir(file) < 0)
X  		string_print(NIL_PTR, "Cannot chdir to %s\n", file);
X  	else {
X***************
X*** 363,370 ****
X    (void) close(fd);
X  }
X  
X! make_header(file, st)
X! char *file;
X  register struct stat *st;
X  {
X    register char *ptr = header.member.m_name;
X--- 385,395 ----
X    (void) close(fd);
X  }
X  
X! /* a new arg link is necessary because link must be written beetween
X!   clear_header() and checksum()	- calling islink in make_header isn't clean*/
X! 
X! make_header(file, st,link)
X! char *file, *link;
X  register struct stat *st;
X  {
X    register char *ptr = header.member.m_name;
X***************
X*** 384,392 ****
X    string_print(header.member.m_gid, "%I ", st->st_gid);
X    string_print(header.member.m_size, "%L ", st->st_size);
X    string_print(header.member.m_time, "%L ", st->st_mtime);
X!   header.member.m_linked = ' ';
X    string_print(header.member.m_checksum, "%I", checksum());
X  }
X  
X  clear_header()
X  {
X--- 409,465 ----
X    string_print(header.member.m_gid, "%I ", st->st_gid);
X    string_print(header.member.m_size, "%L ", st->st_size);
X    string_print(header.member.m_time, "%L ", st->st_mtime);
X!   if (link != NIL_PTR)
X! 	{
X! 	header.member.m_linked = '1';
X! 	strncpy (header.member.m_link, link, NAME_SIZE);
X! 	}
X!   else
X! 	header.member.m_linked = ' ';
X    string_print(header.member.m_checksum, "%I", checksum());
X  }
X+ 
X+ char  *islink(file, st)
X+ 	struct stat *st;
X+ 	char *file;
X+ {
X+ 	/* Handle files that are links.
X+ 	 * Returns 0 if file must be copied.
X+ 	 * Returns 1 if file has been successfully linked.
X+ 	 */
X+ 	int i;
X+ 	int linkent;
X+ 	char *malloc();
X+ 
X+ 	linkent = -1;
X+ 	for (i=0; i<nlinks; i++)
X+ 	{
X+ 		if (links[i].dev==st->st_dev
X+ 			&& links[i].ino==st->st_ino)
X+ 				linkent=i;
X+ 	}
X+ 	if (linkent>=0) /* It's already in the link table */
X+ 	{ /* we must have copied it earlier.
X+ 	   * Don't copy it twice.
X+ 	   */
X+ 		
X+ 		return(links[linkent].path); /* Don't try to copy it */
X+ 
X+ 	} else { /* Make an entry in the link table */
X+ 		if (nlinks >= MAXLINKS)
X+ 			error("Too many links at %s\n",file);	
X+ 		links[nlinks].dev = st->st_dev;
X+ 		links[nlinks].ino = st->st_ino;
X+ 		links[nlinks].path = malloc(strlen(file)+1);
X+ 		if (links[nlinks].path == 0)
X+ 			error("No more memory at %s\n",file);
X+ 		strcpy(links[nlinks].path,file);
X+ 		nlinks++;
X+ 		/* Go ahead and copy it the first time */
X+ 		return(NIL_PTR);
X+ 	}
X+ }
X+ 
X  
X  clear_header()
X  {
+ END-OF-FILE tar.c.cdif
chmod 'u=rw,g=r,o=r' 'tar.c.cdif'
set `wc -c 'tar.c.cdif'`
count=$1
case $count in
4478)	:;;
*)	echo 'Bad character count in ''tar.c.cdif' >&2
		echo 'Count should be 4478' >&2
esac
echo Extracting 'tee.c.cdif'
sed 's/^X//' > 'tee.c.cdif' << '+ END-OF-FILE ''tee.c.cdif'
X*** /local/ast/minix/tape3/commands/tee.c	Mon Sep 26 15:01:28 1988
X--- tee.c	Fri Jan 20 12:18:22 1989
X***************
X*** 35,56 ****
X    }
X    fd[0] = 1;	/* Always output to stdout. */
X    for (s = 1; s < MAXFD && argc > 0; --argc, argv++) {
X! 	if ((fd[s] = open(*argv, 2)) < 0 &&
X! 				(fd[s] = creat(*argv, 0666)) < 0) {
X! 		std_err("Cannot open output file: ");
X! 		std_err(*argv);
X! 		std_err("\n");
X! 		exit(2);
X  	}
X! 	s++;
X    }
X  
X    if (iflag)
X  	signal(SIGINT, SIG_IGN);
X-   for (i = 1; i < s; i++) {	/* Don't lseek stdout. */
X- 	if (aflag)
X- 		lseek(fd[i], 0L, 2);
X-   }
X  
X    while ((n = read(0, buf, BLOCK_SIZE)) > 0) {
X  	for (i = 0; i < s; i++)
X--- 35,60 ----
X    }
X    fd[0] = 1;	/* Always output to stdout. */
X    for (s = 1; s < MAXFD && argc > 0; --argc, argv++) {
X! 	if (aflag) {
X! 		if ((fd[s] = open(*argv, 2)) >= 0) {
X! 			lseek(fd[s], 0L, 2);
X! 			s++;
X! 			continue;
X! 		}
X! 	} else {
X! 		if ((fd[s] = creat(*argv, 0666)) >= 0) {
X! 			s++;
X! 			continue;
X! 		}
X  	}
X! 	std_err("Cannot open output file: ");
X! 	std_err(*argv);
X! 	std_err("\n");
X! 	exit(2);
X    }
X  
X    if (iflag)
X  	signal(SIGINT, SIG_IGN);
X  
X    while ((n = read(0, buf, BLOCK_SIZE)) > 0) {
X  	for (i = 0; i < s; i++)
+ END-OF-FILE tee.c.cdif
chmod 'u=rw,g=r,o=r' 'tee.c.cdif'
set `wc -c 'tee.c.cdif'`
count=$1
case $count in
1214)	:;;
*)	echo 'Bad character count in ''tee.c.cdif' >&2
		echo 'Count should be 1214' >&2
esac
echo Extracting 'term.c.cdif'
sed 's/^X//' > 'term.c.cdif' << '+ END-OF-FILE ''term.c.cdif'
X*** /local/ast/minix/tape3/commands/term.c	Mon Sep 26 15:01:29 1988
X--- term.c	Fri Jan 20 12:18:22 1989
X***************
X*** 1,170 ****
X  /* term - terminal simulator		Author: Andy Tanenbaum */
X  
X  /* This program allows the user to turn a MINIX system into a dumb
X!  * terminal to communicate with a remote computer over a modem.  It
X!  * forks into two processes.  The parent sits in a tight loop copying
X!  * from the keyboard to the modem.  The child sits in a tight loop
X!  * copying from the modem to the screen.
X   *
X   * Example usage:
X!  *	term			: 1200 baud, 8 bits/char, no parity
X   *	term 9600 7 even	: 9600 baud, 7 bits/char, even parity
X   *	term odd 300 7		:  300 baud, 7 bits/char, odd parity
X   */
X  
X- #include <signal.h>
X  #include <sgtty.h>
X  
X! #define MAXARGS 3		/* maximum number of uart params */
X! #define NCHECKS 10
X! #define BAD -1
X! #define GOOD 1
X! #define DEF_SPEED B1200		/* default baudrate */
X! #define DEF_BITS BITS8		/* default bits/char */
X! #define MODEM "/dev/tty1"	/* special file attached to the modem */
X! #define ESC 033			/* character to hit to leave simulator */
X! #define LIMIT 3			/* how often do you have to hit  ESC to exit*/
X  #define CHUNK 1024		/* how much to read at once */
X  
X! int modem, pid;			/* file descriptor for modem */
X! char *pat[NCHECKS] = 
X! 	{"5", "6", "7", "8", "110", "300", "1200", "2400", "4800", "9600"};
X  
X! int value[NCHECKS] = 
X! 	{BITS5, BITS6, BITS7, BITS8, B110, B300, B1200, B2400, B4800, B9600};
X  
X! int hold[MAXARGS];
X! struct sgttyb sgtty, sgsave1, sgsave2;
X  
X  main(argc, argv)
X  int argc;
X  char *argv[];
X  {
X  
X    sync();
X!   modem = open(MODEM, 2);
X!   if (modem < 0) {
X! 	printf("Can't open modem on %s\n", MODEM);
X! 	exit(1);
X    }
X    set_uart(argc, argv);
X  
X    /* Main body of the terminal simulator. */
X!   if ( (pid = fork()))
X! 	copy(0, modem, ESC);	/* copy from stdin to modem */
X!   else
X! 	copy(modem, 1, -1);	/* copy from modem to stdout */
X  }
X  
X  set_uart(argc, argv)
X  int argc;
X  char *argv[];
X  {
X  /* Set up the UART parameters. */
X  
X!   int i, k, v, nspeeds = 0, speed, nbits = 0, bits, parity = 0;
X  
X-   if (argc > MAXARGS + 1)
X- 	error("Usage: term [baudrate] [data_bits] [parity]\n");
X- 
X    /* Examine all the parameters and check for validity. */
X!   speed = DEF_SPEED;		/* default line speed */
X!   bits = DEF_BITS;		/* default bits/char */
X!   for (i = 1; i < argc; i++) {
X! 	if (strcmp(argv[i], "even") == 0) {parity = EVENP; continue;}
X! 	if (strcmp(argv[i], "odd") == 0)  {parity = ODDP; continue;}
X! 	v = validity(argv[i]);
X! 	if (v == BAD) {
X! 		printf("Invalid parameter: %s\n", argv[i]);
X! 		exit(1);
X  	}
X- 	k = atoi(argv[i]);
X- 	if (k > 100) {
X- 		speed = value[v];
X- 		nspeeds++;
X- 	}
X- 	if ( k < 10) {
X- 		bits = value[v];
X- 		nbits++;
X- 	}
X- 	if (nspeeds > 1) error("Too many speeds\n");
X- 	if (nbits > 1) error("Too many character sizes\n");
X    }
X! 
X!   /* Fetch the modem parameters, save them, and set new ones. */
X!   ioctl(modem, TIOCGETP, &sgtty);
X!   sgsave1 = sgtty;		/* modem parameters */
X!   sgtty.sg_ispeed = speed;
X!   sgtty.sg_ospeed = speed;
X!   sgtty.sg_flags = RAW | parity | bits;
X!   ioctl(modem, TIOCSETP, &sgtty);
X!   
X!   /* Fetch the keyboard parameters, save them, and set new ones. */
X!   ioctl(0, TIOCGETP, &sgtty);
X!   sgsave2 = sgtty;		/* modem parameters */
X!   sgtty.sg_flags = (sgtty.sg_flags & 01700) + RAW;
X!   ioctl(0, TIOCSETP, &sgtty);
X  }
X  
X  
X! int validity(s)
X! char *s;
X  {
X! /* Check parameter for legality. */
X  
X!   int i;
X  
X!   for (i = 0; i < NCHECKS; i++) {
X! 	if (strcmp(s, pat[i]) == 0) return(i);
X!   }
X!   return(BAD);
X  }
X-  
X  
X! copy(in, out, end)
X! int in, out, end;
X  {
X! /* Copy from the keyboard to the modem or vice versa. If the end character
X!  * is seen LIMIT times in a row, quit.  For the traffic from the modem, the
X!  * end character is -1, which cannot occur since the characters from the
X!  * modem are unsigned integers in the range 0 to 255.
X   */
X  
X!   int t, count, state = 0;
X!   char buf[CHUNK], *p;
X  
X    while (1) {
X! 	if ( (count = read(in, buf, CHUNK)) < 0) {
X! 		printf("Can't read from modem\r\n");
X  		quit();
X  	}
X! 
X! 	if (end > 0) {
X! 		for (p = &buf[0]; p < &buf[count]; p++) {
X! 			t = *p & 0377;		/* t is unsigned int 0 - 255 */
X! 			if (t == end) {
X! 				if (++state == LIMIT) quit();
X! 			} else {
X! 				state = 0;
X! 			}
X! 		}
X  	}
X- 	write(out, buf, count);
X    }
X  }
X  
X  
X! error(s)
X! char *s;
X  {
X!   printf("%s", s);
X    exit(1);
X  }
X  
X! quit()
X  {
X-   ioctl(modem, TIOCSETP, &sgsave1);
X-   ioctl(0, TIOCSETP, &sgsave2);
X-   if (getpid() != pid) kill(pid, SIGINT);
X    exit(0);
X  }
X--- 1,313 ----
X  /* term - terminal simulator		Author: Andy Tanenbaum */
X  
X  /* This program allows the user to turn a MINIX system into a dumb
X!  * terminal to communicate with a remote computer through one of the ttys.
X!  * It forks into two processes.  The parent sits in a tight loop copying
X!  * from stdin to the tty.  The child sits in a tight loop copying from
X!  * the tty to stdout.
X   *
X+  * 2 Sept 88 BDE (Bruce D. Evans): Massive changes to make current settings the
X+  * default, allow any file as the "tty", support fancy baud rates and remove
X+  * references to and dependencies on modems and keyboards, so (e.g.)
X+  * a local login on /dev/tty1 can do an external login on /dev/tty2.
X+  *
X+  * 3 Sept 88 BDE: Split parent again to main process copies from stdin to a
X+  * pipe which is copied to the tty.  This stops a blocked write to the
X+  * tty from hanging the program.
X+  *
X+  * 11 Oct 88 BDE: Cleaned up baud rates and parity stripping.
X+  *
X   * Example usage:
X!  *	term			: baud, bits/char, parity from /dev/tty1
X   *	term 9600 7 even	: 9600 baud, 7 bits/char, even parity
X   *	term odd 300 7		:  300 baud, 7 bits/char, odd parity
X+  *	term /dev/tty2		: use /dev/tty2 rather than /dev/tty1
X+  *				: Any argument starting with "/" is
X+  *				: taken as the communication device.
X   */
X  
X  #include <sgtty.h>
X+ #include <signal.h>
X  
X! #define MAXARGS  3		/* maximum number of uart params */
X  #define CHUNK 1024		/* how much to read at once */
X+ #define NULL     0
X  
X! /* Hack some new baud rates for Minix. Minix uses a divide-by-100 encoding. */
X! #define B200     2
X! #define B600     6
X! #define B1800   18
X! #define B3600   36
X! #define B7200   72
X! #define B19200 192
X! #define EXTA   192
X! /* We can't handle some standard (slow) V7 speeds and speeds above 25500 since
X!  * since the speed is packed into a char :-(. Trap them with an illegal value.
X!  */
X! #define B50      0
X! #define B75      0
X! #define B134     0
X! #define EXTB     0
X! #define B38400   0
X! #define B57600   0
X! #define B115200  0
X  
X! int commfd;			/* open file no. for comm device */
X! int readpid;			/* pid of child reading commfd */
X! struct sgttyb sgcommfd;		/* saved terminal parameters for commfd */
X! struct sgttyb sgstdin;		/* saved terminal parameters for stdin */
X! int writepid;			/* pid of child writing commfd */
X  
X! char endseq[] = "\033[G";	/* sequence to leave simulator */
X! 				/* keypad '5', and must arrive in 1 piece */
X! struct param_s
X! {
X!   char *pattern;
X!   int value;
X!   char type;
X! #define BAD      0
X! #define BITS     1
X! #define NOSTRIP  2
X! #define PARITY   3
X! #define SPEED    4
X! }
X!   params[] =
X! {
X! 	"5", BITS5, BITS,
X! 	"6", BITS6, BITS,
X! 	"7", BITS7, BITS,
X! 	"8", BITS8, BITS,
X  
X+ 	"even", EVENP, PARITY,
X+ 	"odd", ODDP, PARITY,
X+ 	"nostrip", 0, NOSTRIP,
X+ 
X+ 	"50", B50, SPEED,
X+ 	"75", B75, SPEED,
X+ 	"110", B110, SPEED,
X+ 	"134", B134, SPEED,
X+ 	"200", B200, SPEED,
X+ 	"300", B300, SPEED,
X+ 	"600", B600, SPEED,
X+ 	"1200", B1200, SPEED,
X+ 	"1800", B1800, SPEED,
X+ 	"2400", B2400, SPEED,
X+ 	"3600", B3600, SPEED,
X+ 	"4800", B4800, SPEED,
X+ 	"7200", B7200, SPEED,
X+ 	"9600", B9600, SPEED,
X+ 	"19200", B19200, SPEED,
X+ 	"EXTA", EXTA, SPEED,
X+ 	"EXTB", EXTB, SPEED,
X+ 	"38400", B38400, SPEED,
X+ 	"57600", B57600, SPEED,
X+ 	"115200", B115200, SPEED,
X+ 	"", 0, BAD,		/* BAD type to end list */	
X+ };
X+ unsigned char strip_parity = 1;	/* nonzero to strip high bits before output */
X+ 
X+ int quit();			/* forward declare signal handler */
X+ 
X  main(argc, argv)
X  int argc;
X  char *argv[];
X  {
X+   char *commdev = NULL;
X+   int i;
X+   int pipefd[2];
X  
X    sync();
X!   for (i = 1; i < argc; ++i)
X! 	if ( argv[i][0] == '/') {
X! 		if (commdev != NULL)
X! 			error("Too may communication devices", "");
X! 		commdev = argv[i];
X! 	}
X!   if (commdev == NULL) {
X! 	i = MAXARGS + 1;
X! 	commdev = "/dev/tty1";
X    }
X+   else
X+ 	i = MAXARGS + 2;
X+   if (argc > i)
X+ 	error("Usage: term [baudrate] [data_bits] [parity]", "");
X+   commfd = open(commdev, 2);
X+   if (commfd < 0) error("Can't open ", commdev);
X+ 
X+   /* Save state of both devices before altering either (may be identical!). */
X+   ioctl(0, TIOCGETP, &sgstdin);
X+   ioctl(commfd, TIOCGETP, &sgcommfd);
X+   set_mode(0, -1, -1, -1, &sgstdin);	/* RAW mode on stdin, others current */
X    set_uart(argc, argv);
X  
X    /* Main body of the terminal simulator. */
X!   signal(SIGINT, quit);
X!   signal(SIGPIPE, quit);
X!   if (pipe(pipefd) < 0)
X! 	error("Can't create pipe", "");
X!   switch((writepid = fork()))
X!   {
X!   case -1:
X! 	error("Can't create process to write to comm device", "");
X!   case 0:
X! 	/* piped stdin to tty */
X! 	close(pipefd[1]);
X! 	copy(pipefd[0], "piped stdin", commfd, commdev, "");
X!   }
X!   close(pipefd[0]);
X!   switch((readpid = fork()))
X!   {
X!   case -1:
X! 	error("Can't create process to read from comm device", "");
X!   case 0:
X! 	/* tty to stdout */
X! 	copy(commfd, commdev, 1, "stdout", "");
X!   }  
X!   /* stdin to pipe */
X!   copy(0, "stdin", pipefd[1], "redirect stdin", endseq);
X  }
X  
X+ 
X  set_uart(argc, argv)
X  int argc;
X  char *argv[];
X  {
X  /* Set up the UART parameters. */
X  
X!   int i, j, bits, nbits, parity, nparities, speed, nspeeds;
X!   char *arg;
X!   register struct param_s *param;
X  
X    /* Examine all the parameters and check for validity. */
X!   nspeeds = nparities = nbits = 0;
X!   speed = parity = bits = -1;	/* -1 means use current value */
X!   for (i = 1; i < argc; ++i) {
X! 	if ((arg = argv[i])[0] == '/') continue;
X! 
X! 	/* Check parameter for legality. */
X! 	for (j = 0, param = &params[0];
X! 	     param->type != BAD && strcmp(arg, param->pattern) != 0;
X! 	     ++j, ++param)
X! 		;
X! 	switch (param->type)
X! 	{
X! 	case BAD:
X! 		error("Invalid parameter: ", arg);
X! 	case BITS:
X! 		bits = param->value;
X! 		if (++nbits > 1) error("Too many character sizes", "");
X! 		break;
X! 	case PARITY:
X! 		parity = param->value;
X! 		if (++nparities > 1) error("Too many parities", "");
X! 		break;
X! 	case SPEED:
X! 		speed = param->value;
X! 		if (speed == 0)
X! 			error("Invalid speed: ", arg);
X! 		if (++nspeeds > 1) error("Too many speeds", "");
X! 		break;
X! 	case NOSTRIP:
X! 		strip_parity = 0;
X! 		break;
X  	}
X    }
X!   set_mode(commfd, speed, parity, bits, &sgcommfd);
X  }
X  
X  
X! set_mode(fd, speed, parity, bits, sgsavep)
X! int speed;
X! int parity;
X! int bits;
X! struct sgttyb *sgsavep;
X  {
X!   /* Set open file fd to RAW mode with the given other modes.
X!    * If fd is not a tty, this may do nothing but connecting ordinary files
X!    * as ttys may have some use.
X!    */
X  
X!   struct sgttyb sgtty;
X  
X!   sgtty = *sgsavep;
X!   if (speed == -1) speed = sgtty.sg_ispeed;
X!   if (parity == -1) parity = sgtty.sg_flags & (EVENP | ODDP);
X!   if (bits == -1) bits = sgtty.sg_flags & BITS8; /* BITS8 is actually a mask */
X!   sgtty.sg_ispeed = speed;
X!   sgtty.sg_ospeed = speed;
X!   sgtty.sg_flags = RAW | parity | bits;
X!   ioctl(fd, TIOCSETP, &sgtty);
X  }
X  
X! 
X! copy(in, inname, out, outname, end)
X! int in;
X! char *inname;
X! int out;
X! char *outname;
X! char *end;
X  {
X! /* Copy from one open file to another. If the 'end' sequence is not "", and
X!  * precisely matches the input, terminate the copy and various children.
X!  * The end sequence is best provided by keyboard input from one of the
X!  * special keys which always produces chars in a bunch. RAW mode almost
X!  * guarantees exactly one keystroke's worth of input at a time.
X   */
X  
X!   static char buf[CHUNK];
X!   char *bufend;
X!   register char *bufp;
X!   int count;
X!   int len;
X  
X+   len = strlen(end);
X    while (1) {
X! 	if ( (count = read(in, buf, CHUNK)) <= 0) {
X! 		write2sn("Can't read from ", inname);
X  		quit();
X  	}
X! 	if (count == len && strncmp(buf, end, count) == 0)
X! 		quit();
X! 	if (strip_parity)
X! 		for (bufp = buf, bufend = bufp + count;
X! 		     bufp < bufend; ++bufp )
X! 			*bufp &= 0x7F;
X! 	if (write(out, buf, count) != count) {
X! 		write2sn("Can't write to ", outname);
X! 		quit();
X  	}
X    }
X  }
X  
X  
X! error(s1, s2)
X! char *s1;
X! char *s2;
X  {
X!   write2sn(s1, s2);
X    exit(1);
X  }
X  
X! 
X! nicequit()
X  {
X    exit(0);
X+ }
X+ 
X+ 
X+ quit()
X+ {
X+   ioctl(commfd, TIOCSETP, &sgcommfd);
X+   ioctl(0, TIOCSETP, &sgstdin);
X+   signal(SIGINT, nicequit);	/* if not caught, sh prints extra newline */
X+   kill(0, SIGINT);
X+   nicequit();
X+ }
X+ 
X+ 
X+ write2sn(s1, s2)
X+ {
X+   write(1, s1, strlen(s1));
X+   write(1, s2, strlen(s2));
X+   write(1, "\r\n", 2);
X  }
+ END-OF-FILE term.c.cdif
chmod 'u=rw,g=r,o=r' 'term.c.cdif'
set `wc -c 'term.c.cdif'`
count=$1
case $count in
13013)	:;;
*)	echo 'Bad character count in ''term.c.cdif' >&2
		echo 'Count should be 13013' >&2
esac
echo Extracting 'test.c.cdif'
sed 's/^X//' > 'test.c.cdif' << '+ END-OF-FILE ''test.c.cdif'
X*** /local/ast/minix/tape3/commands/test.c	Mon Sep 26 15:01:29 1988
X--- test.c	Fri Jan 20 12:18:22 1989
X***************
X*** 1,4 ****
X! /* test(1); version 7-like  --  author Erik Baalbergen */
X  #include <sys/types.h>
X  #include <sys/stat.h>
X  #include <sgtty.h>
X--- 1,5 ----
X! /* test - test conditions		Author: Erik Baalbergen */
X! 
X  #include <sys/types.h>
X  #include <sys/stat.h>
X  #include <sgtty.h>
X***************
X*** 85,93 ****
X  main(argc, argv)
X  	char *argv[];
X  {
X  	prog = argv[0];
X  	ip = &argv[1];
X! 	exit(!(expr(lex(*ip)) && *++ip == 0));
X  }
X  
X  expr(n)
X--- 86,101 ----
X  main(argc, argv)
X  	char *argv[];
X  {
X+ 	int st;
X+ 
X+ 	if (argc == 1)
X+ 		exit(1);
X  	prog = argv[0];
X  	ip = &argv[1];
X! 	st = !expr(lex(*ip));
X! 	if (*++ip)
X! 		syntax();
X! 	exit(st);
X  }
X  
X  expr(n)
+ END-OF-FILE test.c.cdif
chmod 'u=rw,g=r,o=r' 'test.c.cdif'
set `wc -c 'test.c.cdif'`
count=$1
case $count in
793)	:;;
*)	echo 'Bad character count in ''test.c.cdif' >&2
		echo 'Count should be 793' >&2
esac
echo Extracting 'tsort.c.cdif'
sed 's/^X//' > 'tsort.c.cdif' << '+ END-OF-FILE ''tsort.c.cdif'
X*** /local/ast/minix/tape3/commands/tsort.c	Mon Sep 26 15:01:33 1988
X--- tsort.c	Fri Jan 20 12:18:22 1989
X***************
X*** 24,29 ****
X--- 24,31 ----
X   * change log:
X   *	possible bug in ungetc(), fixed readone() to avoid - 2/19/88 - mrw
X   *	massive design error, rewrote dump logic - 3/15/88 - mrw
X+  *	stupid error causing overlay of s1 & s2 in readnode - 9/12/88 - mrw
X+  *
X   */
X  
X  #include <stdio.h>
X***************
X*** 89,99 ****
X  struct node *
X  readnode()
X  {
X! 	char *s1, *s2;
X  	register struct node *n1, *n2;
X  	struct dependents *pd;
X  
X! 	if ((s1 = readone()) != (char *)NULL) {
X  		if ((n1 = findnode(s1)) == (struct node *)NULL) {
X  			/* is a new node so build it */
X  			n1 = (struct node *)xalloc(sizeof(struct node));
X--- 91,101 ----
X  struct node *
X  readnode()
X  {
X! 	static char s1[MAXNAMELEN], s2[MAXNAMELEN];
X  	register struct node *n1, *n2;
X  	struct dependents *pd;
X  
X! 	if (readone(s1) != (char *)NULL) {
X  		if ((n1 = findnode(s1)) == (struct node *)NULL) {
X  			/* is a new node so build it */
X  			n1 = (struct node *)xalloc(sizeof(struct node));
X***************
X*** 107,113 ****
X  			n1->visited = 0;
X  			linknode(n1);
X  		}
X! 		if ((s2 = readone()) != (char *)NULL) {
X  			if ((n2 = findnode(s2)) == (struct node *)NULL) {
X  				/* is a new node so build it */
X  				n2 = (struct node *)xalloc(sizeof(struct node));
X--- 109,115 ----
X  			n1->visited = 0;
X  			linknode(n1);
X  		}
X! 		if (readone(s2) != (char *)NULL) {
X  			if ((n2 = findnode(s2)) == (struct node *)NULL) {
X  				/* is a new node so build it */
X  				n2 = (struct node *)xalloc(sizeof(struct node));
X***************
X*** 223,250 ****
X  		fprintf(stderr,"Error: %s - member queue overflow\n",progname);
X  		exit(1);
X  	}
X! 	else
X  		q[back] = t;
X  }
X  
X  char *
X! readone()
X  {
X  	register int c, n = 0;
X- 	static char name[MAXNAMELEN];
X  
X  	/* eat up leading spaces */
X  	while ((c = getchar()) != EOF && isspace(c))
X  		;
X  
X  	if (c != EOF) {
X! 		name[n++] = c;	/* save into name first non blank */
X  		while ((c = getchar()) != EOF && !isspace(c)) {
X  			if (n < MAXNAMELEN)
X! 				name[n++] = c;
X  		}
X! 		name[n] = '\0';
X! 		return (name);
X  	}
X  	else
X  		return ((char *)NULL);
X--- 225,253 ----
X  		fprintf(stderr,"Error: %s - member queue overflow\n",progname);
X  		exit(1);
X  	}
X! 	else {
X  		q[back] = t;
X+ 	}
X  }
X  
X  char *
X! readone(str)
X! char str[];	/* of MAXNAMELEN length */
X  {
X  	register int c, n = 0;
X  
X  	/* eat up leading spaces */
X  	while ((c = getchar()) != EOF && isspace(c))
X  		;
X  
X  	if (c != EOF) {
X! 		str[n++] = c;	/* save into name first non blank */
X  		while ((c = getchar()) != EOF && !isspace(c)) {
X  			if (n < MAXNAMELEN)
X! 				str[n++] = c;
X  		}
X! 		str[n] = '\0';
X! 		return (str);
X  	}
X  	else
X  		return ((char *)NULL);
+ END-OF-FILE tsort.c.cdif
chmod 'u=rw,g=r,o=r' 'tsort.c.cdif'
set `wc -c 'tsort.c.cdif'`
count=$1
case $count in
2775)	:;;
*)	echo 'Bad character count in ''tsort.c.cdif' >&2
		echo 'Count should be 2775' >&2
esac
exit 0