main.c 1.4 KB

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