77 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #ifndef NORCSID
 | |
| static char rcsid[] = "$Header$";
 | |
| #endif
 | |
| 
 | |
| #include <stdio.h>
 | |
| #include "param.h"
 | |
| #include "types.h"
 | |
| #include "alloc.h"
 | |
| #include "../../h/em_spec.h"
 | |
| #include "ext.h"
 | |
| 
 | |
| /*
 | |
|  * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | |
|  *
 | |
|  *          This product is part of the Amsterdam Compiler Kit.
 | |
|  *
 | |
|  * Permission to use, sell, duplicate or disclose this software must be
 | |
|  * obtained in writing. Requests for such permissions may be sent to
 | |
|  *
 | |
|  *      Dr. Andrew S. Tanenbaum
 | |
|  *      Wiskundig Seminarium
 | |
|  *      Vrije Universiteit
 | |
|  *      Postbox 7161
 | |
|  *      1007 MC Amsterdam
 | |
|  *      The Netherlands
 | |
|  *
 | |
|  * Author: Hans van Staveren
 | |
|  */
 | |
| 
 | |
| /*
 | |
|  * Main program for EM optimizer
 | |
|  */
 | |
| 
 | |
| main(argc,argv) int argc; char *argv[]; {
 | |
| 	short somespace[STACKROOM];
 | |
| 
 | |
| 	progname = argv[0];
 | |
| 	while (argc-->1 && **++argv == '-')
 | |
| 		flags(*argv);
 | |
| 	if (argc>1) {
 | |
| 		fprintf(stderr,"Usage: %s [-Ln] [name]\n",progname);
 | |
| 		exit(-1);
 | |
| 	}
 | |
| 	if (argc)
 | |
| 		if (freopen(*argv,"r",stdin) == NULL)
 | |
| 			error("Cannot open %s",*argv);
 | |
| 	fileinit();
 | |
| 	coreinit(somespace,somespace+STACKROOM);
 | |
| 	getlines();
 | |
| 	cleanup();
 | |
| 	return(0);
 | |
| }
 | |
| 
 | |
| flags(s) register char *s; {
 | |
| 
 | |
| 	for (s++;*s;s++)
 | |
| 		switch(*s) {
 | |
| 		case 'L':	Lflag = TRUE; break;
 | |
| 		case 'n':	nflag = TRUE; break;
 | |
| 		}
 | |
| }
 | |
| 
 | |
| fileinit() {
 | |
| 	char *mktemp();
 | |
| 	short readshort();
 | |
| 
 | |
| 	if (readshort() != (short) sp_magic)
 | |
| 		error("wrong input file");
 | |
| 	if (Lflag) {
 | |
| 		outfile = fopen(mktemp(template),"w");
 | |
| 		if (outfile == NULL)
 | |
| 			error("can't create %s",template);
 | |
| 	} else {
 | |
| 		outfile = stdout;
 | |
| 		outshort(sp_magic);
 | |
| 	}
 | |
| }
 |