  8 From:	RHEA::DECWRL::"decvax!minow"   19-DEC-1984 22:13   To:	decwrl!rhea!rex!minow   E Received: from DECWRL by DEC-RHEA with SMTP; Wed, 19 Dec 84 19:06-PST ) Received: by decwrl.ARPA (4.22.01/4.7.34) ( 	id AA19144; Wed, 19 Dec 84 19:08:25 pst# Received: by decvax.UUCP (4.12/1.0) ( 	id AA06288; Wed, 19 Dec 84 21:35:52 est! Date: Wed, 19 Dec 84 21:35:52 est  Return-Path: <decvax!minow> , Message-Id: <8412200235.AA06288@decvax.UUCP>  4 From seismo!cmcl2!hipl!tony Thu Sep 20 13:04:13 1984# Received: by decvax.UUCP (4.12/1.0) ( 	id AA12419; Thu, 20 Sep 84 13:03:10 edtO Received: from cmcl2.UUCP by seismo.ARPA with UUCP; Thu, 20 Sep 84 12:21:56 EDT 8 Received: by NYU-CMCL2.ARPA; Thu, 20 Sep 84 12:08:11 edt! Received: by hipl.UUCP (4.12/4.7) ( 	id AA04456; Thu, 20 Sep 84 11:54:15 edt! Date: Thu, 20 Sep 84 11:54:15 edt + From: seismo!cmcl2!hipl!tony (Tony Movshon) * Message-Id: <8409201554.AA04456@hipl.UUCP> To: minow@decvax	 Status: R    Martin:   I Some more Decus C stuff. (If you want me to stop sending you this kind of 9 thing, say so). This file is a nested archive containing:   > 	Two things for your miscellany: a rudimentary mail system for7 	  TSX-Plus and a build program (alternative to BUILD). < 	A bug-fix for comm.c, in the form of the function equals().  M Cut at the end of this message, extract with archx, then inspect the results.    				Tony Movshon   PS: Thanks for ASCR50.MAC ...   K PPS: I have minor adaptations of archx and archc that run under MSDOS using # the Lattice compiler. Any interest?       . -h- mail.arc	Thu Sep 20 11:46:09 1984	mail.arc. A simple mail system for TSX-Plus, for Decus CM ------------------------Cut here and extract with archx---------------------- + --h- mail.c	Thu Sep 20 11:30:29 1984	mail.c  /*	  * mail.c   *  * Mail service for TSX-Plus.   *    * Syntax:	mail		Reads mail ,  *		mail 0		Checks for the existence of mail9  *		mail uid	Sends mail where uid is a project-programmer   *				number or a user-name   *  */ " /* Dox not in Runoff format ... */ #ifdef	DOCUMENTATION     		   MAIL utility for TSX-Plus  F MAIL is a C program that provides an inter-user mail service for usersF of the TSX-Plus operating system, version 4 or later. The MAIL programC has three functions -- to send mail to a user, to read mail, and to   check for the existence of mail.  D 1. To send mail to another user, type "MAIL name", where name is theE addressee's user name; you may also use the project,programmer number C instead of the user name. The mail program will then accept a typed E message and append it to any other existing messages waiting for that A user. The mail program automatically heads your message with your C identity and with the date and time. To terminate the message, type H control-Z. You may of course send mail to yourself. You may also use the: contents of a file in place of the typed message by typing   		mail henry <file.txt  E 2. To read your own mail, type "MAIL". The mail program will type out G your message file message by message, and then ask you whether you wish E to preserve it or delete it. If you do not have any mail, the program  types "No mail".  D 3. To check for mail, type "MAIL 0". The program will type "You haveB mail" if you do, and nothing if you do not. This mode of using theF program is designed for inclusion in each user's startup command file.   			* * * * *  E To use the mail system, the system manager must ensure the following:   H 1. Each user's startup command file must assign the logical name MSG: toF some permanently-resident disk in the system; all users must have fullD access to MSG:. A subdevice of 100 - 200 blocks is usually suitable.  G 2. For addressees to be searched by user name, MSG: must contain a file F called USR.LST which lists the project-programmer number and user nameG for each user. The format of each line of the file is ppn<tab>username,  e.g.	 		1,2	BOB  		1,4	HENRY  		99,99	SYSOPS  F 3. Each user's startup command file should include a "MAIL 0" command.  1 4. The program MAIL.SAV should be present on SY:.    			* * * * *  F Note that the mail system may only be used with project and programmerH numbers in the range 1 - 999. Note also that it is possible to send mailF to a project-programmer number that is not assigned to any user on theG system, although user names are checked against "msg:usr.lst". The MAIL D program works by creating files on device MSG: for each user to whomD mail is sent. The files are unique to each user, and are of the formD MSG:MAIm.n (expanded with leading zeroes, e.g. MSG:MAI003.012 is theG file for user 3,12). Users may edit their message files, delete them or F whatever. It is not good practice to leave old mail in the file, sinceB the startup message "You have mail" means only that your mail fileE exists, not that someone has added to it since you last looked at it.    			* * * * *  = J. Anthony Movshon, Psychology Dept., NYU, New York, NY 10003 % 10 January 1983, revised 7 June 1984.      #endif     #include	<stdio.h> #include	<time.h> 
 #define EOS	0    FILE			*fi,*fo;  char			fname[16];  char			myname[13]; int			proj,prog; int			j = -10; int			k = -12; int			hatc;  int			type;  int			old = 0; int			skip = 0;  int			out = 0; long			timval; char			*timetext;  extern char		*ctime(); extern long		time(); extern int		call();  extern int		ispy();  extern int		scca();  char			*$$prmt = "mail> ";! char			*namefile = "msg:usr.lst";    main(argc, argv)	 int argc;  char **argv; {  	register c,d;   	proj = call(ispy,1,&j); 	prog = call(ispy,1,&k); 	call(scca,1,&hatc); 	type = sctype();    	if (argc == 1) { 
 		typemail(); 	 		exit();  	}   	argv++; 	if (**argv == '0') {  		chkmail();	 		exit();  	}   	if (**argv == '+') {  		skip = atoi(*argv); 
 		typemail(); 	 		exit();  	}   	if (isalpha(**argv))  		lookup(*argv); 	else { . 		if(sscanf(*argv,"%d,%d",&proj,&prog) != 2) { 			fprintf(stderr,& 			"mail: don't grok \"%s\"\n",*argv);
 			exit(); 		}  	}  
 	maknam();' 	if ((fo = fopen(fname,"w")) == NULL) { < 		fprintf (stderr, "mail: can't create output %s\n", fname);	 		exit();  	}  ' 	if ((fi = fopen(fname,"r")) != NULL) {  		old++; 		while ((c = getc(fi)) != EOF)  			putc(c,fo); 	}  
 	header(); 	if (isatty(fileno(stdin))) { 1 		printf ("Type your message, then control-Z\n"); + 		if (freopen("tt:","run",stdin) == NULL) { 5 			fprintf(stderr,"mail: erk! can't reopen stdin\n"); 
 			exit(); 		}  	}! 	while ((c = getchar()) != EOF) { + 		if(isprint(c) || isspace(c) && c != '\r')  			putc((d=c),fo); 	} 	if (d != '\n')  		putc('\n',fo); 	if (ferror(fo) == NULL)
 		fclose(fo);  	else  		fprintf (stderr,. 		"mail: fatal error writing message file\n"); }    maknam() {  	register	i;  + 	sprintf(fname,"msg:mai%3d.%3d",proj,prog); ! 	for(i=0; fname[i] != EOS; i++) {  		if(fname[i] == ' ')  			fname[i] = '0'; 	} }    lookup(name) char	*name;  {  	int		prj,prg,found; 	char		uname[20];   * 	if ((fi = fopen(namefile,"r")) == NULL) { 		fprintf (stderr,6 		"mail: can't locate system namelist %s\n",namefile);	 		exit();  	} 	found = 0; 4 	while (fscanf(fi,"%d,%d%s",&prj,&prg,uname) == 3) { 		lowers(name);  		lowers(uname);# 		if (strcmp(name,uname) == NULL) {  			found++;  			proj=prj, prog=prg; 			fclose(fi);	 			break;  		}  	} 	if (found == 0) { 		fprintf (stderr,+ 		"mail: can't locate user \"%s\"\n",name); 	 		exit();  	} }    header() {  	register	i;   	proj = call(ispy,1,&j); 	prog = call(ispy,1,&k); 	getuname(myname); 	lowers(myname); 	if(old) 		putc('\f',fo); 	time(&timval);  	timetext = ctime(&timval);  	timetext[24] = '\0';  	fprintf(fo,E 	"--- Mail from %s (%d,%d), %s ---\n", myname, proj, prog, timetext);  }   	 chkmail()  { 
 	maknam();% 	if ((fi = fopen(fname,"r")) != NULL)  		printf("You have mail\n"); }   
 typemail() {  	register c;  
 	maknam();' 	if ((fi = fopen(fname,"r")) == NULL) {  		printf("No mail\n");	 		exit();  	} 	while (skip) {  		if ((c = getc(fi)) == EOF)
 			exit(); 		if (c == '\f')  
 			skip--; 	} 	if (type > 1) 		scerpg(1,1);  	while ((c = getc(fi)) != EOF) { 		if (c == '\f') {/ 			printf("\nType <return> for more messages");9 			while (getchar() != '\n');! 			if (type > 1) 				scerpg(1,1); 		}E 		else 			putchar(c); 	} 	printf("\nDelete? ");  	if(tolower(getchar()) == 'y') { 		delete(fname);  		printf("Mail file deleted\n"); 	} }.   lowers(string) char string[]; {9 	register int i;  ' 	for (i=0 ; string[i] != NULL ; i++ ) {u+ 		if (string[i] >= 'A' && string[i] <= 'Z')0 			string[i] |= 040; 	} }r3 --h- getuna.mac	Thu Sep 20 11:30:29 1984	getuna.mace& ;---	tsx-plus routine to get user name ;2 ;	getuname(string);3 ;	char	*string ;d 	.globl	getuna,csv$,cret$. 	.psect	.prog.
 	space=	40   getuna:	jsr	r5,csv$		;cstuff 	mov	4(5),r4		;point to string 	clrb	(4)		;prepare it 	mov	#1$,r0		;emt argument 	emt	375		;do the emt ! 	mov	#2$,r3		;point to the string1 3$:	movb	(3)+,r2		;get a byte2 	cmpb	r2,#space	;is it a space?g 	beq	4$		;yes - done  	movb	r2,(4)+		;no - copy a byte 	br	3$		;get moren% 4$:	clrb	(4)		;zero the trailing bytew 	clr	r0		;return zeroy 	jmp	cret$		;returnn   1$:	.byte	0,147l	 	.word	2$e
 2$:	.blkb	12.i .end+ --h- from.c	Thu Sep 20 11:30:29 1984	from.cn /*	  * from.cm  *>  * Who is my mail from? (See mail.c for description of "mail")  * x  */c   #include	<stdio.h>
 #define EOS	0u   FILE			*fi;t char			fname[16];s int			proj,prog; int			j = -10; int			k = -12; int			$$narg = 1;h extern int		call();A extern int		ispy();:   main() {  	register c;   	proj = call(ispy,1,&j); 	prog = call(ispy,1,&k);  
 	maknam();  % 	if ((fi = fopen(fname,"r")) == NULL)p	 		exit();9 	for (;;) {c, 		while ((c = getc(fi)) != EOF && c != '\n') 				putchar(c);- 		putchar ('\n');a 		if (c == EOF)r
 			exit();- 		while ((c = getc(fi)) != EOF && c != '\f');  		if (c == EOF) 
 			exit(); 	} }M   maknam() {  	register	i;  + 	sprintf(fname,"msg:mai%3d.%3d",proj,prog);h! 	for(i=0; fname[i] != EOS; i++) {	 		if(fname[i] == ' ')r 			fname[i] = '0'; 	} }e. -h- cbld.arc	Thu Sep 20 11:46:09 1984	cbld.arcL An alternative to "BUILD" for compiling and linking C programs under Decus CM -----------------------Cut here and extract with archx-----------------------u+ --h- cbld.c	Thu Sep 20 11:37:31 1984	cbld.co /*	  *	cbld.ch.  *	Command file processor for DECUS C compiler.  *	J Anthony Movshon, Dept. of Psychology, NYU  *	v 1.0	16-Jan-84  *	v 1.1	6-Jun-84i  *	  *	usage:e8  *		cbld [-baddr][-k][-m][-n][-p] src_list [-l obj_list]  *H  *	Generates command file that compiles and links the files in src_list,9  *	 and optionally links them with the files in obj_list.p  *<  *	-baddr	use "addr" as base address for link (default 2000)  *  *	-k	keep .m, .s, .obj filesy  *+  *	-l	link the following named object filese  *  *	-m	generate load mape  *  *	-n	compile only, do not linko  *;  *	-p	invoke the macro preprocessor mp for each compilationi  *4  *	-x	do not chain to created command file (xcc.com)  */e7 /* Dox in format suitable for inclusion in RT-11HELP */r #ifdef	DOCUMENTATION   .MACRO	CBLDl! CBLD		Compile and link C programsy     SYNTAX9 	cbld [-baddr][-k][-m][-n][-p][-x] src_list [-l obj_list]n     SEMANTICSg? 	Cbld generates and runs a command file that compiles and linkse> 	a C program. Src_list is a list of C program filenames, given; 	without the extension (which MUST be ".c"). The first filel> 	should include main(), and will be used to name the resulting= 	.sav file. Obj_list is an optional list of object files thati; 	may be included in the link. By default, cbld links to theo9 	file "c:suport.obj", and the libraries "c:culib.obj" andy 	"c:clib.obj".  	   OPTIONSl	    -baddr 5 	Pass "addr" to linker as base address (default 2000)l    -k.3 	Do not delete intermediate files after compilationt    -ln/ 	Include the following object files in the linkp    -me! 	Produce a load map from the linke    -nf/ 	Compile the named files only, do not link theme    -p.< 	Invoke the macro preprocessor mp for each compilation; this= 	is needed only if your programs have #define statements withe) 	arguments or nested #include statements.     -x*< 	Create the command file "dk:xcc.com" but do not chain to it  
   EXAMPLES
 	cbld prog 	cbld -n file1 file2 file3+ 	cbld -b10000 -k -m -p prog -l mylib forliba .ENDMt   #endif   #include <stdio.h>   int	mp = 0;		/*invoke mp*/( int	link = 1;	/*link after compilation*/- int	linkobj = 0;	/*include obj_list in link*/c2 int	keep = 0;	/*do not delete intermediate files*/" int	map = 0;	/*generate load map*/$ int	chainx = 1;	/*chain to xcc.com*/! char	fn[20];		/*filename buffer*/s- char	base[] = "002000"; /*link base address*/2/ char	ln[10][20];	/*list of filenames for link*/m3 char	dn[20][20];	/*list of filenames for deletion*/m< char	dln[10][20];	/*list of filenames for deletion if link*/9 char	*version = "!cbld v1.1 7-Jun-84\n";	/* version id */a. char	*$$prmt = "cbld> ";			/* prompt if RUN */ int	i = 0;		/*counters*/
 int	j = 0;
 int	k = 0;
 int	l = 0;
 int	m = 0;   main(argc, argv)	 int	argc;n
 char	*argv[];e {f 	FILE	*fp,*fopen();.  + 	if ((fp = fopen("xcc.com","w")) == NULL) {	4 		fprintf(stderr,"cbld: can't create command file");
 		exit(0); 	} 	fprintf(fp,"%s",version); 	argc--, argv++;& 	for (i = 0 ; argc ; argc--, argv++) { 		if (i > 9) 			usage();g 		if (argv[0][0] == '-') { 			switch (argv[0][1]) { 			case 'b': 				strcpy(base,argv[0]+2); 
 				break; 			case 'k': 				keep++;a
 				break; 			case 'l': 				linkobj = 1; 				goto linkit;
 				break; 			case 'm':
 				map++;
 				break; 			case 'n':
 				link = 0;o
 				break; 			case 'p':	 				mp++;p
 				break; 			case 'x': 				chainx = 0;y
 				break; 			default:  				usage();
 				break; 			} 		}  		else { 			strcpy(fn,*argv); 			if (mp) {' 				fprintf(fp,"ru c:mp %s.c\n",fn,fn); ) 				fprintf(fp,"ru c:cc %s.mpc\n",fn,fn);	! 				sprintf(dn[k++],"%s.mpc",fn);) 			} 			elser% 				fprintf(fp,"ru c:cc %s\n",fn,fn);d 			sprintf(dn[k++],"%s.s",fn);$ 			fprintf(fp,"ru c:as %s\n",fn,fn);! 			sprintf(dln[l++],"%s.obj",fn);  			strcpy(ln[i++],fn); 		}n 	} linkit:= 	if (linkobj) {i 		argc--, argv++;  		for (; argc ; argc--, argv++); 			strcpy(ln[i++],*argv);i 	} 	if (link || linkobj) { ( 		fprintf(fp,"link/prompt/bot:%s",base);
 		if (map) 			fprintf(fp,"/map:%s",ln[0]);i 		fprintf(fp," %s\n",ln[0]); 		for (j = 1 ; j < i ; j++)n 			fprintf(fp,"%s\n",ln[j]);( 		fprintf(fp,"c:suport,culib,clib//\n"); 	} 	fprintf(fp,"pip\n"); 
 	if (!keep) {) 		for (m = 0 ; m < k ; m++)i 			fprintf(fp,"%s/d\n",dn[m]);
 		if (link) {  			for (m = 0 ; m < l ; m++)  				fprintf(fp,"%s/d\n",dln[m]); 		}  	}  	fprintf(fp,"xcc.com/d\n\03\n"); 	fclose(fp); 	if (chainx) 		chain("@xcc"); }, usage(): {t 	fprintf(stderr,F 	"Usage: cbld [-baddr][-k][-m][-n][-p][-x] src_list [-l obj_list]\n"); 	exit(); },1 --h- chain.mac	Thu Sep 20 11:37:31 1984	chain.mac	 ;f; ;---	c exit routine to pass chain command string to monitor  ;r 	.globl	chain,csv$
 	.mcall	.exit  	jsw=	44
 	$chain=	4000  	.psect	.prog.   chain:	jsr	r5,csv$		;cstufft 	mov	4(5),r4		;point to string 	mov	#1000,sp	;reset stack  	mov	#512,r1		;store string here! 1$:	movb	(4)+,r0		;pass characterj 	beq	3$		;null ends string! 	cmpb	r0,#12		;linefeed ends line( 	bne	2$		;anything else goes" 	clrb	r0		;(to make .asciz format)! 2$:	movb	r0,(1)+		;put string out  	br	1$		;get more  3$:	clrb	(1)+		;zero final byte:$ 	sub	#512,r1		;compute string length 	mov	r1,@#510	;store itd* 	bis	#$chain,@#jsw	;inform system of chain 	clr	r0		;make a *hard* exit 	.exit			;go to it .end. -h- equals.c	Thu Sep 20 11:46:09 1984	equals.c /*%  * function from comm.c with bug-fix  B  * the error was in the "return" statement, which omitted the "*"s  */n equals(str1, str2) char		*str1;		/* Strings				*/! char		*str2;		/* to compare				*/f {e 	register char	*p1;r 	register char	*p2;"   	p1 = str1 - 1;) 	p2 = str2 - 1;; 	while (*++p1 == *++p2) {f 		if (*p1 == 0)=
 			return(0);r 	} 	return((*p1 < *p2) ? 1 : 2);  }i      