main.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef NORCSID
  2. static char rcsid[] = "$Header$";
  3. #endif
  4. #include <stdio.h>
  5. #include "param.h"
  6. #include "types.h"
  7. #include "tes.h"
  8. #include "alloc.h"
  9. #include <em_spec.h>
  10. #include "ext.h"
  11. /*
  12. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  13. * See the copyright notice in the ACK home directory, in the file "Copyright".
  14. *
  15. * Author: Hans van Staveren
  16. */
  17. /*
  18. * Main program for EM optimizer
  19. */
  20. main(argc,argv) int argc; char *argv[]; {
  21. int somespace[STACKROOM];
  22. progname = argv[0];
  23. while (argc-->1 && **++argv == '-')
  24. flags(*argv);
  25. if (argc>1) {
  26. fprintf(stderr,"Usage: %s [-Ln] [-m<num>] [name]\n",progname);
  27. exit(-1);
  28. }
  29. if (argc)
  30. if (freopen(*argv,"r",stdin) == NULL)
  31. error("Cannot open %s",*argv);
  32. fileinit();
  33. coreinit((short *)somespace,(short *)(somespace+STACKROOM));
  34. getlines();
  35. cleanup();
  36. return(0);
  37. }
  38. flags(s) register char *s; {
  39. for (s++;*s;s++)
  40. switch(*s) {
  41. case 'L': Lflag = TRUE; break;
  42. case 'n': nflag = TRUE; break;
  43. case 'm': if (*(s+1) == 'l') {
  44. s++;
  45. repl_longmuls = TRUE;
  46. }
  47. repl_muls = atoi(s+1); break;
  48. }
  49. }
  50. fileinit() {
  51. char *mktemp();
  52. short readshort();
  53. if (readshort() != (short) sp_magic)
  54. error("wrong input file");
  55. if (Lflag) {
  56. outfile = fopen(mktemp(template),"w");
  57. if (outfile == NULL)
  58. error("can't create %s",template);
  59. } else {
  60. outfile = stdout;
  61. outshort(sp_magic);
  62. }
  63. }